Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: third_party/WebKit/Source/core/page/FrameTree.h

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: Rebase again. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
32 WTF_MAKE_NONCOPYABLE(FrameTree); 32 WTF_MAKE_NONCOPYABLE(FrameTree);
33 DISALLOW_NEW(); 33 DISALLOW_NEW();
34 34
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&); 40 void setName(const AtomicString&);
41 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 const AtomicString& uniqueName() const { return m_uniqueName; }
48
49 // Directly assigns both the name and uniqueName. Can be used when
50 // |uniqueName| is already known (i.e. when it has been precalculated by
51 // calculateUniqueNameForNewChildFrame OR when replicating the name between
52 // LocalFrames and RemoteFrames for the same logical frame).
53 void setPrecalculatedName(const AtomicString& name,
54 const AtomicString& uniqueName);
55
56 Frame* parent() const; 42 Frame* parent() const;
57 Frame* top() const; 43 Frame* top() const;
58 Frame* nextSibling() const; 44 Frame* nextSibling() const;
59 Frame* firstChild() const; 45 Frame* firstChild() const;
60 46
61 bool isDescendantOf(const Frame* ancestor) const; 47 bool isDescendantOf(const Frame* ancestor) const;
62 Frame* traverseNext(const Frame* stayWithin = nullptr) const; 48 Frame* traverseNext(const Frame* stayWithin = nullptr) const;
63 49
64 Frame* find(const AtomicString& name) const; 50 Frame* find(const AtomicString& name) const;
65 unsigned childCount() const; 51 unsigned childCount() const;
66 52
67 Frame* scopedChild(unsigned index) const; 53 Frame* scopedChild(unsigned index) const;
68 Frame* scopedChild(const AtomicString& name) const; 54 Frame* scopedChild(const AtomicString& name) const;
69 unsigned scopedChildCount() const; 55 unsigned scopedChildCount() const;
70 void invalidateScopedChildCount(); 56 void invalidateScopedChildCount();
71 57
72 DECLARE_TRACE(); 58 DECLARE_TRACE();
73 59
74 AtomicString calculateUniqueNameForNewChildFrame(
75 const AtomicString& name,
76 const AtomicString& fallbackName = nullAtom) const;
77
78 private: 60 private:
79 // Returns true if one of frames in the tree already has unique name equal
80 // to |uniqueNameCandidate|.
81 bool uniqueNameExists(const String& uniqueNameCandidate) const;
82
83 // Generates a hopefully-but-not-necessarily unique name based on frame's
84 // relative position in the tree and on unique names of ancestors.
85 String generateUniqueNameCandidate(bool existingChildFrame) const;
86
87 // Generates a hopefully-but-not-necessarily unique suffix based on |child|
88 // absolute position in the tree. If |child| is nullptr, calculations are
89 // made for a position that a new child of |this| would have.
90 String generateFramePosition(Frame* child) const;
91
92 // Concatenates |prefix|, |likelyUniqueSuffix| (and additional, internally
93 // generated suffix) until the result is a unique name, that doesn't exist
94 // elsewhere in the frame tree. Returns the unique name built in this way.
95 AtomicString appendUniqueSuffix(const String& prefix,
96 const String& likelyUniqueSuffix) const;
97
98 // Calculates a unique name for |child| frame (which might be nullptr if the
99 // child has not yet been created - i.e. when we need unique name for a new
100 // frame). Tries to use the |assignedName| or |fallbackName| if possible,
101 // otherwise falls back to generating a deterministic,
102 // stable-across-page-reloads string based on |child| position in the tree.
103 AtomicString calculateUniqueNameForChildFrame(
104 Frame* child,
105 const AtomicString& assignedName,
106 const AtomicString& fallbackName = nullAtom) const;
107
108 // Sets |m_uniqueName| and asserts its uniqueness.
109 void setUniqueName(const AtomicString&);
110
111 Member<Frame> m_thisFrame; 61 Member<Frame> m_thisFrame;
112 62
113 AtomicString m_name; // The actual frame name (may be empty). 63 AtomicString m_name; // The actual frame name (may be empty).
114 AtomicString m_uniqueName;
115 64
116 mutable unsigned m_scopedChildCount; 65 mutable unsigned m_scopedChildCount;
117 }; 66 };
118 67
119 } // namespace blink 68 } // namespace blink
120 69
121 #ifndef NDEBUG 70 #ifndef NDEBUG
122 // Outside the WebCore namespace for ease of invocation from gdb. 71 // Outside the WebCore namespace for ease of invocation from gdb.
123 void showFrameTree(const blink::Frame*); 72 void showFrameTree(const blink::Frame*);
124 #endif 73 #endif
125 74
126 #endif // FrameTree_h 75 #endif // FrameTree_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/HistoryItem.cpp ('k') | third_party/WebKit/Source/core/page/FrameTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698