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

Unified Diff: Source/core/page/FrameTree.cpp

Issue 33353003: Have Frame::tree() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/FocusController.cpp ('k') | Source/core/page/Page.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/FrameTree.cpp
diff --git a/Source/core/page/FrameTree.cpp b/Source/core/page/FrameTree.cpp
index 7dbe45e6c6108c380b8a17419a20730dccf502a3..b7e7dc1cc101034fe94bd457b349d5d33859f69e 100644
--- a/Source/core/page/FrameTree.cpp
+++ b/Source/core/page/FrameTree.cpp
@@ -36,7 +36,7 @@ namespace WebCore {
FrameTree::~FrameTree()
{
- for (Frame* child = firstChild(); child; child = child->tree()->nextSibling())
+ for (Frame* child = firstChild(); child; child = child->tree().nextSibling())
child->setView(0);
}
@@ -48,7 +48,7 @@ void FrameTree::setName(const AtomicString& name)
return;
}
m_uniqueName = AtomicString(); // Remove our old frame name so it's not considered in uniqueChildName.
- m_uniqueName = parent()->tree()->uniqueChildName(name);
+ m_uniqueName = parent()->tree().uniqueChildName(name);
}
Frame* FrameTree::parent() const
@@ -59,37 +59,37 @@ Frame* FrameTree::parent() const
void FrameTree::appendChild(PassRefPtr<Frame> child)
{
ASSERT(child->page() == m_thisFrame->page());
- child->tree()->m_parent = m_thisFrame;
+ child->tree().m_parent = m_thisFrame;
Frame* oldLast = m_lastChild;
m_lastChild = child.get();
if (oldLast) {
- child->tree()->m_previousSibling = oldLast;
- oldLast->tree()->m_nextSibling = child;
+ child->tree().m_previousSibling = oldLast;
+ oldLast->tree().m_nextSibling = child;
} else
m_firstChild = child;
m_scopedChildCount = invalidCount;
- ASSERT(!m_lastChild->tree()->m_nextSibling);
+ ASSERT(!m_lastChild->tree().m_nextSibling);
}
void FrameTree::removeChild(Frame* child)
{
- child->tree()->m_parent = 0;
+ child->tree().m_parent = 0;
// Slightly tricky way to prevent deleting the child until we are done with it, w/o
// extra refs. These swaps leave the child in a circular list by itself. Clearing its
// previous and next will then finally deref it.
- RefPtr<Frame>& newLocationForNext = m_firstChild == child ? m_firstChild : child->tree()->m_previousSibling->tree()->m_nextSibling;
- Frame*& newLocationForPrevious = m_lastChild == child ? m_lastChild : child->tree()->m_nextSibling->tree()->m_previousSibling;
- swap(newLocationForNext, child->tree()->m_nextSibling);
+ RefPtr<Frame>& newLocationForNext = m_firstChild == child ? m_firstChild : child->tree().m_previousSibling->tree().m_nextSibling;
+ Frame*& newLocationForPrevious = m_lastChild == child ? m_lastChild : child->tree().m_nextSibling->tree().m_previousSibling;
+ swap(newLocationForNext, child->tree().m_nextSibling);
// For some inexplicable reason, the following line does not compile without the explicit std:: namespace
- std::swap(newLocationForPrevious, child->tree()->m_previousSibling);
+ std::swap(newLocationForPrevious, child->tree().m_previousSibling);
- child->tree()->m_previousSibling = 0;
- child->tree()->m_nextSibling = 0;
+ child->tree().m_previousSibling = 0;
+ child->tree().m_nextSibling = 0;
m_scopedChildCount = invalidCount;
}
@@ -113,21 +113,21 @@ AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const
// Find the nearest parent that has a frame with a path in it.
Vector<Frame*, 16> chain;
Frame* frame;
- for (frame = m_thisFrame; frame; frame = frame->tree()->parent()) {
- if (frame->tree()->uniqueName().startsWith(framePathPrefix))
+ for (frame = m_thisFrame; frame; frame = frame->tree().parent()) {
+ if (frame->tree().uniqueName().startsWith(framePathPrefix))
break;
chain.append(frame);
}
StringBuilder name;
name.append(framePathPrefix);
if (frame) {
- name.append(frame->tree()->uniqueName().string().substring(framePathPrefixLength,
- frame->tree()->uniqueName().length() - framePathPrefixLength - framePathSuffixLength));
+ name.append(frame->tree().uniqueName().string().substring(framePathPrefixLength,
+ frame->tree().uniqueName().length() - framePathPrefixLength - framePathSuffixLength));
}
for (int i = chain.size() - 1; i >= 0; --i) {
frame = chain[i];
name.append('/');
- name.append(frame->tree()->uniqueName());
+ name.append(frame->tree().uniqueName());
}
name.appendLiteral("/<!--frame");
@@ -144,7 +144,7 @@ Frame* FrameTree::scopedChild(unsigned index) const
return 0;
unsigned scopedIndex = 0;
- for (Frame* result = firstChild(); result; result = result->tree()->nextSibling()) {
+ for (Frame* result = firstChild(); result; result = result->tree().nextSibling()) {
if (result->inScope(scope)) {
if (scopedIndex == index)
return result;
@@ -161,8 +161,8 @@ Frame* FrameTree::scopedChild(const AtomicString& name) const
if (!scope)
return 0;
- for (Frame* child = firstChild(); child; child = child->tree()->nextSibling())
- if (child->tree()->uniqueName() == name && child->inScope(scope))
+ for (Frame* child = firstChild(); child; child = child->tree().nextSibling())
+ if (child->tree().uniqueName() == name && child->inScope(scope))
return child;
return 0;
}
@@ -173,7 +173,7 @@ inline unsigned FrameTree::scopedChildCount(TreeScope* scope) const
return 0;
unsigned scopedCount = 0;
- for (Frame* result = firstChild(); result; result = result->tree()->nextSibling()) {
+ for (Frame* result = firstChild(); result; result = result->tree().nextSibling()) {
if (result->inScope(scope))
scopedCount++;
}
@@ -191,15 +191,15 @@ unsigned FrameTree::scopedChildCount() const
unsigned FrameTree::childCount() const
{
unsigned count = 0;
- for (Frame* result = firstChild(); result; result = result->tree()->nextSibling())
+ for (Frame* result = firstChild(); result; result = result->tree().nextSibling())
++count;
return count;
}
Frame* FrameTree::child(const AtomicString& name) const
{
- for (Frame* child = firstChild(); child; child = child->tree()->nextSibling())
- if (child->tree()->uniqueName() == name)
+ for (Frame* child = firstChild(); child; child = child->tree().nextSibling())
+ if (child->tree().uniqueName() == name)
return child;
return 0;
}
@@ -220,8 +220,8 @@ Frame* FrameTree::find(const AtomicString& name) const
return 0;
// Search subtree starting with this frame first.
- for (Frame* frame = m_thisFrame; frame; frame = frame->tree()->traverseNext(m_thisFrame))
- if (frame->tree()->uniqueName() == name)
+ for (Frame* frame = m_thisFrame; frame; frame = frame->tree().traverseNext(m_thisFrame))
+ if (frame->tree().uniqueName() == name)
return frame;
// Search the entire tree for this page next.
@@ -231,8 +231,8 @@ Frame* FrameTree::find(const AtomicString& name) const
if (!page)
return 0;
- for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
- if (frame->tree()->uniqueName() == name)
+ for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverseNext())
+ if (frame->tree().uniqueName() == name)
return frame;
// Search the entire tree of each of the other pages in this namespace.
@@ -242,8 +242,8 @@ Frame* FrameTree::find(const AtomicString& name) const
for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
Page* otherPage = *it;
if (otherPage != page) {
- for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
- if (frame->tree()->uniqueName() == name)
+ for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ if (frame->tree().uniqueName() == name)
return frame;
}
}
@@ -260,7 +260,7 @@ bool FrameTree::isDescendantOf(const Frame* ancestor) const
if (m_thisFrame->page() != ancestor->page())
return false;
- for (Frame* frame = m_thisFrame; frame; frame = frame->tree()->parent())
+ for (Frame* frame = m_thisFrame; frame; frame = frame->tree().parent())
if (frame == ancestor)
return true;
return false;
@@ -270,7 +270,7 @@ Frame* FrameTree::traverseNext(const Frame* stayWithin) const
{
Frame* child = firstChild();
if (child) {
- ASSERT(!stayWithin || child->tree()->isDescendantOf(stayWithin));
+ ASSERT(!stayWithin || child->tree().isDescendantOf(stayWithin));
return child;
}
@@ -279,20 +279,20 @@ Frame* FrameTree::traverseNext(const Frame* stayWithin) const
Frame* sibling = nextSibling();
if (sibling) {
- ASSERT(!stayWithin || sibling->tree()->isDescendantOf(stayWithin));
+ ASSERT(!stayWithin || sibling->tree().isDescendantOf(stayWithin));
return sibling;
}
Frame* frame = m_thisFrame;
- while (!sibling && (!stayWithin || frame->tree()->parent() != stayWithin)) {
- frame = frame->tree()->parent();
+ while (!sibling && (!stayWithin || frame->tree().parent() != stayWithin)) {
+ frame = frame->tree().parent();
if (!frame)
return 0;
- sibling = frame->tree()->nextSibling();
+ sibling = frame->tree().nextSibling();
}
if (frame) {
- ASSERT(!stayWithin || !sibling || sibling->tree()->isDescendantOf(stayWithin));
+ ASSERT(!stayWithin || !sibling || sibling->tree().isDescendantOf(stayWithin));
return sibling;
}
@@ -315,7 +315,7 @@ Frame* FrameTree::traversePreviousWithWrap(bool wrap) const
// FIXME: besides the wrap feature, this is just the traversePreviousNode algorithm
if (Frame* prevSibling = previousSibling())
- return prevSibling->tree()->deepLastChild();
+ return prevSibling->tree().deepLastChild();
if (Frame* parentFrame = parent())
return parentFrame;
@@ -330,7 +330,7 @@ Frame* FrameTree::traversePreviousWithWrap(bool wrap) const
Frame* FrameTree::deepLastChild() const
{
Frame* result = m_thisFrame;
- for (Frame* last = lastChild(); last; last = last->tree()->lastChild())
+ for (Frame* last = lastChild(); last; last = last->tree().lastChild())
result = last;
return result;
@@ -339,7 +339,7 @@ Frame* FrameTree::deepLastChild() const
Frame* FrameTree::top() const
{
Frame* frame = m_thisFrame;
- for (Frame* parent = m_thisFrame; parent; parent = parent->tree()->parent())
+ for (Frame* parent = m_thisFrame; parent; parent = parent->tree().parent())
frame = parent;
return frame;
}
@@ -373,7 +373,7 @@ static void printFrames(const WebCore::Frame* frame, const WebCore::Frame* targe
printIndent(indent);
printf(" uri=%s\n\n", frame->document()->documentURI().utf8().data());
- for (WebCore::Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
+ for (WebCore::Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling())
printFrames(child, targetFrame, indent + 1);
}
@@ -384,7 +384,7 @@ void showFrameTree(const WebCore::Frame* frame)
return;
}
- printFrames(frame->tree()->top(), frame, 0);
+ printFrames(frame->tree().top(), frame, 0);
}
#endif
« no previous file with comments | « Source/core/page/FocusController.cpp ('k') | Source/core/page/Page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698