1 /* 2 * Copyright (C) 2006 Apple Computer, Inc. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef FrameTree_h 21 #define FrameTree_h 22 23 #include <wtf/text/AtomicString.h> 24 25 namespace WebCore { 26 27 class Frame; 28 29 class FrameTree { 30 WTF_MAKE_NONCOPYABLE(FrameTree); 31 public: FrameTree(Frame * thisFrame,Frame * parentFrame)32 FrameTree(Frame* thisFrame, Frame* parentFrame) 33 : m_thisFrame(thisFrame) 34 , m_parent(parentFrame) 35 , m_previousSibling(0) 36 , m_lastChild(0) 37 , m_childCount(0) 38 { 39 } 40 ~FrameTree(); 41 name()42 const AtomicString& name() const { return m_name; } uniqueName()43 const AtomicString& uniqueName() const { return m_uniqueName; } 44 void setName(const AtomicString&); 45 void clearName(); 46 Frame* parent(bool checkForDisconnectedFrame = false) const; setParent(Frame * parent)47 void setParent(Frame* parent) { m_parent = parent; } 48 nextSibling()49 Frame* nextSibling() const { return m_nextSibling.get(); } previousSibling()50 Frame* previousSibling() const { return m_previousSibling; } firstChild()51 Frame* firstChild() const { return m_firstChild.get(); } lastChild()52 Frame* lastChild() const { return m_lastChild; } childCount()53 unsigned childCount() const { return m_childCount; } 54 55 bool isDescendantOf(const Frame* ancestor) const; 56 Frame* traverseNext(const Frame* stayWithin = 0) const; 57 Frame* traverseNextWithWrap(bool) const; 58 Frame* traversePreviousWithWrap(bool) const; 59 60 void appendChild(PassRefPtr<Frame>); 61 bool transferChild(PassRefPtr<Frame>); detachFromParent()62 void detachFromParent() { m_parent = 0; } 63 void removeChild(Frame*); 64 65 Frame* child(unsigned index) const; 66 Frame* child(const AtomicString& name) const; 67 Frame* find(const AtomicString& name) const; 68 69 AtomicString uniqueChildName(const AtomicString& requestedName) const; 70 71 Frame* top(bool checkForDisconnectedFrame = false) const; 72 73 private: 74 Frame* deepLastChild() const; 75 void actuallyAppendChild(PassRefPtr<Frame>); 76 77 Frame* m_thisFrame; 78 79 Frame* m_parent; 80 AtomicString m_name; // The actual frame name (may be empty). 81 AtomicString m_uniqueName; 82 83 // FIXME: use ListRefPtr? 84 RefPtr<Frame> m_nextSibling; 85 Frame* m_previousSibling; 86 RefPtr<Frame> m_firstChild; 87 Frame* m_lastChild; 88 unsigned m_childCount; 89 }; 90 91 } // namespace WebCore 92 93 #endif // FrameTree_h 94