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