Regression (r244291): Broken API Test AutoLayoutRenderingProgressRelativeOrdering
[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 WebKit {
32
33 class WebFrame;
34 class WebPage;
35
36 class WebChromeClient final : public WebCore::ChromeClient {
37 public:
38     WebChromeClient(WebPage&);
39
40     WebPage& page() const { return m_page; }
41
42 private:
43     ~WebChromeClient();
44
45     void didInsertMenuElement(WebCore::HTMLMenuElement&);
46     void didRemoveMenuElement(WebCore::HTMLMenuElement&);
47     void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);
48     void didRemoveMenuItemElement(WebCore::HTMLMenuItemElement&);
49
50     void chromeDestroyed() final;
51     
52     void setWindowRect(const WebCore::FloatRect&) final;
53     WebCore::FloatRect windowRect() final;
54     
55     WebCore::FloatRect pageRect() final;
56     
57     void focus() final;
58     void unfocus() final;
59     
60     bool canTakeFocus(WebCore::FocusDirection) final;
61     void takeFocus(WebCore::FocusDirection) final;
62
63     void focusedElementChanged(WebCore::Element*) final;
64     void focusedFrameChanged(WebCore::Frame*) final;
65
66     // The Frame pointer provides the ChromeClient with context about which
67     // Frame wants to create the new Page.  Also, the newly created window
68     // should not be shown to the user until the ChromeClient of the newly
69     // created Page has its show method called.
70     WebCore::Page* createWindow(WebCore::Frame&, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&) final;
71     void show() final;
72     
73     bool canRunModal() final;
74     void runModal() final;
75
76     void reportProcessCPUTime(Seconds, WebCore::ActivityStateForCPUSampling) final;
77     
78     void setToolbarsVisible(bool) final;
79     bool toolbarsVisible() final;
80     
81     void setStatusbarVisible(bool) final;
82     bool statusbarVisible() final;
83     
84     void setScrollbarsVisible(bool) final;
85     bool scrollbarsVisible() final;
86     
87     void setMenubarVisible(bool) final;
88     bool menubarVisible() final;
89     
90     void setResizable(bool) final;
91     
92     void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final;
93     
94     bool canRunBeforeUnloadConfirmPanel() final;
95     bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final;
96     
97     void closeWindowSoon() final;
98     
99     void runJavaScriptAlert(WebCore::Frame&, const String&) final;
100     bool runJavaScriptConfirm(WebCore::Frame&, const String&) final;
101     bool runJavaScriptPrompt(WebCore::Frame&, const String& message, const String& defaultValue, String& result) final;
102     void setStatusbarText(const String&) final;
103
104     WebCore::KeyboardUIMode keyboardUIMode() final;
105
106     // HostWindow member function finals.
107     void invalidateRootView(const WebCore::IntRect&) final;
108     void invalidateContentsAndRootView(const WebCore::IntRect&) final;
109     void invalidateContentsForSlowScroll(const WebCore::IntRect&) final;
110     void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect) final;
111
112     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const final;
113     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const final;
114
115     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final;
116     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final;
117
118     PlatformPageClient platformPageClient() const final;
119     void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final;
120     void intrinsicContentsSizeChanged(const WebCore::IntSize&) const final;
121     void scrollRectIntoView(const WebCore::IntRect&) const final; // Currently only Mac has a non empty implementation.
122
123     bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
124     void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
125
126     void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final;
127
128     void setToolTip(const String&, WebCore::TextDirection) final;
129     
130     void print(WebCore::Frame&) final;
131
132     void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final;
133
134     void reachedMaxAppCacheSize(int64_t spaceNeeded) final;
135     void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t spaceNeeded) final;
136
137 #if ENABLE(DASHBOARD_SUPPORT)
138     void annotatedRegionsChanged() final;
139 #endif
140
141     bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) final;
142     String generateReplacementFile(const String& path) final;
143     
144 #if ENABLE(INPUT_TYPE_COLOR)
145     std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final;
146 #endif
147
148 #if ENABLE(DATALIST_ELEMENT)
149     std::unique_ptr<WebCore::DataListSuggestionPicker> createDataListSuggestionPicker(WebCore::DataListSuggestionsClient&) final;
150 #endif
151
152 #if ENABLE(IOS_TOUCH_EVENTS)
153     void didPreventDefaultForEvent() final;
154 #endif
155
156 #if PLATFORM(IOS_FAMILY)
157     void didReceiveMobileDocType(bool) final;
158     void setNeedsScrollNotifications(WebCore::Frame&, bool) final;
159     void observedContentChange(WebCore::Frame&) final;
160     void notifyRevealedSelectionByScrollingFrame(WebCore::Frame&) final;
161     bool isStopping() final;
162
163     void didLayout(LayoutType = NormalLayout) final;
164     void didStartOverflowScroll() final;
165     void didEndOverflowScroll() final;
166     bool hasStablePageScaleFactor() const final;
167
168     // FIXME: See <rdar://problem/5975559>
169     void suppressFormNotifications() final;
170     void restoreFormNotifications() final;
171
172     void addOrUpdateScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const WebCore::IntSize& scrollSize, bool allowHorizontalScrollbar, bool allowVerticalScrollbar) final;
173     void removeScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) final;
174
175     void webAppOrientationsUpdated() final;
176     void showPlaybackTargetPicker(bool hasVideo, WebCore::RouteSharingPolicy, const String&) final;
177
178     Seconds eventThrottlingDelay() final;
179
180     void associateEditableImageWithAttachment(WebCore::GraphicsLayer::EmbeddedViewID, const String& attachmentID) final;
181     void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
182     void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final;
183 #endif
184
185 #if ENABLE(ORIENTATION_EVENTS)
186     int deviceOrientation() const final;
187 #endif
188
189     void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) final;
190     void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) final;
191     void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final;
192
193 #if !PLATFORM(IOS_FAMILY)
194     void setCursor(const WebCore::Cursor&) final;
195     void setCursorHiddenUntilMouseMoves(bool) final;
196 #endif
197
198 #if ENABLE(POINTER_LOCK)
199     bool requestPointerLock() final;
200     void requestPointerUnlock() final;
201 #endif
202
203     void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) final;
204     bool shouldNotifyOnFormChanges() final;
205
206     bool selectItemWritingDirectionIsNatural() final;
207     bool selectItemAlignmentFollowsMenuWritingDirection() final;
208     RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient&) const final;
209     RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient&) const final;
210
211     WebCore::GraphicsLayerFactory* graphicsLayerFactory() const final;
212     void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final;
213     void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) final;
214     void setNeedsOneShotDrawingSynchronization() final;
215     void scheduleCompositingLayerFlush() final;
216     bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) final;
217
218     void contentRuleListNotification(const URL&, const WebCore::ContentRuleListResults&) final;
219
220 #if PLATFORM(WIN)
221     void setLastSetCursorToCurrentCursor() final { }
222     void AXStartFrameLoad() final { }
223     void AXFinishFrameLoad() final { }
224 #endif
225
226 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
227     RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) const final;
228 #endif
229
230     CompositingTriggerFlags allowedCompositingTriggers() const final
231     {
232         return static_cast<CompositingTriggerFlags>(
233             ThreeDTransformTrigger |
234             VideoTrigger |
235             PluginTrigger|
236             CanvasTrigger |
237 #if PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
238             ScrollableNonMainFrameTrigger |
239 #endif
240 #if PLATFORM(IOS_FAMILY)
241             AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iPhone: <rdar://problem/7830677>
242 #endif
243             AnimationTrigger);
244     }
245
246     bool layerTreeStateIsFrozen() const final;
247     bool layerFlushThrottlingIsActive() const final;
248
249 #if ENABLE(ASYNC_SCROLLING)
250     RefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page&) const final;
251 #endif
252
253 #if (PLATFORM(IOS_FAMILY) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
254     bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
255     bool supportsVideoFullscreenStandby() final;
256     void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
257     void clearPlaybackControlsManager() final;
258     void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final;
259     void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
260 #endif
261
262 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
263     void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
264 #endif
265
266 #if ENABLE(FULLSCREEN_API)
267     bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final;
268     void enterFullScreenForElement(WebCore::Element&) final;
269     void exitFullScreenForElement(WebCore::Element*) final;
270 #endif
271
272 #if PLATFORM(COCOA)
273     void elementDidFocus(WebCore::Element&) final;
274     void elementDidBlur(WebCore::Element&) final;
275     void elementDidRefocus(WebCore::Element&) final;
276     void focusedElementDidChangeInputMode(WebCore::Element&, WebCore::InputMode) final;
277
278     void makeFirstResponder() final;
279     void assistiveTechnologyMakeFirstResponder() final;
280 #endif
281
282     void enableSuddenTermination() final;
283     void disableSuddenTermination() final;
284
285 #if PLATFORM(IOS_FAMILY)
286     WebCore::FloatSize screenSize() const final;
287     WebCore::FloatSize availableScreenSize() const final;
288     WebCore::FloatSize overrideScreenSize() const final;
289 #endif
290
291     void dispatchDisabledAdaptationsDidChange(const OptionSet<WebCore::DisabledAdaptations>&) const final;
292     void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final;
293
294     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) final;
295     void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) final;
296
297     Optional<WebCore::ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() final;
298
299     WebCore::Color underlayColor() const final;
300
301     void pageExtendedBackgroundColorDidChange(WebCore::Color) const final;
302     
303     void wheelEventHandlersChanged(bool) final;
304
305     String plugInStartLabelTitle(const String& mimeType) const final;
306     String plugInStartLabelSubtitle(const String& mimeType) const final;
307     String plugInExtraStyleSheet() const final;
308     String plugInExtraScript() const final;
309
310     void didAddHeaderLayer(WebCore::GraphicsLayer&) final;
311     void didAddFooterLayer(WebCore::GraphicsLayer&) final;
312
313     bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const final;
314
315     void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final;
316     void handleAutoplayEvent(WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
317
318 #if ENABLE(MEDIA_SESSION)
319     void hasMediaSessionWithActiveMediaElementsDidChange(bool) final;
320     void mediaSessionMetadataDidChange(const WebCore::MediaSessionMetadata&) final;
321     void focusedContentMediaElementDidChange(uint64_t) final;
322 #endif
323
324 #if ENABLE(WEB_CRYPTO)
325     bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
326     bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
327 #endif
328
329     String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final;
330
331 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
332     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&) final;
333 #endif
334
335 #if ENABLE(SERVICE_CONTROLS)
336     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
337     bool hasRelevantSelectionServices(bool isTextOnly) const final;
338 #endif
339
340     bool shouldDispatchFakeMouseMoveEvents() const final;
341
342     void handleAutoFillButtonClick(WebCore::HTMLInputElement&) final;
343
344     void inputElementDidResignStrongPasswordAppearance(WebCore::HTMLInputElement&) final;
345
346 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
347     void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final;
348     void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final;
349     void showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint&, bool) final;
350     void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) final;
351     void setMockMediaPlaybackTargetPickerEnabled(bool) final;
352     void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
353 #endif
354
355     void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
356
357     RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final;
358
359 #if ENABLE(VIDEO) && USE(GSTREAMER)
360     void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) final;
361 #endif
362
363     void didInvalidateDocumentMarkerRects() final;
364
365 #if ENABLE(RESOURCE_LOAD_STATISTICS)
366     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
367     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
368 #endif
369
370 #if ENABLE(DEVICE_ORIENTATION)
371     void shouldAllowDeviceOrientationAndMotionAccess(WebCore::Frame&, bool mayPrompt, CompletionHandler<void(WebCore::DeviceOrientationOrMotionPermissionState)>&&) final;
372 #endif
373
374     void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel) final;
375
376     String m_cachedToolTip;
377     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
378     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
379     mutable bool m_cachedMainFrameHasVerticalScrollbar { false };
380
381     WebPage& m_page;
382 };
383
384 } // namespace WebKit