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

Side by Side Diff: Source/core/page/Page.cpp

Issue 338993003: Cleanup various WebView/WebFrame APIs to properly handle remote frames. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refine comment Created 6 years, 6 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/core/page/Page.h ('k') | Source/web/RemoteFrameClient.h » ('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) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 , m_animator(this) 117 , m_animator(this)
118 , m_autoscrollController(AutoscrollController::create(*this)) 118 , m_autoscrollController(AutoscrollController::create(*this))
119 , m_chrome(Chrome::create(this, pageClients.chromeClient)) 119 , m_chrome(Chrome::create(this, pageClients.chromeClient))
120 , m_dragCaretController(DragCaretController::create()) 120 , m_dragCaretController(DragCaretController::create())
121 , m_dragController(DragController::create(this, pageClients.dragClient)) 121 , m_dragController(DragController::create(this, pageClients.dragClient))
122 , m_focusController(FocusController::create(this)) 122 , m_focusController(FocusController::create(this))
123 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient)) 123 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient))
124 , m_inspectorController(InspectorController::create(this, pageClients.inspec torClient)) 124 , m_inspectorController(InspectorController::create(this, pageClients.inspec torClient))
125 , m_pointerLockController(PointerLockController::create(this)) 125 , m_pointerLockController(PointerLockController::create(this))
126 , m_undoStack(UndoStack::create()) 126 , m_undoStack(UndoStack::create())
127 , m_mainFrame(0)
127 , m_backForwardClient(pageClients.backForwardClient) 128 , m_backForwardClient(pageClients.backForwardClient)
128 , m_editorClient(pageClients.editorClient) 129 , m_editorClient(pageClients.editorClient)
129 , m_spellCheckerClient(pageClients.spellCheckerClient) 130 , m_spellCheckerClient(pageClients.spellCheckerClient)
130 , m_storageClient(pageClients.storageClient) 131 , m_storageClient(pageClients.storageClient)
131 , m_subframeCount(0) 132 , m_subframeCount(0)
132 , m_openedByDOM(false) 133 , m_openedByDOM(false)
133 , m_tabKeyCyclesThroughElements(true) 134 , m_tabKeyCyclesThroughElements(true)
134 , m_defersLoading(false) 135 , m_defersLoading(false)
135 , m_deviceScaleFactor(1) 136 , m_deviceScaleFactor(1)
136 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()) 137 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
137 , m_visibilityState(PageVisibilityStateVisible) 138 , m_visibilityState(PageVisibilityStateVisible)
138 , m_isCursorVisible(true) 139 , m_isCursorVisible(true)
139 #ifndef NDEBUG 140 #ifndef NDEBUG
140 , m_isPainting(false) 141 , m_isPainting(false)
141 #endif 142 #endif
142 , m_frameHost(FrameHost::create(*this)) 143 , m_frameHost(FrameHost::create(*this))
143 { 144 {
144 ASSERT(m_editorClient); 145 ASSERT(m_editorClient);
145 146
146 ASSERT(!allPages().contains(this)); 147 ASSERT(!allPages().contains(this));
147 allPages().add(this); 148 allPages().add(this);
148 149
149 #ifndef NDEBUG 150 #ifndef NDEBUG
150 pageCounter.increment(); 151 pageCounter.increment();
151 #endif 152 #endif
152 } 153 }
153 154
154 Page::~Page() 155 Page::~Page()
155 { 156 {
157 // willBeDestroyed() must be called before Page destruction.
158 ASSERT(!m_mainFrame);
156 } 159 }
157 160
158 void Page::makeOrdinary() 161 void Page::makeOrdinary()
159 { 162 {
160 ASSERT(!ordinaryPages().contains(this)); 163 ASSERT(!ordinaryPages().contains(this));
161 ordinaryPages().add(this); 164 ordinaryPages().add(this);
162 } 165 }
163 166
164 ViewportDescription Page::viewportDescription() const 167 ViewportDescription Page::viewportDescription() const
165 { 168 {
(...skipping 24 matching lines...) Expand all
190 Vector<IntRect> rects; 193 Vector<IntRect> rects;
191 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( )) 194 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( ))
192 rects = scrollingCoordinator->computeShouldHandleScrollGestureOnMainThre adRegion(frame, IntPoint()).rects(); 195 rects = scrollingCoordinator->computeShouldHandleScrollGestureOnMainThre adRegion(frame, IntPoint()).rects();
193 196
194 Vector<FloatQuad> quads(rects.size()); 197 Vector<FloatQuad> quads(rects.size());
195 for (size_t i = 0; i < rects.size(); ++i) 198 for (size_t i = 0; i < rects.size(); ++i)
196 quads[i] = FloatRect(rects[i]); 199 quads[i] = FloatRect(rects[i]);
197 return ClientRectList::create(quads); 200 return ClientRectList::create(quads);
198 } 201 }
199 202
200 void Page::setMainFrame(PassRefPtr<Frame> mainFrame) 203 void Page::setMainFrame(Frame* mainFrame)
201 { 204 {
202 ASSERT(!m_mainFrame); // Should only be called during initialization 205 ASSERT(!m_mainFrame); // Should only be called during initialization
203 m_mainFrame = mainFrame; 206 m_mainFrame = mainFrame;
204 } 207 }
205 208
206 void Page::documentDetached(Document* document) 209 void Page::documentDetached(Document* document)
207 { 210 {
208 m_multisamplingChangedObservers.clear(); 211 m_multisamplingChangedObservers.clear();
209 m_pointerLockController->documentDetached(document); 212 m_pointerLockController->documentDetached(document);
210 m_contextMenuController->documentDetached(document); 213 m_contextMenuController->documentDetached(document);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 deprecatedLocalMainFrame()->deviceOrPageScaleFactorChanged(); 378 deprecatedLocalMainFrame()->deviceOrPageScaleFactorChanged();
376 m_chrome->client().deviceOrPageScaleFactorChanged(); 379 m_chrome->client().deviceOrPageScaleFactorChanged();
377 } 380 }
378 } 381 }
379 382
380 void Page::allVisitedStateChanged() 383 void Page::allVisitedStateChanged()
381 { 384 {
382 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end(); 385 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end();
383 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) { 386 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) {
384 Page* page = *it; 387 Page* page = *it;
385 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext()) { 388 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) {
386 if (frame->isLocalFrame()) 389 if (frame->isLocalFrame())
387 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForAllLinks(); 390 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForAllLinks();
388 } 391 }
389 } 392 }
390 } 393 }
391 394
392 void Page::visitedStateChanged(LinkHash linkHash) 395 void Page::visitedStateChanged(LinkHash linkHash)
393 { 396 {
394 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end(); 397 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end();
395 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) { 398 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) {
396 Page* page = *it; 399 Page* page = *it;
397 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext()) { 400 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) {
398 if (frame->isLocalFrame()) 401 if (frame->isLocalFrame())
399 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash); 402 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash);
400 } 403 }
401 } 404 }
402 } 405 }
403 406
404 StorageNamespace* Page::sessionStorage(bool optionalCreate) 407 StorageNamespace* Page::sessionStorage(bool optionalCreate)
405 { 408 {
406 if (!m_sessionStorage && optionalCreate) 409 if (!m_sessionStorage && optionalCreate)
407 m_sessionStorage = m_storageClient->createSessionStorageNamespace(); 410 m_sessionStorage = m_storageClient->createSessionStorageNamespace();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 visitor->trace(m_pointerLockController); 600 visitor->trace(m_pointerLockController);
598 visitor->trace(m_undoStack); 601 visitor->trace(m_undoStack);
599 visitor->trace(m_validationMessageClient); 602 visitor->trace(m_validationMessageClient);
600 visitor->trace(m_multisamplingChangedObservers); 603 visitor->trace(m_multisamplingChangedObservers);
601 visitor->trace(m_frameHost); 604 visitor->trace(m_frameHost);
602 WillBeHeapSupplementable<Page>::trace(visitor); 605 WillBeHeapSupplementable<Page>::trace(visitor);
603 } 606 }
604 607
605 void Page::willBeDestroyed() 608 void Page::willBeDestroyed()
606 { 609 {
607 if (m_mainFrame && m_mainFrame->isLocalFrame()) 610 RefPtr<Frame> mainFrame = m_mainFrame;
608 deprecatedLocalMainFrame()->loader().frameDetached(); 611
612 if (mainFrame->isLocalFrame())
613 toLocalFrame(mainFrame.get())->loader().frameDetached();
609 614
610 // Disable all agents prior to resetting the frame view. 615 // Disable all agents prior to resetting the frame view.
611 m_inspectorController->willBeDestroyed(); 616 m_inspectorController->willBeDestroyed();
612 617
613 if (m_mainFrame->isLocalFrame()) { 618 if (mainFrame->isLocalFrame()) {
614 toLocalFrame(m_mainFrame.get())->setView(nullptr); 619 toLocalFrame(mainFrame.get())->setView(nullptr);
615 } else { 620 } else {
616 ASSERT(m_mainFrame->isRemoteFrame()); 621 ASSERT(m_mainFrame->isRemoteFrame());
617 toRemoteFrame(m_mainFrame.get())->setView(nullptr); 622 toRemoteFrame(mainFrame.get())->setView(nullptr);
618 } 623 }
619 624
620 allPages().remove(this); 625 allPages().remove(this);
621 if (ordinaryPages().contains(this)) 626 if (ordinaryPages().contains(this))
622 ordinaryPages().remove(this); 627 ordinaryPages().remove(this);
623 628
624 if (m_scrollingCoordinator) 629 if (m_scrollingCoordinator)
625 m_scrollingCoordinator->willBeDestroyed(); 630 m_scrollingCoordinator->willBeDestroyed();
626 631
627 #ifndef NDEBUG 632 #ifndef NDEBUG
628 pageCounter.decrement(); 633 pageCounter.decrement();
629 #endif 634 #endif
630 635
631 m_chrome->willBeDestroyed(); 636 m_chrome->willBeDestroyed();
632 m_mainFrame.clear(); 637 m_mainFrame = 0;
633 if (m_validationMessageClient) 638 if (m_validationMessageClient)
634 m_validationMessageClient->willBeDestroyed(); 639 m_validationMessageClient->willBeDestroyed();
635 WillBeHeapSupplementable<Page>::willBeDestroyed(); 640 WillBeHeapSupplementable<Page>::willBeDestroyed();
636 } 641 }
637 642
638 Page::PageClients::PageClients() 643 Page::PageClients::PageClients()
639 : chromeClient(0) 644 : chromeClient(0)
640 , contextMenuClient(0) 645 , contextMenuClient(0)
641 , editorClient(0) 646 , editorClient(0)
642 , dragClient(0) 647 , dragClient(0)
643 , inspectorClient(0) 648 , inspectorClient(0)
644 , backForwardClient(0) 649 , backForwardClient(0)
645 , spellCheckerClient(0) 650 , spellCheckerClient(0)
646 , storageClient(0) 651 , storageClient(0)
647 { 652 {
648 } 653 }
649 654
650 Page::PageClients::~PageClients() 655 Page::PageClients::~PageClients()
651 { 656 {
652 } 657 }
653 658
654 } // namespace WebCore 659 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/Page.h ('k') | Source/web/RemoteFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698