| 1 | /* |
| 2 | * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 | * Copyright (C) 2013-2019 Apple Inc. All rights reserved. |
| 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 | * |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include "CSSComputedStyleDeclaration.h" |
| 30 | #include "ContextDestructionObserver.h" |
| 31 | #include "Cookie.h" |
| 32 | #include "ExceptionOr.h" |
| 33 | #include "HEVCUtilities.h" |
| 34 | #include "JSDOMPromiseDeferred.h" |
| 35 | #include "OrientationNotifier.h" |
| 36 | #include "PageConsoleClient.h" |
| 37 | #include "RealtimeMediaSource.h" |
| 38 | #include <JavaScriptCore/Float32Array.h> |
| 39 | #include <wtf/Optional.h> |
| 40 | |
| 41 | #if ENABLE(MEDIA_SESSION) |
| 42 | #include "MediaSessionInterruptionProvider.h" |
| 43 | #endif |
| 44 | |
| 45 | #if ENABLE(VIDEO) |
| 46 | #include "MediaElementSession.h" |
| 47 | #endif |
| 48 | |
| 49 | namespace WebCore { |
| 50 | |
| 51 | class AnimationTimeline; |
| 52 | class AudioContext; |
| 53 | class CacheStorageConnection; |
| 54 | class DOMRect; |
| 55 | class DOMRectList; |
| 56 | class DOMURL; |
| 57 | class DOMWindow; |
| 58 | class Document; |
| 59 | class Element; |
| 60 | class ExtendableEvent; |
| 61 | class FetchResponse; |
| 62 | class File; |
| 63 | class Frame; |
| 64 | class GCObservation; |
| 65 | class HTMLAnchorElement; |
| 66 | class HTMLImageElement; |
| 67 | class HTMLInputElement; |
| 68 | class HTMLLinkElement; |
| 69 | class HTMLMediaElement; |
| 70 | class HTMLPictureElement; |
| 71 | class HTMLSelectElement; |
| 72 | class ImageData; |
| 73 | class InspectorStubFrontend; |
| 74 | class InternalSettings; |
| 75 | class MallocStatistics; |
| 76 | class MediaSession; |
| 77 | class MediaStream; |
| 78 | class MediaStreamTrack; |
| 79 | class MemoryInfo; |
| 80 | class MockCDMFactory; |
| 81 | class MockContentFilterSettings; |
| 82 | class MockPageOverlay; |
| 83 | class MockPaymentCoordinator; |
| 84 | class NodeList; |
| 85 | class Page; |
| 86 | class RTCPeerConnection; |
| 87 | class Range; |
| 88 | class RenderedDocumentMarker; |
| 89 | class SVGSVGElement; |
| 90 | class SerializedScriptValue; |
| 91 | class SourceBuffer; |
| 92 | class StringCallback; |
| 93 | class StyleSheet; |
| 94 | class TimeRanges; |
| 95 | class TypeConversions; |
| 96 | class VoidCallback; |
| 97 | class WebGLRenderingContext; |
| 98 | class XMLHttpRequest; |
| 99 | |
| 100 | #if ENABLE(VIDEO_TRACK) |
| 101 | class TextTrackCueGeneric; |
| 102 | #endif |
| 103 | |
| 104 | #if ENABLE(SERVICE_WORKER) |
| 105 | class ServiceWorker; |
| 106 | #endif |
| 107 | |
| 108 | class Internals final : public RefCounted<Internals>, private ContextDestructionObserver |
| 109 | #if ENABLE(MEDIA_STREAM) |
| 110 | , private RealtimeMediaSource::Observer |
| 111 | #endif |
| 112 | { |
| 113 | public: |
| 114 | static Ref<Internals> create(Document&); |
| 115 | virtual ~Internals(); |
| 116 | |
| 117 | static void resetToConsistentState(Page&); |
| 118 | |
| 119 | ExceptionOr<String> elementRenderTreeAsText(Element&); |
| 120 | bool hasPausedImageAnimations(Element&); |
| 121 | |
| 122 | bool isPaintingFrequently(Element&); |
| 123 | void incrementFrequentPaintCounter(Element&); |
| 124 | |
| 125 | String address(Node&); |
| 126 | bool nodeNeedsStyleRecalc(Node&); |
| 127 | String styleChangeType(Node&); |
| 128 | String description(JSC::JSValue); |
| 129 | |
| 130 | bool isPreloaded(const String& url); |
| 131 | bool isLoadingFromMemoryCache(const String& url); |
| 132 | String fetchResponseSource(FetchResponse&); |
| 133 | String xhrResponseSource(XMLHttpRequest&); |
| 134 | bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&); |
| 135 | bool isStyleSheetLoadingSubresources(HTMLLinkElement&); |
| 136 | enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad }; |
| 137 | void setOverrideCachePolicy(CachePolicy); |
| 138 | ExceptionOr<void> setCanShowModalDialogOverride(bool allow); |
| 139 | enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh }; |
| 140 | void setOverrideResourceLoadPriority(ResourceLoadPriority); |
| 141 | void setStrictRawResourceValidationPolicyDisabled(bool); |
| 142 | |
| 143 | void clearMemoryCache(); |
| 144 | void pruneMemoryCacheToSize(unsigned size); |
| 145 | void destroyDecodedDataForAllImages(); |
| 146 | unsigned memoryCacheSize() const; |
| 147 | |
| 148 | unsigned imageFrameIndex(HTMLImageElement&); |
| 149 | unsigned imageFrameCount(HTMLImageElement&); |
| 150 | float imageFrameDurationAtIndex(HTMLImageElement&, unsigned index); |
| 151 | void setImageFrameDecodingDuration(HTMLImageElement&, float duration); |
| 152 | void resetImageAnimation(HTMLImageElement&); |
| 153 | bool isImageAnimating(HTMLImageElement&); |
| 154 | void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool enabled); |
| 155 | unsigned imageDecodeCount(HTMLImageElement&); |
| 156 | unsigned pdfDocumentCachingCount(HTMLImageElement&); |
| 157 | void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled); |
| 158 | void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled); |
| 159 | |
| 160 | void setGridMaxTracksLimit(unsigned); |
| 161 | |
| 162 | void clearPageCache(); |
| 163 | unsigned pageCacheSize() const; |
| 164 | |
| 165 | void disableTileSizeUpdateDelay(); |
| 166 | |
| 167 | void setSpeculativeTilingDelayDisabledForTesting(bool); |
| 168 | |
| 169 | Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const; |
| 170 | |
| 171 | Node* ensureUserAgentShadowRoot(Element& host); |
| 172 | Node* shadowRoot(Element& host); |
| 173 | ExceptionOr<String> shadowRootType(const Node&) const; |
| 174 | String shadowPseudoId(Element&); |
| 175 | void setShadowPseudoId(Element&, const String&); |
| 176 | |
| 177 | // CSS Deferred Parsing Testing |
| 178 | unsigned deferredStyleRulesCount(StyleSheet&); |
| 179 | unsigned deferredGroupRulesCount(StyleSheet&); |
| 180 | unsigned deferredKeyframesRulesCount(StyleSheet&); |
| 181 | |
| 182 | // DOMTimers throttling testing. |
| 183 | ExceptionOr<bool> isTimerThrottled(int timeoutId); |
| 184 | bool isRequestAnimationFrameThrottled() const; |
| 185 | double requestAnimationFrameInterval() const; |
| 186 | bool scriptedAnimationsAreSuspended() const; |
| 187 | bool areTimersThrottled() const; |
| 188 | |
| 189 | enum EventThrottlingBehavior { Responsive, Unresponsive }; |
| 190 | void setEventThrottlingBehaviorOverride(Optional<EventThrottlingBehavior>); |
| 191 | Optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const; |
| 192 | |
| 193 | // Spatial Navigation testing. |
| 194 | ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const; |
| 195 | |
| 196 | // CSS Animation testing. |
| 197 | unsigned numberOfActiveAnimations() const; |
| 198 | ExceptionOr<bool> animationsAreSuspended() const; |
| 199 | ExceptionOr<void> suspendAnimations() const; |
| 200 | ExceptionOr<void> resumeAnimations() const; |
| 201 | ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&); |
| 202 | ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId); |
| 203 | double animationsInterval() const; |
| 204 | |
| 205 | // CSS Transition testing. |
| 206 | ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&); |
| 207 | ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId); |
| 208 | |
| 209 | // Web Animations testing. |
| 210 | struct AcceleratedAnimation { |
| 211 | String property; |
| 212 | double speed; |
| 213 | }; |
| 214 | Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&); |
| 215 | unsigned numberOfAnimationTimelineInvalidations() const; |
| 216 | |
| 217 | // For animations testing, we need a way to get at pseudo elements. |
| 218 | ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&); |
| 219 | |
| 220 | Node* treeScopeRootNode(Node&); |
| 221 | Node* parentTreeScope(Node&); |
| 222 | |
| 223 | String visiblePlaceholder(Element&); |
| 224 | void selectColorInColorChooser(HTMLInputElement&, const String& colorValue); |
| 225 | ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem(); |
| 226 | ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&); |
| 227 | |
| 228 | ExceptionOr<Ref<DOMRect>> absoluteCaretBounds(); |
| 229 | ExceptionOr<bool> isCaretBlinkingSuspended(); |
| 230 | |
| 231 | Ref<DOMRect> boundingBox(Element&); |
| 232 | |
| 233 | ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects(); |
| 234 | |
| 235 | ExceptionOr<unsigned> markerCountForNode(Node&, const String&); |
| 236 | ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index); |
| 237 | ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index); |
| 238 | ExceptionOr<String> dumpMarkerRects(const String& markerType); |
| 239 | void addTextMatchMarker(const Range&, bool isActive); |
| 240 | ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool); |
| 241 | |
| 242 | void invalidateFontCache(); |
| 243 | void setFontSmoothingEnabled(bool); |
| 244 | |
| 245 | ExceptionOr<void> setLowPowerModeEnabled(bool); |
| 246 | |
| 247 | ExceptionOr<void> setScrollViewPosition(int x, int y); |
| 248 | ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y); |
| 249 | |
| 250 | ExceptionOr<Ref<DOMRect>> layoutViewportRect(); |
| 251 | ExceptionOr<Ref<DOMRect>> visualViewportRect(); |
| 252 | |
| 253 | ExceptionOr<void> setViewIsTransparent(bool); |
| 254 | |
| 255 | ExceptionOr<String> viewBaseBackgroundColor(); |
| 256 | ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue); |
| 257 | |
| 258 | ExceptionOr<void> (const String& mode, int gap, int pageLength); |
| 259 | ExceptionOr<void> (bool); |
| 260 | ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight); |
| 261 | |
| 262 | ExceptionOr<bool> wasLastChangeUserEdit(Element& textField); |
| 263 | bool elementShouldAutoComplete(HTMLInputElement&); |
| 264 | void setAutofilled(HTMLInputElement&, bool enabled); |
| 265 | enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, CreditCard }; |
| 266 | void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType); |
| 267 | AutoFillButtonType autoFillButtonType(const HTMLInputElement&); |
| 268 | AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&); |
| 269 | ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h); |
| 270 | |
| 271 | ExceptionOr<String> autofillFieldName(Element&); |
| 272 | |
| 273 | ExceptionOr<void> invalidateControlTints(); |
| 274 | |
| 275 | RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength); |
| 276 | unsigned locationFromRange(Element& scope, const Range&); |
| 277 | unsigned lengthFromRange(Element& scope, const Range&); |
| 278 | String rangeAsText(const Range&); |
| 279 | String rangeAsTextUsingBackwardsTextIterator(const Range&); |
| 280 | Ref<Range> subrange(Range&, int rangeLocation, int rangeLength); |
| 281 | ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y); |
| 282 | RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned); |
| 283 | |
| 284 | ExceptionOr<void> setDelegatesScrolling(bool enabled); |
| 285 | |
| 286 | ExceptionOr<int> lastSpellCheckRequestSequence(); |
| 287 | ExceptionOr<int> lastSpellCheckProcessedSequence(); |
| 288 | |
| 289 | Vector<String> userPreferredLanguages() const; |
| 290 | void setUserPreferredLanguages(const Vector<String>&); |
| 291 | |
| 292 | Vector<String> userPreferredAudioCharacteristics() const; |
| 293 | void setUserPreferredAudioCharacteristic(const String&); |
| 294 | |
| 295 | ExceptionOr<unsigned> wheelEventHandlerCount(); |
| 296 | ExceptionOr<unsigned> touchEventHandlerCount(); |
| 297 | |
| 298 | ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&); |
| 299 | ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects(); |
| 300 | |
| 301 | ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const; |
| 302 | |
| 303 | String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined); |
| 304 | |
| 305 | void updateEditorUINowIfScheduled(); |
| 306 | |
| 307 | bool sentenceRetroCorrectionEnabled() const |
| 308 | { |
| 309 | #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 |
| 310 | return true; |
| 311 | #else |
| 312 | return false; |
| 313 | #endif |
| 314 | } |
| 315 | bool hasSpellingMarker(int from, int length); |
| 316 | bool hasGrammarMarker(int from, int length); |
| 317 | bool hasAutocorrectedMarker(int from, int length); |
| 318 | void setContinuousSpellCheckingEnabled(bool); |
| 319 | void setAutomaticQuoteSubstitutionEnabled(bool); |
| 320 | void setAutomaticLinkDetectionEnabled(bool); |
| 321 | void setAutomaticDashSubstitutionEnabled(bool); |
| 322 | void setAutomaticTextReplacementEnabled(bool); |
| 323 | void setAutomaticSpellingCorrectionEnabled(bool); |
| 324 | |
| 325 | void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length); |
| 326 | void changeSelectionListType(); |
| 327 | |
| 328 | bool isOverwriteModeEnabled(); |
| 329 | void toggleOverwriteModeEnabled(); |
| 330 | |
| 331 | ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions); |
| 332 | ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches); |
| 333 | ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions); |
| 334 | |
| 335 | unsigned numberOfScrollableAreas(); |
| 336 | |
| 337 | ExceptionOr<bool> isPageBoxVisible(int pageNumber); |
| 338 | |
| 339 | static const char* internalsId; |
| 340 | |
| 341 | InternalSettings* settings() const; |
| 342 | unsigned workerThreadCount() const; |
| 343 | ExceptionOr<bool> areSVGAnimationsPaused() const; |
| 344 | ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const; |
| 345 | |
| 346 | enum { |
| 347 | // Values need to be kept in sync with Internals.idl. |
| 348 | LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1, |
| 349 | LAYER_TREE_INCLUDES_TILE_CACHES = 2, |
| 350 | LAYER_TREE_INCLUDES_REPAINT_RECTS = 4, |
| 351 | LAYER_TREE_INCLUDES_PAINTING_PHASES = 8, |
| 352 | LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16, |
| 353 | LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32, |
| 354 | LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64, |
| 355 | LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES = 128, |
| 356 | LAYER_TREE_INCLUDES_EVENT_REGION = 256, |
| 357 | }; |
| 358 | ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const; |
| 359 | ExceptionOr<uint64_t> layerIDForElement(Element&); |
| 360 | ExceptionOr<String> repaintRectsAsText() const; |
| 361 | |
| 362 | ExceptionOr<String> scrollbarOverlayStyle(Node*) const; |
| 363 | ExceptionOr<bool> scrollbarUsingDarkAppearance(Node*) const; |
| 364 | |
| 365 | ExceptionOr<String> scrollingStateTreeAsText() const; |
| 366 | ExceptionOr<String> mainThreadScrollingReasons() const; |
| 367 | ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const; |
| 368 | |
| 369 | ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing); |
| 370 | ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay); |
| 371 | |
| 372 | enum { |
| 373 | // Values need to be kept in sync with Internals.idl. |
| 374 | DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1, |
| 375 | }; |
| 376 | ExceptionOr<String> displayListForElement(Element&, unsigned short flags); |
| 377 | ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags); |
| 378 | |
| 379 | ExceptionOr<void> garbageCollectDocumentResources() const; |
| 380 | |
| 381 | void beginSimulatedMemoryPressure(); |
| 382 | void endSimulatedMemoryPressure(); |
| 383 | bool isUnderMemoryPressure(); |
| 384 | |
| 385 | ExceptionOr<void> insertAuthorCSS(const String&) const; |
| 386 | ExceptionOr<void> insertUserCSS(const String&) const; |
| 387 | |
| 388 | unsigned numberOfIDBTransactions() const; |
| 389 | |
| 390 | unsigned numberOfLiveNodes() const; |
| 391 | unsigned numberOfLiveDocuments() const; |
| 392 | unsigned referencingNodeCount(const Document&) const; |
| 393 | |
| 394 | #if ENABLE(INTERSECTION_OBSERVER) |
| 395 | unsigned numberOfIntersectionObservers(const Document&) const; |
| 396 | #endif |
| 397 | |
| 398 | uint64_t documentIdentifier(const Document&) const; |
| 399 | bool isDocumentAlive(uint64_t documentIdentifier) const; |
| 400 | |
| 401 | bool isAnyWorkletGlobalScopeAlive() const; |
| 402 | |
| 403 | String serviceWorkerClientIdentifier(const Document&) const; |
| 404 | |
| 405 | RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url); |
| 406 | void closeDummyInspectorFrontend(); |
| 407 | ExceptionOr<void> setInspectorIsUnderTest(bool); |
| 408 | |
| 409 | String counterValue(Element&); |
| 410 | |
| 411 | int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600); |
| 412 | Vector<String> shortcutIconURLs() const; |
| 413 | |
| 414 | int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600); |
| 415 | ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const; |
| 416 | ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const; |
| 417 | |
| 418 | ExceptionOr<float> pageScaleFactor() const; |
| 419 | |
| 420 | ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y); |
| 421 | ExceptionOr<void> setPageZoomFactor(float); |
| 422 | ExceptionOr<void> setTextZoomFactor(float); |
| 423 | |
| 424 | ExceptionOr<void> setUseFixedLayout(bool); |
| 425 | ExceptionOr<void> setFixedLayoutSize(int width, int height); |
| 426 | ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height); |
| 427 | void setPrinting(int width, int height); |
| 428 | |
| 429 | void (float); |
| 430 | void (float); |
| 431 | |
| 432 | void setTopContentInset(float); |
| 433 | |
| 434 | #if ENABLE(FULLSCREEN_API) |
| 435 | void webkitWillEnterFullScreenForElement(Element&); |
| 436 | void webkitDidEnterFullScreenForElement(Element&); |
| 437 | void webkitWillExitFullScreenForElement(Element&); |
| 438 | void webkitDidExitFullScreenForElement(Element&); |
| 439 | bool isAnimatingFullScreen() const; |
| 440 | #endif |
| 441 | |
| 442 | struct FullscreenInsets { |
| 443 | float top { 0 }; |
| 444 | float left { 0 }; |
| 445 | float bottom { 0 }; |
| 446 | float right { 0 }; |
| 447 | }; |
| 448 | void setFullscreenInsets(FullscreenInsets); |
| 449 | void setFullscreenAutoHideDuration(double); |
| 450 | void setFullscreenControlsHidden(bool); |
| 451 | |
| 452 | WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long); |
| 453 | |
| 454 | void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme); |
| 455 | void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme); |
| 456 | |
| 457 | void registerDefaultPortForProtocol(unsigned short port, const String& protocol); |
| 458 | |
| 459 | Ref<MallocStatistics> mallocStatistics() const; |
| 460 | Ref<TypeConversions> typeConversions() const; |
| 461 | Ref<MemoryInfo> memoryInfo() const; |
| 462 | |
| 463 | Vector<String> getReferencedFilePaths() const; |
| 464 | |
| 465 | ExceptionOr<void> startTrackingRepaints(); |
| 466 | ExceptionOr<void> stopTrackingRepaints(); |
| 467 | |
| 468 | ExceptionOr<void> startTrackingLayerFlushes(); |
| 469 | ExceptionOr<unsigned> layerFlushCount(); |
| 470 | |
| 471 | ExceptionOr<void> startTrackingStyleRecalcs(); |
| 472 | ExceptionOr<unsigned> styleRecalcCount(); |
| 473 | unsigned lastStyleUpdateSize() const; |
| 474 | |
| 475 | ExceptionOr<void> startTrackingCompositingUpdates(); |
| 476 | ExceptionOr<unsigned> compositingUpdateCount(); |
| 477 | |
| 478 | enum CompositingPolicy { Normal, Conservative }; |
| 479 | ExceptionOr<void> setCompositingPolicyOverride(Optional<CompositingPolicy>); |
| 480 | ExceptionOr<Optional<CompositingPolicy>> compositingPolicyOverride() const; |
| 481 | |
| 482 | ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*); |
| 483 | unsigned layoutCount() const; |
| 484 | |
| 485 | Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const; |
| 486 | Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const; |
| 487 | |
| 488 | bool isFromCurrentWorld(JSC::JSValue) const; |
| 489 | |
| 490 | void setUsesOverlayScrollbars(bool); |
| 491 | void setUsesMockScrollAnimator(bool); |
| 492 | |
| 493 | ExceptionOr<String> getCurrentCursorInfo(); |
| 494 | |
| 495 | String markerTextForListItem(Element&); |
| 496 | |
| 497 | String toolTipFromElement(Element&) const; |
| 498 | |
| 499 | void forceReload(bool endToEnd); |
| 500 | void reloadExpiredOnly(); |
| 501 | |
| 502 | void enableAutoSizeMode(bool enabled, int width, int height); |
| 503 | |
| 504 | #if ENABLE(LEGACY_ENCRYPTED_MEDIA) |
| 505 | void initializeMockCDM(); |
| 506 | #endif |
| 507 | |
| 508 | #if ENABLE(ENCRYPTED_MEDIA) |
| 509 | Ref<MockCDMFactory> registerMockCDM(); |
| 510 | #endif |
| 511 | |
| 512 | void enableMockMediaCapabilities(); |
| 513 | |
| 514 | #if ENABLE(SPEECH_SYNTHESIS) |
| 515 | void enableMockSpeechSynthesizer(); |
| 516 | #endif |
| 517 | |
| 518 | #if ENABLE(MEDIA_STREAM) |
| 519 | void setMockMediaCaptureDevicesEnabled(bool); |
| 520 | void setMediaCaptureRequiresSecureConnection(bool); |
| 521 | void setCustomPrivateRecorderCreator(); |
| 522 | #endif |
| 523 | |
| 524 | #if ENABLE(WEB_RTC) |
| 525 | void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action); |
| 526 | void useMockRTCPeerConnectionFactory(const String&); |
| 527 | void setICECandidateFiltering(bool); |
| 528 | void setEnumeratingAllNetworkInterfacesEnabled(bool); |
| 529 | void stopPeerConnection(RTCPeerConnection&); |
| 530 | void clearPeerConnectionFactory(); |
| 531 | void applyRotationForOutgoingVideoSources(RTCPeerConnection&); |
| 532 | #endif |
| 533 | |
| 534 | String getImageSourceURL(Element&); |
| 535 | |
| 536 | #if ENABLE(VIDEO) |
| 537 | Vector<String> mediaResponseSources(HTMLMediaElement&); |
| 538 | Vector<String> mediaResponseContentRanges(HTMLMediaElement&); |
| 539 | void simulateAudioInterruption(HTMLMediaElement&); |
| 540 | ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&); |
| 541 | void beginSimulatedHDCPError(HTMLMediaElement&); |
| 542 | void endSimulatedHDCPError(HTMLMediaElement&); |
| 543 | |
| 544 | bool elementShouldBufferData(HTMLMediaElement&); |
| 545 | String elementBufferingPolicy(HTMLMediaElement&); |
| 546 | #endif |
| 547 | |
| 548 | bool (HTMLSelectElement&); |
| 549 | |
| 550 | ExceptionOr<String> captionsStyleSheetOverride(); |
| 551 | ExceptionOr<void> setCaptionsStyleSheetOverride(const String&); |
| 552 | ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&); |
| 553 | ExceptionOr<void> setCaptionDisplayMode(const String&); |
| 554 | #if ENABLE(VIDEO_TRACK) |
| 555 | RefPtr<TextTrackCueGeneric> createGenericCue(double startTime, double endTime, String text); |
| 556 | #endif |
| 557 | |
| 558 | #if ENABLE(VIDEO) |
| 559 | Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes); |
| 560 | double closestTimeToTimeRanges(double time, TimeRanges&); |
| 561 | #endif |
| 562 | |
| 563 | ExceptionOr<Ref<DOMRect>> selectionBounds(); |
| 564 | void setSelectionWithoutValidation(Ref<Node> baseNode, unsigned baseOffset, RefPtr<Node> extentNode, unsigned extentOffset); |
| 565 | |
| 566 | ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&); |
| 567 | ExceptionOr<String> unavailablePluginReplacementText(Element&); |
| 568 | bool isPluginSnapshotted(Element&); |
| 569 | bool pluginIsBelowSizeThreshold(Element&); |
| 570 | |
| 571 | #if ENABLE(MEDIA_SOURCE) |
| 572 | WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource(); |
| 573 | Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&); |
| 574 | Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&); |
| 575 | void setShouldGenerateTimestamps(SourceBuffer&, bool); |
| 576 | #endif |
| 577 | |
| 578 | #if ENABLE(VIDEO) |
| 579 | ExceptionOr<void> beginMediaSessionInterruption(const String&); |
| 580 | void endMediaSessionInterruption(const String&); |
| 581 | void applicationWillBecomeInactive(); |
| 582 | void applicationDidBecomeActive(); |
| 583 | void applicationWillEnterForeground(bool suspendedUnderLock) const; |
| 584 | void applicationDidEnterBackground(bool suspendedUnderLock) const; |
| 585 | ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString); |
| 586 | ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const; |
| 587 | void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString); |
| 588 | ExceptionOr<void> postRemoteControlCommand(const String&, float argument); |
| 589 | bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const; |
| 590 | #endif |
| 591 | |
| 592 | #if ENABLE(MEDIA_SESSION) |
| 593 | void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory); |
| 594 | void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory); |
| 595 | String mediaSessionCurrentState(MediaSession&) const; |
| 596 | double mediaElementPlayerVolume(HTMLMediaElement&) const; |
| 597 | enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack }; |
| 598 | void sendMediaControlEvent(MediaControlEvent); |
| 599 | #endif |
| 600 | |
| 601 | #if ENABLE(WIRELESS_PLAYBACK_TARGET) |
| 602 | void setMockMediaPlaybackTargetPickerEnabled(bool); |
| 603 | ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState); |
| 604 | #endif |
| 605 | |
| 606 | #if ENABLE(WEB_AUDIO) |
| 607 | void setAudioContextRestrictions(AudioContext&, StringView restrictionsString); |
| 608 | #endif |
| 609 | |
| 610 | void simulateSystemSleep() const; |
| 611 | void simulateSystemWake() const; |
| 612 | |
| 613 | enum class PageOverlayType { View, Document }; |
| 614 | ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType); |
| 615 | ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const; |
| 616 | |
| 617 | void setPageMuted(StringView); |
| 618 | String pageMediaState(); |
| 619 | |
| 620 | void setPageDefersLoading(bool); |
| 621 | ExceptionOr<bool> pageDefersLoading(); |
| 622 | |
| 623 | RefPtr<File> createFile(const String&); |
| 624 | void queueMicroTask(int); |
| 625 | bool testPreloaderSettingViewport(); |
| 626 | |
| 627 | #if ENABLE(CONTENT_FILTERING) |
| 628 | MockContentFilterSettings& mockContentFilterSettings(); |
| 629 | #endif |
| 630 | |
| 631 | #if ENABLE(CSS_SCROLL_SNAP) |
| 632 | ExceptionOr<String> scrollSnapOffsets(Element&); |
| 633 | void setPlatformMomentumScrollingPredictionEnabled(bool); |
| 634 | #endif |
| 635 | |
| 636 | ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius); |
| 637 | |
| 638 | String getCurrentMediaControlsStatusForElement(HTMLMediaElement&); |
| 639 | |
| 640 | String userVisibleString(const DOMURL&); |
| 641 | void setShowAllPlugins(bool); |
| 642 | |
| 643 | String resourceLoadStatisticsForURL(const DOMURL&); |
| 644 | void setResourceLoadStatisticsEnabled(bool); |
| 645 | |
| 646 | #if ENABLE(STREAMS_API) |
| 647 | bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue); |
| 648 | JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue); |
| 649 | #endif |
| 650 | |
| 651 | String composedTreeAsText(Node&); |
| 652 | |
| 653 | bool isProcessingUserGesture(); |
| 654 | double lastHandledUserGestureTimestamp(); |
| 655 | |
| 656 | void withUserGesture(RefPtr<VoidCallback>&&); |
| 657 | |
| 658 | bool userIsInteracting(); |
| 659 | |
| 660 | RefPtr<GCObservation> observeGC(JSC::JSValue); |
| 661 | |
| 662 | enum class UserInterfaceLayoutDirection : uint8_t { LTR, RTL }; |
| 663 | void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection); |
| 664 | |
| 665 | bool userPrefersReducedMotion() const; |
| 666 | |
| 667 | void reportBacktrace(); |
| 668 | |
| 669 | enum class BaseWritingDirection { Natural, Ltr, Rtl }; |
| 670 | void setBaseWritingDirection(BaseWritingDirection); |
| 671 | |
| 672 | #if ENABLE(POINTER_LOCK) |
| 673 | bool pageHasPendingPointerLock() const; |
| 674 | bool pageHasPointerLock() const; |
| 675 | #endif |
| 676 | |
| 677 | Vector<String> accessKeyModifiers() const; |
| 678 | |
| 679 | void setQuickLookPassword(const String&); |
| 680 | |
| 681 | void setAsRunningUserScripts(Document&); |
| 682 | #if ENABLE(APPLE_PAY) |
| 683 | void setHasStartedApplePaySession(Document&); |
| 684 | #endif |
| 685 | |
| 686 | #if ENABLE(WEBGL) |
| 687 | void simulateWebGLContextChanged(WebGLRenderingContext&); |
| 688 | void failNextGPUStatusCheck(WebGLRenderingContext&); |
| 689 | bool hasLowAndHighPowerGPUs(); |
| 690 | #endif |
| 691 | |
| 692 | void setPageVisibility(bool isVisible); |
| 693 | void setPageIsFocusedAndActive(bool); |
| 694 | |
| 695 | |
| 696 | #if ENABLE(WEB_RTC) |
| 697 | void setH264HardwareEncoderAllowed(bool allowed); |
| 698 | #endif |
| 699 | |
| 700 | #if ENABLE(MEDIA_STREAM) |
| 701 | void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation); |
| 702 | unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; } |
| 703 | unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; } |
| 704 | void observeMediaStreamTrack(MediaStreamTrack&); |
| 705 | using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>; |
| 706 | void grabNextMediaStreamTrackFrame(TrackFramePromise&&); |
| 707 | void delayMediaStreamTrackSamples(MediaStreamTrack&, float); |
| 708 | void setMediaStreamTrackMuted(MediaStreamTrack&, bool); |
| 709 | void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&); |
| 710 | void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&); |
| 711 | void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id); |
| 712 | void setMediaStreamSourceInterrupted(MediaStreamTrack&, bool); |
| 713 | void setDisableGetDisplayMediaUserGestureConstraint(bool); |
| 714 | #endif |
| 715 | |
| 716 | String audioSessionCategory() const; |
| 717 | double preferredAudioBufferSize() const; |
| 718 | bool audioSessionActive() const; |
| 719 | |
| 720 | void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&); |
| 721 | void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&); |
| 722 | void setResponseSizeWithPadding(FetchResponse&, uint64_t size); |
| 723 | uint64_t responseSizeWithPadding(FetchResponse&) const; |
| 724 | |
| 725 | void updateQuotaBasedOnSpaceUsage(); |
| 726 | |
| 727 | void setConsoleMessageListener(RefPtr<StringCallback>&&); |
| 728 | |
| 729 | #if ENABLE(SERVICE_WORKER) |
| 730 | using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>; |
| 731 | void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&); |
| 732 | void terminateServiceWorker(ServiceWorker&); |
| 733 | bool hasServiceWorkerConnection(); |
| 734 | #endif |
| 735 | |
| 736 | #if ENABLE(APPLE_PAY) |
| 737 | MockPaymentCoordinator& mockPaymentCoordinator(Document&); |
| 738 | #endif |
| 739 | |
| 740 | bool isSystemPreviewLink(Element&) const; |
| 741 | bool isSystemPreviewImage(Element&) const; |
| 742 | |
| 743 | void postTask(RefPtr<VoidCallback>&&); |
| 744 | void markContextAsInsecure(); |
| 745 | |
| 746 | bool usingAppleInternalSDK() const; |
| 747 | |
| 748 | struct NowPlayingState { |
| 749 | String title; |
| 750 | double duration; |
| 751 | double elapsedTime; |
| 752 | uint64_t uniqueIdentifier; |
| 753 | bool hasActiveSession; |
| 754 | bool registeredAsNowPlayingApplication; |
| 755 | }; |
| 756 | ExceptionOr<NowPlayingState> nowPlayingState() const; |
| 757 | |
| 758 | #if ENABLE(VIDEO) |
| 759 | using PlaybackControlsPurpose = MediaElementSession::PlaybackControlsPurpose; |
| 760 | RefPtr<HTMLMediaElement> bestMediaElementForShowingPlaybackControlsManager(PlaybackControlsPurpose); |
| 761 | |
| 762 | using MediaSessionState = PlatformMediaSession::State; |
| 763 | MediaSessionState mediaSessionState(HTMLMediaElement&); |
| 764 | #endif |
| 765 | |
| 766 | void (bool); |
| 767 | String ongoingLoadsDescriptions() const; |
| 768 | |
| 769 | void reloadWithoutContentExtensions(); |
| 770 | |
| 771 | void setUseSystemAppearance(bool); |
| 772 | |
| 773 | size_t pluginCount(); |
| 774 | |
| 775 | void notifyResourceLoadObserver(); |
| 776 | |
| 777 | unsigned primaryScreenDisplayID(); |
| 778 | |
| 779 | bool capsLockIsOn(); |
| 780 | |
| 781 | bool supportsVCPEncoder(); |
| 782 | |
| 783 | using HEVCParameterSet = WebCore::HEVCParameterSet; |
| 784 | Optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString); |
| 785 | |
| 786 | struct CookieData { |
| 787 | String name; |
| 788 | String value; |
| 789 | String domain; |
| 790 | // Expiration dates are expressed as milliseconds since the UNIX epoch. |
| 791 | double expires { 0 }; |
| 792 | bool isHttpOnly { false }; |
| 793 | bool isSecure { false }; |
| 794 | bool isSession { false }; |
| 795 | bool isSameSiteLax { false }; |
| 796 | bool isSameSiteStrict { false }; |
| 797 | |
| 798 | CookieData(Cookie cookie) |
| 799 | : name(cookie.name) |
| 800 | , value(cookie.value) |
| 801 | , domain(cookie.domain) |
| 802 | , expires(cookie.expires) |
| 803 | , isHttpOnly(cookie.httpOnly) |
| 804 | , isSecure(cookie.secure) |
| 805 | , isSession(cookie.session) |
| 806 | , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax) |
| 807 | , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict) |
| 808 | { |
| 809 | ASSERT(!(isSameSiteLax && isSameSiteStrict)); |
| 810 | } |
| 811 | |
| 812 | CookieData() |
| 813 | { |
| 814 | } |
| 815 | }; |
| 816 | Vector<CookieData> getCookies() const; |
| 817 | |
| 818 | void setAlwaysAllowLocalWebarchive(bool); |
| 819 | void processWillSuspend(); |
| 820 | void processDidResume(); |
| 821 | |
| 822 | void testDictionaryLogging(); |
| 823 | |
| 824 | void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest&, double); |
| 825 | |
| 826 | private: |
| 827 | explicit Internals(Document&); |
| 828 | Document* contextDocument() const; |
| 829 | Frame* frame() const; |
| 830 | |
| 831 | ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index); |
| 832 | |
| 833 | // RealtimeMediaSource::Observer API |
| 834 | #if ENABLE(MEDIA_STREAM) |
| 835 | void videoSampleAvailable(MediaSample&) final; |
| 836 | void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; } |
| 837 | |
| 838 | OrientationNotifier m_orientationNotifier; |
| 839 | unsigned long m_trackVideoSampleCount { 0 }; |
| 840 | unsigned long m_trackAudioSampleCount { 0 }; |
| 841 | RefPtr<MediaStreamTrack> m_track; |
| 842 | Optional<TrackFramePromise> m_nextTrackFramePromise; |
| 843 | #endif |
| 844 | |
| 845 | std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend; |
| 846 | RefPtr<CacheStorageConnection> m_cacheStorageConnection; |
| 847 | }; |
| 848 | |
| 849 | } // namespace WebCore |
| 850 | |