bool operator==(const CounterDirectives& a, const CounterDirectives& b) { return a.isIncrement() == b.isIncrement() && a.incrementValue() == b.incrementValue() && a.isReset() == b.isReset() && a.resetValue() == b.resetValue(); }
static bool planCounter(RenderElement* object, const AtomicString& identifier, bool& isReset, int& value) { ASSERT(object); // We must have a generating node or else we cannot have a counter. Element* generatingElement = object->generatingElement(); if (!generatingElement) return false; RenderStyle* style = object->style(); ASSERT(style); switch (style->styleType()) { case NOPSEUDO: // Sometimes elements have more then one renderer. Only the first one gets the counter // LayoutTests/http/tests/css/counter-crash.html if (generatingElement->renderer() != object) return false; break; case BEFORE: case AFTER: break; default: return false; // Counters are forbidden from all other pseudo elements. } const CounterDirectives directives = style->getCounterDirectives(identifier); if (directives.isDefined()) { value = directives.combinedValue(); isReset = directives.isReset(); return true; } if (identifier == "list-item") { if (object->isListItem()) { if (toRenderListItem(object)->hasExplicitValue()) { value = toRenderListItem(object)->explicitValue(); isReset = true; return true; } value = 1; isReset = false; return true; } if (Element* e = object->element()) { if (e->hasTagName(olTag)) { value = static_cast<HTMLOListElement*>(e)->start(); isReset = true; return true; } if (e->hasTagName(ulTag) || e->hasTagName(menuTag) || e->hasTagName(dirTag)) { value = 0; isReset = true; return true; } } } return false; }
static bool planCounter(LayoutObject& object, const AtomicString& identifier, bool& isReset, int& value) { // Real text nodes don't have their own style so they can't have counters. // We can't even look at their styles or we'll see extra resets and increments! if (object.isText() && !object.isBR()) return false; Node* generatingNode = object.generatingNode(); // We must have a generating node or else we cannot have a counter. if (!generatingNode) return false; const ComputedStyle& style = object.styleRef(); switch (style.styleType()) { case NOPSEUDO: // Sometimes nodes have more then one layoutObject. Only the first one gets the counter // LayoutTests/http/tests/css/counter-crash.html if (generatingNode->layoutObject() != &object) return false; break; case BEFORE: case AFTER: break; default: return false; // Counters are forbidden from all other pseudo elements. } const CounterDirectives directives = style.getCounterDirectives(identifier); if (directives.isDefined()) { value = directives.combinedValue(); isReset = directives.isReset(); return true; } if (identifier == "list-item") { if (object.isListItem()) { if (toLayoutListItem(object).hasExplicitValue()) { value = toLayoutListItem(object).explicitValue(); isReset = true; return true; } value = 1; isReset = false; return true; } if (Node* e = object.node()) { if (isHTMLOListElement(*e)) { value = toHTMLOListElement(e)->start(); isReset = true; return true; } if (isHTMLUListElement(*e) || isHTMLMenuElement(*e) || isHTMLDirectoryElement(*e)) { value = 0; isReset = true; return true; } } } return false; }
static bool planCounter(RenderElement& renderer, const AtomicString& identifier, bool& isReset, int& value) { // We must have a generating node or else we cannot have a counter. Element* generatingElement = renderer.generatingElement(); if (!generatingElement) return false; const RenderStyle& style = renderer.style(); switch (style.styleType()) { case NOPSEUDO: // Sometimes elements have more then one renderer. Only the first one gets the counter // LayoutTests/http/tests/css/counter-crash.html if (generatingElement->renderer() != &renderer) return false; break; case BEFORE: case AFTER: break; default: return false; // Counters are forbidden from all other pseudo elements. } const CounterDirectives directives = style.getCounterDirectives(identifier); if (directives.isDefined()) { value = directives.combinedValue(); isReset = directives.isReset(); return true; } if (identifier == "list-item") { if (is<RenderListItem>(renderer)) { if (downcast<RenderListItem>(renderer).hasExplicitValue()) { value = downcast<RenderListItem>(renderer).explicitValue(); isReset = true; return true; } value = 1; isReset = false; return true; } if (Element* element = renderer.element()) { if (is<HTMLOListElement>(*element)) { value = downcast<HTMLOListElement>(*element).start(); isReset = true; return true; } if (element->hasTagName(ulTag) || element->hasTagName(menuTag) || element->hasTagName(dirTag)) { value = 0; isReset = true; return true; } } } return false; }
static bool planCounter(RenderObject* object, const AtomicString& identifier, bool& isReset, int& value) { ASSERT(object); // Real text nodes don't have their own style so they can't have counters. // We can't even look at their styles or we'll see extra resets and increments! if (object->isText() && !object->isBR()) return false; Node* generatingNode = object->generatingNode(); // We must have a generating node or else we cannot have a counter. if (!generatingNode) return false; RenderStyle* style = object->style(); ASSERT(style); switch (style->styleType()) { case NOPSEUDO: // Sometimes nodes have more then one renderer. Only the first one gets the counter // LayoutTests/http/tests/css/counter-crash.html if (generatingNode->renderer() != object) return false; break; case BEFORE: case AFTER: break; default: return false; // Counters are forbidden from all other pseudo elements. } const CounterDirectives directives = style->getCounterDirectives(identifier); if (directives.isDefined()) { value = directives.combinedValue(); isReset = directives.isReset(); return true; } if (identifier == "list-item") { if (object->isListItem()) { if (toRenderListItem(object)->hasExplicitValue()) { value = toRenderListItem(object)->explicitValue(); isReset = true; return true; } value = 1; isReset = false; return true; } if (Node* e = object->node()) { if (e->hasTagName(olTag)) { value = toHTMLOListElement(e)->start(); isReset = true; return true; } if (e->hasTagName(ulTag) || e->hasTagName(menuTag) || e->hasTagName(dirTag)) { value = 0; isReset = true; return true; } } } return false; }