| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 // TODO(kenrb): Popup coordination for out-of-process iframes needs to be | 1731 WebLocalFrameImpl* local_root) { |
| 1732 // added. Because of the early return here a select element | |
| 1733 // 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 // popups. | |
| 1736 // See https://crbug.com/566130 | |
| 1737 if (!MainFrameImpl()) | |
| 1738 return; | |
| 1739 DCHECK(!popup_mouse_wheel_event_listener_); | 1732 DCHECK(!popup_mouse_wheel_event_listener_); |
| 1740 Document* document = MainFrameImpl()->GetFrame()->GetDocument(); | 1733 Document* document = local_root->GetDocument(); |
| 1741 DCHECK(document); | 1734 DCHECK(document); |
| 1742 // We register an empty event listener, EmptyEventListener, so that mouse | 1735 // We register an empty event listener, EmptyEventListener, so that mouse |
| 1743 // wheel events get sent to the WebView. | 1736 // wheel events get sent to the WebView. |
| 1744 popup_mouse_wheel_event_listener_ = EmptyEventListener::Create(); | 1737 popup_mouse_wheel_event_listener_ = EmptyEventListener::Create(); |
| 1745 document->addEventListener(EventTypeNames::mousewheel, | 1738 document->addEventListener(EventTypeNames::mousewheel, |
| 1746 popup_mouse_wheel_event_listener_, false); | 1739 popup_mouse_wheel_event_listener_, false); |
| 1740 local_root_with_empty_mouse_wheel_listener_ = local_root; |
| 1747 } | 1741 } |
| 1748 | 1742 |
| 1749 void WebViewImpl::DisablePopupMouseWheelEventListener() { | 1743 void WebViewImpl::DisablePopupMouseWheelEventListener() { |
| 1750 // TODO(kenrb): Concerns the same as in enablePopupMouseWheelEventListener. | 1744 // TODO(kenrb): Concerns the same as in enablePopupMouseWheelEventListener. |
| 1751 // See https://crbug.com/566130 | 1745 // See https://crbug.com/566130 |
| 1752 if (!MainFrameImpl()) | |
| 1753 return; | |
| 1754 DCHECK(popup_mouse_wheel_event_listener_); | 1746 DCHECK(popup_mouse_wheel_event_listener_); |
| 1755 Document* document = MainFrameImpl()->GetFrame()->GetDocument(); | 1747 Document* document = |
| 1748 local_root_with_empty_mouse_wheel_listener_->GetDocument(); |
| 1756 DCHECK(document); | 1749 DCHECK(document); |
| 1757 // Document may have already removed the event listener, for instance, due | 1750 // Document may have already removed the event listener, for instance, due |
| 1758 // to a navigation, but remove it anyway. | 1751 // to a navigation, but remove it anyway. |
| 1759 document->removeEventListener(EventTypeNames::mousewheel, | 1752 document->removeEventListener(EventTypeNames::mousewheel, |
| 1760 popup_mouse_wheel_event_listener_.Release(), | 1753 popup_mouse_wheel_event_listener_.Release(), |
| 1761 false); | 1754 false); |
| 1755 local_root_with_empty_mouse_wheel_listener_ = nullptr; |
| 1762 } | 1756 } |
| 1763 | 1757 |
| 1764 LocalDOMWindow* WebViewImpl::PagePopupWindow() const { | 1758 LocalDOMWindow* WebViewImpl::PagePopupWindow() const { |
| 1765 return page_popup_ ? page_popup_->Window() : nullptr; | 1759 return page_popup_ ? page_popup_->Window() : nullptr; |
| 1766 } | 1760 } |
| 1767 | 1761 |
| 1768 Frame* WebViewImpl::FocusedCoreFrame() const { | 1762 Frame* WebViewImpl::FocusedCoreFrame() const { |
| 1769 return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr; | 1763 return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr; |
| 1770 } | 1764 } |
| 1771 | 1765 |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 if (!page_->MainFrame()) | 2478 if (!page_->MainFrame()) |
| 2485 return BaseBackgroundColor().Rgb(); | 2479 return BaseBackgroundColor().Rgb(); |
| 2486 if (!page_->MainFrame()->IsLocalFrame()) | 2480 if (!page_->MainFrame()->IsLocalFrame()) |
| 2487 return BaseBackgroundColor().Rgb(); | 2481 return BaseBackgroundColor().Rgb(); |
| 2488 FrameView* view = page_->DeprecatedLocalMainFrame()->View(); | 2482 FrameView* view = page_->DeprecatedLocalMainFrame()->View(); |
| 2489 if (!view) | 2483 if (!view) |
| 2490 return BaseBackgroundColor().Rgb(); | 2484 return BaseBackgroundColor().Rgb(); |
| 2491 return view->DocumentBackgroundColor().Rgb(); | 2485 return view->DocumentBackgroundColor().Rgb(); |
| 2492 } | 2486 } |
| 2493 | 2487 |
| 2494 WebPagePopup* WebViewImpl::GetPagePopup() const { | 2488 WebPagePopupImpl* WebViewImpl::GetPagePopup() const { |
| 2495 return page_popup_.Get(); | 2489 return page_popup_.Get(); |
| 2496 } | 2490 } |
| 2497 | 2491 |
| 2498 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | 2492 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
| 2499 // well. This code needs to be refactored (http://crbug.com/629721). | 2493 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2500 WebRange WebViewImpl::CaretOrSelectionRange() { | 2494 WebRange WebViewImpl::CaretOrSelectionRange() { |
| 2501 const LocalFrame* focused = FocusedLocalFrameInWidget(); | 2495 const LocalFrame* focused = FocusedLocalFrameInWidget(); |
| 2502 if (!focused) | 2496 if (!focused) |
| 2503 return WebRange(); | 2497 return WebRange(); |
| 2504 | 2498 |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4190 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) | 4184 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) |
| 4191 return nullptr; | 4185 return nullptr; |
| 4192 return focused_frame; | 4186 return focused_frame; |
| 4193 } | 4187 } |
| 4194 | 4188 |
| 4195 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { | 4189 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { |
| 4196 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; | 4190 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; |
| 4197 } | 4191 } |
| 4198 | 4192 |
| 4199 } // namespace blink | 4193 } // namespace blink |
| OLD | NEW |