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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + | 922 String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + |
| 923 dialogMessage + "') during " + | 923 dialogMessage + "') during " + |
| 924 dismissalTypeToString(dismissalType) + "."; | 924 dismissalTypeToString(dismissalType) + "."; |
| 925 WebLocalFrameImpl::fromFrame(frame)->addMessageToConsole( | 925 WebLocalFrameImpl::fromFrame(frame)->addMessageToConsole( |
| 926 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 926 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
| 927 | 927 |
| 928 return false; | 928 return false; |
| 929 } | 929 } |
| 930 | 930 |
| 931 void ChromeClientImpl::setEventListenerProperties( | 931 void ChromeClientImpl::setEventListenerProperties( |
| 932 LocalFrame* frame, | |
| 932 WebEventListenerClass eventClass, | 933 WebEventListenerClass eventClass, |
| 933 WebEventListenerProperties properties) { | 934 WebEventListenerProperties properties) { |
| 934 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { | 935 // |frame| might be null if called via TreeScopeAdopter:: |
| 936 // moveNodeToNewDocument() and the new document has no frame attached. | |
| 937 // Since a document without a frame cannot attach one later, it is safe to | |
| 938 // exit early. | |
| 939 if (!frame) | |
| 940 return; | |
| 941 | |
| 942 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); | |
| 943 WebFrameWidgetBase* widget = webFrame->localRoot()->frameWidget(); | |
| 944 // The widget may be nullptr if the frame is provisional. | |
|
dcheng
2017/01/18 00:13:03
Please add a TODO(dcheng) referencing https://crbu
wjmaclean
2017/01/18 14:01:24
Done.
| |
| 945 if (!widget) { | |
| 946 // If we hit a provisional frame, we expect it to be during initialization | |
| 947 // in which case the |properties| should be 'nothing'. | |
| 948 DCHECK(properties == WebEventListenerProperties::Nothing); | |
| 949 return; | |
| 950 } | |
| 951 | |
| 952 // This relies on widget always pointing to a WebFrameWidgetImpl when | |
| 953 // |frame| points to an OOPIF frame, i.e. |frame|'s mainFrame() is | |
| 954 // remote. | |
| 955 setEventListenerProperties(*widget, eventClass, properties); | |
| 956 } | |
| 957 | |
| 958 void ChromeClientImpl::setEventListenerProperties( | |
|
dcheng
2017/01/18 00:13:03
Nit: either merge this into the previous function,
wjmaclean
2017/01/18 14:01:24
Done.
| |
| 959 WebFrameWidgetBase& widget, | |
| 960 WebEventListenerClass eventClass, | |
| 961 WebEventListenerProperties properties) { | |
| 962 WebWidgetClient* client = widget.client(); | |
| 963 if (WebLayerTreeView* treeView = widget.getLayerTreeView()) { | |
| 935 treeView->setEventListenerProperties(eventClass, properties); | 964 treeView->setEventListenerProperties(eventClass, properties); |
| 936 if (eventClass == WebEventListenerClass::TouchStartOrMove) { | 965 if (eventClass == WebEventListenerClass::TouchStartOrMove) { |
| 937 m_webView->hasTouchEventHandlers( | 966 client->hasTouchEventHandlers( |
| 938 properties != WebEventListenerProperties::Nothing || | 967 properties != WebEventListenerProperties::Nothing || |
| 939 eventListenerProperties(WebEventListenerClass::TouchEndOrCancel) != | 968 treeView->eventListenerProperties( |
| 969 WebEventListenerClass::TouchEndOrCancel) != | |
| 940 WebEventListenerProperties::Nothing); | 970 WebEventListenerProperties::Nothing); |
| 941 } else if (eventClass == WebEventListenerClass::TouchEndOrCancel) { | 971 } else if (eventClass == WebEventListenerClass::TouchEndOrCancel) { |
| 942 m_webView->hasTouchEventHandlers( | 972 client->hasTouchEventHandlers( |
| 943 properties != WebEventListenerProperties::Nothing || | 973 properties != WebEventListenerProperties::Nothing || |
| 944 eventListenerProperties(WebEventListenerClass::TouchStartOrMove) != | 974 treeView->eventListenerProperties( |
| 975 WebEventListenerClass::TouchStartOrMove) != | |
| 945 WebEventListenerProperties::Nothing); | 976 WebEventListenerProperties::Nothing); |
| 946 } | 977 } |
| 947 } else { | 978 } else { |
| 948 m_webView->hasTouchEventHandlers(true); | 979 client->hasTouchEventHandlers(true); |
| 949 } | 980 } |
| 950 } | 981 } |
| 951 | 982 |
| 952 void ChromeClientImpl::beginLifecycleUpdates() { | 983 void ChromeClientImpl::beginLifecycleUpdates() { |
| 953 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { | 984 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) { |
| 954 treeView->setDeferCommits(false); | 985 treeView->setDeferCommits(false); |
| 955 treeView->setNeedsBeginFrame(); | 986 treeView->setNeedsBeginFrame(); |
| 956 } | 987 } |
| 957 } | 988 } |
| 958 | 989 |
| 959 WebEventListenerProperties ChromeClientImpl::eventListenerProperties( | 990 WebEventListenerProperties ChromeClientImpl::eventListenerProperties( |
| 991 LocalFrame* frame, | |
| 960 WebEventListenerClass eventClass) const { | 992 WebEventListenerClass eventClass) const { |
| 961 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 993 if (!frame) |
| 962 return treeView->eventListenerProperties(eventClass); | 994 return WebEventListenerProperties::Nothing; |
| 963 return WebEventListenerProperties::Nothing; | 995 |
| 996 WebFrameWidgetBase* widget = | |
| 997 WebLocalFrameImpl::fromFrame(frame)->localRoot()->frameWidget(); | |
| 998 | |
| 999 if (!widget || !widget->getLayerTreeView()) | |
| 1000 return WebEventListenerProperties::Nothing; | |
| 1001 return widget->getLayerTreeView()->eventListenerProperties(eventClass); | |
| 964 } | 1002 } |
| 965 | 1003 |
| 966 void ChromeClientImpl::setHasScrollEventHandlers(bool hasEventHandlers) { | 1004 void ChromeClientImpl::setHasScrollEventHandlers(LocalFrame* frame, |
| 967 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 1005 bool hasEventHandlers) { |
| 968 treeView->setHaveScrollEventHandlers(hasEventHandlers); | 1006 // |frame| might be null if called via TreeScopeAdopter:: |
| 969 } | 1007 // moveNodeToNewDocument() and the new document has no frame attached. |
| 1008 // Since a document without a frame cannot attach one later, it is safe to | |
| 1009 // exit early. | |
| 1010 if (!frame) | |
| 1011 return; | |
| 970 | 1012 |
| 971 bool ChromeClientImpl::hasScrollEventHandlers() const { | 1013 WebFrameWidgetBase* widget = |
| 972 if (WebLayerTreeView* treeView = m_webView->layerTreeView()) | 1014 WebLocalFrameImpl::fromFrame(frame)->localRoot()->frameWidget(); |
| 973 return treeView->haveScrollEventHandlers(); | 1015 // While a frame is shutting down, we may get called after the layerTreeView |
| 974 return false; | 1016 // is gone: in this case we always expect |hasEventHandlers| to be false. |
| 1017 DCHECK(!widget || widget->getLayerTreeView() || !hasEventHandlers); | |
| 1018 if (widget && widget->getLayerTreeView()) | |
| 1019 widget->getLayerTreeView()->setHaveScrollEventHandlers(hasEventHandlers); | |
| 975 } | 1020 } |
| 976 | 1021 |
| 977 void ChromeClientImpl::setTouchAction(LocalFrame* frame, | 1022 void ChromeClientImpl::setTouchAction(LocalFrame* frame, |
| 978 TouchAction touchAction) { | 1023 TouchAction touchAction) { |
| 979 DCHECK(frame); | 1024 DCHECK(frame); |
| 980 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); | 1025 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(frame); |
| 981 WebFrameWidgetBase* widget = webFrame->localRoot()->frameWidget(); | 1026 WebFrameWidgetBase* widget = webFrame->localRoot()->frameWidget(); |
| 982 if (!widget) | 1027 if (!widget) |
| 983 return; | 1028 return; |
| 984 | 1029 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 PresentationController::provideTo(frame, client->presentationClient()); | 1211 PresentationController::provideTo(frame, client->presentationClient()); |
| 1167 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) { | 1212 if (RuntimeEnabledFeatures::audioOutputDevicesEnabled()) { |
| 1168 provideAudioOutputDeviceClientTo(frame, | 1213 provideAudioOutputDeviceClientTo(frame, |
| 1169 new AudioOutputDeviceClientImpl(frame)); | 1214 new AudioOutputDeviceClientImpl(frame)); |
| 1170 } | 1215 } |
| 1171 if (RuntimeEnabledFeatures::installedAppEnabled()) | 1216 if (RuntimeEnabledFeatures::installedAppEnabled()) |
| 1172 InstalledAppController::provideTo(frame, client->installedAppClient()); | 1217 InstalledAppController::provideTo(frame, client->installedAppClient()); |
| 1173 } | 1218 } |
| 1174 | 1219 |
| 1175 } // namespace blink | 1220 } // namespace blink |
| OLD | NEW |