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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 { | 476 { |
477 if (!ContextFeatures::pushStateEnabled(document())) | 477 if (!ContextFeatures::pushStateEnabled(document())) |
478 return; | 478 return; |
479 | 479 |
480 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs to fire asynchronously | 480 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs to fire asynchronously |
481 dispatchEvent(PopStateEvent::create(stateObject, &history())); | 481 dispatchEvent(PopStateEvent::create(stateObject, &history())); |
482 } | 482 } |
483 | 483 |
484 void LocalDOMWindow::statePopped(PassRefPtr<SerializedScriptValue> stateObject) | 484 void LocalDOMWindow::statePopped(PassRefPtr<SerializedScriptValue> stateObject) |
485 { | 485 { |
486 if (!frame()) | 486 if (!m_frame) |
487 return; | 487 return; |
488 | 488 |
489 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we | 489 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we |
490 // defer firing of popstate until we're in the complete state. | 490 // defer firing of popstate until we're in the complete state. |
491 if (document()->isLoadCompleted()) | 491 if (document()->isLoadCompleted()) |
492 enqueuePopstateEvent(stateObject); | 492 enqueuePopstateEvent(stateObject); |
493 else | 493 else |
494 m_pendingStateObject = stateObject; | 494 m_pendingStateObject = stateObject; |
495 } | 495 } |
496 | 496 |
497 LocalDOMWindow::~LocalDOMWindow() | 497 LocalDOMWindow::~LocalDOMWindow() |
498 { | 498 { |
499 #if !ENABLE(OILPAN) | |
499 ASSERT(m_hasBeenReset); | 500 ASSERT(m_hasBeenReset); |
500 reset(); | 501 reset(); |
haraken
2014/09/08 07:25:58
Why is it OK to just remove the reset() call from
sof
2014/09/08 21:17:45
Notifying the registered DOMWindowProperty instanc
| |
502 #endif | |
501 | 503 |
502 #if ENABLE(OILPAN) | 504 #if ENABLE(OILPAN) |
503 // Oilpan: the frame host and document objects are | 505 // Oilpan: the frame host and document objects are |
504 // also garbage collected; cannot notify these | 506 // also garbage collected; cannot notify these |
505 // when removing event listeners. | 507 // when removing event listeners. |
506 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); | 508 removeAllEventListenersInternal(DoNotBroadcastListenerRemoval); |
507 | 509 |
508 // Cleared when detaching document. | 510 // Cleared when detaching document. |
509 ASSERT(!m_eventQueue); | 511 ASSERT(!m_eventQueue); |
510 #else | 512 #else |
(...skipping 22 matching lines...) Expand all Loading... | |
533 PassRefPtrWillBeRawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String& media) | 535 PassRefPtrWillBeRawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String& media) |
534 { | 536 { |
535 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr; | 537 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr; |
536 } | 538 } |
537 | 539 |
538 Page* LocalDOMWindow::page() | 540 Page* LocalDOMWindow::page() |
539 { | 541 { |
540 return frame() ? frame()->page() : 0; | 542 return frame() ? frame()->page() : 0; |
541 } | 543 } |
542 | 544 |
545 #if !ENABLE(OILPAN) | |
543 void LocalDOMWindow::frameDestroyed() | 546 void LocalDOMWindow::frameDestroyed() |
544 { | 547 { |
545 FrameDestructionObserver::frameDestroyed(); | 548 FrameDestructionObserver::frameDestroyed(); |
546 reset(); | 549 reset(); |
haraken
2014/09/08 07:25:58
Ditto.
sof
2014/09/08 21:17:45
The additional frame clearing that that reset() ef
| |
547 } | 550 } |
551 #endif | |
548 | 552 |
549 void LocalDOMWindow::willDetachFrameHost() | 553 void LocalDOMWindow::willDetachFrameHost() |
550 { | 554 { |
551 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); | 555 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); |
552 m_frame->console().messageStorage()->frameWindowDiscarded(this); | 556 m_frame->console().messageStorage()->frameWindowDiscarded(this); |
553 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); | 557 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); |
554 } | 558 } |
555 | 559 |
556 void LocalDOMWindow::willDestroyDocumentInFrame() | 560 void LocalDOMWindow::willDestroyDocumentInFrame() |
557 { | 561 { |
558 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may | 562 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may |
559 // unregister themselves from the LocalDOMWindow as a result of the call to willDestroyGlobalObjectInFrame. | 563 // unregister themselves from the LocalDOMWindow as a result of the call to willDestroyGlobalObjectInFrame. |
560 Vector<DOMWindowProperty*> properties; | 564 WillBeHeapVector<RawPtrWillBeMember<DOMWindowProperty> > properties; |
561 copyToVector(m_properties, properties); | 565 copyToVector(m_properties, properties); |
562 for (size_t i = 0; i < properties.size(); ++i) | 566 for (size_t i = 0; i < properties.size(); ++i) |
563 properties[i]->willDestroyGlobalObjectInFrame(); | 567 properties[i]->willDestroyGlobalObjectInFrame(); |
564 } | 568 } |
565 | 569 |
566 void LocalDOMWindow::willDetachDocumentFromFrame() | 570 void LocalDOMWindow::willDetachDocumentFromFrame() |
567 { | 571 { |
568 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may | 572 // It is necessary to copy m_properties to a separate vector because the DOM WindowProperties may |
569 // unregister themselves from the LocalDOMWindow as a result of the call to willDetachGlobalObjectFromFrame. | 573 // unregister themselves from the LocalDOMWindow as a result of the call to willDetachGlobalObjectFromFrame. |
570 Vector<DOMWindowProperty*> properties; | 574 WillBeHeapVector<RawPtrWillBeMember<DOMWindowProperty> > properties; |
571 copyToVector(m_properties, properties); | 575 copyToVector(m_properties, properties); |
572 for (size_t i = 0; i < properties.size(); ++i) | 576 for (size_t i = 0; i < properties.size(); ++i) |
573 properties[i]->willDetachGlobalObjectFromFrame(); | 577 properties[i]->willDetachGlobalObjectFromFrame(); |
574 } | 578 } |
575 | 579 |
576 void LocalDOMWindow::registerProperty(DOMWindowProperty* property) | 580 void LocalDOMWindow::registerProperty(DOMWindowProperty* property) |
577 { | 581 { |
578 m_properties.add(property); | 582 m_properties.add(property); |
579 } | 583 } |
580 | 584 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 frameConsole()->addMessage(consoleMessage.release()); | 910 frameConsole()->addMessage(consoleMessage.release()); |
907 return; | 911 return; |
908 } | 912 } |
909 } | 913 } |
910 | 914 |
911 dispatchEvent(event); | 915 dispatchEvent(event); |
912 } | 916 } |
913 | 917 |
914 DOMSelection* LocalDOMWindow::getSelection() | 918 DOMSelection* LocalDOMWindow::getSelection() |
915 { | 919 { |
916 if (!isCurrentlyDisplayedInFrame() || !m_frame) | 920 if (!isCurrentlyDisplayedInFrame()) |
917 return 0; | 921 return 0; |
918 | 922 |
919 return m_frame->document()->getSelection(); | 923 return m_frame->document()->getSelection(); |
920 } | 924 } |
921 | 925 |
922 Element* LocalDOMWindow::frameElement() const | 926 Element* LocalDOMWindow::frameElement() const |
923 { | 927 { |
924 if (!m_frame) | 928 if (!m_frame) |
925 return 0; | 929 return 0; |
926 | 930 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 | 1068 |
1065 return String(); | 1069 return String(); |
1066 } | 1070 } |
1067 | 1071 |
1068 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const | 1072 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const |
1069 { | 1073 { |
1070 if (!isCurrentlyDisplayedInFrame()) | 1074 if (!isCurrentlyDisplayedInFrame()) |
1071 return false; | 1075 return false; |
1072 | 1076 |
1073 // |m_frame| can be destructed during |Editor::findString()| via | 1077 // |m_frame| can be destructed during |Editor::findString()| via |
1074 // |Document::updateLayou()|, e.g. event handler removes a frame. | 1078 // |Document::updateLayout()|, e.g. event handler removes a frame. |
1075 RefPtr<LocalFrame> protectFrame(m_frame); | 1079 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get()); |
1076 | 1080 |
1077 // FIXME (13016): Support wholeWord, searchInFrames and showDialog | 1081 // FIXME (13016): Support wholeWord, searchInFrames and showDialog |
1078 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap, false); | 1082 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap, false); |
1079 } | 1083 } |
1080 | 1084 |
1081 bool LocalDOMWindow::offscreenBuffering() const | 1085 bool LocalDOMWindow::offscreenBuffering() const |
1082 { | 1086 { |
1083 return true; | 1087 return true; |
1084 } | 1088 } |
1085 | 1089 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 if (!view) | 1202 if (!view) |
1199 return 0; | 1203 return 0; |
1200 | 1204 |
1201 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1205 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
1202 | 1206 |
1203 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor()); | 1207 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor()); |
1204 } | 1208 } |
1205 | 1209 |
1206 bool LocalDOMWindow::closed() const | 1210 bool LocalDOMWindow::closed() const |
1207 { | 1211 { |
1212 #if ENABLE(OILPAN) | |
1213 // FIXME: Oilpan: the timing of when m_frame is GCed is clearly | |
1214 // different to what happens non-Oilpan. m_frame->hasBeenClosed() | |
1215 // is considered instead/additionally to mirror extant behavior as | |
1216 // closely as possible. | |
1217 // | |
1218 // However, the observed behavior isn't identical. Non-Oilpan, for | |
1219 // an iframe removed from the DOM, window.closed will only turn | |
1220 // 'true' once all references to it have gone and the object is | |
1221 // finalized at the next v8 GC. This will naturally happen at some | |
1222 // point after close() has been called on the underlying | |
1223 // LocalFrame (as a side-effect of detaching and removing the | |
1224 // frame from the DOM), hence with Oilpan 'window.closed' will | |
1225 // transition to 'true' slightly earlier. | |
haraken
2014/09/08 07:25:58
If possible, we should make this behavior change b
sof
2014/09/08 21:17:45
It wouldn't be a problem to separate it out and la
sof
2014/09/16 12:23:22
Handling the change to window.closed via http://cr
| |
1226 return !m_frame || m_frame->hasBeenClosed(); | |
1227 #else | |
1208 return !m_frame; | 1228 return !m_frame; |
1229 #endif | |
1209 } | 1230 } |
1210 | 1231 |
1211 unsigned LocalDOMWindow::length() const | 1232 unsigned LocalDOMWindow::length() const |
1212 { | 1233 { |
1213 if (!isCurrentlyDisplayedInFrame()) | 1234 if (!isCurrentlyDisplayedInFrame()) |
1214 return 0; | 1235 return 0; |
1215 | 1236 |
1216 return m_frame->tree().scopedChildCount(); | 1237 return m_frame->tree().scopedChildCount(); |
1217 } | 1238 } |
1218 | 1239 |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1867 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, | 1888 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, |
1868 *callingWindow, *firstFrame, *m_frame, function, functionContext); | 1889 *callingWindow, *firstFrame, *m_frame, function, functionContext); |
1869 if (!dialogFrame) | 1890 if (!dialogFrame) |
1870 return; | 1891 return; |
1871 UserGestureIndicatorDisabler disabler; | 1892 UserGestureIndicatorDisabler disabler; |
1872 dialogFrame->host()->chrome().runModal(); | 1893 dialogFrame->host()->chrome().runModal(); |
1873 } | 1894 } |
1874 | 1895 |
1875 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) | 1896 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) |
1876 { | 1897 { |
1877 LocalFrame* frame = this->frame(); | 1898 if (!m_frame) |
1878 if (!frame) | |
1879 return 0; | 1899 return 0; |
1880 | 1900 |
1881 Frame* child = frame->tree().scopedChild(index); | 1901 Frame* child = m_frame->tree().scopedChild(index); |
1882 if (child) | 1902 if (child) |
1883 return child->domWindow(); | 1903 return child->domWindow(); |
1884 | 1904 |
1885 return 0; | 1905 return 0; |
1886 } | 1906 } |
1887 | 1907 |
1888 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() | 1908 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() |
1889 { | 1909 { |
1890 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier()); | 1910 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier()); |
1891 } | 1911 } |
1892 | 1912 |
1893 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier() | 1913 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier() |
1894 { | 1914 { |
1895 return DOMWindowLifecycleNotifier::create(this); | 1915 return DOMWindowLifecycleNotifier::create(this); |
1896 } | 1916 } |
1897 | 1917 |
1898 void LocalDOMWindow::trace(Visitor* visitor) | 1918 void LocalDOMWindow::trace(Visitor* visitor) |
1899 { | 1919 { |
1900 visitor->trace(m_document); | 1920 visitor->trace(m_document); |
1921 #if ENABLE(OILPAN) | |
1922 visitor->trace(m_properties); | |
1923 #endif | |
1901 visitor->trace(m_screen); | 1924 visitor->trace(m_screen); |
1902 visitor->trace(m_history); | 1925 visitor->trace(m_history); |
1903 visitor->trace(m_locationbar); | 1926 visitor->trace(m_locationbar); |
1904 visitor->trace(m_menubar); | 1927 visitor->trace(m_menubar); |
1905 visitor->trace(m_personalbar); | 1928 visitor->trace(m_personalbar); |
1906 visitor->trace(m_scrollbars); | 1929 visitor->trace(m_scrollbars); |
1907 visitor->trace(m_statusbar); | 1930 visitor->trace(m_statusbar); |
1908 visitor->trace(m_toolbar); | 1931 visitor->trace(m_toolbar); |
1909 visitor->trace(m_console); | 1932 visitor->trace(m_console); |
1910 visitor->trace(m_navigator); | 1933 visitor->trace(m_navigator); |
1911 visitor->trace(m_location); | 1934 visitor->trace(m_location); |
1912 visitor->trace(m_media); | 1935 visitor->trace(m_media); |
1913 visitor->trace(m_sessionStorage); | 1936 visitor->trace(m_sessionStorage); |
1914 visitor->trace(m_localStorage); | 1937 visitor->trace(m_localStorage); |
1915 visitor->trace(m_applicationCache); | 1938 visitor->trace(m_applicationCache); |
1916 visitor->trace(m_performance); | 1939 visitor->trace(m_performance); |
1917 visitor->trace(m_css); | 1940 visitor->trace(m_css); |
1918 visitor->trace(m_eventQueue); | 1941 visitor->trace(m_eventQueue); |
1919 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); | 1942 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); |
1920 EventTargetWithInlineData::trace(visitor); | 1943 EventTargetWithInlineData::trace(visitor); |
1921 LifecycleContext<LocalDOMWindow>::trace(visitor); | 1944 LifecycleContext<LocalDOMWindow>::trace(visitor); |
1945 FrameDestructionObserver::trace(visitor); | |
1922 } | 1946 } |
1923 | 1947 |
1924 } // namespace blink | 1948 } // namespace blink |
OLD | NEW |