bdakin | 5d6edd4 | 2006-10-02 23:15:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the HTML rendering engine for KDE. |
| 3 | * |
| 4 | * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 | * Copyright (C) 2006 Apple Computer, Inc. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public License |
| 18 | * along with this library; see the file COPYING.LIB. If not, write to |
| 19 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | * Boston, MA 02111-1307, USA. |
| 21 | * |
| 22 | */ |
weinig | 1497a7e | 2006-10-26 20:23:55 +0000 | [diff] [blame^] | 23 | #ifndef CounterNode_h |
| 24 | #define CounterNode_h |
bdakin | 5d6edd4 | 2006-10-02 23:15:31 +0000 | [diff] [blame] | 25 | |
| 26 | #include "RenderObject.h" |
| 27 | |
| 28 | namespace WebCore { |
| 29 | |
| 30 | class CounterResetNode; |
| 31 | |
| 32 | // This file implements a counter-tree that is used for finding all parents in counters() lookup, |
| 33 | // and for propagating count-changes when nodes are added or removed. |
| 34 | // Please note that only counter-reset and root can be parents here, and that render-tree parents |
| 35 | // are just counter-tree siblings |
| 36 | |
| 37 | class CounterNode { |
| 38 | public: |
| 39 | CounterNode(RenderObject*); |
weinig | 1497a7e | 2006-10-26 20:23:55 +0000 | [diff] [blame^] | 40 | virtual ~CounterNode() { } |
bdakin | 5d6edd4 | 2006-10-02 23:15:31 +0000 | [diff] [blame] | 41 | |
| 42 | CounterResetNode* parent() const { return m_parent; } |
| 43 | CounterNode* previousSibling() const { return m_previous; } |
| 44 | virtual CounterNode* nextSibling() const { return m_next; } |
| 45 | virtual CounterNode* firstChild() const { return 0; } |
| 46 | virtual CounterNode* lastChild() const { return 0; } |
| 47 | virtual void insertAfter(CounterNode* newChild, CounterNode* refChild); |
weinig | 1497a7e | 2006-10-26 20:23:55 +0000 | [diff] [blame^] | 48 | virtual void removeChild(CounterNode*); |
bdakin | 5d6edd4 | 2006-10-02 23:15:31 +0000 | [diff] [blame] | 49 | void remove(); |
| 50 | |
| 51 | int value() const { return m_value; } |
| 52 | void setValue(int v) { m_value = v; } |
| 53 | int count() const { return m_count; } |
| 54 | void setCount(int c) { m_count = c; } |
| 55 | void setHasSeparator() { m_hasSeparator = true; } |
| 56 | |
weinig | 1497a7e | 2006-10-26 20:23:55 +0000 | [diff] [blame^] | 57 | virtual bool isReset() const { return false; } |
bdakin | 5d6edd4 | 2006-10-02 23:15:31 +0000 | [diff] [blame] | 58 | virtual CounterNode* recountAndGetNext(bool setDirty = true); |
| 59 | virtual void recountTree(bool setDirty = true); |
| 60 | virtual void setSelfDirty(); |
| 61 | virtual void setParentDirty(); |
| 62 | |
| 63 | bool hasSeparator() const { return m_hasSeparator; } |
| 64 | bool willNeedLayout() const { return m_willNeedLayout; } |
| 65 | void setUsesSeparator(); |
| 66 | void setWillNeedLayout() { m_willNeedLayout = true; } |
| 67 | bool isRoot() const { return m_renderer && m_renderer->isRoot(); } |
| 68 | |
| 69 | void setRenderer(RenderObject* o) { m_renderer = o; } |
| 70 | RenderObject* renderer() const { return m_renderer; } |
| 71 | |
| 72 | friend class CounterResetNode; |
| 73 | protected: |
| 74 | bool m_hasSeparator; |
| 75 | bool m_willNeedLayout; |
| 76 | int m_value; |
| 77 | int m_count; |
| 78 | CounterResetNode* m_parent; |
| 79 | CounterNode* m_previous; |
| 80 | CounterNode* m_next; |
| 81 | RenderObject* m_renderer; |
| 82 | }; |
| 83 | |
| 84 | } // namespace WebCore |
| 85 | |
| 86 | #endif // CounterNode_h |