OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "wtf/text/AtomicString.h" | 23 #include "wtf/text/AtomicString.h" |
24 | 24 |
25 namespace WebCore { | 25 namespace WebCore { |
26 | 26 |
27 class Frame; | 27 class Frame; |
28 class TreeScope; | 28 class TreeScope; |
29 | 29 |
30 class FrameTree { | 30 class FrameTree { |
31 WTF_MAKE_NONCOPYABLE(FrameTree); | 31 WTF_MAKE_NONCOPYABLE(FrameTree); |
32 public: | 32 public: |
33 const static unsigned invalidCount = static_cast<unsigned>(-1); | 33 explicit FrameTree(Frame* thisFrame); |
34 | |
35 FrameTree(Frame* thisFrame, Frame* parentFrame) | |
36 : m_thisFrame(thisFrame) | |
37 , m_parent(parentFrame) | |
38 , m_previousSibling(0) | |
39 , m_lastChild(0) | |
40 , m_scopedChildCount(invalidCount) | |
41 { | |
42 } | |
43 | |
44 ~FrameTree(); | 34 ~FrameTree(); |
45 | 35 |
46 const AtomicString& name() const { return m_name; } | 36 const AtomicString& name() const { return m_name; } |
47 const AtomicString& uniqueName() const { return m_uniqueName; } | 37 const AtomicString& uniqueName() const { return m_uniqueName; } |
48 void setName(const AtomicString&); | 38 void setName(const AtomicString&); |
| 39 |
49 Frame* parent() const; | 40 Frame* parent() const; |
50 | 41 Frame* top() const; |
51 Frame* nextSibling() const { return m_nextSibling.get(); } | 42 Frame* previousSibling() const; |
52 Frame* previousSibling() const { return m_previousSibling; } | 43 Frame* nextSibling() const; |
53 Frame* firstChild() const { return m_firstChild.get(); } | 44 Frame* firstChild() const; |
54 Frame* lastChild() const { return m_lastChild; } | 45 Frame* lastChild() const; |
55 | 46 |
56 bool isDescendantOf(const Frame* ancestor) const; | 47 bool isDescendantOf(const Frame* ancestor) const; |
| 48 Frame* traversePreviousWithWrap(bool) const; |
57 Frame* traverseNext(const Frame* stayWithin = 0) const; | 49 Frame* traverseNext(const Frame* stayWithin = 0) const; |
58 Frame* traverseNextWithWrap(bool) const; | 50 Frame* traverseNextWithWrap(bool) const; |
59 Frame* traversePreviousWithWrap(bool) const; | |
60 | |
61 void appendChild(PassRefPtr<Frame>); | |
62 void removeChild(Frame*); | |
63 | 51 |
64 Frame* child(const AtomicString& name) const; | 52 Frame* child(const AtomicString& name) const; |
65 Frame* find(const AtomicString& name) const; | 53 Frame* find(const AtomicString& name) const; |
66 unsigned childCount() const; | 54 unsigned childCount() const; |
67 | 55 |
68 Frame* top() const; | |
69 | |
70 Frame* scopedChild(unsigned index) const; | 56 Frame* scopedChild(unsigned index) const; |
71 Frame* scopedChild(const AtomicString& name) const; | 57 Frame* scopedChild(const AtomicString& name) const; |
72 unsigned scopedChildCount() const; | 58 unsigned scopedChildCount() const; |
| 59 void invalidateScopedChildCount(); |
73 | 60 |
74 private: | 61 private: |
75 Frame* deepLastChild() const; | 62 Frame* deepLastChild() const; |
76 AtomicString uniqueChildName(const AtomicString& requestedName) const; | 63 AtomicString uniqueChildName(const AtomicString& requestedName) const; |
77 unsigned scopedChildCount(TreeScope*) const; | 64 unsigned scopedChildCount(TreeScope*) const; |
78 | 65 |
79 Frame* m_thisFrame; | 66 Frame* m_thisFrame; |
80 | 67 |
81 Frame* m_parent; | |
82 AtomicString m_name; // The actual frame name (may be empty). | 68 AtomicString m_name; // The actual frame name (may be empty). |
83 AtomicString m_uniqueName; | 69 AtomicString m_uniqueName; |
84 | 70 |
85 // FIXME: use ListRefPtr? | |
86 RefPtr<Frame> m_nextSibling; | |
87 Frame* m_previousSibling; | |
88 RefPtr<Frame> m_firstChild; | |
89 Frame* m_lastChild; | |
90 mutable unsigned m_scopedChildCount; | 71 mutable unsigned m_scopedChildCount; |
91 }; | 72 }; |
92 | 73 |
93 } // namespace WebCore | 74 } // namespace WebCore |
94 | 75 |
95 #ifndef NDEBUG | 76 #ifndef NDEBUG |
96 // Outside the WebCore namespace for ease of invocation from gdb. | 77 // Outside the WebCore namespace for ease of invocation from gdb. |
97 void showFrameTree(const WebCore::Frame*); | 78 void showFrameTree(const WebCore::Frame*); |
98 #endif | 79 #endif |
99 | 80 |
100 #endif // FrameTree_h | 81 #endif // FrameTree_h |
OLD | NEW |