| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "core/page/scrolling/ScrollingCoordinator.h" | 72 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 73 #include "platform/EventDispatchForbiddenScope.h" | 73 #include "platform/EventDispatchForbiddenScope.h" |
| 74 #include "platform/weborigin/SecurityOrigin.h" | 74 #include "platform/weborigin/SecurityOrigin.h" |
| 75 #include "platform/weborigin/Suborigin.h" | 75 #include "platform/weborigin/Suborigin.h" |
| 76 #include "public/platform/Platform.h" | 76 #include "public/platform/Platform.h" |
| 77 #include "public/platform/WebFrameScheduler.h" | 77 #include "public/platform/WebFrameScheduler.h" |
| 78 #include "public/platform/WebScreenInfo.h" | 78 #include "public/platform/WebScreenInfo.h" |
| 79 | 79 |
| 80 namespace blink { | 80 namespace blink { |
| 81 | 81 |
| 82 LocalDOMWindow::WindowFrameObserver::WindowFrameObserver(LocalDOMWindow* window,
LocalFrame& frame) | 82 // Rather than simply inheriting LocalFrameLifecycleObserver like most other |
| 83 : LocalFrameLifecycleObserver(&frame) | 83 // classes, LocalDOMWindow hides its LocalFrameLifecycleObserver with |
| 84 , m_window(window) | 84 // composition. This prevents conflicting overloads between DOMWindow, which |
| 85 { | 85 // has a frame() accessor that returns Frame* for bindings code, and |
| 86 } | 86 // LocalFrameLifecycleObserver, which has a frame() accessor that returns a |
| 87 // LocalFrame*. |
| 88 class LocalDOMWindow::WindowFrameObserver final : public GarbageCollected<LocalD
OMWindow::WindowFrameObserver>, public LocalFrameLifecycleObserver { |
| 89 USING_GARBAGE_COLLECTED_MIXIN(WindowFrameObserver); |
| 90 public: |
| 91 static WindowFrameObserver* create(LocalDOMWindow* window, LocalFrame& frame
) |
| 92 { |
| 93 return new WindowFrameObserver(window, frame); |
| 94 } |
| 87 | 95 |
| 88 LocalDOMWindow::WindowFrameObserver* LocalDOMWindow::WindowFrameObserver::create
(LocalDOMWindow* window, LocalFrame& frame) | 96 DEFINE_INLINE_VIRTUAL_TRACE() |
| 89 { | 97 { |
| 90 return new WindowFrameObserver(window, frame); | 98 visitor->trace(m_window); |
| 91 } | 99 LocalFrameLifecycleObserver::trace(visitor); |
| 100 } |
| 92 | 101 |
| 93 DEFINE_TRACE(LocalDOMWindow::WindowFrameObserver) | 102 // LocalFrameLifecycleObserver overrides: |
| 94 { | 103 void willDetachFrameHost() override |
| 95 visitor->trace(m_window); | 104 { |
| 96 LocalFrameLifecycleObserver::trace(visitor); | 105 m_window->willDetachFrameHost(); |
| 97 } | 106 } |
| 98 | 107 |
| 99 void LocalDOMWindow::WindowFrameObserver::willDetachFrameHost() | 108 void contextDestroyed() override |
| 100 { | 109 { |
| 101 m_window->willDetachFrameHost(); | 110 m_window->frameDestroyed(); |
| 102 } | 111 LocalFrameLifecycleObserver::contextDestroyed(); |
| 112 } |
| 103 | 113 |
| 104 void LocalDOMWindow::WindowFrameObserver::contextDestroyed() | 114 private: |
| 105 { | 115 WindowFrameObserver(LocalDOMWindow* window, LocalFrame& frame) |
| 106 m_window->frameDestroyed(); | 116 : LocalFrameLifecycleObserver(&frame) |
| 107 LocalFrameLifecycleObserver::contextDestroyed(); | 117 , m_window(window) |
| 108 } | 118 { |
| 119 } |
| 120 |
| 121 Member<LocalDOMWindow> m_window; |
| 122 }; |
| 109 | 123 |
| 110 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { | 124 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { |
| 111 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); | 125 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); |
| 112 public: | 126 public: |
| 113 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, SecurityOrigin
* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGe
stureToken) | 127 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, SecurityOrigin
* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGe
stureToken) |
| 114 : SuspendableTimer(window.document()) | 128 : SuspendableTimer(window.document()) |
| 115 , m_event(event) | 129 , m_event(event) |
| 116 , m_window(&window) | 130 , m_window(&window) |
| 117 , m_targetOrigin(targetOrigin) | 131 , m_targetOrigin(targetOrigin) |
| 118 , m_stackTrace(stackTrace) | 132 , m_stackTrace(stackTrace) |
| 119 , m_userGestureToken(userGestureToken) | 133 , m_userGestureToken(userGestureToken) |
| 120 , m_disposalAllowed(true) | 134 , m_disposalAllowed(true) |
| 121 { | 135 { |
| 122 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes
sage", this); | 136 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes
sage", this); |
| 123 } | 137 } |
| 124 | 138 |
| 125 MessageEvent* event() const { return m_event.get(); } | 139 MessageEvent* event() const { return m_event; } |
| 126 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 140 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
| 127 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 141 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
| 128 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } | 142 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } |
| 129 void stop() override | 143 void stop() override |
| 130 { | 144 { |
| 131 SuspendableTimer::stop(); | 145 SuspendableTimer::stop(); |
| 132 | 146 |
| 133 if (m_disposalAllowed) | 147 if (m_disposalAllowed) |
| 134 dispose(); | 148 dispose(); |
| 135 } | 149 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 293 } |
| 280 | 294 |
| 281 bool LocalDOMWindow::allowPopUp() | 295 bool LocalDOMWindow::allowPopUp() |
| 282 { | 296 { |
| 283 return frame() && allowPopUp(*frame()); | 297 return frame() && allowPopUp(*frame()); |
| 284 } | 298 } |
| 285 | 299 |
| 286 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) | 300 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) |
| 287 : m_frameObserver(WindowFrameObserver::create(this, frame)) | 301 : m_frameObserver(WindowFrameObserver::create(this, frame)) |
| 288 , m_shouldPrintWhenFinishedLoading(false) | 302 , m_shouldPrintWhenFinishedLoading(false) |
| 289 #if ENABLE(ASSERT) | |
| 290 , m_hasBeenReset(false) | |
| 291 #endif | |
| 292 { | 303 { |
| 293 ThreadState::current()->registerPreFinalizer(this); | 304 ThreadState::current()->registerPreFinalizer(this); |
| 294 } | 305 } |
| 295 | 306 |
| 296 void LocalDOMWindow::clearDocument() | 307 void LocalDOMWindow::clearDocument() |
| 297 { | 308 { |
| 298 if (!m_document) | 309 if (!m_document) |
| 299 return; | 310 return; |
| 300 | 311 |
| 301 ASSERT(!m_document->isActive()); | 312 ASSERT(!m_document->isActive()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 m_locationbar = nullptr; | 538 m_locationbar = nullptr; |
| 528 m_menubar = nullptr; | 539 m_menubar = nullptr; |
| 529 m_personalbar = nullptr; | 540 m_personalbar = nullptr; |
| 530 m_scrollbars = nullptr; | 541 m_scrollbars = nullptr; |
| 531 m_statusbar = nullptr; | 542 m_statusbar = nullptr; |
| 532 m_toolbar = nullptr; | 543 m_toolbar = nullptr; |
| 533 m_navigator = nullptr; | 544 m_navigator = nullptr; |
| 534 m_media = nullptr; | 545 m_media = nullptr; |
| 535 m_customElements = nullptr; | 546 m_customElements = nullptr; |
| 536 m_applicationCache = nullptr; | 547 m_applicationCache = nullptr; |
| 537 #if ENABLE(ASSERT) | |
| 538 m_hasBeenReset = true; | |
| 539 #endif | |
| 540 | 548 |
| 541 LocalDOMWindow::notifyContextDestroyed(); | 549 LocalDOMWindow::notifyContextDestroyed(); |
| 542 } | 550 } |
| 543 | 551 |
| 544 void LocalDOMWindow::sendOrientationChangeEvent() | 552 void LocalDOMWindow::sendOrientationChangeEvent() |
| 545 { | 553 { |
| 546 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); | 554 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); |
| 547 ASSERT(frame()->isMainFrame()); | 555 ASSERT(frame()->isMainFrame()); |
| 548 | 556 |
| 549 // Before dispatching the event, build a list of all frames in the page | 557 // Before dispatching the event, build a list of all frames in the page |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 { | 1505 { |
| 1498 // If the LocalDOMWindow still has a frame reference, that frame must point | 1506 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1499 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1507 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1500 // where script execution leaks between different LocalDOMWindows. | 1508 // where script execution leaks between different LocalDOMWindows. |
| 1501 if (m_frameObserver->frame()) | 1509 if (m_frameObserver->frame()) |
| 1502 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1510 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
| 1503 return m_frameObserver->frame(); | 1511 return m_frameObserver->frame(); |
| 1504 } | 1512 } |
| 1505 | 1513 |
| 1506 } // namespace blink | 1514 } // namespace blink |
| OLD | NEW |