summaryrefslogtreecommitdiffstats
path: root/khtml/rendering/counter_tree.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /khtml/rendering/counter_tree.h
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khtml/rendering/counter_tree.h')
-rw-r--r--khtml/rendering/counter_tree.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/khtml/rendering/counter_tree.h b/khtml/rendering/counter_tree.h
new file mode 100644
index 000000000..55b924b80
--- /dev/null
+++ b/khtml/rendering/counter_tree.h
@@ -0,0 +1,114 @@
+/*
+ * This file is part of the HTML rendering engine for KDE.
+ *
+ * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _Counter_Tree_h_
+#define _Counter_Tree_h_
+
+#include "misc/shared.h"
+#include "rendering/render_object.h"
+
+namespace khtml {
+
+class CounterReset;
+
+// This file implements a counter-tree that is used for finding all parents in counters() lookup,
+// and for propagating count-changes when nodes are added or removed.
+// Please note that only counter-reset and root can be parents here, and that render-tree parents
+// are just counter-tree siblings
+
+// Implementation of counter-increment and counter-content
+class CounterNode
+{
+public:
+ CounterNode(RenderObject *o);
+ virtual ~CounterNode();
+
+ CounterReset* parent() const { return m_parent; }
+ CounterNode* previousSibling() const { return m_previous; }
+ CounterNode* nextSibling() const { return m_next; }
+ virtual CounterNode* firstChild() const { return 0; } ;
+ virtual CounterNode* lastChild() const { return 0; };
+ virtual void insertAfter ( CounterNode *newChild, CounterNode *refChild );
+ virtual void removeChild ( CounterNode *oldChild );
+ // Convenient self-refering version of the above
+ void remove();
+
+ int value() const { return m_value; };
+ void setValue(short v) { m_value = v; };
+ int count() const { return m_count; };
+
+ virtual bool isReset() { return false; };
+ virtual void recount( bool first = false );
+ virtual void setSelfDirty();
+ virtual void setParentDirty();
+
+ bool hasCounters() const { return m_hasCounters; };
+ bool isVisual() const { return m_isVisual; };
+ void setHasCounters();
+ void setIsVisual() { m_isVisual = true; };
+ bool isRoot() { return m_renderer && m_renderer->isRoot(); };
+
+ void setRenderer(RenderObject *o) { m_renderer = o; };
+ RenderObject* renderer() const { return m_renderer; };
+
+ friend class CounterReset;
+protected:
+ bool m_hasCounters : 1;
+ bool m_isVisual : 1;
+ short m_value;
+ short m_count;
+ CounterReset *m_parent;
+ CounterNode *m_previous;
+ CounterNode *m_next;
+ RenderObject *m_renderer;
+};
+
+// Implementation of counter-reset and root
+class CounterReset : public CounterNode
+{
+public:
+ CounterReset(RenderObject *o);
+ virtual ~CounterReset();
+
+ virtual CounterNode *firstChild() const { return m_first; };
+ virtual CounterNode *lastChild() const { return m_last; };
+ virtual void insertAfter ( CounterNode *newChild, CounterNode *refChild );
+ virtual void removeChild ( CounterNode *oldChild );
+
+ virtual bool isReset() { return true; };
+ virtual void recount( bool first = false );
+ virtual void setSelfDirty();
+ virtual void setParentDirty();
+
+ void updateTotal(int value);
+ // The highest value among children
+ int total() const { return m_total; };
+
+protected:
+ int m_total;
+ CounterNode *m_first;
+ CounterNode *m_last;
+};
+
+} // namespace
+
+#endif
+