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

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: Comments + fix fast/events/message-port-gc-closed.html 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 main frame reference should be set.
474 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
475 #endif
458 } 476 }
459 477
478 #if ENABLE(OILPAN)
479 void WebViewImpl::clearMainFrame(WebLocalFrameImpl* frame)
480 {
481 ASSERT(frame && frame->frame() && frame->frame()->isMainFrame());
482 // At most one Persistent main frame reference should be set.
483 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
484
485 // Assume that non-current main frames may attempt to clear
486 // themselves, so check for equality.
487 if (m_localMainFrame.get() == frame)
488 m_localMainFrame.clear();
489 }
490
491 void WebViewImpl::clearMainFrame(WebRemoteFrameImpl* frame)
492 {
493 ASSERT(frame && frame->frame() && frame->frame()->isMainFrame());
494 // At most one Persistent main frame reference should be set.
495 ASSERT(!(m_localMainFrame && m_remoteMainFrame));
496
497 // Assume that non-current main frames may attempt to clear
498 // themselves, so check for equality.
499 if (m_remoteMainFrame.get() == frame)
500 m_remoteMainFrame.clear();
501 }
502 #endif
503
460 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 504 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
461 { 505 {
462 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0; 506 return m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0;
463 } 507 }
464 508
465 bool WebViewImpl::tabKeyCyclesThroughElements() const 509 bool WebViewImpl::tabKeyCyclesThroughElements() const
466 { 510 {
467 ASSERT(m_page); 511 ASSERT(m_page);
468 return m_page->tabKeyCyclesThroughElements(); 512 return m_page->tabKeyCyclesThroughElements();
469 } 513 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) ); 994 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
951 if (m_pagePopup) { 995 if (m_pagePopup) {
952 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 996 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
953 // We need to ignore the next Char event after this otherwise pressing 997 // 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. 998 // enter when selecting an item in the popup will go to the page.
955 if (WebInputEvent::RawKeyDown == event.type) 999 if (WebInputEvent::RawKeyDown == event.type)
956 m_suppressNextKeypressEvent = true; 1000 m_suppressNextKeypressEvent = true;
957 return true; 1001 return true;
958 } 1002 }
959 1003
960 RefPtr<Frame> focusedFrame = focusedCoreFrame(); 1004 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
961 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) { 1005 if (focusedFrame && focusedFrame->isRemoteFrameTemporary()) {
962 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get())); 1006 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameT emporary(focusedFrame.get()));
963 webFrame->client()->forwardInputEvent(&event); 1007 webFrame->client()->forwardInputEvent(&event);
964 return true; 1008 return true;
965 } 1009 }
966 1010
967 if (!focusedFrame || !focusedFrame->isLocalFrame()) 1011 if (!focusedFrame || !focusedFrame->isLocalFrame())
968 return false; 1012 return false;
969 1013
970 RefPtr<LocalFrame> frame = toLocalFrame(focusedFrame.get()); 1014 LocalFrame* frame = toLocalFrame(focusedFrame.get());
971 1015
972 PlatformKeyboardEventBuilder evt(event); 1016 PlatformKeyboardEventBuilder evt(event);
973 1017
974 if (frame->eventHandler().keyEvent(evt)) { 1018 if (frame->eventHandler().keyEvent(evt)) {
975 if (WebInputEvent::RawKeyDown == event.type) { 1019 if (WebInputEvent::RawKeyDown == event.type) {
976 // Suppress the next keypress event unless the focused node is a plu g-in node. 1020 // 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.) 1021 // (Flash needs these keypress events to handle non-US keyboards.)
978 Element* element = focusedElement(); 1022 Element* element = focusedElement();
979 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject()) 1023 if (!element || !element->renderer() || !element->renderer()->isEmbe ddedObject())
980 m_suppressNextKeypressEvent = true; 1024 m_suppressNextKeypressEvent = true;
(...skipping 1041 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 Frame* frame = page()->focusController().focusedOrMainFrame(); 2713 Frame* frame = page()->focusController().focusedOrMainFrame();
2670 if (frame->isLocalFrame()) { 2714 if (frame->isLocalFrame()) {
2671 if (Document* document = toLocalFrame(frame)->document()) 2715 if (Document* document = toLocalFrame(frame)->document())
2672 document->setFocusedElement(nullptr); 2716 document->setFocusedElement(nullptr);
2673 } 2717 }
2674 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward); 2718 page()->focusController().setInitialFocus(reverse ? FocusTypeBackward : Focu sTypeForward);
2675 } 2719 }
2676 2720
2677 void WebViewImpl::clearFocusedElement() 2721 void WebViewImpl::clearFocusedElement()
2678 { 2722 {
2679 RefPtr<Frame> frame = focusedCoreFrame(); 2723 RefPtrWillBeRawPtr<Frame> frame = focusedCoreFrame();
2680 if (!frame || !frame->isLocalFrame()) 2724 if (!frame || !frame->isLocalFrame())
2681 return; 2725 return;
2682 2726
2683 LocalFrame* localFrame = toLocalFrame(frame.get()); 2727 LocalFrame* localFrame = toLocalFrame(frame.get());
2684 2728
2685 RefPtrWillBeRawPtr<Document> document = localFrame->document(); 2729 RefPtrWillBeRawPtr<Document> document = localFrame->document();
2686 if (!document) 2730 if (!document)
2687 return; 2731 return;
2688 2732
2689 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement(); 2733 RefPtrWillBeRawPtr<Element> oldFocusedElement = document->focusedElement();
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
4315 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4359 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4316 4360
4317 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4361 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4318 return false; 4362 return false;
4319 4363
4320 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4364 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4321 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4365 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4322 } 4366 }
4323 4367
4324 } // namespace blink 4368 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698