2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
29 #include <WebCore/ChromeClient.h>
36 class WebChromeClient final : public WebCore::ChromeClient {
38 WebChromeClient(WebPage&);
40 WebPage& page() const { return m_page; }
45 void didInsertMenuElement(WebCore::HTMLMenuElement&);
46 void didRemoveMenuElement(WebCore::HTMLMenuElement&);
47 void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);
48 void didRemoveMenuItemElement(WebCore::HTMLMenuItemElement&);
50 void chromeDestroyed() final;
52 void setWindowRect(const WebCore::FloatRect&) final;
53 WebCore::FloatRect windowRect() final;
55 WebCore::FloatRect pageRect() final;
60 bool canTakeFocus(WebCore::FocusDirection) final;
61 void takeFocus(WebCore::FocusDirection) final;
63 void focusedElementChanged(WebCore::Element*) final;
64 void focusedFrameChanged(WebCore::Frame*) final;
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;
73 bool canRunModal() final;
74 void runModal() final;
76 void reportProcessCPUTime(Seconds, WebCore::ActivityStateForCPUSampling) final;
78 void setToolbarsVisible(bool) final;
79 bool toolbarsVisible() final;
81 void setStatusbarVisible(bool) final;
82 bool statusbarVisible() final;
84 void setScrollbarsVisible(bool) final;
85 bool scrollbarsVisible() final;
87 void setMenubarVisible(bool) final;
88 bool menubarVisible() final;
90 void setResizable(bool) final;
92 void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final;
94 bool canRunBeforeUnloadConfirmPanel() final;
95 bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final;
97 void closeWindowSoon() final;
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;
104 WebCore::KeyboardUIMode keyboardUIMode() final;
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;
112 #if USE(COORDINATED_GRAPHICS)
113 void delegatedScrollRequested(const WebCore::IntPoint& scrollOffset) final;
114 void resetUpdateAtlasForTesting() final;
117 WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const final;
118 WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const final;
121 WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final;
122 WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final;
125 PlatformPageClient platformPageClient() const final;
126 void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final;
127 void scrollRectIntoView(const WebCore::IntRect&) const final; // Currently only Mac has a non empty implementation.
129 bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
130 void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final;
132 void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final;
134 void setToolTip(const String&, WebCore::TextDirection) final;
136 void print(WebCore::Frame&) final;
138 void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final;
140 void reachedMaxAppCacheSize(int64_t spaceNeeded) final;
141 void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t spaceNeeded) final;
143 #if ENABLE(DASHBOARD_SUPPORT)
144 void annotatedRegionsChanged() final;
147 bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) final;
148 String generateReplacementFile(const String& path) final;
150 #if ENABLE(INPUT_TYPE_COLOR)
151 std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final;
154 #if ENABLE(IOS_TOUCH_EVENTS)
155 void didPreventDefaultForEvent() final;
159 void didReceiveMobileDocType(bool) final;
160 void setNeedsScrollNotifications(WebCore::Frame&, bool) final;
161 void observedContentChange(WebCore::Frame&) final;
162 void clearContentChangeObservers(WebCore::Frame&) final;
163 void notifyRevealedSelectionByScrollingFrame(WebCore::Frame&) final;
164 bool isStopping() final;
166 void didLayout(LayoutType = NormalLayout) final;
167 void didStartOverflowScroll() final;
168 void didEndOverflowScroll() final;
169 bool hasStablePageScaleFactor() const final;
171 // FIXME: See <rdar://problem/5975559>
172 void suppressFormNotifications() final;
173 void restoreFormNotifications() final;
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;
178 void webAppOrientationsUpdated() final;
179 void showPlaybackTargetPicker(bool hasVideo) final;
181 Seconds eventThrottlingDelay() final;
184 #if ENABLE(ORIENTATION_EVENTS)
185 int deviceOrientation() const final;
188 void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) final;
189 void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final;
192 void setCursor(const WebCore::Cursor&) final;
193 void setCursorHiddenUntilMouseMoves(bool) final;
196 #if ENABLE(POINTER_LOCK)
197 bool requestPointerLock() final;
198 void requestPointerUnlock() final;
201 void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&) final;
202 bool shouldNotifyOnFormChanges() final;
204 bool selectItemWritingDirectionIsNatural() final;
205 bool selectItemAlignmentFollowsMenuWritingDirection() final;
206 RefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient&) const final;
207 RefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient&) const final;
209 WebCore::GraphicsLayerFactory* graphicsLayerFactory() const final;
210 void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final;
211 void attachViewOverlayGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final;
212 void setNeedsOneShotDrawingSynchronization() final;
213 void scheduleCompositingLayerFlush() final;
214 bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) final;
216 void contentRuleListNotification(const WebCore::URL&, const HashSet<std::pair<String, String>>&) final;
218 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
219 RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) const final;
222 CompositingTriggerFlags allowedCompositingTriggers() const final
224 return static_cast<CompositingTriggerFlags>(
225 ThreeDTransformTrigger |
229 #if PLATFORM(MAC) || PLATFORM(IOS)
230 ScrollableNonMainFrameTrigger |
233 AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iPhone: <rdar://problem/7830677>
238 bool layerTreeStateIsFrozen() const final;
240 #if ENABLE(ASYNC_SCROLLING)
241 RefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page&) const final;
245 void elementDidRefocus(WebCore::Element&) final;
248 #if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
249 bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
250 void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final;
251 void clearPlaybackControlsManager() final;
252 void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
253 void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final;
256 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
257 void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final;
260 #if ENABLE(FULLSCREEN_API)
261 bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final;
262 void enterFullScreenForElement(WebCore::Element&) final;
263 void exitFullScreenForElement(WebCore::Element*) final;
267 void elementDidFocus(WebCore::Element&) final;
268 void elementDidBlur(WebCore::Element&) final;
270 void makeFirstResponder() final;
273 void enableSuddenTermination() final;
274 void disableSuddenTermination() final;
277 WebCore::FloatSize screenSize() const final;
278 WebCore::FloatSize availableScreenSize() const final;
281 void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final;
283 void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) final;
284 void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) final;
286 std::optional<WebCore::ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() final;
288 WebCore::Color underlayColor() const final;
290 void pageExtendedBackgroundColorDidChange(WebCore::Color) const final;
292 void wheelEventHandlersChanged(bool) final;
294 String plugInStartLabelTitle(const String& mimeType) const final;
295 String plugInStartLabelSubtitle(const String& mimeType) const final;
296 String plugInExtraStyleSheet() const final;
297 String plugInExtraScript() const final;
299 void didAddHeaderLayer(WebCore::GraphicsLayer&) final;
300 void didAddFooterLayer(WebCore::GraphicsLayer&) final;
302 bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const final;
304 void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final;
305 void handleAutoplayEvent(WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
307 #if ENABLE(MEDIA_SESSION)
308 void hasMediaSessionWithActiveMediaElementsDidChange(bool) final;
309 void mediaSessionMetadataDidChange(const WebCore::MediaSessionMetadata&) final;
310 void focusedContentMediaElementDidChange(uint64_t) final;
313 #if ENABLE(SUBTLE_CRYPTO)
314 bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
315 bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final;
318 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
319 void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&) final;
322 #if ENABLE(SERVICE_CONTROLS)
323 void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
324 bool hasRelevantSelectionServices(bool isTextOnly) const final;
327 bool shouldDispatchFakeMouseMoveEvents() const final;
329 void handleAutoFillButtonClick(WebCore::HTMLInputElement&) final;
331 void handleAlternativePresentationButtonClick(WebCore::Node&) final;
333 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
334 void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final;
335 void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final;
336 void showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint&, bool) final;
337 void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) final;
338 void setMockMediaPlaybackTargetPickerEnabled(bool) final;
339 void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final;
342 void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
344 RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final;
346 #if ENABLE(VIDEO) && USE(GSTREAMER)
347 void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) final;
350 void didInvalidateDocumentMarkerRects() final;
352 void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&&) final;
354 String m_cachedToolTip;
355 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
356 mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
357 mutable bool m_cachedMainFrameHasVerticalScrollbar { false };
362 } // namespace WebKit