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

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

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Android/Mac fixes 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
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 16 matching lines...) Expand all
27 #include "core/editing/Caret.h" 27 #include "core/editing/Caret.h"
28 #include "core/editing/UndoStack.h" 28 #include "core/editing/UndoStack.h"
29 #include "core/events/Event.h" 29 #include "core/events/Event.h"
30 #include "core/fetch/ResourceFetcher.h" 30 #include "core/fetch/ResourceFetcher.h"
31 #include "core/frame/DOMTimer.h" 31 #include "core/frame/DOMTimer.h"
32 #include "core/frame/DOMWindow.h" 32 #include "core/frame/DOMWindow.h"
33 #include "core/frame/EventHandlerRegistry.h" 33 #include "core/frame/EventHandlerRegistry.h"
34 #include "core/frame/FrameHost.h" 34 #include "core/frame/FrameHost.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/frame/RemoteFrame.h"
38 #include "core/frame/RemoteFrameView.h"
37 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
38 #include "core/inspector/InspectorController.h" 40 #include "core/inspector/InspectorController.h"
39 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
40 #include "core/loader/FrameLoader.h" 42 #include "core/loader/FrameLoader.h"
41 #include "core/loader/HistoryItem.h" 43 #include "core/loader/HistoryItem.h"
42 #include "core/page/AutoscrollController.h" 44 #include "core/page/AutoscrollController.h"
43 #include "core/page/Chrome.h" 45 #include "core/page/Chrome.h"
44 #include "core/page/ChromeClient.h" 46 #include "core/page/ChromeClient.h"
45 #include "core/page/ContextMenuController.h" 47 #include "core/page/ContextMenuController.h"
46 #include "core/page/DragController.h" 48 #include "core/page/DragController.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 156 }
155 157
156 void Page::makeOrdinary() 158 void Page::makeOrdinary()
157 { 159 {
158 ASSERT(!ordinaryPages().contains(this)); 160 ASSERT(!ordinaryPages().contains(this));
159 ordinaryPages().add(this); 161 ordinaryPages().add(this);
160 } 162 }
161 163
162 ViewportDescription Page::viewportDescription() const 164 ViewportDescription Page::viewportDescription() const
163 { 165 {
164 return mainFrame() && mainFrame()->document() ? mainFrame()->document()->vie wportDescription() : ViewportDescription(); 166 return mainFrame() && mainFrame()->isLocalFrame() && toLocalFrame(mainFrame( ))->document() ? toLocalFrame(mainFrame())->document()->viewportDescription() : ViewportDescription();
165 } 167 }
166 168
167 ScrollingCoordinator* Page::scrollingCoordinator() 169 ScrollingCoordinator* Page::scrollingCoordinator()
168 { 170 {
169 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) 171 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled())
170 m_scrollingCoordinator = ScrollingCoordinator::create(this); 172 m_scrollingCoordinator = ScrollingCoordinator::create(this);
171 173
172 return m_scrollingCoordinator.get(); 174 return m_scrollingCoordinator.get();
173 } 175 }
174 176
175 String Page::mainThreadScrollingReasonsAsText() 177 String Page::mainThreadScrollingReasonsAsText()
176 { 178 {
177 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( )) 179 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( ))
178 return scrollingCoordinator->mainThreadScrollingReasonsAsText(); 180 return scrollingCoordinator->mainThreadScrollingReasonsAsText();
179 181
180 return String(); 182 return String();
181 } 183 }
182 184
183 PassRefPtrWillBeRawPtr<ClientRectList> Page::nonFastScrollableRects(const LocalF rame* frame) 185 PassRefPtrWillBeRawPtr<ClientRectList> Page::nonFastScrollableRects(const LocalF rame* frame)
184 { 186 {
185 if (Document* document = m_mainFrame->document()) 187 if (m_mainFrame->isLocalFrame() && toLocalFrame(m_mainFrame.get())->document ())
186 document->updateLayout(); 188 toLocalFrame(m_mainFrame.get())->document()->updateLayout();
187 189
188 Vector<IntRect> rects; 190 Vector<IntRect> rects;
189 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( )) 191 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( ))
190 rects = scrollingCoordinator->computeShouldHandleScrollGestureOnMainThre adRegion(frame, IntPoint()).rects(); 192 rects = scrollingCoordinator->computeShouldHandleScrollGestureOnMainThre adRegion(frame, IntPoint()).rects();
191 193
192 Vector<FloatQuad> quads(rects.size()); 194 Vector<FloatQuad> quads(rects.size());
193 for (size_t i = 0; i < rects.size(); ++i) 195 for (size_t i = 0; i < rects.size(); ++i)
194 quads[i] = FloatRect(rects[i]); 196 quads[i] = FloatRect(rects[i]);
195 return ClientRectList::create(quads); 197 return ClientRectList::create(quads);
196 } 198 }
197 199
198 void Page::setMainFrame(PassRefPtr<LocalFrame> mainFrame) 200 void Page::setMainFrame(PassRefPtr<Frame> mainFrame)
199 { 201 {
200 ASSERT(!m_mainFrame); // Should only be called during initialization 202 ASSERT(!m_mainFrame); // Should only be called during initialization
201 m_mainFrame = mainFrame; 203 m_mainFrame = mainFrame;
202 } 204 }
203 205
204 void Page::documentDetached(Document* document) 206 void Page::documentDetached(Document* document)
205 { 207 {
206 m_multisamplingChangedObservers.clear(); 208 m_multisamplingChangedObservers.clear();
207 m_pointerLockController->documentDetached(document); 209 m_pointerLockController->documentDetached(document);
208 m_contextMenuController->documentDetached(document); 210 m_contextMenuController->documentDetached(document);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 framesNeedingReload.append(toLocalFrame(frame)); 278 framesNeedingReload.append(toLocalFrame(frame));
277 } 279 }
278 } 280 }
279 281
280 for (size_t i = 0; i < framesNeedingReload.size(); ++i) 282 for (size_t i = 0; i < framesNeedingReload.size(); ++i)
281 framesNeedingReload[i]->loader().reload(); 283 framesNeedingReload[i]->loader().reload();
282 } 284 }
283 285
284 PluginData* Page::pluginData() const 286 PluginData* Page::pluginData() const
285 { 287 {
286 if (!mainFrame()->loader().allowPlugins(NotAboutToInstantiatePlugin)) 288 if (!toLocalFrame(mainFrame())->loader().allowPlugins(NotAboutToInstantiateP lugin))
287 return 0; 289 return 0;
288 if (!m_pluginData) 290 if (!m_pluginData)
289 m_pluginData = PluginData::create(this); 291 m_pluginData = PluginData::create(this);
290 return m_pluginData.get(); 292 return m_pluginData.get();
291 } 293 }
292 294
293 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag) 295 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
294 { 296 {
295 return forward 297 return forward
296 ? curr->tree().traverseNextWithWrap(wrapFlag) 298 ? curr->tree().traverseNextWithWrap(wrapFlag)
(...skipping 25 matching lines...) Expand all
322 324
323 m_defersLoading = defers; 325 m_defersLoading = defers;
324 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) { 326 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) {
325 if (frame->isLocalFrame()) 327 if (frame->isLocalFrame())
326 toLocalFrame(frame)->loader().setDefersLoading(defers); 328 toLocalFrame(frame)->loader().setDefersLoading(defers);
327 } 329 }
328 } 330 }
329 331
330 void Page::setPageScaleFactor(float scale, const IntPoint& origin) 332 void Page::setPageScaleFactor(float scale, const IntPoint& origin)
331 { 333 {
332 FrameView* view = mainFrame()->view(); 334 // FIXME: Setting the page scale factor is broken for OOPI.
335 if (!mainFrame()->isLocalFrame())
336 return;
337
338 FrameView* view = toLocalFrame(mainFrame())->view();
333 PinchViewport& viewport = frameHost().pinchViewport(); 339 PinchViewport& viewport = frameHost().pinchViewport();
334 340
335 if (scale != viewport.scale()) { 341 if (scale != viewport.scale()) {
336 viewport.setScale(scale); 342 viewport.setScale(scale);
337 343
338 if (view && !settings().pinchVirtualViewportEnabled()) 344 if (view && !settings().pinchVirtualViewportEnabled())
339 view->setVisibleContentScaleFactor(scale); 345 view->setVisibleContentScaleFactor(scale);
340 346
341 mainFrame()->deviceOrPageScaleFactorChanged(); 347 toLocalFrame(mainFrame())->deviceOrPageScaleFactorChanged();
342 m_chrome->client().deviceOrPageScaleFactorChanged(); 348 m_chrome->client().deviceOrPageScaleFactorChanged();
343 349
344 // FIXME: In virtual-viewport pinch mode, scale doesn't change the fixed -pos viewport; 350 // FIXME: In virtual-viewport pinch mode, scale doesn't change the fixed -pos viewport;
345 // remove once it's the only pinch mode in town. 351 // remove once it's the only pinch mode in town.
346 if (view) 352 if (view)
347 view->viewportConstrainedVisibleContentSizeChanged(true, true); 353 view->viewportConstrainedVisibleContentSizeChanged(true, true);
348 354
349 mainFrame()->loader().saveScrollState(); 355 toLocalFrame(mainFrame())->loader().saveScrollState();
350 } 356 }
351 357
352 if (view && view->scrollPosition() != origin) 358 if (view && view->scrollPosition() != origin)
353 view->notifyScrollPositionChanged(origin); 359 view->notifyScrollPositionChanged(origin);
354 } 360 }
355 361
356 float Page::pageScaleFactor() const 362 float Page::pageScaleFactor() const
357 { 363 {
358 return frameHost().pinchViewport().scale(); 364 return frameHost().pinchViewport().scale();
359 } 365 }
360 366
361 void Page::setDeviceScaleFactor(float scaleFactor) 367 void Page::setDeviceScaleFactor(float scaleFactor)
362 { 368 {
363 if (m_deviceScaleFactor == scaleFactor) 369 if (m_deviceScaleFactor == scaleFactor)
364 return; 370 return;
365 371
366 m_deviceScaleFactor = scaleFactor; 372 m_deviceScaleFactor = scaleFactor;
367 setNeedsRecalcStyleInAllFrames(); 373 setNeedsRecalcStyleInAllFrames();
368 374
369 if (mainFrame()) { 375 if (mainFrame() && mainFrame()->isLocalFrame()) {
370 mainFrame()->deviceOrPageScaleFactorChanged(); 376 toLocalFrame(mainFrame())->deviceOrPageScaleFactorChanged();
371 m_chrome->client().deviceOrPageScaleFactorChanged(); 377 m_chrome->client().deviceOrPageScaleFactorChanged();
372 } 378 }
373 } 379 }
374 380
375 void Page::allVisitedStateChanged() 381 void Page::allVisitedStateChanged()
376 { 382 {
377 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end(); 383 HashSet<Page*>::iterator pagesEnd = ordinaryPages().end();
378 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) { 384 for (HashSet<Page*>::iterator it = ordinaryPages().begin(); it != pagesEnd; ++it) {
379 Page* page = *it; 385 Page* page = *it;
380 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext()) { 386 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree( ).traverseNext()) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 m_visibilityState = visibilityState; 446 m_visibilityState = visibilityState;
441 447
442 if (visibilityState == WebCore::PageVisibilityStateHidden) 448 if (visibilityState == WebCore::PageVisibilityStateHidden)
443 setTimerAlignmentInterval(DOMTimer::hiddenPageAlignmentInterval()); 449 setTimerAlignmentInterval(DOMTimer::hiddenPageAlignmentInterval());
444 else 450 else
445 setTimerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval()); 451 setTimerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval());
446 452
447 if (!isInitialState) 453 if (!isInitialState)
448 lifecycleNotifier().notifyPageVisibilityChanged(); 454 lifecycleNotifier().notifyPageVisibilityChanged();
449 455
450 if (!isInitialState && m_mainFrame) 456 if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame())
451 m_mainFrame->didChangeVisibilityState(); 457 toLocalFrame(m_mainFrame.get())->didChangeVisibilityState();
452 } 458 }
453 459
454 PageVisibilityState Page::visibilityState() const 460 PageVisibilityState Page::visibilityState() const
455 { 461 {
456 return m_visibilityState; 462 return m_visibilityState;
457 } 463 }
458 464
459 bool Page::isCursorVisible() const 465 bool Page::isCursorVisible() const
460 { 466 {
461 return m_isCursorVisible && settings().deviceSupportsMouse(); 467 return m_isCursorVisible && settings().deviceSupportsMouse();
462 } 468 }
463 469
464 void Page::addMultisamplingChangedObserver(MultisamplingChangedObserver* observe r) 470 void Page::addMultisamplingChangedObserver(MultisamplingChangedObserver* observe r)
465 { 471 {
466 m_multisamplingChangedObservers.add(observer); 472 m_multisamplingChangedObservers.add(observer);
467 } 473 }
468 474
469 void Page::removeMultisamplingChangedObserver(MultisamplingChangedObserver* obse rver) 475 void Page::removeMultisamplingChangedObserver(MultisamplingChangedObserver* obse rver)
470 { 476 {
471 m_multisamplingChangedObservers.remove(observer); 477 m_multisamplingChangedObservers.remove(observer);
472 } 478 }
473 479
474 void Page::settingsChanged(SettingsDelegate::ChangeType changeType) 480 void Page::settingsChanged(SettingsDelegate::ChangeType changeType)
475 { 481 {
476 switch (changeType) { 482 switch (changeType) {
477 case SettingsDelegate::StyleChange: 483 case SettingsDelegate::StyleChange:
478 setNeedsRecalcStyleInAllFrames(); 484 setNeedsRecalcStyleInAllFrames();
479 break; 485 break;
480 case SettingsDelegate::ViewportDescriptionChange: 486 case SettingsDelegate::ViewportDescriptionChange:
481 if (mainFrame()) 487 if (mainFrame() && mainFrame()->isLocalFrame())
482 mainFrame()->document()->updateViewportDescription(); 488 toLocalFrame(mainFrame())->document()->updateViewportDescription();
483 break; 489 break;
484 case SettingsDelegate::MediaTypeChange: 490 case SettingsDelegate::MediaTypeChange:
485 m_mainFrame->view()->setMediaType(AtomicString(settings().mediaTypeOverr ide())); 491 if (m_mainFrame->isLocalFrame()) {
486 setNeedsRecalcStyleInAllFrames(); 492 toLocalFrame(m_mainFrame.get())->view()->setMediaType(AtomicString(s ettings().mediaTypeOverride()));
493 setNeedsRecalcStyleInAllFrames();
494 }
487 break; 495 break;
488 case SettingsDelegate::DNSPrefetchingChange: 496 case SettingsDelegate::DNSPrefetchingChange:
489 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNe xt()) { 497 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNe xt()) {
490 if (frame->isLocalFrame()) 498 if (frame->isLocalFrame())
491 toLocalFrame(frame)->document()->initDNSPrefetch(); 499 toLocalFrame(frame)->document()->initDNSPrefetch();
492 } 500 }
493 break; 501 break;
494 case SettingsDelegate::MultisamplingChange: { 502 case SettingsDelegate::MultisamplingChange: {
495 WillBeHeapHashSet<RawPtrWillBeWeakMember<MultisamplingChangedObserver> > ::iterator stop = m_multisamplingChangedObservers.end(); 503 WillBeHeapHashSet<RawPtrWillBeWeakMember<MultisamplingChangedObserver> > ::iterator stop = m_multisamplingChangedObservers.end();
496 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<MultisamplingChangedObserv er> >::iterator it = m_multisamplingChangedObservers.begin(); it != stop; ++it) 504 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<MultisamplingChangedObserv er> >::iterator it = m_multisamplingChangedObservers.begin(); it != stop; ++it)
497 (*it)->multisamplingChanged(m_settings->openGLMultisamplingEnabled() ); 505 (*it)->multisamplingChanged(m_settings->openGLMultisamplingEnabled() );
498 break; 506 break;
499 } 507 }
500 case SettingsDelegate::ImageLoadingChange: 508 case SettingsDelegate::ImageLoadingChange:
501 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNe xt()) { 509 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNe xt()) {
502 if (frame->isLocalFrame()) { 510 if (frame->isLocalFrame()) {
503 toLocalFrame(frame)->document()->fetcher()->setImagesEnabled(set tings().imagesEnabled()); 511 toLocalFrame(frame)->document()->fetcher()->setImagesEnabled(set tings().imagesEnabled());
504 toLocalFrame(frame)->document()->fetcher()->setAutoLoadImages(se ttings().loadsImagesAutomatically()); 512 toLocalFrame(frame)->document()->fetcher()->setAutoLoadImages(se ttings().loadsImagesAutomatically());
505 } 513 }
506 } 514 }
507 break; 515 break;
508 case SettingsDelegate::TextAutosizingChange: 516 case SettingsDelegate::TextAutosizingChange:
509 if (!mainFrame()) 517 if (!mainFrame() || !mainFrame()->isLocalFrame())
510 break; 518 break;
511 if (FastTextAutosizer* textAutosizer = mainFrame()->document()->fastText Autosizer()) { 519 if (FastTextAutosizer* textAutosizer = toLocalFrame(mainFrame())->docume nt()->fastTextAutosizer()) {
512 textAutosizer->updatePageInfoInAllFrames(); 520 textAutosizer->updatePageInfoInAllFrames();
513 } else { 521 } else {
514 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traver seNext()) { 522 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traver seNext()) {
515 if (!frame->isLocalFrame()) 523 if (!frame->isLocalFrame())
516 continue; 524 continue;
517 if (TextAutosizer* textAutosizer = toLocalFrame(frame)->document ()->textAutosizer()) 525 if (TextAutosizer* textAutosizer = toLocalFrame(frame)->document ()->textAutosizer())
518 textAutosizer->recalculateMultipliers(); 526 textAutosizer->recalculateMultipliers();
519 } 527 }
520 // TextAutosizing updates RenderStyle during layout phase (via TextA utosizer::processSubtree). 528 // TextAutosizing updates RenderStyle during layout phase (via TextA utosizer::processSubtree).
521 // We should invoke setNeedsLayout here. 529 // We should invoke setNeedsLayout here.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 visitor->trace(m_multisamplingChangedObservers); 598 visitor->trace(m_multisamplingChangedObservers);
591 visitor->trace(m_frameHost); 599 visitor->trace(m_frameHost);
592 WillBeHeapSupplementable<Page>::trace(visitor); 600 WillBeHeapSupplementable<Page>::trace(visitor);
593 } 601 }
594 602
595 void Page::willBeDestroyed() 603 void Page::willBeDestroyed()
596 { 604 {
597 // Disable all agents prior to resetting the frame view. 605 // Disable all agents prior to resetting the frame view.
598 m_inspectorController->willBeDestroyed(); 606 m_inspectorController->willBeDestroyed();
599 607
600 m_mainFrame->setView(nullptr); 608 if (m_mainFrame->isLocalFrame()) {
609 toLocalFrame(m_mainFrame.get())->setView(nullptr);
610 } else {
611 ASSERT(m_mainFrame->isRemoteFrame());
612 toRemoteFrame(m_mainFrame.get())->setView(nullptr);
613 }
601 614
602 allPages().remove(this); 615 allPages().remove(this);
603 if (ordinaryPages().contains(this)) 616 if (ordinaryPages().contains(this))
604 ordinaryPages().remove(this); 617 ordinaryPages().remove(this);
605 618
606 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) { 619 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) {
607 if (frame->isLocalFrame()) 620 if (frame->isLocalFrame())
608 toLocalFrame(frame)->loader().frameDetached(); 621 toLocalFrame(frame)->loader().frameDetached();
609 } 622 }
610 623
(...skipping 21 matching lines...) Expand all
632 , spellCheckerClient(0) 645 , spellCheckerClient(0)
633 , storageClient(0) 646 , storageClient(0)
634 { 647 {
635 } 648 }
636 649
637 Page::PageClients::~PageClients() 650 Page::PageClients::~PageClients()
638 { 651 {
639 } 652 }
640 653
641 } // namespace WebCore 654 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698