Update ANGLE
[WebKit-https.git] / Source / WebKit / WebProcess / WebCoreSupport / WebChromeClient.h
1 /*
2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #pragma once
28
29 #include <WebCore/ChromeClient.h>
30
31 namespace WebCore {
32 class HTMLImageElement;
33 class RegistrableDomain;
34 enum class StorageAccessPromptWasShown : bool;
35 enum class StorageAccessWasGranted : bool;
36 }
37
38 namespace WebKit {
39
40 class WebFrame;
41 class WebPage;
42
43 class WebChromeClient final : public WebCore::ChromeClient {
44     WTF_MAKE_FAST_ALLOCATED;
45 public:
46     WebChromeClient(WebPage&);
47
48     WebPage& page() const { return m_page; }
49
50 private:
51     ~WebChromeClient();
52
53     void didInsertMenuElement(WebCore::HTMLMenuElement&);
54     void didRemoveMenuElement(WebCore::HTMLMenuElement&);
55     void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);
56     void didRemoveMenuItemElement(WebCore::HTMLMenuItemElement&);
57
58     void chromeDestroyed() final;
59     
60     void setWindowRect(const WebCore::FloatRect&) final;
61     WebCore::FloatRect windowRect() final;
62     
63     WebCore::FloatRect pageRect() final;
64     
65     void focus() final;
66     void unfocus() final;
67     
68     bool canTakeFocus(WebCore::FocusDirection) final;
69     void takeFocus(WebCore::FocusDirection) final;
70
71     void focusedElementChanged(WebCore::Element*) final;
72     void focusedFrameChanged(WebCore::Frame*) final;
73
74     // The Frame pointer provides the ChromeClient with context about which
75     // Frame wants to create the new Page.  Also, the newly created window
76     // should not be shown to the user until the ChromeClient of the newly
77     // created Page has its show method called.
78     WebCore::Page* createWindow(WebCore::Frame&, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&) final;
79     void show() final;
80     
81     bool canRunModal() final;
82     void runModal() final;
83
84     void reportProcessCPUTime(Seconds, WebCore::ActivityStateForCPUSampling) final;
85     
86     void setToolbarsVisible(bool) final;
87     bool toolbarsVisible() final;
88     
89     void setStatusbarVisible(bool) final;
90     bool statusbarVisible() final;
91     
92     void setScrollbarsVisible(bool) final;
93     bool scrollbarsVisible() final;
94     
95     void setMenubarVisible(bool) final;
96     bool menubarVisible() final;
97     
98     void setResizable(bool) final;
99     
100     void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final;
101     
102     bool canRunBeforeUnloadConfirmPanel() final;
103     bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final;
104     
105     void closeWindowSoon() final;
106     
107     void runJavaScriptAlert(WebCore::Frame&, const String&) final;
108     bool runJavaScriptConfirm(WebCore::Frame&, const String&) final;
109     bool runJavaScriptPrompt(WebCore::Frame&, const String& message, const String& defaultValue, String& result) final;
110     void setStatusbarText(const String&) final;
111
112     WebCore::KeyboardUIMode keyboardUIMode() final;
113
114     // HostWindow member function finals.
115     void invalidateRootView(const WebCore::IntRect&) final;
116     void invalidateContentsAndRootView(const WebCore::IntRect&) final;
117     void invalidateContentsForSlowScroll(const WebCore::IntRect&) final;
118     void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect) final;
119
120     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const final;
121     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const final;
122
123     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final;
124     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final;
125
126     void didFinishLoadingImageForElement(WebCore::HTMLImageElement&) final;
127
128     PlatformPageClient platformPageClient() const final;
129     void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final;
130     void intrinsicContentsSizeChanged(const WebCore::IntSize&) const final;
131     void scrollRectIntoView(const WebCore::IntRect&) const final; // Currently only Mac has a non empty implementation.
132
133     bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
134     void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
135
136     void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final;
137
138     void setToolTip(const String&, WebCore::TextDirection) final;
139     
140     void print(WebCore::Frame&) final;
141
142     void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final;
143
144     void reachedMaxAppCacheSize(int64_t spaceNeeded) final;
145     void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t spaceNeeded) final;
146     
147 #if ENABLE(INPUT_TYPE_COLOR)
148     std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final;
149 #endif
150
151 #if ENABLE(DATALIST_ELEMENT)
152     std::unique_ptr<WebCore::DataListSuggestionPicker> createDataListSuggestionPicker(WebCore::DataListSuggestionsClient&) final;
153 #endif
154
155 #if ENABLE(IOS_TOUCH_EVENTS)
156     void didPreventDefaultForEvent() final;
157 #endif
158
159 #if PLATFORM(IOS_FAMILY)
160     void didReceiveMobileDocType(bool) final;
161     void setNeedsScrollNotifications(WebCore::Frame&, bool) final;
162     void didFinishContentChangeObserving(WebCore::Frame&, WKContentChange) final;
163     void notifyRevealedSelectionByScrollingFrame(WebCore::Frame&) final;
164     bool isStopping() final;
165
166     void didLayout(LayoutType = NormalLayout) final;
167     void didStartOverflowScroll() final;
168     void didEndOverflowScroll() final;
169     bool hasStablePageScaleFactor() const final;
170
171     // FIXME: See <rdar://problem/5975559>
172     void suppressFormNotifications() final;
173     void restoreFormNotifications() final;
174
175     void addOrUpdateScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const WebCore::IntSize& scrollSize, bool allowHorizontalScrollbar, bool allowVerticalScrollbar) final;
176     void removeScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) final;
177
178     void webAppOrientationsUpdated() final;
179     void showPlaybackTargetPicker(bool hasVideo, WebCore::RouteSharingPolicy, const String&) final;
180
181     Seconds eventThrottlingDelay() final;
182
183     void associateEditableImageWithAttachment(WebCore::GraphicsLayer::EmbeddedViewID, const String& attachmentID) final;
184     void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
185     void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
186 #endif
187
188 #if ENABLE(ORIENTATION_EVENTS)
189     int deviceOrientation() const final;
190 #endif
191
192     void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) final;
193     void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) final;
194     void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final;
195
196 #if !PLATFORM(IOS_FAMILY)
197     void setCursor(const WebCore::Cursor&) final;
198     void setCursorHiddenUntilMouseMoves(bool) final;
199 #endif
200
201 #if ENABLE(POINTER_LOCK)
202     bool requestPointerLock() final;
203     void requestPointerUnlock() final;
204 #endif
205
206     void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&, WebCore::Frame&) final;
207     bool shouldNotifyOnFormChanges() final;
208
209     bool selectItemWritingDirectionIsNatural() final;
210     bool selectItemAlignmentFollowsMenuWritingDirection() final;
211     RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient&) const final;
212     RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient&) const final;
213
214     WebCore::GraphicsLayerFactory* graphicsLayerFactory() const final;
215     void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final;
216     void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) final;
217     void setNeedsOneShotDrawingSynchronization() final;
218     void scheduleCompositingLayerFlush() final;
219     bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) final;
220
221     void contentRuleListNotification(const URL&, const WebCore::ContentRuleListResults&) final;
222
223     bool testProcessIncomingSyncMessagesWhenWaitingForSyncReply() final;
224
225 #if PLATFORM(WIN)
226     void setLastSetCursorToCurrentCursor() final { }
227     void AXStartFrameLoad() final { }
228     void AXFinishFrameLoad() final { }
229 #endif
230
231 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
232     RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) const final;
233 #endif
234
235     CompositingTriggerFlags allowedCompositingTriggers() const final
236     {
237         return static_cast<CompositingTriggerFlags>(
238             ThreeDTransformTrigger |
239             VideoTrigger |
240             PluginTrigger|
241             CanvasTrigger |
242 #if PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
243             ScrollableNonMainFrameTrigger |
244 #endif
245 #if PLATFORM(IOS_FAMILY)
246             AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iPhone: <rdar://problem/7830677>
247 #endif
248             AnimationTrigger);
249     }
250
251     bool layerTreeStateIsFrozen() const final;
252     bool layerFlushThrottlingIsActive() const final;
253
254 #if ENABLE(ASYNC_SCROLLING)
255     RefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page&) const final;
256 #endif
257
258 #if (PLATFORM(IOS_FAMILY) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
259     bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
260     bool supportsVideoFullscreenStandby() final;
261     void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
262     void clearPlaybackControlsManager() final;
263     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
264     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
265 #endif
266
267 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
268     void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
269 #endif
270
271 #if ENABLE(FULLSCREEN_API)
272     bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final;
273     void enterFullScreenForElement(WebCore::Element&) final;
274     void exitFullScreenForElement(WebCore::Element*) final;
275 #endif
276
277 #if PLATFORM(COCOA)
278     void elementDidFocus(WebCore::Element&) final;
279     void elementDidBlur(WebCore::Element&) final;
280     void elementDidRefocus(WebCore::Element&) final;
281     void focusedElementDidChangeInputMode(WebCore::Element&, WebCore::InputMode) final;
282
283     void makeFirstResponder() final;
284     void assistiveTechnologyMakeFirstResponder() final;
285 #endif
286
287     void enableSuddenTermination() final;
288     void disableSuddenTermination() final;
289
290 #if PLATFORM(IOS_FAMILY)
291     WebCore::FloatSize screenSize() const final;
292     WebCore::FloatSize availableScreenSize() const final;
293     WebCore::FloatSize overrideScreenSize() const final;
294 #endif
295
296     void dispatchDisabledAdaptationsDidChange(const OptionSet<WebCore::DisabledAdaptations>&) const final;
297     void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final;
298
299     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) final;
300     void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) final;
301
302     Optional<WebCore::ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() final;
303
304     WebCore::Color underlayColor() const final;
305
306     void pageExtendedBackgroundColorDidChange(WebCore::Color) const final;
307     
308     void wheelEventHandlersChanged(bool) final;
309
310     String plugInStartLabelTitle(const String& mimeType) const final;
311     String plugInStartLabelSubtitle(const String& mimeType) const final;
312     String plugInExtraStyleSheet() const final;
313     String plugInExtraScript() const final;
314
315     void didAddHeaderLayer(WebCore::GraphicsLayer&) final;
316     void didAddFooterLayer(WebCore::GraphicsLayer&) final;
317
318     bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const final;
319
320     void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final;
321     void handleAutoplayEvent(WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
322
323 #if ENABLE(MEDIA_SESSION)
324     void hasMediaSessionWithActiveMediaElementsDidChange(bool) final;
325     void mediaSessionMetadataDidChange(const WebCore::MediaSessionMetadata&) final;
326     void focusedContentMediaElementDidChange(uint64_t) final;
327 #endif
328
329 #if ENABLE(WEB_CRYPTO)
330     bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
331     bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
332 #endif
333
334     String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final;
335
336 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
337     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&) final;
338 #endif
339
340 #if ENABLE(SERVICE_CONTROLS)
341     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
342     bool hasRelevantSelectionServices(bool isTextOnly) const final;
343 #endif
344
345     bool shouldDispatchFakeMouseMoveEvents() const final;
346
347     void handleAutoFillButtonClick(WebCore::HTMLInputElement&) final;
348
349     void inputElementDidResignStrongPasswordAppearance(WebCore::HTMLInputElement&) final;
350
351 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
352     void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final;
353     void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final;
354     void showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint&, bool) final;
355     void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) final;
356     void setMockMediaPlaybackTargetPickerEnabled(bool) final;
357     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
358 #endif
359
360     void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
361
362     RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final;
363
364 #if ENABLE(VIDEO) && USE(GSTREAMER)
365     void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) final;
366 #endif
367
368     void didInvalidateDocumentMarkerRects() final;
369
370 #if ENABLE(RESOURCE_LOAD_STATISTICS)
371     void hasStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, WebCore::Frame&, WTF::CompletionHandler<void(bool)>&&) final;
372     void requestStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, WebCore::Frame&, WTF::CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&) final;
373 #endif
374
375 #if ENABLE(DEVICE_ORIENTATION)
376     void shouldAllowDeviceOrientationAndMotionAccess(WebCore::Frame&, bool mayPrompt, CompletionHandler<void(WebCore::DeviceOrientationOrMotionPermissionState)>&&) final;
377 #endif
378
379     void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel) final;
380
381     bool userIsInteracting() const final;
382     void setUserIsInteracting(bool) final;
383
384     String m_cachedToolTip;
385     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
386     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
387     mutable bool m_cachedMainFrameHasVerticalScrollbar { false };
388
389     WebPage& m_page;
390 };
391
392 } // namespace WebKit