Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + | 921 String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + |
| 922 dialogMessage + "') during " + | 922 dialogMessage + "') during " + |
| 923 dismissalTypeToString(dismissalType) + "."; | 923 dismissalTypeToString(dismissalType) + "."; |
| 924 WebLocalFrameImpl::fromFrame(frame)->addMessageToConsole( | 924 WebLocalFrameImpl::fromFrame(frame)->addMessageToConsole( |
| 925 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 925 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
| 926 | 926 |
| 927 return false; | 927 return false; |
| 928 } | 928 } |
| 929 | 929 |
| 930 void ChromeClientImpl::setEventListenerProperties( | 930 void ChromeClientImpl::setEventListenerProperties( |
| 931 LocalFrame* frame, | |
| 931 WebEventListenerClass eventClass, | 932 WebEventListenerClass eventClass, |
| 932 WebEventListenerProperties properties) { | 933 WebEventListenerProperties properties) { |
| 933 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { | 934 // |frame| might be null if called via TreeScopeAdopter:: |
| 935 // moveNodeToNewDocument() and the new document has no frame attached. | |
| 936 // Since a document without a frame cannot attach one later, it is safe to | |
| 937 // exit early. | |
| 938 if (!frame) | |
| 939 return; | |
| 940 | |
| 941 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); | |
| 942 WebFrameWidgetBase* widget = webFrame->localRoot()->frameWidget(); | |
| 943 // The widget may be nullptr if the frame is provisional. | |
| 944 if (!widget) { | |
| 945 // If we hit a provisional frame, we expect it to be during initialization | |
| 946 // in which case the |properties| should be 'nothing'. | |
| 947 DCHECK(properties == WebEventListenerProperties::Nothing); | |
| 948 return; | |
| 949 } | |
| 950 | |
| 951 // This relies on widget always pointing to a WebFrameWidgetImpl when | |
| 952 // |frame| points to an OOPIF frame, i.e. |frame|'s mainFrame() is | |
| 953 // remote. | |
| 954 setEventListenerProperties(widget, eventClass, properties); | |
| 955 } | |
| 956 | |
| 957 void ChromeClientImpl::setEventListenerProperties( | |
| 958 WebFrameWidgetBase* widget, | |
| 959 WebEventListenerClass eventClass, | |
| 960 WebEventListenerProperties properties) { | |
| 961 DCHECK(widget); | |
|
dcheng
2017/01/16 11:05:41
In Blink, prefer to pass by mutable reference to i
wjmaclean
2017/01/17 18:23:28
Done.
| |
| 962 WebWidgetClient* client = widget->client(); | |
| 963 if (WebLayerTreeView* treeView = widget->getLayerTreeView()) { | |
| 934 treeView->setEventListenerProperties(eventClass, properties); | 964 treeView->setEventListenerProperties(eventClass, properties); |
| 935 if (eventClass == WebEventListenerClass::TouchStartOrMove) { | 965 if (eventClass == WebEventListenerClass::TouchStartOrMove) { |
| 936 m_webView->hasTouchEventHandlers( | 966 client->hasTouchEventHandlers( |
| 937 properties != WebEventListenerProperties::Nothing || | 967 properties != WebEventListenerProperties::Nothing || |
| 938 eventListenerProperties(WebEventListenerClass::TouchEndOrCancel) != | 968 eventListenerProperties(treeView, |
| 969 WebEventListenerClass::TouchEndOrCancel) != | |
| 939 WebEventListenerProperties::Nothing); | 970 WebEventListenerProperties::Nothing); |
| 940 } else if (eventClass == WebEventListenerClass::TouchEndOrCancel) { | 971 } else if (eventClass == WebEventListenerClass::TouchEndOrCancel) { |
| 941 m_webView->hasTouchEventHandlers( | 972 client->hasTouchEventHandlers( |
| 942 properties != WebEventListenerProperties::Nothing || | 973 properties != WebEventListenerProperties::Nothing || |
| 943 eventListenerProperties(WebEventListenerClass::TouchStartOrMove) != | 974 eventListenerProperties(treeView, |
| 975 WebEventListenerClass::TouchStartOrMove) != | |
| 944 WebEventListenerProperties::Nothing); | 976 WebEventListenerProperties::Nothing); |
| 945 } | 977 } |
| 946 } else { | 978 } else { |
| 947 m_webView->hasTouchEventHandlers(true); | 979 client->hasTouchEventHandlers(true); |
| 948 } | 980 } |
| 949 } | 981 } |
| 950 | 982 |
| 951 void ChromeClientImpl::beginLifecycleUpdates() { | 983 void ChromeClientImpl::beginLifecycleUpdates() { |
| 952 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { | 984 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { |
| 953 treeView->setDeferCommits(false); | 985 treeView->setDeferCommits(false); |
| 954 treeView->setNeedsBeginFrame(); | 986 treeView->setNeedsBeginFrame(); |
| 955 } | 987 } |
| 956 } | 988 } |
| 957 | 989 |
| 958 WebEventListenerProperties ChromeClientImpl::eventListenerProperties( | 990 WebEventListenerProperties ChromeClientImpl::eventListenerProperties( |
| 991 LocalFrame* frame, | |
| 959 WebEventListenerClass eventClass) const { | 992 WebEventListenerClass eventClass) const { |
| 960 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 993 if (!frame) |
| 994 return WebEventListenerProperties::Nothing; | |
| 995 | |
| 996 WebFrameWidgetBase* widget = | |
| 997 WebLocalFrameImpl::fromFrame(frame)->localRoot()->frameWidget(); | |
| 998 | |
| 999 if (!widget) | |
|
dcheng
2017/01/16 11:05:41
I guess this can also be called on provisional fra
wjmaclean
2017/01/17 18:23:27
I assume so ... we do see null widgets getting in
| |
| 1000 return WebEventListenerProperties::Nothing; | |
| 1001 return eventListenerProperties(widget->getLayerTreeView(), eventClass); | |
| 1002 } | |
| 1003 | |
| 1004 WebEventListenerProperties ChromeClientImpl::eventListenerProperties( | |
|
dcheng
2017/01/16 11:05:40
Would it make sense to fold this into eventListene
wjmaclean
2017/01/17 18:23:28
Done.
| |
| 1005 WebLayerTreeView* treeView, | |
| 1006 WebEventListenerClass eventClass) const { | |
| 1007 if (treeView) | |
| 961 return treeView->eventListenerProperties(eventClass); | 1008 return treeView->eventListenerProperties(eventClass); |
| 962 return WebEventListenerProperties::Nothing; | 1009 return WebEventListenerProperties::Nothing; |
| 963 } | 1010 } |
| 964 | 1011 |
| 965 void ChromeClientImpl::setHasScrollEventHandlers(bool hasEventHandlers) { | 1012 void ChromeClientImpl::setHasScrollEventHandlers(LocalFrame* frame, |
| 966 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 1013 bool hasEventHandlers) { |
| 967 treeView->setHaveScrollEventHandlers(hasEventHandlers); | 1014 // |frame| might be null if called via TreeScopeAdopter:: |
| 968 } | 1015 // moveNodeToNewDocument() and the new document has no frame attached. |
| 1016 // Since a document without a frame cannot attach one later, it is safe to | |
| 1017 // exit early. | |
| 1018 if (!frame) | |
| 1019 return; | |
| 969 | 1020 |
| 970 bool ChromeClientImpl::hasScrollEventHandlers() const { | 1021 WebFrameWidgetBase* widget = |
| 971 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 1022 WebLocalFrameImpl::fromFrame(frame)->localRoot()->frameWidget(); |
| 972 return treeView->haveScrollEventHandlers(); | 1023 // While a frame is shutting down, we may get called after the layerTreeView |
| 973 return false; | 1024 // is gone: in this case we always expect |hasEventHandlers| to be false. |
| 1025 DCHECK(!widget || widget->getLayerTreeView() || !hasEventHandlers); | |
| 1026 if (widget && widget->getLayerTreeView()) | |
| 1027 widget->getLayerTreeView()->setHaveScrollEventHandlers(hasEventHandlers); | |
| 974 } | 1028 } |
| 975 | 1029 |
| 976 void ChromeClientImpl::setTouchAction(TouchAction touchAction) { | 1030 void ChromeClientImpl::setTouchAction(TouchAction touchAction) { |
| 977 if (WebViewClient* client = m_webView->client()) | 1031 if (WebViewClient* client = m_webView->client()) |
| 978 client->setTouchAction(static_cast<WebTouchAction>(touchAction)); | 1032 client->setTouchAction(static_cast<WebTouchAction>(touchAction)); |
| 979 } | 1033 } |
| 980 | 1034 |
| 981 bool ChromeClientImpl::requestPointerLock(LocalFrame* frame) { | 1035 bool ChromeClientImpl::requestPointerLock(LocalFrame* frame) { |
| 982 LocalFrame* localRoot = frame->localFrameRoot(); | 1036 LocalFrame* localRoot = frame->localFrameRoot(); |
| 983 return WebLocalFrameImpl::fromFrame(localRoot) | 1037 return WebLocalFrameImpl::fromFrame(localRoot) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1157 PresentationController::provideTo(frame, client->presentationClient()); | 1211 PresentationController::provideTo(frame, client->presentationClient()); |
| 1158 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) { | 1212 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) { |
| 1159 provideAudioOutputDeviceClientTo(frame, | 1213 provideAudioOutputDeviceClientTo(frame, |
| 1160 new AudioOutputDeviceClientImpl(frame)); | 1214 new AudioOutputDeviceClientImpl(frame)); |
| 1161 } | 1215 } |
| 1162 if (RuntimeEnabledFeatures::installedAppEnabled()) | 1216 if (RuntimeEnabledFeatures::installedAppEnabled()) |
| 1163 InstalledAppController::provideTo(frame, client->installedAppClient()); | 1217 InstalledAppController::provideTo(frame, client->installedAppClient()); |
| 1164 } | 1218 } |
| 1165 | 1219 |
| 1166 } // namespace blink | 1220 } // namespace blink |
| OLD | NEW |