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

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: Add LocalFrame::detachView() + more Oilpan frame finalization comments 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Change the text zoom level by kTextSizeMultiplierRatio each time the user 205 // Change the text zoom level by kTextSizeMultiplierRatio each time the user
206 // zooms text in or out (ie., change by 20%). The min and max values limit 206 // zooms text in or out (ie., change by 20%). The min and max values limit
207 // text zoom to half and 3x the original text size. These three values match 207 // text zoom to half and 3x the original text size. These three values match
208 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm 208 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
209 const double WebView::textSizeMultiplierRatio = 1.2; 209 const double WebView::textSizeMultiplierRatio = 1.2;
210 const double WebView::minTextSizeMultiplier = 0.5; 210 const double WebView::minTextSizeMultiplier = 0.5;
211 const double WebView::maxTextSizeMultiplier = 3.0; 211 const double WebView::maxTextSizeMultiplier = 3.0;
212 212
213 // Used to defer all page activity in cases where the embedder wishes to run 213 // Used to defer all page activity in cases where the embedder wishes to run
214 // a nested event loop. Using a stack enables nesting of message loop invocation s. 214 // a nested event loop. Using a stack enables nesting of message loop invocation s.
215 static Vector<ScopedPageLoadDeferrer*>& pageLoadDeferrerStack() 215 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe ferrerStack()
216 { 216 {
217 DEFINE_STATIC_LOCAL(Vector<ScopedPageLoadDeferrer*>, deferrerStack, ()); 217 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ())));
218 return deferrerStack; 218 return *deferrerStack;
219 } 219 }
220 220
221 // Ensure that the WebDragOperation enum values stay in sync with the original 221 // Ensure that the WebDragOperation enum values stay in sync with the original
222 // DragOperation constants. 222 // DragOperation constants.
223 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \ 223 #define COMPILE_ASSERT_MATCHING_ENUM(coreName) \
224 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName) 224 COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName)
225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone); 225 COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone);
226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy); 226 COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy);
227 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink); 227 COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink);
228 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric); 228 COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 void WebView::willEnterModalLoop() 312 void WebView::willEnterModalLoop()
313 { 313 {
314 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer()); 314 pageLoadDeferrerStack().append(new ScopedPageLoadDeferrer());
315 } 315 }
316 316
317 void WebView::didExitModalLoop() 317 void WebView::didExitModalLoop()
318 { 318 {
319 ASSERT(pageLoadDeferrerStack().size()); 319 ASSERT(pageLoadDeferrerStack().size());
320 320
321 delete pageLoadDeferrerStack().last(); 321 ScopedPageLoadDeferrer* deferrer = pageLoadDeferrerStack().last();
322 #if ENABLE(OILPAN)
323 deferrer->dispose();
324 #else
325 delete deferrer;
326 #endif
322 pageLoadDeferrerStack().removeLast(); 327 pageLoadDeferrerStack().removeLast();
323 } 328 }
324 329
325 void WebViewImpl::setMainFrame(WebFrame* frame) 330 void WebViewImpl::setMainFrame(WebFrame* frame)
326 { 331 {
327 if (frame->isWebLocalFrame()) 332 if (frame->isWebLocalFrame()) {
333 #if ENABLE(OILPAN)
334 m_localMainFrame = toWebLocalFrameImpl(frame);
335 m_remoteMainFrame.clear();
336 #endif
328 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom); 337 toWebLocalFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0, nullAtom, nullAtom);
329 else 338 } else {
339 #if ENABLE(OILPAN)
340 m_localMainFrame.clear();
341 m_remoteMainFrame = toWebRemoteFrameImpl(frame);
342 #endif
330 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom); 343 toWebRemoteFrameImpl(frame)->initializeCoreFrame(&page()->frameHost(), 0 , nullAtom);
344 }
331 } 345 }
332 346
333 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient) 347 void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
334 { 348 {
335 m_autofillClient = autofillClient; 349 m_autofillClient = autofillClient;
336 } 350 }
337 351
338 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient) 352 void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCred entialManagerClient)
339 { 353 {
340 ASSERT(m_page); 354 ASSERT(m_page);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor); 463 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor);
450 setVisibilityState(m_client->visibilityState(), true); 464 setVisibilityState(m_client->visibilityState(), true);
451 } 465 }
452 466
453 initializeLayerTreeView(); 467 initializeLayerTreeView();
454 } 468 }
455 469
456 WebViewImpl::~WebViewImpl() 470 WebViewImpl::~WebViewImpl()
457 { 471 {
458 ASSERT(!m_page); 472 ASSERT(!m_page);
473 #if ENABLE(OILPAN)
474 // At most one Persistent main frame reference should be set.
475 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
476 #endif
459 } 477 }
460 478
479 #if ENABLE(OILPAN)
480 void WebViewImpl::clearMainFrame(WebLocalFrameImpl* frame)
481 {
482 ASSERT(frame && frame->frame() && frame->frame()->isMainFrame());
483 // At most one Persistent main frame reference should be set.
484 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
485
486 // Assume that non-current main frames may attempt to clear
487 // themselves, so check for equality.
488 if (m_localMainFrame.get() == frame)
489 m_localMainFrame.clear();
490 }
491
492 void WebViewImpl::clearMainFrame(WebRemoteFrameImpl* frame)
493 {
494 ASSERT(frame && frame->frame() && frame->frame()->isMainFrame());
495 // At most one Persistent main frame reference should be set.
496 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
497
498 // Assume that non-current main frames may attempt to clear
499 // themselves, so check for equality.
500 if (m_remoteMainFrame.get() == frame)
501 m_remoteMainFrame.clear();
502 }
503 #endif
504
461 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 505 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
462 { 506 {
463 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0; 507 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0;
464 } 508 }
465 509
466 bool WebViewImpl::tabKeyCyclesThroughElements() const 510 bool WebViewImpl::tabKeyCyclesThroughElements() const
467 { 511 {
468 ASSERT(m_page); 512 ASSERT(m_page);
469 return m_page->tabKeyCyclesThroughElements(); 513 return m_page->tabKeyCyclesThroughElements();
470 } 514 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 995 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
952 if (m_pagePopup) { 996 if (m_pagePopup) {
953 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 997 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
954 // We need to ignore the next Char event after this otherwise pressing 998 // We need to ignore the next Char event after this otherwise pressing
955 // enter when selecting an item in the popup will go to the page. 999 // enter when selecting an item in the popup will go to the page.
956 if (WebInputEvent::RawKeyDown == event.type) 1000 if (WebInputEvent::RawKeyDown == event.type)
957 m_suppressNextKeypressEvent = true; 1001 m_suppressNextKeypressEvent = true;
958 return true; 1002 return true;
959 } 1003 }
960 1004
961 RefPtr<Frame> focusedFrame = focusedCoreFrame(); 1005 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
962 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 1006 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
963 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 1007 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get()));
964 webFrame->client()->forwardInputEvent(&event); 1008 webFrame->client()->forwardInputEvent(&event);
965 return true; 1009 return true;
966 } 1010 }
967 1011
968 if (!focusedFrame || !focusedFrame->isLocalFrame()) 1012 if (!focusedFrame || !focusedFrame->isLocalFrame())
969 return false; 1013 return false;
970 1014
971 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 1015 LocalFrame* frame = toLocalFrame(focusedFrame.get());
972 1016
973 PlatformKeyboardEventBuilder evt(event); 1017 PlatformKeyboardEventBuilder evt(event);
974 1018
975 if (frame->eventHandler().keyEvent(evt)) { 1019 if (frame->eventHandler().keyEvent(evt)) {
976 if (WebInputEvent::RawKeyDown == event.type) { 1020 if (WebInputEvent::RawKeyDown == event.type) {
977 // Suppress the next keypress event unless the focused node is a plu g-in node. 1021 // Suppress the next keypress event unless the focused node is a plu g-in node.
978 // (Flash needs these keypress events to handle non-US keyboards.) 1022 // (Flash needs these keypress events to handle non-US keyboards.)
979 Element* element = focusedElement(); 1023 Element* element = focusedElement();
980 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 1024 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
981 m_suppressNextKeypressEvent = true; 1025 m_suppressNextKeypressEvent = true;
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 { 2066 {
2023 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 2067 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
2024 m_mouseCaptureNode = nullptr; 2068 m_mouseCaptureNode = nullptr;
2025 } 2069 }
2026 2070
2027 void WebViewImpl::setFocus(bool enable) 2071 void WebViewImpl::setFocus(bool enable)
2028 { 2072 {
2029 m_page->focusController().setFocused(enable); 2073 m_page->focusController().setFocused(enable);
2030 if (enable) { 2074 if (enable) {
2031 m_page->focusController().setActive(true); 2075 m_page->focusController().setActive(true);
2032 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2076 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2033 if (focusedFrame && focusedFrame->isLocalFrame()) { 2077 if (focusedFrame && focusedFrame->isLocalFrame()) {
2034 LocalFrame* localFrame = toLocalFrame(focusedFrame.get()); 2078 LocalFrame* localFrame = toLocalFrame(focusedFrame.get());
2035 Element* element = localFrame->document()->focusedElement(); 2079 Element* element = localFrame->document()->focusedElement();
2036 if (element && localFrame->selection().selection().isNone()) { 2080 if (element && localFrame->selection().selection().isNone()) {
2037 // If the selection was cleared while the WebView was not 2081 // If the selection was cleared while the WebView was not
2038 // focused, then the focus element shows with a focus ring but 2082 // focused, then the focus element shows with a focus ring but
2039 // no caret and does respond to keyboard inputs. 2083 // no caret and does respond to keyboard inputs.
2040 if (element->isTextFormControl()) { 2084 if (element->isTextFormControl()) {
2041 element->updateFocusAppearance(true); 2085 element->updateFocusAppearance(true);
2042 } else if (element->isContentEditable()) { 2086 } else if (element->isContentEditable()) {
(...skipping 12 matching lines...) Expand all
2055 2099
2056 // Clear focus on the currently focused frame if any. 2100 // Clear focus on the currently focused frame if any.
2057 if (!m_page) 2101 if (!m_page)
2058 return; 2102 return;
2059 2103
2060 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame() 2104 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF rame()
2061 ? m_page->deprecatedLocalMainFrame() : 0; 2105 ? m_page->deprecatedLocalMainFrame() : 0;
2062 if (!frame) 2106 if (!frame)
2063 return; 2107 return;
2064 2108
2065 RefPtr<Frame> focusedFrame = m_page->focusController().focusedFrame(); 2109 RefPtrWillBeRawPtr<Frame> focusedFrame = m_page->focusController().focus edFrame();
2066 if (focusedFrame && focusedFrame->isLocalFrame()) { 2110 if (focusedFrame && focusedFrame->isLocalFrame()) {
2067 // Finish an ongoing composition to delete the composition node. 2111 // Finish an ongoing composition to delete the composition node.
2068 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) { 2112 if (toLocalFrame(focusedFrame.get())->inputMethodController().hasCom position()) {
2069 if (m_autofillClient) 2113 if (m_autofillClient)
2070 m_autofillClient->setIgnoreTextChanges(true); 2114 m_autofillClient->setIgnoreTextChanges(true);
2071 2115
2072 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition(); 2116 toLocalFrame(focusedFrame.get())->inputMethodController().confir mComposition();
2073 2117
2074 if (m_autofillClient) 2118 if (m_autofillClient)
2075 m_autofillClient->setIgnoreTextChanges(false); 2119 m_autofillClient->setIgnoreTextChanges(false);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 Frame* frame = page()->focusController().focusedOrMainFrame(); 2718 Frame* frame = page()->focusController().focusedOrMainFrame();
2675 if (frame->isLocalFrame()) { 2719 if (frame->isLocalFrame()) {
2676 if (Document* document = toLocalFrame(frame)->document()) 2720 if (Document* document = toLocalFrame(frame)->document())
2677 document->setFocusedElement(nullptr); 2721 document->setFocusedElement(nullptr);
2678 } 2722 }
2679 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2723 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2680 } 2724 }
2681 2725
2682 void WebViewImpl::clearFocusedElement() 2726 void WebViewImpl::clearFocusedElement()
2683 { 2727 {
2684 RefPtr<Frame> frame = focusedCoreFrame(); 2728 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame();
2685 if (!frame || !frame->isLocalFrame()) 2729 if (!frame || !frame->isLocalFrame())
2686 return; 2730 return;
2687 2731
2688 LocalFrame* localFrame = toLocalFrame(frame.get()); 2732 LocalFrame* localFrame = toLocalFrame(frame.get());
2689 2733
2690 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2734 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2691 if (!document) 2735 if (!document)
2692 return; 2736 return;
2693 2737
2694 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2738 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4363 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4320 4364
4321 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4365 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4322 return false; 4366 return false;
4323 4367
4324 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4368 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4325 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4369 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4326 } 4370 }
4327 4371
4328 } // namespace blink 4372 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698