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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2804813002: Hide popups when handling mouse down, mouse wheel, or gesture tap in a WebFrameWidget (Closed)
Patch Set: Fix a compile error (2) Created 3 years, 8 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 #include "web/PrerendererClientImpl.h" 167 #include "web/PrerendererClientImpl.h"
168 #include "web/ResizeViewportAnchor.h" 168 #include "web/ResizeViewportAnchor.h"
169 #include "web/RotationViewportAnchor.h" 169 #include "web/RotationViewportAnchor.h"
170 #include "web/SpeechRecognitionClientProxy.h" 170 #include "web/SpeechRecognitionClientProxy.h"
171 #include "web/StorageQuotaClientImpl.h" 171 #include "web/StorageQuotaClientImpl.h"
172 #include "web/ValidationMessageClientImpl.h" 172 #include "web/ValidationMessageClientImpl.h"
173 #include "web/WebDevToolsAgentImpl.h" 173 #include "web/WebDevToolsAgentImpl.h"
174 #include "web/WebInputEventConversion.h" 174 #include "web/WebInputEventConversion.h"
175 #include "web/WebInputMethodControllerImpl.h" 175 #include "web/WebInputMethodControllerImpl.h"
176 #include "web/WebLocalFrameImpl.h" 176 #include "web/WebLocalFrameImpl.h"
177 #include "web/WebPagePopupImpl.h"
178 #include "web/WebPluginContainerImpl.h" 177 #include "web/WebPluginContainerImpl.h"
179 #include "web/WebRemoteFrameImpl.h" 178 #include "web/WebRemoteFrameImpl.h"
180 #include "web/WebSettingsImpl.h" 179 #include "web/WebSettingsImpl.h"
181 180
182 #if USE(DEFAULT_RENDER_THEME) 181 #if USE(DEFAULT_RENDER_THEME)
183 #include "core/layout/LayoutThemeDefault.h" 182 #include "core/layout/LayoutThemeDefault.h"
184 #endif 183 #endif
185 184
186 // Get rid of WTF's pow define so we can use std::pow. 185 // Get rid of WTF's pow define so we can use std::pow.
187 #undef pow 186 #undef pow
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 1696
1698 WebWidget* popup_widget = client_->CreatePopupMenu(kWebPopupTypePage); 1697 WebWidget* popup_widget = client_->CreatePopupMenu(kWebPopupTypePage);
1699 // createPopupMenu returns nullptr if this renderer process is about to die. 1698 // createPopupMenu returns nullptr if this renderer process is about to die.
1700 if (!popup_widget) 1699 if (!popup_widget)
1701 return nullptr; 1700 return nullptr;
1702 page_popup_ = ToWebPagePopupImpl(popup_widget); 1701 page_popup_ = ToWebPagePopupImpl(popup_widget);
1703 if (!page_popup_->Initialize(this, client)) { 1702 if (!page_popup_->Initialize(this, client)) {
1704 page_popup_->ClosePopup(); 1703 page_popup_->ClosePopup();
1705 page_popup_ = nullptr; 1704 page_popup_ = nullptr;
1706 } 1705 }
1707 EnablePopupMouseWheelEventListener(); 1706 EnablePopupMouseWheelEventListener(WebLocalFrameImpl::FromFrame(
1707 client->OwnerElement().GetDocument().GetFrame()->LocalFrameRoot()));
1708 return page_popup_.Get(); 1708 return page_popup_.Get();
1709 } 1709 }
1710 1710
1711 void WebViewImpl::ClosePagePopup(PagePopup* popup) { 1711 void WebViewImpl::ClosePagePopup(PagePopup* popup) {
1712 DCHECK(popup); 1712 DCHECK(popup);
1713 WebPagePopupImpl* popup_impl = ToWebPagePopupImpl(popup); 1713 WebPagePopupImpl* popup_impl = ToWebPagePopupImpl(popup);
1714 DCHECK_EQ(page_popup_.Get(), popup_impl); 1714 DCHECK_EQ(page_popup_.Get(), popup_impl);
1715 if (page_popup_.Get() != popup_impl) 1715 if (page_popup_.Get() != popup_impl)
1716 return; 1716 return;
1717 page_popup_->ClosePopup(); 1717 page_popup_->ClosePopup();
1718 } 1718 }
1719 1719
1720 void WebViewImpl::CleanupPagePopup() { 1720 void WebViewImpl::CleanupPagePopup() {
1721 page_popup_ = nullptr; 1721 page_popup_ = nullptr;
1722 DisablePopupMouseWheelEventListener(); 1722 DisablePopupMouseWheelEventListener();
1723 } 1723 }
1724 1724
1725 void WebViewImpl::CancelPagePopup() { 1725 void WebViewImpl::CancelPagePopup() {
1726 if (page_popup_) 1726 if (page_popup_)
1727 page_popup_->Cancel(); 1727 page_popup_->Cancel();
1728 } 1728 }
1729 1729
1730 void WebViewImpl::EnablePopupMouseWheelEventListener() { 1730 void WebViewImpl::EnablePopupMouseWheelEventListener(
1731 WebLocalFrameImpl* local_root) {
1731 // TODO(kenrb): Popup coordination for out-of-process iframes needs to be 1732 // TODO(kenrb): Popup coordination for out-of-process iframes needs to be
kenrb 2017/04/18 19:25:53 I think this comment can be entirely removed. Ther
EhsanK 2017/04/20 15:23:09 Acknowledged.
1732 // added. Because of the early return here a select element 1733 // added. Because of the early return here a select element
1733 // popup can remain visible even when the element underneath it is 1734 // popup can remain visible even when the element underneath it is
1734 // scrolled to a new position. This is part of a larger set of issues with 1735 // scrolled to a new position. This is part of a larger set of issues with
1735 // popups. 1736 // popups.
1736 // See https://crbug.com/566130 1737 // See https://crbug.com/566130
1737 if (!MainFrameImpl())
1738 return;
1739 DCHECK(!popup_mouse_wheel_event_listener_); 1738 DCHECK(!popup_mouse_wheel_event_listener_);
1740 Document* document = MainFrameImpl()->GetFrame()->GetDocument(); 1739 Document* document = local_root->GetDocument();
1741 DCHECK(document); 1740 DCHECK(document);
1742 // We register an empty event listener, EmptyEventListener, so that mouse 1741 // We register an empty event listener, EmptyEventListener, so that mouse
1743 // wheel events get sent to the WebView. 1742 // wheel events get sent to the WebView.
1744 popup_mouse_wheel_event_listener_ = EmptyEventListener::Create(); 1743 popup_mouse_wheel_event_listener_ = EmptyEventListener::Create();
1745 document->addEventListener(EventTypeNames::mousewheel, 1744 document->addEventListener(EventTypeNames::mousewheel,
1746 popup_mouse_wheel_event_listener_, false); 1745 popup_mouse_wheel_event_listener_, false);
1746 local_root_with_empty_mouse_wheel_listener_ = local_root;
1747 } 1747 }
1748 1748
1749 void WebViewImpl::DisablePopupMouseWheelEventListener() { 1749 void WebViewImpl::DisablePopupMouseWheelEventListener() {
1750 // TODO(kenrb): Concerns the same as in enablePopupMouseWheelEventListener. 1750 // TODO(kenrb): Concerns the same as in enablePopupMouseWheelEventListener.
1751 // See https://crbug.com/566130 1751 // See https://crbug.com/566130
1752 if (!MainFrameImpl())
1753 return;
1754 DCHECK(popup_mouse_wheel_event_listener_); 1752 DCHECK(popup_mouse_wheel_event_listener_);
1755 Document* document = MainFrameImpl()->GetFrame()->GetDocument(); 1753 Document* document =
1754 local_root_with_empty_mouse_wheel_listener_->GetDocument();
1756 DCHECK(document); 1755 DCHECK(document);
1757 // Document may have already removed the event listener, for instance, due 1756 // Document may have already removed the event listener, for instance, due
1758 // to a navigation, but remove it anyway. 1757 // to a navigation, but remove it anyway.
1759 document->removeEventListener(EventTypeNames::mousewheel, 1758 document->removeEventListener(EventTypeNames::mousewheel,
1760 popup_mouse_wheel_event_listener_.Release(), 1759 popup_mouse_wheel_event_listener_.Release(),
1761 false); 1760 false);
1761 local_root_with_empty_mouse_wheel_listener_ = nullptr;
1762 } 1762 }
1763 1763
1764 LocalDOMWindow* WebViewImpl::PagePopupWindow() const { 1764 LocalDOMWindow* WebViewImpl::PagePopupWindow() const {
1765 return page_popup_ ? page_popup_->Window() : nullptr; 1765 return page_popup_ ? page_popup_->Window() : nullptr;
1766 } 1766 }
1767 1767
1768 Frame* WebViewImpl::FocusedCoreFrame() const { 1768 Frame* WebViewImpl::FocusedCoreFrame() const {
1769 return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr; 1769 return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr;
1770 } 1770 }
1771 1771
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 if (!page_->MainFrame()) 2484 if (!page_->MainFrame())
2485 return BaseBackgroundColor().Rgb(); 2485 return BaseBackgroundColor().Rgb();
2486 if (!page_->MainFrame()->IsLocalFrame()) 2486 if (!page_->MainFrame()->IsLocalFrame())
2487 return BaseBackgroundColor().Rgb(); 2487 return BaseBackgroundColor().Rgb();
2488 FrameView* view = page_->DeprecatedLocalMainFrame()->View(); 2488 FrameView* view = page_->DeprecatedLocalMainFrame()->View();
2489 if (!view) 2489 if (!view)
2490 return BaseBackgroundColor().Rgb(); 2490 return BaseBackgroundColor().Rgb();
2491 return view->DocumentBackgroundColor().Rgb(); 2491 return view->DocumentBackgroundColor().Rgb();
2492 } 2492 }
2493 2493
2494 WebPagePopup* WebViewImpl::GetPagePopup() const { 2494 WebPagePopupImpl* WebViewImpl::GetPagePopup() const {
2495 return page_popup_.Get(); 2495 return page_popup_.Get();
2496 } 2496 }
2497 2497
2498 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as 2498 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as
2499 // well. This code needs to be refactored (http://crbug.com/629721). 2499 // well. This code needs to be refactored (http://crbug.com/629721).
2500 WebRange WebViewImpl::CaretOrSelectionRange() { 2500 WebRange WebViewImpl::CaretOrSelectionRange() {
2501 const LocalFrame* focused = FocusedLocalFrameInWidget(); 2501 const LocalFrame* focused = FocusedLocalFrameInWidget();
2502 if (!focused) 2502 if (!focused)
2503 return WebRange(); 2503 return WebRange();
2504 2504
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) 4190 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame())
4191 return nullptr; 4191 return nullptr;
4192 return focused_frame; 4192 return focused_frame;
4193 } 4193 }
4194 4194
4195 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { 4195 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const {
4196 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; 4196 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr;
4197 } 4197 }
4198 4198
4199 } // namespace blink 4199 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698