chromium/third_party/blink/renderer/core/css/counters_attachment_context.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/css/counters_attachment_context.h"

#include "base/containers/adapters.h"
#include "base/not_fatal_until.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h"
#include "third_party/blink/renderer/core/html/html_directory_element.h"
#include "third_party/blink/renderer/core/html/html_li_element.h"
#include "third_party/blink/renderer/core/html/html_menu_element.h"
#include "third_party/blink/renderer/core/html/html_olist_element.h"
#include "third_party/blink/renderer/core/html/html_ulist_element.h"
#include "third_party/blink/renderer/core/html/list_item_ordinal.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/style/computed_style.h"

namespace blink {

namespace {

bool IsAncestorOf(const Element& ancestor, const Element& descendant) {}

std::optional<std::pair<unsigned, int>> DetermineCounterTypeAndValue(
    const LayoutObject& layout_object,
    const CounterDirectives& directives) {}

inline bool IsReset(unsigned counter_type) {}

inline bool IsSetOrReset(unsigned counter_type) {}

int CalculateCounterValue(unsigned counter_type,
                          int counter_value,
                          int counter_current_value) {}

}  // namespace

CountersAttachmentContext::CountersAttachmentContext()
    :{}

bool CountersAttachmentContext::ElementGeneratesListItemCounter(
    const Element& element) {}

void CountersAttachmentContext::EnterElement(const Element& element) {}

void CountersAttachmentContext::LeaveElement(const Element& element) {}

// Check if we need to create implicit list-item counter.
void CountersAttachmentContext::MaybeCreateListItemCounter(
    const Element& element) {}

// Traverse the stack and collect counters values for counter() and counters()
// functions.
Vector<int> CountersAttachmentContext::GetCounterValues(
    const Element& element,
    const AtomicString& counter_name,
    bool only_last) {}

// Push the counter on stack or create stack if there is none. Also set the
// value in the table.
// Also, per https://drafts.csswg.org/css-lists/#instantiating-counters:
// If innermost counter’s originating element is `element` or a previous sibling
// of `element`, remove innermost counter from counters.
void CountersAttachmentContext::CreateCounter(const Element& element,
                                              const AtomicString& counter_name,
                                              int value) {}

// Remove counters parent is not ancestor of current element from stack,
// meaning that we left the scope of such counter already, e.g.:
//        ()
//    ()--------(S)
// (R)-(I)-()
// R will create and put on stack counter;
// I will use it from stack, but when we visit the next sibling of I,
// we don't remove R from stack, even we leave its scope, as we would have
// to check every last child in the tree if there were any counters created
// on this level. Instead, once we reach S we pop all stale counters from stack,
// here R will be removed from stack.
void CountersAttachmentContext::RemoveStaleCounters(
    const Element& element,
    const AtomicString& counter_name) {}

// When leaving the element that created counter we might want to
// pop it from stack, if previous counter on stack is ancestor of it.
// This is done because we should always inherit counters from ancestor first,
// so, if the previous counter is ancestor to the last one, the last one will
// never be inherited, remove it.
void CountersAttachmentContext::RemoveCounterIfAncestorExists(
    const Element& element,
    const AtomicString& counter_name) {}

// Set the counter's value by either updating the existing value or create
// a new record in the table, if there is no record yet.
void CountersAttachmentContext::SetCounterValue(
    const Element& element,
    const AtomicString& counter_name,
    int value) {}

// Get the value for counter created on `element`.
int CountersAttachmentContext::GetCounterValue(
    const Element& element,
    const AtomicString& counter_name) {}

// Update the value of last on stack counter or create a new one, if there
// is no last counter on stack.
void CountersAttachmentContext::UpdateCounterValue(
    const Element& element,
    const AtomicString& counter_name,
    unsigned counter_type,
    int counter_value) {}

void CountersAttachmentContext::EnterStyleContainmentScope() {}

void CountersAttachmentContext::LeaveStyleContainmentScope() {}

}  // namespace blink