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

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: 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/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('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) 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Change the text zoom level by kTextSizeMultiplierRatio each time the user 203 // Change the text zoom level by kTextSizeMultiplierRatio each time the user
204 // zooms text in or out (ie., change by 20%). The min and max values limit 204 // zooms text in or out (ie., change by 20%). The min and max values limit
205 // text zoom to half and 3x the original text size. These three values match 205 // text zoom to half and 3x the original text size. These three values match
206 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm 206 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
207 const double WebView::textSizeMultiplierRatio = 1.2; 207 const double WebView::textSizeMultiplierRatio = 1.2;
208 const double WebView::minTextSizeMultiplier = 0.5; 208 const double WebView::minTextSizeMultiplier = 0.5;
209 const double WebView::maxTextSizeMultiplier = 3.0; 209 const double WebView::maxTextSizeMultiplier = 3.0;
210 210
211 // Used to defer all page activity in cases where the embedder wishes to run 211 // Used to defer all page activity in cases where the embedder wishes to run
212 // a nested event loop. Using a stack enables nesting of message loop invocation s. 212 // a nested event loop. Using a stack enables nesting of message loop invocation s.
213 static Vector<ScopedPageLoadDeferrer*>& pageLoadDeferrerStack() 213 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe ferrerStack()
214 { 214 {
215 DEFINE_STATIC_LOCAL(Vector<ScopedPageLoadDeferrer*>, deferrerStack, ()); 215 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ())));
216 return deferrerStack; 216 return *deferrerStack;
217 } 217 }
218 218
219 // Ensure that the WebDragOperation enum values stay in sync with the original 219 // Ensure that the WebDragOperation enum values stay in sync with the original
220 // DragOperation constants. 220 // DragOperation constants.
221 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ 221 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \
222 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) 222 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName)
223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); 223 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone);
224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); 224 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy);
225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); 225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink);
226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); 226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 void WebView::willEnterModalLoop() 310 void WebView::willEnterModalLoop()
311 { 311 {
312 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); 312 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer());
313 } 313 }
314 314
315 void WebView::didExitModalLoop() 315 void WebView::didExitModalLoop()
316 { 316 {
317 ASSERT(pageLoadDeferrerStack().size()); 317 ASSERT(pageLoadDeferrerStack().size());
318 318
319 delete pageLoadDeferrerStack().last(); 319 ScopedPageLoadDeferrer* deferrer = pageLoadDeferrerStack().last();
320 #if ENABLE(OILPAN)
321 deferrer->dispose();
322 #else
323 delete deferrer;
324 #endif
320 pageLoadDeferrerStack().removeLast(); 325 pageLoadDeferrerStack().removeLast();
321 } 326 }
322 327
323 void WebViewImpl::setMainFrame(WebFrame* frame) 328 void WebViewImpl::setMainFrame(WebFrame* frame)
324 { 329 {
325 if (frame->isWebLocalFrame()) 330 if (frame->isWebLocalFrame()) {
331 #if ENABLE(OILPAN)
332 m_localMainFrame = toWebLocalFrameImpl(frame);
333 m_remoteMainFrame.clear();
334 #endif
326 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); 335 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom);
327 else 336 } else {
337 #if ENABLE(OILPAN)
338 m_localMainFrame.clear();
339 m_remoteMainFrame = toWebRemoteFrameImpl(frame);
340 #endif
328 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom); 341 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom);
342 }
329 } 343 }
330 344
331 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) 345 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
332 { 346 {
333 m_autofillClient = autofillClient; 347 m_autofillClient = autofillClient;
334 } 348 }
335 349
336 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient) 350 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient)
337 { 351 {
338 ASSERT(m_page); 352 ASSERT(m_page);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor); 461 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor);
448 setVisibilityState(m_client->visibilityState(), true); 462 setVisibilityState(m_client->visibilityState(), true);
449 } 463 }
450 464
451 initializeLayerTreeView(); 465 initializeLayerTreeView();
452 } 466 }
453 467
454 WebViewImpl::~WebViewImpl() 468 WebViewImpl::~WebViewImpl()
455 { 469 {
456 ASSERT(!m_page); 470 ASSERT(!m_page);
471 #if ENABLE(OILPAN)
472 // At most one Persistent frame reference should be set.
473 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
474 #endif
457 } 475 }
458 476
459 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 477 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
460 { 478 {
461 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0; 479 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0;
462 } 480 }
463 481
464 bool WebViewImpl::tabKeyCyclesThroughElements() const 482 bool WebViewImpl::tabKeyCyclesThroughElements() const
465 { 483 {
466 ASSERT(m_page); 484 ASSERT(m_page);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 967 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
950 if (m_pagePopup) { 968 if (m_pagePopup) {
951 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 969 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
952 // We need to ignore the next Char event after this otherwise pressing 970 // We need to ignore the next Char event after this otherwise pressing
953 // enter when selecting an item in the popup will go to the page. 971 // enter when selecting an item in the popup will go to the page.
954 if (WebInputEvent::RawKeyDown == event.type) 972 if (WebInputEvent::RawKeyDown == event.type)
955 m_suppressNextKeypressEvent = true; 973 m_suppressNextKeypressEvent = true;
956 return true; 974 return true;
957 } 975 }
958 976
959 RefPtr<Frame> focusedFrame = focusedCoreFrame(); 977 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
960 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 978 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
961 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 979 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get()));
962 webFrame->client()->forwardInputEvent(&event); 980 webFrame->client()->forwardInputEvent(&event);
963 return true; 981 return true;
964 } 982 }
965 983
966 if (!focusedFrame || !focusedFrame->isLocalFrame()) 984 if (!focusedFrame || !focusedFrame->isLocalFrame())
967 return false; 985 return false;
968 986
969 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 987 LocalFrame* frame = toLocalFrame(focusedFrame.get());
970 988
971 PlatformKeyboardEventBuilder evt(event); 989 PlatformKeyboardEventBuilder evt(event);
972 990
973 if (frame->eventHandler().keyEvent(evt)) { 991 if (frame->eventHandler().keyEvent(evt)) {
974 if (WebInputEvent::RawKeyDown == event.type) { 992 if (WebInputEvent::RawKeyDown == event.type) {
975 // Suppress the next keypress event unless the focused node is a plu g-in node. 993 // Suppress the next keypress event unless the focused node is a plu g-in node.
976 // (Flash needs these keypress events to handle non-US keyboards.) 994 // (Flash needs these keypress events to handle non-US keyboards.)
977 Element* element = focusedElement(); 995 Element* element = focusedElement();
978 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 996 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
979 m_suppressNextKeypressEvent = true; 997 m_suppressNextKeypressEvent = true;
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 { 2039 {
2022 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 2040 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
2023 m_mouseCaptureNode = nullptr; 2041 m_mouseCaptureNode = nullptr;
2024 } 2042 }
2025 2043
2026 void WebViewImpl::setFocus(bool enable) 2044 void WebViewImpl::setFocus(bool enable)
2027 { 2045 {
2028 m_page->focusController().setFocused(enable); 2046 m_page->focusController().setFocused(enable);
2029 if (enable) { 2047 if (enable) {
2030 m_page->focusController().setActive(true); 2048 m_page->focusController().setActive(true);
2031 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2049 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2032 if (focusedFrame && focusedFrame->isLocalFrame()) { 2050 if (focusedFrame && focusedFrame->isLocalFrame()) {
2033 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); 2051 LocalFrame* localFrame = toLocalFrame(focusedFrame.get());
2034 Element* element = localFrame->document()->focusedElement(); 2052 Element* element = localFrame->document()->focusedElement();
2035 if (element && localFrame->selection().selection().isNone()) { 2053 if (element && localFrame->selection().selection().isNone()) {
2036 // If the selection was cleared while the WebView was not 2054 // If the selection was cleared while the WebView was not
2037 // focused, then the focus element shows with a focus ring but 2055 // focused, then the focus element shows with a focus ring but
2038 // no caret and does respond to keyboard inputs. 2056 // no caret and does respond to keyboard inputs.
2039 if (element->isTextFormControl()) { 2057 if (element->isTextFormControl()) {
2040 element->updateFocusAppearance(true); 2058 element->updateFocusAppearance(true);
2041 } else if (element->isContentEditable()) { 2059 } else if (element->isContentEditable()) {
(...skipping 12 matching lines...) Expand all
2054 2072
2055 // Clear focus on the currently focused frame if any. 2073 // Clear focus on the currently focused frame if any.
2056 if (!m_page) 2074 if (!m_page)
2057 return; 2075 return;
2058 2076
2059 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() 2077 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame()
2060 ? m_page->deprecatedLocalMainFrame() : 0; 2078 ? m_page->deprecatedLocalMainFrame() : 0;
2061 if (!frame) 2079 if (!frame)
2062 return; 2080 return;
2063 2081
2064 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2082 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2065 if (focusedFrame && focusedFrame->isLocalFrame()) { 2083 if (focusedFrame && focusedFrame->isLocalFrame()) {
2066 // Finish an ongoing composition to delete the composition node. 2084 // Finish an ongoing composition to delete the composition node.
2067 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { 2085 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) {
2068 if (m_autofillClient) 2086 if (m_autofillClient)
2069 m_autofillClient->setIgnoreTextChanges(true); 2087 m_autofillClient->setIgnoreTextChanges(true);
2070 2088
2071 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); 2089 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition();
2072 2090
2073 if (m_autofillClient) 2091 if (m_autofillClient)
2074 m_autofillClient->setIgnoreTextChanges(false); 2092 m_autofillClient->setIgnoreTextChanges(false);
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 Frame* frame = page()->focusController().focusedOrMainFrame(); 2683 Frame* frame = page()->focusController().focusedOrMainFrame();
2666 if (frame->isLocalFrame()) { 2684 if (frame->isLocalFrame()) {
2667 if (Document* document = toLocalFrame(frame)->document()) 2685 if (Document* document = toLocalFrame(frame)->document())
2668 document->setFocusedElement(nullptr); 2686 document->setFocusedElement(nullptr);
2669 } 2687 }
2670 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2688 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2671 } 2689 }
2672 2690
2673 void WebViewImpl::clearFocusedElement() 2691 void WebViewImpl::clearFocusedElement()
2674 { 2692 {
2675 RefPtr<Frame> frame = focusedCoreFrame(); 2693 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame();
2676 if (!frame || !frame->isLocalFrame()) 2694 if (!frame || !frame->isLocalFrame())
2677 return; 2695 return;
2678 2696
2679 LocalFrame* localFrame = toLocalFrame(frame.get()); 2697 LocalFrame* localFrame = toLocalFrame(frame.get());
2680 2698
2681 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2699 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2682 if (!document) 2700 if (!document)
2683 return; 2701 return;
2684 2702
2685 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2703 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4309 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4292 4310
4293 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4311 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4294 return false; 4312 return false;
4295 4313
4296 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4314 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4297 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4315 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4298 } 4316 }
4299 4317
4300 } // namespace blink 4318 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698