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

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: Handle FrameHost-detached access in FrameLoader::allowPlugins() 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
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
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
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();
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
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
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
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 {
1208 return !m_frame; 1212 // FIXME: Oilpan: the timing of when m_frame is GCed is clearly
1213 // different to what happens non-Oilpan. m_frame->hasBeenClosed()
1214 // is considered in both settings to make the behavior the same --
1215 // the flag is set when the WebView (and frame) is closed. Finalization
1216 // of the m_frame will happen at some point later.
1217 //
1218 return !m_frame || m_frame->hasBeenClosed();
1209 } 1219 }
1210 1220
1211 unsigned LocalDOMWindow::length() const 1221 unsigned LocalDOMWindow::length() const
1212 { 1222 {
1213 if (!isCurrentlyDisplayedInFrame()) 1223 if (!isCurrentlyDisplayedInFrame())
1214 return 0; 1224 return 0;
1215 1225
1216 return m_frame->tree().scopedChildCount(); 1226 return m_frame->tree().scopedChildCount();
1217 } 1227 }
1218 1228
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, 1877 LocalFrame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures,
1868 *callingWindow, *firstFrame, *m_frame, function, functionContext); 1878 *callingWindow, *firstFrame, *m_frame, function, functionContext);
1869 if (!dialogFrame) 1879 if (!dialogFrame)
1870 return; 1880 return;
1871 UserGestureIndicatorDisabler disabler; 1881 UserGestureIndicatorDisabler disabler;
1872 dialogFrame->host()->chrome().runModal(); 1882 dialogFrame->host()->chrome().runModal();
1873 } 1883 }
1874 1884
1875 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index) 1885 LocalDOMWindow* LocalDOMWindow::anonymousIndexedGetter(uint32_t index)
1876 { 1886 {
1877 LocalFrame* frame = this->frame(); 1887 if (!m_frame)
1878 if (!frame)
1879 return 0; 1888 return 0;
1880 1889
1881 Frame* child = frame->tree().scopedChild(index); 1890 Frame* child = m_frame->tree().scopedChild(index);
1882 if (child) 1891 if (child)
1883 return child->domWindow(); 1892 return child->domWindow();
1884 1893
1885 return 0; 1894 return 0;
1886 } 1895 }
1887 1896
1888 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier() 1897 DOMWindowLifecycleNotifier& LocalDOMWindow::lifecycleNotifier()
1889 { 1898 {
1890 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier()); 1899 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<LocalDOMWin dow>::lifecycleNotifier());
1891 } 1900 }
1892 1901
1893 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier() 1902 PassOwnPtr<LifecycleNotifier<LocalDOMWindow> > LocalDOMWindow::createLifecycleNo tifier()
1894 { 1903 {
1895 return DOMWindowLifecycleNotifier::create(this); 1904 return DOMWindowLifecycleNotifier::create(this);
1896 } 1905 }
1897 1906
1898 void LocalDOMWindow::trace(Visitor* visitor) 1907 void LocalDOMWindow::trace(Visitor* visitor)
1899 { 1908 {
1900 visitor->trace(m_document); 1909 visitor->trace(m_document);
1910 #if ENABLE(OILPAN)
1911 visitor->trace(m_properties);
1912 #endif
1901 visitor->trace(m_screen); 1913 visitor->trace(m_screen);
1902 visitor->trace(m_history); 1914 visitor->trace(m_history);
1903 visitor->trace(m_locationbar); 1915 visitor->trace(m_locationbar);
1904 visitor->trace(m_menubar); 1916 visitor->trace(m_menubar);
1905 visitor->trace(m_personalbar); 1917 visitor->trace(m_personalbar);
1906 visitor->trace(m_scrollbars); 1918 visitor->trace(m_scrollbars);
1907 visitor->trace(m_statusbar); 1919 visitor->trace(m_statusbar);
1908 visitor->trace(m_toolbar); 1920 visitor->trace(m_toolbar);
1909 visitor->trace(m_console); 1921 visitor->trace(m_console);
1910 visitor->trace(m_navigator); 1922 visitor->trace(m_navigator);
1911 visitor->trace(m_location); 1923 visitor->trace(m_location);
1912 visitor->trace(m_media); 1924 visitor->trace(m_media);
1913 visitor->trace(m_sessionStorage); 1925 visitor->trace(m_sessionStorage);
1914 visitor->trace(m_localStorage); 1926 visitor->trace(m_localStorage);
1915 visitor->trace(m_applicationCache); 1927 visitor->trace(m_applicationCache);
1916 visitor->trace(m_performance); 1928 visitor->trace(m_performance);
1917 visitor->trace(m_css); 1929 visitor->trace(m_css);
1918 visitor->trace(m_eventQueue); 1930 visitor->trace(m_eventQueue);
1919 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor); 1931 WillBeHeapSupplementable<LocalDOMWindow>::trace(visitor);
1920 EventTargetWithInlineData::trace(visitor); 1932 EventTargetWithInlineData::trace(visitor);
1921 LifecycleContext<LocalDOMWindow>::trace(visitor); 1933 LifecycleContext<LocalDOMWindow>::trace(visitor);
1934 FrameDestructionObserver::trace(visitor);
1922 } 1935 }
1923 1936
1924 } // namespace blink 1937 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698