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

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

Issue 2388693002: Make DOMWindowProperty a thin wrapper of ContextLifecycleObserver
Patch Set: temp 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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 LocalDOMWindow* LocalDOMWindow::toLocalDOMWindow() { 467 LocalDOMWindow* LocalDOMWindow::toLocalDOMWindow() {
468 return this; 468 return this;
469 } 469 }
470 470
471 MediaQueryList* LocalDOMWindow::matchMedia(const String& media) { 471 MediaQueryList* LocalDOMWindow::matchMedia(const String& media) {
472 return document() ? document()->mediaQueryMatcher().matchMedia(media) 472 return document() ? document()->mediaQueryMatcher().matchMedia(media)
473 : nullptr; 473 : nullptr;
474 } 474 }
475 475
476 void LocalDOMWindow::frameDestroyed() { 476 void LocalDOMWindow::contextDestroyed() {
477 for (const auto& domWindowProperty : m_properties)
478 domWindowProperty->frameDestroyed();
479
480 resetLocation(); 477 resetLocation();
481 m_properties.clear();
482 removeAllEventListeners(); 478 removeAllEventListeners();
483 m_frame = nullptr; 479 m_frame = nullptr;
484 } 480 }
485 481
486 void LocalDOMWindow::registerProperty(DOMWindowProperty* property) {
487 m_properties.add(property);
488 }
489
490 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property) {
491 m_properties.remove(property);
dcheng 2016/12/12 06:50:50 Oh wow... this hasn't been called in some time.
haraken 2016/12/12 06:54:28 It would be okay because m_properties is a hash se
sof 2016/12/12 13:00:50 Yes, I wouldn't be too surprised if there are a co
492 }
493
494 void LocalDOMWindow::registerEventListenerObserver( 482 void LocalDOMWindow::registerEventListenerObserver(
495 EventListenerObserver* eventListenerObserver) { 483 EventListenerObserver* eventListenerObserver) {
496 m_eventListenerObservers.add(eventListenerObserver); 484 m_eventListenerObservers.add(eventListenerObserver);
497 } 485 }
498 486
499 void LocalDOMWindow::reset() { 487 void LocalDOMWindow::reset() {
500 DCHECK(document()); 488 DCHECK(document());
501 // Since |Document| class has multiple |LifecycleNotifier| as base class, 489 // Since |Document| class has multiple |LifecycleNotifier| as base class,
502 // we need to have |static_cast<ExecutionContext>| here. 490 // we need to have |static_cast<ExecutionContext>| here.
503 static_cast<ExecutionContext*>(document())->notifyContextDestroyed(); 491 static_cast<ExecutionContext*>(document())->notifyContextDestroyed();
504 frameDestroyed(); 492 contextDestroyed();
505 493
506 m_screen = nullptr; 494 m_screen = nullptr;
507 m_history = nullptr; 495 m_history = nullptr;
508 m_locationbar = nullptr; 496 m_locationbar = nullptr;
509 m_menubar = nullptr; 497 m_menubar = nullptr;
510 m_personalbar = nullptr; 498 m_personalbar = nullptr;
511 m_scrollbars = nullptr; 499 m_scrollbars = nullptr;
512 m_statusbar = nullptr; 500 m_statusbar = nullptr;
513 m_toolbar = nullptr; 501 m_toolbar = nullptr;
514 m_navigator = nullptr; 502 m_navigator = nullptr;
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1525
1538 WindowFeatures features(windowFeaturesString); 1526 WindowFeatures features(windowFeaturesString);
1539 DOMWindow* newWindow = createWindow(urlString, frameName, features, 1527 DOMWindow* newWindow = createWindow(urlString, frameName, features,
1540 *callingWindow, *firstFrame, *frame()); 1528 *callingWindow, *firstFrame, *frame());
1541 return features.noopener ? nullptr : newWindow; 1529 return features.noopener ? nullptr : newWindow;
1542 } 1530 }
1543 1531
1544 DEFINE_TRACE(LocalDOMWindow) { 1532 DEFINE_TRACE(LocalDOMWindow) {
1545 visitor->trace(m_frame); 1533 visitor->trace(m_frame);
1546 visitor->trace(m_document); 1534 visitor->trace(m_document);
1547 visitor->trace(m_properties);
1548 visitor->trace(m_screen); 1535 visitor->trace(m_screen);
1549 visitor->trace(m_history); 1536 visitor->trace(m_history);
1550 visitor->trace(m_locationbar); 1537 visitor->trace(m_locationbar);
1551 visitor->trace(m_menubar); 1538 visitor->trace(m_menubar);
1552 visitor->trace(m_personalbar); 1539 visitor->trace(m_personalbar);
1553 visitor->trace(m_scrollbars); 1540 visitor->trace(m_scrollbars);
1554 visitor->trace(m_statusbar); 1541 visitor->trace(m_statusbar);
1555 visitor->trace(m_toolbar); 1542 visitor->trace(m_toolbar);
1556 visitor->trace(m_navigator); 1543 visitor->trace(m_navigator);
1557 visitor->trace(m_media); 1544 visitor->trace(m_media);
1558 visitor->trace(m_customElements); 1545 visitor->trace(m_customElements);
1559 visitor->trace(m_applicationCache); 1546 visitor->trace(m_applicationCache);
1560 visitor->trace(m_eventQueue); 1547 visitor->trace(m_eventQueue);
1561 visitor->trace(m_postMessageTimers); 1548 visitor->trace(m_postMessageTimers);
1562 visitor->trace(m_visualViewport); 1549 visitor->trace(m_visualViewport);
1563 visitor->trace(m_eventListenerObservers); 1550 visitor->trace(m_eventListenerObservers);
1564 DOMWindow::trace(visitor); 1551 DOMWindow::trace(visitor);
1565 Supplementable<LocalDOMWindow>::trace(visitor); 1552 Supplementable<LocalDOMWindow>::trace(visitor);
1566 } 1553 }
1567 1554
1568 LocalFrame* LocalDOMWindow::frame() const { 1555 LocalFrame* LocalDOMWindow::frame() const {
1569 // If the LocalDOMWindow still has a frame reference, that frame must point 1556 // If the LocalDOMWindow still has a frame reference, that frame must point
1570 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1557 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1571 // where script execution leaks between different LocalDOMWindows. 1558 // where script execution leaks between different LocalDOMWindows.
1572 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); 1559 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this);
1573 return m_frame; 1560 return m_frame;
1574 } 1561 }
1575 1562
1576 } // namespace blink 1563 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalDOMWindow.h ('k') | third_party/WebKit/Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698