| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // and for propagating count changes when nodes are added or removed. | 30 // and for propagating count changes when nodes are added or removed. |
| 31 | 31 |
| 32 // Parents represent unique counters and their scope, which are created either e
xplicitly | 32 // Parents represent unique counters and their scope, which are created either e
xplicitly |
| 33 // by "counter-reset" style rules or implicitly by referring to a counter that i
s not in scope. | 33 // by "counter-reset" style rules or implicitly by referring to a counter that i
s not in scope. |
| 34 // Such nodes are tagged as "reset" nodes, although they are not all due to "cou
nter-reset". | 34 // Such nodes are tagged as "reset" nodes, although they are not all due to "cou
nter-reset". |
| 35 | 35 |
| 36 // Not that render tree children are often counter tree siblings due to counter
scoping rules. | 36 // Not that render tree children are often counter tree siblings due to counter
scoping rules. |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class RenderObject; | 40 class LayoutObject; |
| 41 class LayoutCounter; | 41 class LayoutCounter; |
| 42 | 42 |
| 43 class CounterNode : public RefCounted<CounterNode> { | 43 class CounterNode : public RefCounted<CounterNode> { |
| 44 public: | 44 public: |
| 45 static PassRefPtr<CounterNode> create(RenderObject&, bool isReset, int value
); | 45 static PassRefPtr<CounterNode> create(LayoutObject&, bool isReset, int value
); |
| 46 ~CounterNode(); | 46 ~CounterNode(); |
| 47 bool actsAsReset() const { return m_hasResetType || !m_parent; } | 47 bool actsAsReset() const { return m_hasResetType || !m_parent; } |
| 48 bool hasResetType() const { return m_hasResetType; } | 48 bool hasResetType() const { return m_hasResetType; } |
| 49 int value() const { return m_value; } | 49 int value() const { return m_value; } |
| 50 int countInParent() const { return m_countInParent; } | 50 int countInParent() const { return m_countInParent; } |
| 51 RenderObject& owner() const { return m_owner; } | 51 LayoutObject& owner() const { return m_owner; } |
| 52 void addRenderer(LayoutCounter*); | 52 void addRenderer(LayoutCounter*); |
| 53 void removeRenderer(LayoutCounter*); | 53 void removeRenderer(LayoutCounter*); |
| 54 | 54 |
| 55 // Invalidates the text in the renderers of this counter, if any. | 55 // Invalidates the text in the renderers of this counter, if any. |
| 56 void resetRenderers(); | 56 void resetRenderers(); |
| 57 | 57 |
| 58 CounterNode* parent() const { return m_parent; } | 58 CounterNode* parent() const { return m_parent; } |
| 59 CounterNode* previousSibling() const { return m_previousSibling; } | 59 CounterNode* previousSibling() const { return m_previousSibling; } |
| 60 CounterNode* nextSibling() const { return m_nextSibling; } | 60 CounterNode* nextSibling() const { return m_nextSibling; } |
| 61 CounterNode* firstChild() const { return m_firstChild; } | 61 CounterNode* firstChild() const { return m_firstChild; } |
| 62 CounterNode* lastChild() const { return m_lastChild; } | 62 CounterNode* lastChild() const { return m_lastChild; } |
| 63 CounterNode* lastDescendant() const; | 63 CounterNode* lastDescendant() const; |
| 64 CounterNode* previousInPreOrder() const; | 64 CounterNode* previousInPreOrder() const; |
| 65 CounterNode* nextInPreOrder(const CounterNode* stayWithin = 0) const; | 65 CounterNode* nextInPreOrder(const CounterNode* stayWithin = 0) const; |
| 66 CounterNode* nextInPreOrderAfterChildren(const CounterNode* stayWithin = 0)
const; | 66 CounterNode* nextInPreOrderAfterChildren(const CounterNode* stayWithin = 0)
const; |
| 67 | 67 |
| 68 void insertAfter(CounterNode* newChild, CounterNode* beforeChild, const Atom
icString& identifier); | 68 void insertAfter(CounterNode* newChild, CounterNode* beforeChild, const Atom
icString& identifier); |
| 69 | 69 |
| 70 // identifier must match the identifier of this counter. | 70 // identifier must match the identifier of this counter. |
| 71 void removeChild(CounterNode*); | 71 void removeChild(CounterNode*); |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 CounterNode(RenderObject&, bool isReset, int value); | 74 CounterNode(LayoutObject&, bool isReset, int value); |
| 75 int computeCountInParent() const; | 75 int computeCountInParent() const; |
| 76 // Invalidates the text in the renderer of this counter, if any, | 76 // Invalidates the text in the renderer of this counter, if any, |
| 77 // and in the renderers of all descendants of this counter, if any. | 77 // and in the renderers of all descendants of this counter, if any. |
| 78 void resetThisAndDescendantsRenderers(); | 78 void resetThisAndDescendantsRenderers(); |
| 79 void recount(); | 79 void recount(); |
| 80 | 80 |
| 81 bool m_hasResetType; | 81 bool m_hasResetType; |
| 82 int m_value; | 82 int m_value; |
| 83 int m_countInParent; | 83 int m_countInParent; |
| 84 RenderObject& m_owner; | 84 LayoutObject& m_owner; |
| 85 LayoutCounter* m_rootRenderer; | 85 LayoutCounter* m_rootRenderer; |
| 86 | 86 |
| 87 CounterNode* m_parent; | 87 CounterNode* m_parent; |
| 88 CounterNode* m_previousSibling; | 88 CounterNode* m_previousSibling; |
| 89 CounterNode* m_nextSibling; | 89 CounterNode* m_nextSibling; |
| 90 CounterNode* m_firstChild; | 90 CounterNode* m_firstChild; |
| 91 CounterNode* m_lastChild; | 91 CounterNode* m_lastChild; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace blink | 94 } // namespace blink |
| 95 | 95 |
| 96 #ifndef NDEBUG | 96 #ifndef NDEBUG |
| 97 // Outside the WebCore namespace for ease of invocation from gdb. | 97 // Outside the WebCore namespace for ease of invocation from gdb. |
| 98 void showCounterTree(const blink::CounterNode*); | 98 void showCounterTree(const blink::CounterNode*); |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 #endif // CounterNode_h | 101 #endif // CounterNode_h |
| OLD | NEW |