| 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 19 matching lines...) Expand all Loading... |
| 30 class TreeScope; | 30 class TreeScope; |
| 31 | 31 |
| 32 class CORE_EXPORT FrameTree final { | 32 class CORE_EXPORT FrameTree final { |
| 33 WTF_MAKE_NONCOPYABLE(FrameTree); | 33 WTF_MAKE_NONCOPYABLE(FrameTree); |
| 34 DISALLOW_NEW(); | 34 DISALLOW_NEW(); |
| 35 public: | 35 public: |
| 36 explicit FrameTree(Frame* thisFrame); | 36 explicit FrameTree(Frame* thisFrame); |
| 37 ~FrameTree(); | 37 ~FrameTree(); |
| 38 | 38 |
| 39 const AtomicString& name() const { return m_name; } | 39 const AtomicString& name() const { return m_name; } |
| 40 void setName(const AtomicString&); |
| 41 |
| 42 // Unique name of a frame (unique per page). Mainly used to identify the |
| 43 // frame for session history purposes, but also used in expected results |
| 44 // of layout tests. |
| 45 // |
| 46 // The value should be treated as an unstructured, opaque string. |
| 47 // The implementation details can be found in FrameTree.cpp, in a comment |
| 48 // inside calculateUniqueNameForChildFrame method. |
| 40 const AtomicString& uniqueName() const { return m_uniqueName; } | 49 const AtomicString& uniqueName() const { return m_uniqueName; } |
| 41 // If |name| is not empty, |fallbackName| is ignored. Otherwise, | |
| 42 // |fallbackName| is used as a source of uniqueName. | |
| 43 void setName(const AtomicString& name, const AtomicString& fallbackName = nu
llAtom); | |
| 44 | 50 |
| 45 // Directly assigns both the name and uniqueName. Can be used when | 51 // Directly assigns both the name and uniqueName. Can be used when |
| 46 // |uniqueName| is already known (i.e. when it has been precalculated by | 52 // |uniqueName| is already known (i.e. when it has been precalculated by |
| 47 // calculateUniqueNameForNewChildFrame OR when replicating the name between | 53 // calculateUniqueNameForNewChildFrame OR when replicating the name between |
| 48 // LocalFrames and RemoteFrames for the same logical frame). | 54 // LocalFrames and RemoteFrames for the same logical frame). |
| 49 void setPrecalculatedName(const AtomicString& name, const AtomicString& uniq
ueName); | 55 void setPrecalculatedName(const AtomicString& name, const AtomicString& uniq
ueName); |
| 50 | 56 |
| 51 Frame* parent() const; | 57 Frame* parent() const; |
| 52 Frame* top() const; | 58 Frame* top() const; |
| 53 Frame* previousSibling() const; | 59 Frame* previousSibling() const; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 void invalidateScopedChildCount(); | 76 void invalidateScopedChildCount(); |
| 71 | 77 |
| 72 DECLARE_TRACE(); | 78 DECLARE_TRACE(); |
| 73 | 79 |
| 74 AtomicString calculateUniqueNameForNewChildFrame( | 80 AtomicString calculateUniqueNameForNewChildFrame( |
| 75 const AtomicString& name, | 81 const AtomicString& name, |
| 76 const AtomicString& fallbackName = nullAtom) const; | 82 const AtomicString& fallbackName = nullAtom) const; |
| 77 | 83 |
| 78 private: | 84 private: |
| 79 Frame* deepLastChild() const; | 85 Frame* deepLastChild() const; |
| 86 |
| 87 // Returns true if one of frames in the tree already has unique name equal |
| 88 // to |uniqueNameCandidate|. |
| 89 bool uniqueNameExists(const AtomicString& uniqueNameCandidate) const; |
| 90 |
| 91 // Generates a hopefully-but-not-necessarily unique name based on frame's |
| 92 // relative position in the tree and on unique names of ancestors. |
| 93 AtomicString generateUniqueNameCandidate(bool existingChildFrame) const; |
| 94 |
| 95 // Generates a hopefully-but-not-necessarily unique suffix based on |child| |
| 96 // absolute position in the tree. If |child| is nullptr, calculations are |
| 97 // made for a position that a new child of |this| would have. |
| 98 String generateFramePosition(Frame* child) const; |
| 99 |
| 100 // Concatenates |prefix|, |likelyUniqueSuffix| (and additional, internally |
| 101 // generated suffix) until the result is a unique name, that doesn't exist |
| 102 // elsewhere in the frame tree. Returns the unique name built in this way. |
| 103 AtomicString appendUniqueSuffix( |
| 104 const AtomicString& prefix, |
| 105 const String& likelyUniqueSuffix) const; |
| 106 |
| 107 // Calculates a unique name for |child| frame (which might be nullptr if the |
| 108 // child has not yet been created - i.e. when we need unique name for a new |
| 109 // frame). Tries to use the |assignedName| or |fallbackName| if possible, |
| 110 // otherwise falls back to generating a deterministic, |
| 111 // stable-across-page-reloads string based on |child| position in the tree. |
| 80 AtomicString calculateUniqueNameForChildFrame( | 112 AtomicString calculateUniqueNameForChildFrame( |
| 81 bool existingChildFrame, | 113 Frame* child, |
| 82 const AtomicString& name, | 114 const AtomicString& assignedName, |
| 83 const AtomicString& fallbackName = nullAtom) const; | 115 const AtomicString& fallbackName = nullAtom) const; |
| 84 bool uniqueNameExists(const AtomicString& name) const; | 116 |
| 117 // Sets |m_uniqueName| and asserts its uniqueness. |
| 118 void setUniqueName(const AtomicString&); |
| 85 | 119 |
| 86 Member<Frame> m_thisFrame; | 120 Member<Frame> m_thisFrame; |
| 87 | 121 |
| 88 AtomicString m_name; // The actual frame name (may be empty). | 122 AtomicString m_name; // The actual frame name (may be empty). |
| 89 AtomicString m_uniqueName; | 123 AtomicString m_uniqueName; |
| 90 | 124 |
| 91 mutable unsigned m_scopedChildCount; | 125 mutable unsigned m_scopedChildCount; |
| 92 }; | 126 }; |
| 93 | 127 |
| 94 } // namespace blink | 128 } // namespace blink |
| 95 | 129 |
| 96 #ifndef NDEBUG | 130 #ifndef NDEBUG |
| 97 // Outside the WebCore namespace for ease of invocation from gdb. | 131 // Outside the WebCore namespace for ease of invocation from gdb. |
| 98 void showFrameTree(const blink::Frame*); | 132 void showFrameTree(const blink::Frame*); |
| 99 #endif | 133 #endif |
| 100 | 134 |
| 101 #endif // FrameTree_h | 135 #endif // FrameTree_h |
| OLD | NEW |