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

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

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplify DOMWindowProperty for Oilpan + other review improvements Created 6 years, 3 months 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
545 void LocalDOMWindow::frameDestroyed()
546 {
547 FrameDestructionObserver::frameDestroyed();
548 reset();
549 }
550
551 void LocalDOMWindow::willDetachFrameHost() 544 void LocalDOMWindow::willDetachFrameHost()
552 { 545 {
553 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); 546 m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this);
554 m_frame->console().messageStorage()->frameWindowDiscarded(this); 547 m_frame->console().messageStorage()->frameWindowDiscarded(this);
555 InspectorInstrumentation::frameWindowDiscarded(m_frame, this); 548 InspectorInstrumentation::frameWindowDiscarded(m_frame, this);
556 } 549 }
557 550
558 void LocalDOMWindow::willDestroyDocumentInFrame() 551 void LocalDOMWindow::willDestroyDocumentInFrame()
559 { 552 {
560 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<DOMWindowProperty> >::const_it erator it = m_properties.begin(); it != m_properties.end(); ++it) 553 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<DOMWindowProperty> >::const_it erator it = m_properties.begin(); it != m_properties.end(); ++it)
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 frameConsole()->addMessage(consoleMessage.release()); 889 frameConsole()->addMessage(consoleMessage.release());
897 return; 890 return;
898 } 891 }
899 } 892 }
900 893
901 dispatchEvent(event); 894 dispatchEvent(event);
902 } 895 }
903 896
904 DOMSelection* LocalDOMWindow::getSelection() 897 DOMSelection* LocalDOMWindow::getSelection()
905 { 898 {
906 if (!isCurrentlyDisplayedInFrame() || !m_frame) 899 if (!isCurrentlyDisplayedInFrame())
907 return 0; 900 return 0;
908 901
909 return m_frame->document()->getSelection(); 902 return m_frame->document()->getSelection();
910 } 903 }
911 904
912 Element* LocalDOMWindow::frameElement() const 905 Element* LocalDOMWindow::frameElement() const
913 { 906 {
914 if (!m_frame) 907 if (!m_frame)
915 return 0; 908 return 0;
916 909
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1047
1055 return String(); 1048 return String();
1056 } 1049 }
1057 1050
1058 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const 1051 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
1059 { 1052 {
1060 if (!isCurrentlyDisplayedInFrame()) 1053 if (!isCurrentlyDisplayedInFrame())
1061 return false; 1054 return false;
1062 1055
1063 // |m_frame| can be destructed during |Editor::findString()| via 1056 // |m_frame| can be destructed during |Editor::findString()| via
1064 // |Document::updateLayou()|, e.g. event handler removes a frame. 1057 // |Document::updateLayout()|, e.g. event handler removes a frame.
1065 RefPtr<LocalFrame> protectFrame(m_frame); 1058 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame.get());
1066 1059
1067 // FIXME (13016): Support wholeWord, searchInFrames and showDialog 1060 // FIXME (13016): Support wholeWord, searchInFrames and showDialog
1068 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap, false); 1061 return m_frame->editor().findString(string, !backwards, caseSensitive, wrap, false);
1069 } 1062 }
1070 1063
1071 bool LocalDOMWindow::offscreenBuffering() const 1064 bool LocalDOMWindow::offscreenBuffering() const
1072 { 1065 {
1073 return true; 1066 return true;
1074 } 1067 }
1075 1068
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 if (!view) 1181 if (!view)
1189 return 0; 1182 return 0;
1190 1183
1191 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 1184 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1192 1185
1193 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor()); 1186 return adjustForAbsoluteZoom(view->scrollY(), m_frame->pageZoomFactor());
1194 } 1187 }
1195 1188
1196 bool LocalDOMWindow::closed() const 1189 bool LocalDOMWindow::closed() const
1197 { 1190 {
1198 return !m_frame; 1191 // FIXME: Oilpan: the timing of when m_frame is GCed is clearly
1192 // different to what happens non-Oilpan. m_frame->hasBeenClosed()
1193 // is considered in both settings to make the behavior the same --
1194 // the flag is set when the WebView (and frame) is closed. Finalization
1195 // of the m_frame will happen at some point later.
1196 //
1197 return !m_frame || m_frame->hasBeenClosed();
1199 } 1198 }
1200 1199
1201 unsigned LocalDOMWindow::length() const 1200 unsigned LocalDOMWindow::length() const
1202 { 1201 {
1203 if (!isCurrentlyDisplayedInFrame()) 1202 if (!isCurrentlyDisplayedInFrame())
1204 return 0; 1203 return 0;
1205 1204
1206 return m_frame->tree().scopedChildCount(); 1205 return m_frame->tree().scopedChildCount();
1207 } 1206 }
1208 1207
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, 1856 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures,
1858 *callingWindow, *firstFrame, *m_frame, function, functionContext); 1857 *callingWindow, *firstFrame, *m_frame, function, functionContext);
1859 if (!dialogFrame) 1858 if (!dialogFrame)
1860 return; 1859 return;
1861 UserGestureIndicatorDisabler disabler; 1860 UserGestureIndicatorDisabler disabler;
1862 dialogFrame->host()->chrome().runModal(); 1861 dialogFrame->host()->chrome().runModal();
1863 } 1862 }
1864 1863
1865 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) 1864 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index)
1866 { 1865 {
1867 LocalFrame* frame = this->frame(); 1866 if (!m_frame)
1868 if (!frame)
1869 return 0; 1867 return 0;
1870 1868
1871 Frame* child = frame->tree().scopedChild(index); 1869 Frame* child = m_frame->tree().scopedChild(index);
1872 if (child) 1870 if (child)
1873 return child->domWindow(); 1871 return child->domWindow();
1874 1872
1875 return 0; 1873 return 0;
1876 } 1874 }
1877 1875
1878 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() 1876 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier()
1879 { 1877 {
1880 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier()); 1878 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier());
1881 } 1879 }
(...skipping 23 matching lines...) Expand all
1905 visitor->trace(m_sessionStorage); 1903 visitor->trace(m_sessionStorage);
1906 visitor->trace(m_localStorage); 1904 visitor->trace(m_localStorage);
1907 visitor->trace(m_applicationCache); 1905 visitor->trace(m_applicationCache);
1908 visitor->trace(m_performance); 1906 visitor->trace(m_performance);
1909 visitor->trace(m_css); 1907 visitor->trace(m_css);
1910 visitor->trace(m_eventQueue); 1908 visitor->trace(m_eventQueue);
1911 #endif 1909 #endif
1912 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); 1910 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor);
1913 EventTargetWithInlineData::trace(visitor); 1911 EventTargetWithInlineData::trace(visitor);
1914 LifecycleContext<LocalDOMWindow>::trace(visitor); 1912 LifecycleContext<LocalDOMWindow>::trace(visitor);
1913 FrameDestructionObserver::trace(visitor);
1915 } 1914 }
1916 1915
1917 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate) 1916 v8::Handle<v8::Object> LocalDOMWindow::wrap(v8::Handle<v8::Object> creationConte xt, v8::Isolate* isolate)
1918 { 1917 {
1919 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8]. 1918 ASSERT_NOT_REACHED(); // LocalDOMWindow has [Custom=ToV8].
1920 return v8::Handle<v8::Object>(); 1919 return v8::Handle<v8::Object>();
1921 } 1920 }
1922 1921
1923 } // namespace blink 1922 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698