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

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 r181764 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 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 966 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
949 if (m_pagePopup) { 967 if (m_pagePopup) {
950 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 968 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
951 // We need to ignore the next Char event after this otherwise pressing 969 // We need to ignore the next Char event after this otherwise pressing
952 // enter when selecting an item in the popup will go to the page. 970 // enter when selecting an item in the popup will go to the page.
953 if (WebInputEvent::RawKeyDown == event.type) 971 if (WebInputEvent::RawKeyDown == event.type)
954 m_suppressNextKeypressEvent = true; 972 m_suppressNextKeypressEvent = true;
955 return true; 973 return true;
956 } 974 }
957 975
958 RefPtr<Frame> focusedFrame = focusedCoreFrame(); 976 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
959 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 977 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
960 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 978 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get()));
961 webFrame->client()->forwardInputEvent(&event); 979 webFrame->client()->forwardInputEvent(&event);
962 return true; 980 return true;
963 } 981 }
964 982
965 if (!focusedFrame || !focusedFrame->isLocalFrame()) 983 if (!focusedFrame || !focusedFrame->isLocalFrame())
966 return false; 984 return false;
967 985
968 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 986 LocalFrame* frame = toLocalFrame(focusedFrame.get());
969 987
970 PlatformKeyboardEventBuilder evt(event); 988 PlatformKeyboardEventBuilder evt(event);
971 989
972 if (frame->eventHandler().keyEvent(evt)) { 990 if (frame->eventHandler().keyEvent(evt)) {
973 if (WebInputEvent::RawKeyDown == event.type) { 991 if (WebInputEvent::RawKeyDown == event.type) {
974 // Suppress the next keypress event unless the focused node is a plu g-in node. 992 // Suppress the next keypress event unless the focused node is a plu g-in node.
975 // (Flash needs these keypress events to handle non-US keyboards.) 993 // (Flash needs these keypress events to handle non-US keyboards.)
976 Element* element = focusedElement(); 994 Element* element = focusedElement();
977 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 995 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
978 m_suppressNextKeypressEvent = true; 996 m_suppressNextKeypressEvent = true;
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 { 2038 {
2021 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 2039 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
2022 m_mouseCaptureNode = nullptr; 2040 m_mouseCaptureNode = nullptr;
2023 } 2041 }
2024 2042
2025 void WebViewImpl::setFocus(bool enable) 2043 void WebViewImpl::setFocus(bool enable)
2026 { 2044 {
2027 m_page->focusController().setFocused(enable); 2045 m_page->focusController().setFocused(enable);
2028 if (enable) { 2046 if (enable) {
2029 m_page->focusController().setActive(true); 2047 m_page->focusController().setActive(true);
2030 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2048 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2031 if (focusedFrame && focusedFrame->isLocalFrame()) { 2049 if (focusedFrame && focusedFrame->isLocalFrame()) {
2032 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); 2050 LocalFrame* localFrame = toLocalFrame(focusedFrame.get());
2033 Element* element = localFrame->document()->focusedElement(); 2051 Element* element = localFrame->document()->focusedElement();
2034 if (element && localFrame->selection().selection().isNone()) { 2052 if (element && localFrame->selection().selection().isNone()) {
2035 // If the selection was cleared while the WebView was not 2053 // If the selection was cleared while the WebView was not
2036 // focused, then the focus element shows with a focus ring but 2054 // focused, then the focus element shows with a focus ring but
2037 // no caret and does respond to keyboard inputs. 2055 // no caret and does respond to keyboard inputs.
2038 if (element->isTextFormControl()) { 2056 if (element->isTextFormControl()) {
2039 element->updateFocusAppearance(true); 2057 element->updateFocusAppearance(true);
2040 } else if (element->isContentEditable()) { 2058 } else if (element->isContentEditable()) {
(...skipping 12 matching lines...) Expand all
2053 2071
2054 // Clear focus on the currently focused frame if any. 2072 // Clear focus on the currently focused frame if any.
2055 if (!m_page) 2073 if (!m_page)
2056 return; 2074 return;
2057 2075
2058 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() 2076 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame()
2059 ? m_page->deprecatedLocalMainFrame() : 0; 2077 ? m_page->deprecatedLocalMainFrame() : 0;
2060 if (!frame) 2078 if (!frame)
2061 return; 2079 return;
2062 2080
2063 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2081 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2064 if (focusedFrame && focusedFrame->isLocalFrame()) { 2082 if (focusedFrame && focusedFrame->isLocalFrame()) {
2065 // Finish an ongoing composition to delete the composition node. 2083 // Finish an ongoing composition to delete the composition node.
2066 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { 2084 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) {
2067 if (m_autofillClient) 2085 if (m_autofillClient)
2068 m_autofillClient->setIgnoreTextChanges(true); 2086 m_autofillClient->setIgnoreTextChanges(true);
2069 2087
2070 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); 2088 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition();
2071 2089
2072 if (m_autofillClient) 2090 if (m_autofillClient)
2073 m_autofillClient->setIgnoreTextChanges(false); 2091 m_autofillClient->setIgnoreTextChanges(false);
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 Frame* frame = page()->focusController().focusedOrMainFrame(); 2682 Frame* frame = page()->focusController().focusedOrMainFrame();
2665 if (frame->isLocalFrame()) { 2683 if (frame->isLocalFrame()) {
2666 if (Document* document = toLocalFrame(frame)->document()) 2684 if (Document* document = toLocalFrame(frame)->document())
2667 document->setFocusedElement(nullptr); 2685 document->setFocusedElement(nullptr);
2668 } 2686 }
2669 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2687 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2670 } 2688 }
2671 2689
2672 void WebViewImpl::clearFocusedElement() 2690 void WebViewImpl::clearFocusedElement()
2673 { 2691 {
2674 RefPtr<Frame> frame = focusedCoreFrame(); 2692 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame();
2675 if (!frame || !frame->isLocalFrame()) 2693 if (!frame || !frame->isLocalFrame())
2676 return; 2694 return;
2677 2695
2678 LocalFrame* localFrame = toLocalFrame(frame.get()); 2696 LocalFrame* localFrame = toLocalFrame(frame.get());
2679 2697
2680 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2698 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2681 if (!document) 2699 if (!document)
2682 return; 2700 return;
2683 2701
2684 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2702 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4290 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4308 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4291 4309
4292 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4310 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4293 return false; 4311 return false;
4294 4312
4295 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4313 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4296 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4314 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4297 } 4315 }
4298 4316
4299 } // namespace blink 4317 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698