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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2562323002: Devirtualize Frame::domWindow(). (Closed)
Patch Set: Created 4 years 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 visitor->trace(m_editor); 342 visitor->trace(m_editor);
343 visitor->trace(m_spellChecker); 343 visitor->trace(m_spellChecker);
344 visitor->trace(m_selection); 344 visitor->trace(m_selection);
345 visitor->trace(m_eventHandler); 345 visitor->trace(m_eventHandler);
346 visitor->trace(m_console); 346 visitor->trace(m_console);
347 visitor->trace(m_inputMethodController); 347 visitor->trace(m_inputMethodController);
348 Frame::trace(visitor); 348 Frame::trace(visitor);
349 Supplementable<LocalFrame>::trace(visitor); 349 Supplementable<LocalFrame>::trace(visitor);
350 } 350 }
351 351
352 DOMWindow* LocalFrame::domWindow() const {
353 return m_domWindow.get();
354 }
355
356 WindowProxy* LocalFrame::windowProxy(DOMWrapperWorld& world) { 352 WindowProxy* LocalFrame::windowProxy(DOMWrapperWorld& world) {
357 return m_script->windowProxy(world); 353 return m_script->windowProxy(world);
358 } 354 }
359 355
360 void LocalFrame::navigate(Document& originDocument, 356 void LocalFrame::navigate(Document& originDocument,
361 const KURL& url, 357 const KURL& url,
362 bool replaceCurrentItem, 358 bool replaceCurrentItem,
363 UserGestureStatus userGestureStatus) { 359 UserGestureStatus userGestureStatus) {
364 m_navigationScheduler->scheduleLocationChange( 360 m_navigationScheduler->scheduleLocationChange(
365 &originDocument, url.getString(), replaceCurrentItem); 361 &originDocument, url.getString(), replaceCurrentItem);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 m_loader.clear(); 418 m_loader.clear();
423 if (!client()) 419 if (!client())
424 return; 420 return;
425 421
426 client()->willBeDetached(); 422 client()->willBeDetached();
427 // Notify ScriptController that the frame is closing, since its cleanup ends 423 // Notify ScriptController that the frame is closing, since its cleanup ends
428 // up calling back to FrameLoaderClient via WindowProxy. 424 // up calling back to FrameLoaderClient via WindowProxy.
429 script().clearForClose(); 425 script().clearForClose();
430 setView(nullptr); 426 setView(nullptr);
431 427
432 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*localDOMWindow()); 428 m_host->eventHandlerRegistry().didRemoveAllEventHandlers(*domWindow());
433 429
434 localDOMWindow()->frameDestroyed(); 430 domWindow()->frameDestroyed();
435 431
436 // TODO: Page should take care of updating focus/scrolling instead of Frame. 432 // TODO: Page should take care of updating focus/scrolling instead of Frame.
437 // TODO: It's unclear as to why this is called more than once, but it is, 433 // TODO: It's unclear as to why this is called more than once, but it is,
438 // so page() could be null. 434 // so page() could be null.
439 if (page() && page()->focusController().focusedFrame() == this) 435 if (page() && page()->focusController().focusedFrame() == this)
440 page()->focusController().setFocusedFrame(nullptr); 436 page()->focusController().setFocusedFrame(nullptr);
441 437
442 if (page() && page()->scrollingCoordinator() && m_view) 438 if (page() && page()->scrollingCoordinator() && m_view)
443 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); 439 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get());
444 440
(...skipping 22 matching lines...) Expand all
467 ? "with URL '" + 463 ? "with URL '" +
468 toLocalFrame(targetFrame).document()->url().getString() + "'" 464 toLocalFrame(targetFrame).document()->url().getString() + "'"
469 : "with origin '" + 465 : "with origin '" +
470 targetFrame.securityContext()->getSecurityOrigin()->toString() + 466 targetFrame.securityContext()->getSecurityOrigin()->toString() +
471 "'"; 467 "'";
472 String message = 468 String message =
473 "Unsafe JavaScript attempt to initiate navigation for frame " + 469 "Unsafe JavaScript attempt to initiate navigation for frame " +
474 targetFrameDescription + " from frame with URL '" + 470 targetFrameDescription + " from frame with URL '" +
475 document()->url().getString() + "'. " + reason + "\n"; 471 document()->url().getString() + "'. " + reason + "\n";
476 472
477 localDOMWindow()->printErrorMessage(message); 473 domWindow()->printErrorMessage(message);
478 } 474 }
479 475
480 WindowProxyManager* LocalFrame::getWindowProxyManager() const { 476 WindowProxyManager* LocalFrame::getWindowProxyManager() const {
481 return m_script->getWindowProxyManager(); 477 return m_script->getWindowProxyManager();
482 } 478 }
483 479
484 bool LocalFrame::shouldClose() { 480 bool LocalFrame::shouldClose() {
485 // TODO(dcheng): This should be fixed to dispatch beforeunload events to 481 // TODO(dcheng): This should be fixed to dispatch beforeunload events to
486 // both local and remote frames. 482 // both local and remote frames.
487 return m_loader.shouldClose(); 483 return m_loader.shouldClose();
488 } 484 }
489 485
490 void LocalFrame::detachChildren() { 486 void LocalFrame::detachChildren() {
491 DCHECK(m_loader.stateMachine()->creatingInitialEmptyDocument() || document()); 487 DCHECK(m_loader.stateMachine()->creatingInitialEmptyDocument() || document());
492 488
493 if (Document* document = this->document()) 489 if (Document* document = this->document())
494 ChildFrameDisconnector(*document).disconnect(); 490 ChildFrameDisconnector(*document).disconnect();
495 } 491 }
496 492
497 void LocalFrame::documentAttached() { 493 void LocalFrame::documentAttached() {
498 DCHECK(document()); 494 DCHECK(document());
499 selection().documentAttached(document()); 495 selection().documentAttached(document());
500 inputMethodController().documentAttached(document()); 496 inputMethodController().documentAttached(document());
501 } 497 }
502 498
499 LocalDOMWindow* LocalFrame::domWindow() const {
500 return toLocalDOMWindow(m_domWindow);
501 }
502
503 void LocalFrame::setDOMWindow(LocalDOMWindow* domWindow) { 503 void LocalFrame::setDOMWindow(LocalDOMWindow* domWindow) {
504 // TODO(haraken): Update this comment. 504 // TODO(haraken): Update this comment.
505 // Oilpan: setDOMWindow() cannot be used when finalizing. Which 505 // Oilpan: setDOMWindow() cannot be used when finalizing. Which
506 // is acceptable as its actions are either not needed or handled 506 // is acceptable as its actions are either not needed or handled
507 // by other means -- 507 // by other means --
508 // 508 //
509 // - LocalFrameLifecycleObserver::willDetachFrameHost() will have 509 // - LocalFrameLifecycleObserver::willDetachFrameHost() will have
510 // signalled the Inspector frameWindowDiscarded() notifications. 510 // signalled the Inspector frameWindowDiscarded() notifications.
511 // We assume that all LocalFrames are detached, where that notification 511 // We assume that all LocalFrames are detached, where that notification
512 // will have been done. 512 // will have been done.
513 // 513 //
514 // - Calling LocalDOMWindow::reset() is not needed (called from 514 // - Calling LocalDOMWindow::reset() is not needed (called from
515 // Frame::setDOMWindow().) The Member references it clears will now 515 // Frame::setDOMWindow().) The Member references it clears will now
516 // die with the window. And the registered DOMWindowProperty instances that 516 // die with the window. And the registered DOMWindowProperty instances that
517 // don't, only keep a weak reference to this frame, so there's no need to 517 // don't, only keep a weak reference to this frame, so there's no need to
518 // be explicitly notified that this frame is going away. 518 // be explicitly notified that this frame is going away.
519 if (domWindow) 519 if (domWindow)
520 script().clearWindowProxy(); 520 script().clearWindowProxy();
521 521
522 if (m_domWindow) 522 if (this->domWindow())
523 m_domWindow->reset(); 523 this->domWindow()->reset();
524 m_domWindow = domWindow; 524 m_domWindow = domWindow;
haraken 2016/12/12 09:54:59 LocalFrame::m_domWindow is reset here. Where is Re
dcheng 2016/12/12 10:21:39 LocalDOMWindow is swapped on navigation, but Remot
525 } 525 }
526 526
527 Document* LocalFrame::document() const { 527 Document* LocalFrame::document() const {
528 return m_domWindow ? m_domWindow->document() : nullptr; 528 return m_domWindow ? m_domWindow->document() : nullptr;
529 } 529 }
530 530
531 void LocalFrame::setPagePopupOwner(Element& owner) { 531 void LocalFrame::setPagePopupOwner(Element& owner) {
532 m_pagePopupOwner = &owner; 532 m_pagePopupOwner = &owner;
533 } 533 }
534 534
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 929 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
930 m_frame->client()->frameBlameContext()->Enter(); 930 m_frame->client()->frameBlameContext()->Enter();
931 } 931 }
932 932
933 ScopedFrameBlamer::~ScopedFrameBlamer() { 933 ScopedFrameBlamer::~ScopedFrameBlamer() {
934 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 934 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
935 m_frame->client()->frameBlameContext()->Leave(); 935 m_frame->client()->frameBlameContext()->Leave();
936 } 936 }
937 937
938 } // namespace blink 938 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698