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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r181245 conflict 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/editing/Editor.h" 42 #include "core/editing/Editor.h"
43 #include "core/editing/FrameSelection.h" 43 #include "core/editing/FrameSelection.h"
44 #include "core/editing/HTMLInterchange.h" 44 #include "core/editing/HTMLInterchange.h"
45 #include "core/editing/InputMethodController.h" 45 #include "core/editing/InputMethodController.h"
46 #include "core/editing/TextIterator.h" 46 #include "core/editing/TextIterator.h"
47 #include "core/editing/markup.h" 47 #include "core/editing/markup.h"
48 #include "core/events/KeyboardEvent.h" 48 #include "core/events/KeyboardEvent.h"
49 #include "core/events/WheelEvent.h" 49 #include "core/events/WheelEvent.h"
50 #include "core/frame/EventHandlerRegistry.h" 50 #include "core/frame/EventHandlerRegistry.h"
51 #include "core/frame/FrameHost.h" 51 #include "core/frame/FrameHost.h"
52 #include "core/frame/FrameProtector.h"
52 #include "core/frame/FrameView.h" 53 #include "core/frame/FrameView.h"
53 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
54 #include "core/frame/PinchViewport.h" 55 #include "core/frame/PinchViewport.h"
55 #include "core/frame/RemoteFrame.h" 56 #include "core/frame/RemoteFrame.h"
56 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
57 #include "core/frame/SmartClip.h" 58 #include "core/frame/SmartClip.h"
58 #include "core/html/HTMLInputElement.h" 59 #include "core/html/HTMLInputElement.h"
59 #include "core/html/HTMLMediaElement.h" 60 #include "core/html/HTMLMediaElement.h"
60 #include "core/html/HTMLPlugInElement.h" 61 #include "core/html/HTMLPlugInElement.h"
61 #include "core/html/HTMLTextAreaElement.h" 62 #include "core/html/HTMLTextAreaElement.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Change the text zoom level by kTextSizeMultiplierRatio each time the user 202 // Change the text zoom level by kTextSizeMultiplierRatio each time the user
202 // zooms text in or out (ie., change by 20%). The min and max values limit 203 // zooms text in or out (ie., change by 20%). The min and max values limit
203 // text zoom to half and 3x the original text size. These three values match 204 // text zoom to half and 3x the original text size. These three values match
204 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm 205 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
205 const double WebView::textSizeMultiplierRatio = 1.2; 206 const double WebView::textSizeMultiplierRatio = 1.2;
206 const double WebView::minTextSizeMultiplier = 0.5; 207 const double WebView::minTextSizeMultiplier = 0.5;
207 const double WebView::maxTextSizeMultiplier = 3.0; 208 const double WebView::maxTextSizeMultiplier = 3.0;
208 209
209 // Used to defer all page activity in cases where the embedder wishes to run 210 // Used to defer all page activity in cases where the embedder wishes to run
210 // a nested event loop. Using a stack enables nesting of message loop invocation s. 211 // a nested event loop. Using a stack enables nesting of message loop invocation s.
211 static Vector<ScopedPageLoadDeferrer*>& pageLoadDeferrerStack() 212 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe ferrerStack()
212 { 213 {
213 DEFINE_STATIC_LOCAL(Vector<ScopedPageLoadDeferrer*>, deferrerStack, ()); 214 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ())));
214 return deferrerStack; 215 return *deferrerStack;
215 } 216 }
216 217
217 // Ensure that the WebDragOperation enum values stay in sync with the original 218 // Ensure that the WebDragOperation enum values stay in sync with the original
218 // DragOperation constants. 219 // DragOperation constants.
219 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ 220 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \
220 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) 221 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName)
221 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); 222 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone);
222 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); 223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy);
223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); 224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink);
224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); 225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 308
308 void WebView::willEnterModalLoop() 309 void WebView::willEnterModalLoop()
309 { 310 {
310 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); 311 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer());
311 } 312 }
312 313
313 void WebView::didExitModalLoop() 314 void WebView::didExitModalLoop()
314 { 315 {
315 ASSERT(pageLoadDeferrerStack().size()); 316 ASSERT(pageLoadDeferrerStack().size());
316 317
317 delete pageLoadDeferrerStack().last(); 318 ScopedPageLoadDeferrer* deferrer = pageLoadDeferrerStack().last();
319 #if ENABLE(OILPAN)
320 deferrer->dispose();
321 #else
322 delete deferrer;
323 #endif
318 pageLoadDeferrerStack().removeLast(); 324 pageLoadDeferrerStack().removeLast();
319 } 325 }
320 326
321 void WebViewImpl::setMainFrame(WebFrame* frame) 327 void WebViewImpl::setMainFrame(WebFrame* frame)
322 { 328 {
323 if (frame->isWebLocalFrame()) 329 if (frame->isWebLocalFrame()) {
330 #if ENABLE(OILPAN)
331 m_localMainFrame = toWebLocalFrameImpl(frame);
332 m_remoteMainFrame.clear();
333 #endif
324 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); 334 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom);
325 else 335 } else {
336 #if ENABLE(OILPAN)
337 m_localMainFrame.clear();
338 m_remoteMainFrame = toWebRemoteFrameImpl(frame);
339 #endif
326 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom); 340 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom);
341 }
327 } 342 }
328 343
329 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) 344 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
330 { 345 {
331 m_autofillClient = autofillClient; 346 m_autofillClient = autofillClient;
332 } 347 }
333 348
334 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient) 349 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient)
335 { 350 {
336 ASSERT(m_page); 351 ASSERT(m_page);
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 961 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
947 if (m_pagePopup) { 962 if (m_pagePopup) {
948 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 963 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
949 // We need to ignore the next Char event after this otherwise pressing 964 // We need to ignore the next Char event after this otherwise pressing
950 // enter when selecting an item in the popup will go to the page. 965 // enter when selecting an item in the popup will go to the page.
951 if (WebInputEvent::RawKeyDown == event.type) 966 if (WebInputEvent::RawKeyDown == event.type)
952 m_suppressNextKeypressEvent = true; 967 m_suppressNextKeypressEvent = true;
953 return true; 968 return true;
954 } 969 }
955 970
956 RefPtr<Frame> focusedFrame = focusedCoreFrame(); 971 Frame* focusedFrame = focusedCoreFrame();
972 FrameProtector protect(focusedFrame);
957 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 973 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
958 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 974 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame));
959 webFrame->client()->forwardInputEvent(&event); 975 webFrame->client()->forwardInputEvent(&event);
960 return true; 976 return true;
961 } 977 }
962 978
963 if (!focusedFrame || !focusedFrame->isLocalFrame()) 979 if (!focusedFrame || !focusedFrame->isLocalFrame())
964 return false; 980 return false;
965 981
966 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 982 LocalFrame* frame = toLocalFrame(focusedFrame);
967 983
968 PlatformKeyboardEventBuilder evt(event); 984 PlatformKeyboardEventBuilder evt(event);
969 985
970 if (frame->eventHandler().keyEvent(evt)) { 986 if (frame->eventHandler().keyEvent(evt)) {
971 if (WebInputEvent::RawKeyDown == event.type) { 987 if (WebInputEvent::RawKeyDown == event.type) {
972 // Suppress the next keypress event unless the focused node is a plu g-in node. 988 // Suppress the next keypress event unless the focused node is a plu g-in node.
973 // (Flash needs these keypress events to handle non-US keyboards.) 989 // (Flash needs these keypress events to handle non-US keyboards.)
974 Element* element = focusedElement(); 990 Element* element = focusedElement();
975 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 991 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
976 m_suppressNextKeypressEvent = true; 992 m_suppressNextKeypressEvent = true;
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 { 2021 {
2006 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 2022 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
2007 m_mouseCaptureNode = nullptr; 2023 m_mouseCaptureNode = nullptr;
2008 } 2024 }
2009 2025
2010 void WebViewImpl::setFocus(bool enable) 2026 void WebViewImpl::setFocus(bool enable)
2011 { 2027 {
2012 m_page->focusController().setFocused(enable); 2028 m_page->focusController().setFocused(enable);
2013 if (enable) { 2029 if (enable) {
2014 m_page->focusController().setActive(true); 2030 m_page->focusController().setActive(true);
2015 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2031 Frame* focusedFrame = m_page->focusController().focusedFrame();
2032 FrameProtector protect(focusedFrame);
2016 if (focusedFrame && focusedFrame->isLocalFrame()) { 2033 if (focusedFrame && focusedFrame->isLocalFrame()) {
2017 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); 2034 LocalFrame* localFrame = toLocalFrame(focusedFrame);
2018 Element* element = localFrame->document()->focusedElement(); 2035 Element* element = localFrame->document()->focusedElement();
2019 if (element && localFrame->selection().selection().isNone()) { 2036 if (element && localFrame->selection().selection().isNone()) {
2020 // If the selection was cleared while the WebView was not 2037 // If the selection was cleared while the WebView was not
2021 // focused, then the focus element shows with a focus ring but 2038 // focused, then the focus element shows with a focus ring but
2022 // no caret and does respond to keyboard inputs. 2039 // no caret and does respond to keyboard inputs.
2023 if (element->isTextFormControl()) { 2040 if (element->isTextFormControl()) {
2024 element->updateFocusAppearance(true); 2041 element->updateFocusAppearance(true);
2025 } else if (element->isContentEditable()) { 2042 } else if (element->isContentEditable()) {
2026 // updateFocusAppearance() selects all the text of 2043 // updateFocusAppearance() selects all the text of
2027 // contentseditable DIVs. So we set the selection explicitly 2044 // contentseditable DIVs. So we set the selection explicitly
(...skipping 10 matching lines...) Expand all
2038 2055
2039 // Clear focus on the currently focused frame if any. 2056 // Clear focus on the currently focused frame if any.
2040 if (!m_page) 2057 if (!m_page)
2041 return; 2058 return;
2042 2059
2043 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() 2060 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame()
2044 ? m_page->deprecatedLocalMainFrame() : 0; 2061 ? m_page->deprecatedLocalMainFrame() : 0;
2045 if (!frame) 2062 if (!frame)
2046 return; 2063 return;
2047 2064
2048 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2065 Frame* focusedFrame = m_page->focusController().focusedFrame();
2066 FrameProtector protect(focusedFrame);
2049 if (focusedFrame && focusedFrame->isLocalFrame()) { 2067 if (focusedFrame && focusedFrame->isLocalFrame()) {
2050 // Finish an ongoing composition to delete the composition node. 2068 // Finish an ongoing composition to delete the composition node.
2051 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { 2069 if (toLocalFrame(focusedFrame)->inputMethodController().hasCompositi on()) {
2052 if (m_autofillClient) 2070 if (m_autofillClient)
2053 m_autofillClient->setIgnoreTextChanges(true); 2071 m_autofillClient->setIgnoreTextChanges(true);
2054 2072
2055 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); 2073 toLocalFrame(focusedFrame)->inputMethodController().confirmCompo sition();
2056 2074
2057 if (m_autofillClient) 2075 if (m_autofillClient)
2058 m_autofillClient->setIgnoreTextChanges(false); 2076 m_autofillClient->setIgnoreTextChanges(false);
2059 } 2077 }
2060 m_imeAcceptEvents = false; 2078 m_imeAcceptEvents = false;
2061 } 2079 }
2062 } 2080 }
2063 } 2081 }
2064 2082
2065 bool WebViewImpl::setComposition( 2083 bool WebViewImpl::setComposition(
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 Frame* frame = page()->focusController().focusedOrMainFrame(); 2665 Frame* frame = page()->focusController().focusedOrMainFrame();
2648 if (frame->isLocalFrame()) { 2666 if (frame->isLocalFrame()) {
2649 if (Document* document = toLocalFrame(frame)->document()) 2667 if (Document* document = toLocalFrame(frame)->document())
2650 document->setFocusedElement(nullptr); 2668 document->setFocusedElement(nullptr);
2651 } 2669 }
2652 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2670 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2653 } 2671 }
2654 2672
2655 void WebViewImpl::clearFocusedElement() 2673 void WebViewImpl::clearFocusedElement()
2656 { 2674 {
2657 RefPtr<Frame> frame = focusedCoreFrame(); 2675 Frame* frame = focusedCoreFrame();
2658 if (!frame || !frame->isLocalFrame()) 2676 if (!frame || !frame->isLocalFrame())
2659 return; 2677 return;
2660 2678
2661 LocalFrame* localFrame = toLocalFrame(frame.get()); 2679 FrameProtector protect(frame);
2680 LocalFrame* localFrame = toLocalFrame(frame);
2662 2681
2663 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2682 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2664 if (!document) 2683 if (!document)
2665 return; 2684 return;
2666 2685
2667 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2686 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
2668 2687
2669 // Clear the focused node. 2688 // Clear the focused node.
2670 document->setFocusedElement(nullptr); 2689 document->setFocusedElement(nullptr);
2671 2690
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 if (TextAutosizer* textAutosizer = frame->document()->textAutosizer()) 3117 if (TextAutosizer* textAutosizer = frame->document()->textAutosizer())
3099 textAutosizer->updatePageInfoInAllFrames(); 3118 textAutosizer->updatePageInfoInAllFrames();
3100 } 3119 }
3101 } 3120 }
3102 3121
3103 void WebViewImpl::updateMainFrameLayoutSize() 3122 void WebViewImpl::updateMainFrameLayoutSize()
3104 { 3123 {
3105 if (m_fixedLayoutSizeLock || m_shouldAutoResize || !mainFrameImpl()) 3124 if (m_fixedLayoutSizeLock || m_shouldAutoResize || !mainFrameImpl())
3106 return; 3125 return;
3107 3126
3108 RefPtr<FrameView> view = mainFrameImpl()->frameView(); 3127 FrameView* view = mainFrameImpl()->frameView();
3128 FrameViewProtector protect(view);
3109 if (!view) 3129 if (!view)
3110 return; 3130 return;
3111 3131
3112 WebSize layoutSize = m_size; 3132 WebSize layoutSize = m_size;
3113 3133
3114 if (settings()->viewportEnabled()) 3134 if (settings()->viewportEnabled())
3115 layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstra ints().layoutSize); 3135 layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedConstra ints().layoutSize);
3116 3136
3117 if (page()->settings().forceZeroLayoutHeight()) 3137 if (page()->settings().forceZeroLayoutHeight())
3118 layoutSize.height = 0; 3138 layoutSize.height = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 3196
3177 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) 3197 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
3178 { 3198 {
3179 if (!page() || !page()->mainFrame()->isLocalFrame()) 3199 if (!page() || !page()->mainFrame()->isLocalFrame())
3180 return; 3200 return;
3181 3201
3182 LocalFrame* frame = page()->deprecatedLocalMainFrame(); 3202 LocalFrame* frame = page()->deprecatedLocalMainFrame();
3183 if (!frame) 3203 if (!frame)
3184 return; 3204 return;
3185 3205
3186 RefPtr<FrameView> view = frame->view(); 3206 FrameView* view = frame->view();
3207 FrameViewProtector protect(view);
3187 if (!view) 3208 if (!view)
3188 return; 3209 return;
3189 3210
3190 m_fixedLayoutSizeLock = layoutSize.width || layoutSize.height; 3211 m_fixedLayoutSizeLock = layoutSize.width || layoutSize.height;
3191 3212
3192 if (m_fixedLayoutSizeLock) 3213 if (m_fixedLayoutSizeLock)
3193 view->setLayoutSize(layoutSize); 3214 view->setLayoutSize(layoutSize);
3194 else 3215 else
3195 updateMainFrameLayoutSize(); 3216 updateMainFrameLayoutSize();
3196 } 3217 }
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4286 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4266 4287
4267 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4288 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4268 return false; 4289 return false;
4269 4290
4270 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4291 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4271 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4292 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4272 } 4293 }
4273 4294
4274 } // namespace blink 4295 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698