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

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

Powered by Google App Engine
This is Rietveld 408576698