| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "sky/engine/core/dom/Document.h" | 46 #include "sky/engine/core/dom/Document.h" |
| 47 #include "sky/engine/core/dom/Element.h" | 47 #include "sky/engine/core/dom/Element.h" |
| 48 #include "sky/engine/core/dom/ExceptionCode.h" | 48 #include "sky/engine/core/dom/ExceptionCode.h" |
| 49 #include "sky/engine/core/dom/ExecutionContext.h" | 49 #include "sky/engine/core/dom/ExecutionContext.h" |
| 50 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" | 50 #include "sky/engine/core/dom/RequestAnimationFrameCallback.h" |
| 51 #include "sky/engine/core/editing/Editor.h" | 51 #include "sky/engine/core/editing/Editor.h" |
| 52 #include "sky/engine/core/events/DOMWindowEventQueue.h" | 52 #include "sky/engine/core/events/DOMWindowEventQueue.h" |
| 53 #include "sky/engine/core/events/EventListener.h" | 53 #include "sky/engine/core/events/EventListener.h" |
| 54 #include "sky/engine/core/events/HashChangeEvent.h" | 54 #include "sky/engine/core/events/HashChangeEvent.h" |
| 55 #include "sky/engine/core/events/PageTransitionEvent.h" | 55 #include "sky/engine/core/events/PageTransitionEvent.h" |
| 56 #include "sky/engine/core/events/PopStateEvent.h" | |
| 57 #include "sky/engine/core/frame/Console.h" | 56 #include "sky/engine/core/frame/Console.h" |
| 58 #include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h" | 57 #include "sky/engine/core/frame/DOMWindowLifecycleNotifier.h" |
| 59 #include "sky/engine/core/frame/FrameConsole.h" | 58 #include "sky/engine/core/frame/FrameConsole.h" |
| 60 #include "sky/engine/core/frame/FrameHost.h" | 59 #include "sky/engine/core/frame/FrameHost.h" |
| 61 #include "sky/engine/core/frame/FrameView.h" | 60 #include "sky/engine/core/frame/FrameView.h" |
| 62 #include "sky/engine/core/frame/History.h" | |
| 63 #include "sky/engine/core/frame/LocalFrame.h" | 61 #include "sky/engine/core/frame/LocalFrame.h" |
| 64 #include "sky/engine/core/frame/Location.h" | 62 #include "sky/engine/core/frame/Location.h" |
| 65 #include "sky/engine/core/frame/Screen.h" | 63 #include "sky/engine/core/frame/Screen.h" |
| 66 #include "sky/engine/core/frame/Settings.h" | 64 #include "sky/engine/core/frame/Settings.h" |
| 67 #include "sky/engine/core/html/HTMLDocument.h" | 65 #include "sky/engine/core/html/HTMLDocument.h" |
| 68 #include "sky/engine/core/inspector/ConsoleMessage.h" | 66 #include "sky/engine/core/inspector/ConsoleMessage.h" |
| 69 #include "sky/engine/core/inspector/ConsoleMessageStorage.h" | 67 #include "sky/engine/core/inspector/ConsoleMessageStorage.h" |
| 70 #include "sky/engine/core/inspector/InspectorTraceEvents.h" | 68 #include "sky/engine/core/inspector/InspectorTraceEvents.h" |
| 71 #include "sky/engine/core/loader/FrameLoaderClient.h" | 69 #include "sky/engine/core/loader/FrameLoaderClient.h" |
| 72 #include "sky/engine/core/page/Chrome.h" | 70 #include "sky/engine/core/page/Chrome.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 void LocalDOMWindow::dispatchWindowLoadEvent() | 261 void LocalDOMWindow::dispatchWindowLoadEvent() |
| 264 { | 262 { |
| 265 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 263 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 266 dispatchLoadEvent(); | 264 dispatchLoadEvent(); |
| 267 } | 265 } |
| 268 | 266 |
| 269 void LocalDOMWindow::documentWasClosed() | 267 void LocalDOMWindow::documentWasClosed() |
| 270 { | 268 { |
| 271 dispatchWindowLoadEvent(); | 269 dispatchWindowLoadEvent(); |
| 272 enqueuePageshowEvent(PageshowEventNotPersisted); | 270 enqueuePageshowEvent(PageshowEventNotPersisted); |
| 273 if (m_pendingStateObject) | |
| 274 enqueuePopstateEvent(m_pendingStateObject.release()); | |
| 275 } | 271 } |
| 276 | 272 |
| 277 void LocalDOMWindow::enqueuePageshowEvent(PageshowEventPersistence persisted) | 273 void LocalDOMWindow::enqueuePageshowEvent(PageshowEventPersistence persisted) |
| 278 { | 274 { |
| 279 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs
to fire asynchronously. | 275 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs
to fire asynchronously. |
| 280 // As per spec pageshow must be triggered asynchronously. | 276 // As per spec pageshow must be triggered asynchronously. |
| 281 // However to be compatible with other browsers blink fires pageshow synchro
nously. | 277 // However to be compatible with other browsers blink fires pageshow synchro
nously. |
| 282 dispatchEvent(PageTransitionEvent::create(EventTypeNames::pageshow, persiste
d), m_document.get()); | 278 dispatchEvent(PageTransitionEvent::create(EventTypeNames::pageshow, persiste
d), m_document.get()); |
| 283 } | 279 } |
| 284 | 280 |
| 285 void LocalDOMWindow::enqueueHashchangeEvent(const String& oldURL, const String&
newURL) | 281 void LocalDOMWindow::enqueueHashchangeEvent(const String& oldURL, const String&
newURL) |
| 286 { | 282 { |
| 287 enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL)); | 283 enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL)); |
| 288 } | 284 } |
| 289 | 285 |
| 290 void LocalDOMWindow::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stat
eObject) | |
| 291 { | |
| 292 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs
to fire asynchronously | |
| 293 dispatchEvent(PopStateEvent::create(stateObject, &history())); | |
| 294 } | |
| 295 | |
| 296 void LocalDOMWindow::statePopped(PassRefPtr<SerializedScriptValue> stateObject) | |
| 297 { | |
| 298 if (!frame()) | |
| 299 return; | |
| 300 | |
| 301 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we | |
| 302 // defer firing of popstate until we're in the complete state. | |
| 303 if (document()->isLoadCompleted()) | |
| 304 enqueuePopstateEvent(stateObject); | |
| 305 else | |
| 306 m_pendingStateObject = stateObject; | |
| 307 } | |
| 308 | |
| 309 LocalDOMWindow::~LocalDOMWindow() | 286 LocalDOMWindow::~LocalDOMWindow() |
| 310 { | 287 { |
| 311 ASSERT(m_hasBeenReset); | 288 ASSERT(m_hasBeenReset); |
| 312 reset(); | 289 reset(); |
| 313 | 290 |
| 314 #if ENABLE(OILPAN) | 291 #if ENABLE(OILPAN) |
| 315 // Oilpan: the frame host and document objects are | 292 // Oilpan: the frame host and document objects are |
| 316 // also garbage collected; cannot notify these | 293 // also garbage collected; cannot notify these |
| 317 // when removing event listeners. | 294 // when removing event listeners. |
| 318 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); | 295 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 { | 374 { |
| 398 willDestroyDocumentInFrame(); | 375 willDestroyDocumentInFrame(); |
| 399 resetDOMWindowProperties(); | 376 resetDOMWindowProperties(); |
| 400 } | 377 } |
| 401 | 378 |
| 402 void LocalDOMWindow::resetDOMWindowProperties() | 379 void LocalDOMWindow::resetDOMWindowProperties() |
| 403 { | 380 { |
| 404 m_properties.clear(); | 381 m_properties.clear(); |
| 405 | 382 |
| 406 m_screen = nullptr; | 383 m_screen = nullptr; |
| 407 m_history = nullptr; | |
| 408 m_console = nullptr; | 384 m_console = nullptr; |
| 409 m_location = nullptr; | 385 m_location = nullptr; |
| 410 m_media = nullptr; | 386 m_media = nullptr; |
| 411 #if ENABLE(ASSERT) | 387 #if ENABLE(ASSERT) |
| 412 m_hasBeenReset = true; | 388 m_hasBeenReset = true; |
| 413 #endif | 389 #endif |
| 414 } | 390 } |
| 415 | 391 |
| 416 int LocalDOMWindow::orientation() const | 392 int LocalDOMWindow::orientation() const |
| 417 { | 393 { |
| 418 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); | 394 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); |
| 419 | 395 |
| 420 int orientation = screenOrientationAngle(m_frame->view()); | 396 int orientation = screenOrientationAngle(m_frame->view()); |
| 421 // For backward compatibility, we want to return a value in the range of | 397 // For backward compatibility, we want to return a value in the range of |
| 422 // [-90; 180] instead of [0; 360[ because window.orientation used to behave | 398 // [-90; 180] instead of [0; 360[ because window.orientation used to behave |
| 423 // like that in WebKit (this is a WebKit proprietary API). | 399 // like that in WebKit (this is a WebKit proprietary API). |
| 424 if (orientation == 270) | 400 if (orientation == 270) |
| 425 return -90; | 401 return -90; |
| 426 return orientation; | 402 return orientation; |
| 427 } | 403 } |
| 428 | 404 |
| 429 Screen& LocalDOMWindow::screen() const | 405 Screen& LocalDOMWindow::screen() const |
| 430 { | 406 { |
| 431 if (!m_screen) | 407 if (!m_screen) |
| 432 m_screen = Screen::create(m_frame); | 408 m_screen = Screen::create(m_frame); |
| 433 return *m_screen; | 409 return *m_screen; |
| 434 } | 410 } |
| 435 | 411 |
| 436 History& LocalDOMWindow::history() const | |
| 437 { | |
| 438 if (!m_history) | |
| 439 m_history = History::create(m_frame); | |
| 440 return *m_history; | |
| 441 } | |
| 442 | |
| 443 Console& LocalDOMWindow::console() const | 412 Console& LocalDOMWindow::console() const |
| 444 { | 413 { |
| 445 if (!m_console) | 414 if (!m_console) |
| 446 m_console = Console::create(m_frame); | 415 m_console = Console::create(m_frame); |
| 447 return *m_console; | 416 return *m_console; |
| 448 } | 417 } |
| 449 | 418 |
| 450 FrameConsole* LocalDOMWindow::frameConsole() const | 419 FrameConsole* LocalDOMWindow::frameConsole() const |
| 451 { | 420 { |
| 452 return &m_frame->console(); | 421 return &m_frame->console(); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 { | 743 { |
| 775 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); | 744 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); |
| 776 } | 745 } |
| 777 | 746 |
| 778 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
tifier() | 747 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo
tifier() |
| 779 { | 748 { |
| 780 return DOMWindowLifecycleNotifier::create(this); | 749 return DOMWindowLifecycleNotifier::create(this); |
| 781 } | 750 } |
| 782 | 751 |
| 783 } // namespace blink | 752 } // namespace blink |
| OLD | NEW |