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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 { | 477 { |
478 if (!ContextFeatures::pushStateEnabled(document())) | 478 if (!ContextFeatures::pushStateEnabled(document())) |
479 return; | 479 return; |
480 | 480 |
481 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs
to fire asynchronously | 481 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs
to fire asynchronously |
482 dispatchEvent(PopStateEvent::create(stateObject, &history())); | 482 dispatchEvent(PopStateEvent::create(stateObject, &history())); |
483 } | 483 } |
484 | 484 |
485 void LocalDOMWindow::statePopped(PassRefPtr<SerializedScriptValue> stateObject) | 485 void LocalDOMWindow::statePopped(PassRefPtr<SerializedScriptValue> stateObject) |
486 { | 486 { |
487 if (!frame()) | 487 if (!m_frame) |
488 return; | 488 return; |
489 | 489 |
490 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we | 490 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we |
491 // defer firing of popstate until we're in the complete state. | 491 // defer firing of popstate until we're in the complete state. |
492 if (document()->isLoadCompleted()) | 492 if (document()->isLoadCompleted()) |
493 enqueuePopstateEvent(stateObject); | 493 enqueuePopstateEvent(stateObject); |
494 else | 494 else |
495 m_pendingStateObject = stateObject; | 495 m_pendingStateObject = stateObject; |
496 } | 496 } |
497 | 497 |
498 LocalDOMWindow::~LocalDOMWindow() | 498 LocalDOMWindow::~LocalDOMWindow() |
499 { | 499 { |
500 ASSERT(m_hasBeenReset); | |
501 | |
502 #if ENABLE(OILPAN) | 500 #if ENABLE(OILPAN) |
503 // Oilpan: the frame host and document objects are | 501 // Oilpan: the frame host and document objects are |
504 // also garbage collected; cannot notify these | 502 // also garbage collected; cannot notify these |
505 // when removing event listeners. | 503 // when removing event listeners. |
506 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); | 504 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); |
507 | 505 |
508 // Cleared when detaching document. | 506 // Cleared when detaching document. |
509 ASSERT(!m_eventQueue); | 507 ASSERT(!m_eventQueue); |
510 #else | 508 #else |
| 509 ASSERT(m_hasBeenReset); |
511 reset(); | 510 reset(); |
512 | 511 |
513 removeAllEventListenersInternal(DoBroadcastListenerRemoval); | 512 removeAllEventListenersInternal(DoBroadcastListenerRemoval); |
514 | 513 |
515 ASSERT(m_document->isStopped()); | 514 ASSERT(m_document->isStopped()); |
516 clearDocument(); | 515 clearDocument(); |
517 #endif | 516 #endif |
518 } | 517 } |
519 | 518 |
520 const AtomicString& LocalDOMWindow::interfaceName() const | 519 const AtomicString& LocalDOMWindow::interfaceName() const |
(...skipping 14 matching lines...) Expand all Loading... |
535 PassRefPtrWillBeRawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String&
media) | 534 PassRefPtrWillBeRawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String&
media) |
536 { | 535 { |
537 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null
ptr; | 536 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null
ptr; |
538 } | 537 } |
539 | 538 |
540 Page* LocalDOMWindow::page() | 539 Page* LocalDOMWindow::page() |
541 { | 540 { |
542 return frame() ? frame()->page() : 0; | 541 return frame() ? frame()->page() : 0; |
543 } | 542 } |
544 | 543 |
| 544 #if !ENABLE(OILPAN) |
545 void LocalDOMWindow::frameDestroyed() | 545 void LocalDOMWindow::frameDestroyed() |
546 { | 546 { |
547 FrameDestructionObserver::frameDestroyed(); | 547 FrameDestructionObserver::frameDestroyed(); |
548 reset(); | 548 // The frame resets its LocalDOMWindow prior to frame destruction |
| 549 // notifications. |
| 550 ASSERT(m_hasBeenReset); |
549 } | 551 } |
| 552 #endif |
550 | 553 |
551 void LocalDOMWindow::willDetachFrameHost() | 554 void LocalDOMWindow::willDetachFrameHost() |
552 { | 555 { |
553 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); | 556 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); |
554 m_frame->console().messageStorage()->frameWindowDiscarded(this); | 557 m_frame->console().messageStorage()->frameWindowDiscarded(this); |
555 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); | 558 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); |
556 } | 559 } |
557 | 560 |
558 void LocalDOMWindow::willDestroyDocumentInFrame() | 561 void LocalDOMWindow::willDestroyDocumentInFrame() |
559 { | 562 { |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 frameConsole()->addMessage(consoleMessage.release()); | 899 frameConsole()->addMessage(consoleMessage.release()); |
897 return; | 900 return; |
898 } | 901 } |
899 } | 902 } |
900 | 903 |
901 dispatchEvent(event); | 904 dispatchEvent(event); |
902 } | 905 } |
903 | 906 |
904 DOMSelection* LocalDOMWindow::getSelection() | 907 DOMSelection* LocalDOMWindow::getSelection() |
905 { | 908 { |
906 if (!isCurrentlyDisplayedInFrame() || !m_frame) | 909 if (!isCurrentlyDisplayedInFrame()) |
907 return 0; | 910 return 0; |
908 | 911 |
909 return m_frame->document()->getSelection(); | 912 return m_frame->document()->getSelection(); |
910 } | 913 } |
911 | 914 |
912 Element* LocalDOMWindow::frameElement() const | 915 Element* LocalDOMWindow::frameElement() const |
913 { | 916 { |
914 if (!m_frame) | 917 if (!m_frame) |
915 return 0; | 918 return 0; |
916 | 919 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1057 |
1055 return String(); | 1058 return String(); |
1056 } | 1059 } |
1057 | 1060 |
1058 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar
ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/)
const | 1061 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar
ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/)
const |
1059 { | 1062 { |
1060 if (!isCurrentlyDisplayedInFrame()) | 1063 if (!isCurrentlyDisplayedInFrame()) |
1061 return false; | 1064 return false; |
1062 | 1065 |
1063 // |m_frame| can be destructed during |Editor::findString()| via | 1066 // |m_frame| can be destructed during |Editor::findString()| via |
1064 // |Document::updateLayou()|, e.g. event handler removes a frame. | 1067 // |Document::updateLayout()|, e.g. event handler removes a frame. |
1065 RefPtr<LocalFrame> protectFrame(m_frame); | 1068 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); |
1066 | 1069 |
1067 // FIXME (13016): Support wholeWord, searchInFrames and showDialog | 1070 // FIXME (13016): Support wholeWord, searchInFrames and showDialog |
1068 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap,
false); | 1071 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap,
false); |
1069 } | 1072 } |
1070 | 1073 |
1071 bool LocalDOMWindow::offscreenBuffering() const | 1074 bool LocalDOMWindow::offscreenBuffering() const |
1072 { | 1075 { |
1073 return true; | 1076 return true; |
1074 } | 1077 } |
1075 | 1078 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 if (!view) | 1191 if (!view) |
1189 return 0; | 1192 return 0; |
1190 | 1193 |
1191 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1194 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
1192 | 1195 |
1193 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor()); | 1196 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor()); |
1194 } | 1197 } |
1195 | 1198 |
1196 bool LocalDOMWindow::closed() const | 1199 bool LocalDOMWindow::closed() const |
1197 { | 1200 { |
1198 return !m_frame; | 1201 // FIXME: Oilpan: the timing of when m_frame is GCed is clearly |
| 1202 // different to what happens non-Oilpan. m_frame->hasBeenClosed() |
| 1203 // is considered in both settings to make the behavior the same -- |
| 1204 // the flag is set when the WebView (and frame) is closed. Finalization |
| 1205 // of the m_frame will happen at some point later. |
| 1206 // |
| 1207 return !m_frame || m_frame->hasBeenClosed(); |
1199 } | 1208 } |
1200 | 1209 |
1201 unsigned LocalDOMWindow::length() const | 1210 unsigned LocalDOMWindow::length() const |
1202 { | 1211 { |
1203 if (!isCurrentlyDisplayedInFrame()) | 1212 if (!isCurrentlyDisplayedInFrame()) |
1204 return 0; | 1213 return 0; |
1205 | 1214 |
1206 return m_frame->tree().scopedChildCount(); | 1215 return m_frame->tree().scopedChildCount(); |
1207 } | 1216 } |
1208 | 1217 |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, | 1866 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, |
1858 *callingWindow, *firstFrame, *m_frame, function, functionContext); | 1867 *callingWindow, *firstFrame, *m_frame, function, functionContext); |
1859 if (!dialogFrame) | 1868 if (!dialogFrame) |
1860 return; | 1869 return; |
1861 UserGestureIndicatorDisabler disabler; | 1870 UserGestureIndicatorDisabler disabler; |
1862 dialogFrame->host()->chrome().runModal(); | 1871 dialogFrame->host()->chrome().runModal(); |
1863 } | 1872 } |
1864 | 1873 |
1865 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) | 1874 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) |
1866 { | 1875 { |
1867 LocalFrame* frame = this->frame(); | 1876 if (!m_frame) |
1868 if (!frame) | |
1869 return 0; | 1877 return 0; |
1870 | 1878 |
1871 Frame* child = frame->tree().scopedChild(index); | 1879 Frame* child = m_frame->tree().scopedChild(index); |
1872 if (child) | 1880 if (child) |
1873 return child->domWindow(); | 1881 return child->domWindow(); |
1874 | 1882 |
1875 return 0; | 1883 return 0; |
1876 } | 1884 } |
1877 | 1885 |
1878 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() | 1886 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() |
1879 { | 1887 { |
1880 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); | 1888 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin
dow>::lifecycleNotifier()); |
1881 } | 1889 } |
(...skipping 23 matching lines...) Expand all Loading... |
1905 visitor->trace(m_sessionStorage); | 1913 visitor->trace(m_sessionStorage); |
1906 visitor->trace(m_localStorage); | 1914 visitor->trace(m_localStorage); |
1907 visitor->trace(m_applicationCache); | 1915 visitor->trace(m_applicationCache); |
1908 visitor->trace(m_performance); | 1916 visitor->trace(m_performance); |
1909 visitor->trace(m_css); | 1917 visitor->trace(m_css); |
1910 visitor->trace(m_eventQueue); | 1918 visitor->trace(m_eventQueue); |
1911 #endif | 1919 #endif |
1912 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); | 1920 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); |
1913 EventTargetWithInlineData::trace(visitor); | 1921 EventTargetWithInlineData::trace(visitor); |
1914 LifecycleContext<LocalDOMWindow>::trace(visitor); | 1922 LifecycleContext<LocalDOMWindow>::trace(visitor); |
| 1923 FrameDestructionObserver::trace(visitor); |
1915 } | 1924 } |
1916 | 1925 |
1917 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) | 1926 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte
xt, v8::Isolate* isolate) |
1918 { | 1927 { |
1919 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. | 1928 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. |
1920 return v8::Handle<v8::Object>(); | 1929 return v8::Handle<v8::Object>(); |
1921 } | 1930 } |
1922 | 1931 |
1923 } // namespace blink | 1932 } // namespace blink |
OLD | NEW |