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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 156123004: Move the frame tree into the embedder. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: T -> t Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebFrameImpl.h ('k') | Source/web/tests/FrameTestHelpers.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 return fromFrame(frame()->loader().opener()); 640 return fromFrame(frame()->loader().opener());
641 } 641 }
642 642
643 void WebFrameImpl::setOpener(const WebFrame* webFrame) 643 void WebFrameImpl::setOpener(const WebFrame* webFrame)
644 { 644 {
645 frame()->loader().setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() : 0 ); 645 frame()->loader().setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() : 0 );
646 } 646 }
647 647
648 void WebFrameImpl::appendChild(WebFrame* child) 648 void WebFrameImpl::appendChild(WebFrame* child)
649 { 649 {
650 // FIXME: Implement after this revision rolls into Chrome. 650 // FIXME: Original code asserts that the frames have the same Page. We
651 // should add an equivalent check... figure out what.
652 WebFrameImpl* childImpl = toWebFrameImpl(child);
653 childImpl->m_parent = this;
654 WebFrameImpl* oldLast = m_lastChild;
655 m_lastChild = childImpl;
656
657 if (oldLast) {
658 childImpl->m_previousSibling = oldLast;
659 oldLast->m_nextSibling = childImpl;
660 } else {
661 m_firstChild = childImpl;
662 }
663 // FIXME: Not sure if this is a legitimate assert.
664 ASSERT(frame());
665 frame()->tree().invalidateScopedChildCount();
651 } 666 }
652 667
653 void WebFrameImpl::removeChild(WebFrame* child) 668 void WebFrameImpl::removeChild(WebFrame* child)
654 { 669 {
655 // FIXME: Implement after this revision rolls into Chrome. 670 WebFrameImpl* childImpl = toWebFrameImpl(child);
671 childImpl->m_parent = 0;
672
673 if (m_firstChild == childImpl)
674 m_firstChild = childImpl->m_nextSibling;
675 else
676 childImpl->m_previousSibling->m_nextSibling = childImpl->m_nextSibling;
677
678 if (m_lastChild == childImpl)
679 m_lastChild = childImpl->m_previousSibling;
680 else
681 childImpl->m_nextSibling->m_previousSibling = childImpl->m_previousSibli ng;
682
683 childImpl->m_previousSibling = childImpl->m_nextSibling = 0;
684 // FIXME: Not sure if this is a legitimate assert.
685 ASSERT(frame());
686 frame()->tree().invalidateScopedChildCount();
656 } 687 }
657 688
658 WebFrame* WebFrameImpl::parent() const 689 WebFrame* WebFrameImpl::parent() const
659 { 690 {
660 if (!frame()) 691 return m_parent;
661 return 0;
662 return fromFrame(frame()->tree().parent());
663 } 692 }
664 693
665 WebFrame* WebFrameImpl::top() const 694 WebFrame* WebFrameImpl::top() const
666 { 695 {
667 if (!frame()) 696 WebFrameImpl* frame = const_cast<WebFrameImpl*>(this);
668 return 0; 697 for (WebFrameImpl* parent = frame; parent; parent = parent->m_parent)
669 return fromFrame(frame()->tree().top()); 698 frame = parent;
699 return frame;
700 }
701
702 WebFrame* WebFrameImpl::previousSibling() const
703 {
704 return m_previousSibling;
705 }
706
707 WebFrame* WebFrameImpl::nextSibling() const
708 {
709 return m_nextSibling;
670 } 710 }
671 711
672 WebFrame* WebFrameImpl::firstChild() const 712 WebFrame* WebFrameImpl::firstChild() const
673 { 713 {
674 if (!frame()) 714 return m_firstChild;
675 return 0;
676 return fromFrame(frame()->tree().firstChild());
677 } 715 }
678 716
679 WebFrame* WebFrameImpl::lastChild() const 717 WebFrame* WebFrameImpl::lastChild() const
680 { 718 {
681 if (!frame()) 719 return m_lastChild;
682 return 0;
683 return fromFrame(frame()->tree().lastChild());
684 } 720 }
685 721
686 WebFrame* WebFrameImpl::nextSibling() const 722 WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
687 { 723 {
688 if (!frame()) 724 if (!frame())
689 return 0; 725 return 0;
690 return fromFrame(frame()->tree().nextSibling()); 726 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap));
691 }
692
693 WebFrame* WebFrameImpl::previousSibling() const
694 {
695 if (!frame())
696 return 0;
697 return fromFrame(frame()->tree().previousSibling());
698 } 727 }
699 728
700 WebFrame* WebFrameImpl::traverseNext(bool wrap) const 729 WebFrame* WebFrameImpl::traverseNext(bool wrap) const
701 { 730 {
702 if (!frame()) 731 if (!frame())
703 return 0; 732 return 0;
704 return fromFrame(frame()->tree().traverseNextWithWrap(wrap)); 733 return fromFrame(frame()->tree().traverseNextWithWrap(wrap));
705 } 734 }
706 735
707 WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
708 {
709 if (!frame())
710 return 0;
711 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap));
712 }
713
714 WebFrame* WebFrameImpl::findChildByName(const WebString& name) const 736 WebFrame* WebFrameImpl::findChildByName(const WebString& name) const
715 { 737 {
716 if (!frame()) 738 if (!frame())
717 return 0; 739 return 0;
718 return fromFrame(frame()->tree().child(name)); 740 return fromFrame(frame()->tree().child(name));
719 } 741 }
720 742
721 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const 743 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const
722 { 744 {
723 if (xpath.isEmpty()) 745 if (xpath.isEmpty())
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 return WebFrameImpl::create(client, generateEmbedderIdentifier()); 2108 return WebFrameImpl::create(client, generateEmbedderIdentifier());
2087 } 2109 }
2088 2110
2089 WebFrameImpl* WebFrameImpl::create(WebFrameClient* client, long long embedderIde ntifier) 2111 WebFrameImpl* WebFrameImpl::create(WebFrameClient* client, long long embedderIde ntifier)
2090 { 2112 {
2091 return adoptRef(new WebFrameImpl(client, embedderIdentifier)).leakRef(); 2113 return adoptRef(new WebFrameImpl(client, embedderIdentifier)).leakRef();
2092 } 2114 }
2093 2115
2094 WebFrameImpl::WebFrameImpl(WebFrameClient* client, long long embedderIdentifier) 2116 WebFrameImpl::WebFrameImpl(WebFrameClient* client, long long embedderIdentifier)
2095 : m_frameInit(WebFrameInit::create(this, embedderIdentifier)) 2117 : m_frameInit(WebFrameInit::create(this, embedderIdentifier))
2118 , m_parent(0)
2119 , m_previousSibling(0)
2120 , m_nextSibling(0)
2121 , m_firstChild(0)
2122 , m_lastChild(0)
2096 , m_client(client) 2123 , m_client(client)
2097 , m_permissionClient(0) 2124 , m_permissionClient(0)
2098 , m_currentActiveMatchFrame(0) 2125 , m_currentActiveMatchFrame(0)
2099 , m_activeMatchIndexInCurrentFrame(-1) 2126 , m_activeMatchIndexInCurrentFrame(-1)
2100 , m_locatingActiveRect(false) 2127 , m_locatingActiveRect(false)
2101 , m_resumeScopingFromRange(0) 2128 , m_resumeScopingFromRange(0)
2102 , m_lastMatchCount(-1) 2129 , m_lastMatchCount(-1)
2103 , m_totalMatchCount(-1) 2130 , m_totalMatchCount(-1)
2104 , m_framesScopingCount(-1) 2131 , m_framesScopingCount(-1)
2105 , m_findRequestIdentifier(-1) 2132 , m_findRequestIdentifier(-1)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 if (!webframe) 2171 if (!webframe)
2145 return 0; 2172 return 0;
2146 2173
2147 webframe->m_frameInit->setFrameHost(frame()->host()); 2174 webframe->m_frameInit->setFrameHost(frame()->host());
2148 webframe->m_frameInit->setOwnerElement(ownerElement); 2175 webframe->m_frameInit->setOwnerElement(ownerElement);
2149 RefPtr<Frame> childFrame = Frame::create(webframe->m_frameInit); 2176 RefPtr<Frame> childFrame = Frame::create(webframe->m_frameInit);
2150 webframe->setWebCoreFrame(childFrame); 2177 webframe->setWebCoreFrame(childFrame);
2151 2178
2152 childFrame->tree().setName(request.frameName()); 2179 childFrame->tree().setName(request.frameName());
2153 2180
2154 frame()->tree().appendChild(childFrame); 2181 // FIXME: This comment is not quite accurate anymore.
2155
2156 // Frame::init() can trigger onload event in the parent frame, 2182 // Frame::init() can trigger onload event in the parent frame,
2157 // which may detach this frame and trigger a null-pointer access 2183 // which may detach this frame and trigger a null-pointer access
2158 // in FrameTree::removeChild. Move init() after appendChild call 2184 // in FrameTree::removeChild. Move init() after appendChild call
2159 // so that webframe->mFrame is in the tree before triggering 2185 // so that webframe->mFrame is in the tree before triggering
2160 // onload event handler. 2186 // onload event handler.
2161 // Because the event handler may set webframe->mFrame to null, 2187 // Because the event handler may set webframe->mFrame to null,
2162 // it is necessary to check the value after calling init() and 2188 // it is necessary to check the value after calling init() and
2163 // return without loading URL. 2189 // return without loading URL.
2164 // NOTE: m_client will be null if this frame has been detached. 2190 // NOTE: m_client will be null if this frame has been detached.
2165 // (b:791612) 2191 // (b:791612)
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 2512
2487 // There is a possibility that the frame being detached was the only 2513 // There is a possibility that the frame being detached was the only
2488 // pending one. We need to make sure final replies can be sent. 2514 // pending one. We need to make sure final replies can be sent.
2489 flushCurrentScopingEffort(m_findRequestIdentifier); 2515 flushCurrentScopingEffort(m_findRequestIdentifier);
2490 2516
2491 cancelPendingScopingEffort(); 2517 cancelPendingScopingEffort();
2492 } 2518 }
2493 } 2519 }
2494 2520
2495 } // namespace blink 2521 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebFrameImpl.h ('k') | Source/web/tests/FrameTestHelpers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698