Chromium Code Reviews| 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 (at least outside of FrameTree.cpp) as an | |
|
dcheng
2016/05/31 19:57:47
I would just condense this down to "The value shou
Łukasz Anforowicz
2016/05/31 23:50:20
Done. Let me know if you think I should also remo
dcheng
2016/06/01 20:58:11
I think it makes sense to remove that part of the
Łukasz Anforowicz
2016/06/01 22:31:28
Done.
| |
| 47 // unstructured, opaque string. The implementation details, including | |
| 48 // the format description can be found in FrameTree.cpp, in a comment | |
| 49 // inside calculateUniqueNameForChildFrame method. | |
| 40 const AtomicString& uniqueName() const { return m_uniqueName; } | 50 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 | 51 |
| 45 // Directly assigns both the name and uniqueName. Can be used when | 52 // Directly assigns both the name and uniqueName. Can be used when |
| 46 // |uniqueName| is already known (i.e. when it has been precalculated by | 53 // |uniqueName| is already known (i.e. when it has been precalculated by |
| 47 // calculateUniqueNameForNewChildFrame OR when replicating the name between | 54 // calculateUniqueNameForNewChildFrame OR when replicating the name between |
| 48 // LocalFrames and RemoteFrames for the same logical frame). | 55 // LocalFrames and RemoteFrames for the same logical frame). |
| 49 void setPrecalculatedName(const AtomicString& name, const AtomicString& uniq ueName); | 56 void setPrecalculatedName(const AtomicString& name, const AtomicString& uniq ueName); |
| 50 | 57 |
| 51 Frame* parent() const; | 58 Frame* parent() const; |
| 52 Frame* top() const; | 59 Frame* top() const; |
| 53 Frame* previousSibling() const; | 60 Frame* previousSibling() const; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 70 void invalidateScopedChildCount(); | 77 void invalidateScopedChildCount(); |
| 71 | 78 |
| 72 DECLARE_TRACE(); | 79 DECLARE_TRACE(); |
| 73 | 80 |
| 74 AtomicString calculateUniqueNameForNewChildFrame( | 81 AtomicString calculateUniqueNameForNewChildFrame( |
| 75 const AtomicString& name, | 82 const AtomicString& name, |
| 76 const AtomicString& fallbackName = nullAtom) const; | 83 const AtomicString& fallbackName = nullAtom) const; |
| 77 | 84 |
| 78 private: | 85 private: |
| 79 Frame* deepLastChild() const; | 86 Frame* deepLastChild() const; |
| 87 | |
| 88 // Returns true if one of frames in the tree already has unique name equal | |
| 89 // to |uniqueNameCandidate|. | |
| 90 bool uniqueNameExists(const AtomicString& uniqueNameCandidate) const; | |
| 91 | |
| 92 // Generates a hopefully-but-not-necessarily unique name based on frame's | |
| 93 // relative position in the tree and on unique names of ancestors. | |
| 94 AtomicString generateOldStyleMaybeUniqueName(bool existingChildFrame) const; | |
|
dcheng
2016/05/31 19:57:47
Nit: generateUniqueNameCandidate?
Łukasz Anforowicz
2016/05/31 23:50:20
Done.
| |
| 95 | |
| 96 // Generates a hopefully-but-not-necessarily unique suffix based on |child| | |
| 97 // absolute position in the tree. If |child| is nullptr, calculations are | |
| 98 // made for a position that a new child of |this| would have. | |
| 99 String generateLikelyUniqueSuffix(Frame* child) const; | |
|
dcheng
2016/05/31 19:57:47
Nit: generateFramePosition?
Łukasz Anforowicz
2016/05/31 23:50:20
Done.
| |
| 100 | |
| 101 // Returns a unique name created by appending a suffix to |notYetUniqueName| . | |
| 102 // The appended suffix is based on |likelyUniqueSuffix|, but can also | |
| 103 // be extended to fulfill the uniqueness requirement. | |
| 104 AtomicString ensureUniquenessOfUniqueName( | |
|
dcheng
2016/05/31 19:57:47
Nit: generateUniqueNameFromCandidate
Łukasz Anforowicz
2016/05/31 23:50:20
How about
// Concatenates |prefix|, |likelyUni
| |
| 105 const AtomicString& notYetUniqueName, | |
|
dcheng
2016/05/31 19:57:47
Nit: candidate
Łukasz Anforowicz
2016/05/31 23:50:20
How about |prefix| (we use |uniqueNameCandidate| a
| |
| 106 const String& likelyUniqueSuffix) const; | |
| 107 | |
| 108 // Calculates a unique name for |child| frame (which might be nullptr if the | |
| 109 // child has not yet been created - i.e. when we need unique name for a new | |
| 110 // frame). Tries to use the |assignedName| or |fallbackName| if possible, | |
| 111 // otherwise falls back to generating a deterministic, | |
| 112 // stable-across-page-reloads string based on |child| position in the tree. | |
| 80 AtomicString calculateUniqueNameForChildFrame( | 113 AtomicString calculateUniqueNameForChildFrame( |
| 81 bool existingChildFrame, | 114 Frame* child, |
| 82 const AtomicString& name, | 115 const AtomicString& assignedName, |
| 83 const AtomicString& fallbackName = nullAtom) const; | 116 const AtomicString& fallbackName = nullAtom) const; |
| 84 bool uniqueNameExists(const AtomicString& name) const; | 117 |
| 118 // Sets |m_uniqueName| and asserts its uniqueness. | |
| 119 void setUniqueName(const AtomicString&); | |
| 85 | 120 |
| 86 Member<Frame> m_thisFrame; | 121 Member<Frame> m_thisFrame; |
| 87 | 122 |
| 88 AtomicString m_name; // The actual frame name (may be empty). | 123 AtomicString m_name; // The actual frame name (may be empty). |
| 89 AtomicString m_uniqueName; | 124 AtomicString m_uniqueName; |
| 90 | 125 |
| 91 mutable unsigned m_scopedChildCount; | 126 mutable unsigned m_scopedChildCount; |
| 92 }; | 127 }; |
| 93 | 128 |
| 94 } // namespace blink | 129 } // namespace blink |
| 95 | 130 |
| 96 #ifndef NDEBUG | 131 #ifndef NDEBUG |
| 97 // Outside the WebCore namespace for ease of invocation from gdb. | 132 // Outside the WebCore namespace for ease of invocation from gdb. |
| 98 void showFrameTree(const blink::Frame*); | 133 void showFrameTree(const blink::Frame*); |
| 99 #endif | 134 #endif |
| 100 | 135 |
| 101 #endif // FrameTree_h | 136 #endif // FrameTree_h |
| OLD | NEW |