1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2011 Google Inc. All rights reserved.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 *
26 */
27
28#pragma once
29
30#include "CSSRegisteredCustomProperty.h"
31#include "Color.h"
32#include "ContainerNode.h"
33#include "DisabledAdaptations.h"
34#include "DocumentEventQueue.h"
35#include "DocumentIdentifier.h"
36#include "DocumentTiming.h"
37#include "ElementIdentifier.h"
38#include "FocusDirection.h"
39#include "FontSelectorClient.h"
40#include "FrameDestructionObserver.h"
41#include "GenericTaskQueue.h"
42#include "MediaProducer.h"
43#include "MutationObserver.h"
44#include "OrientationNotifier.h"
45#include "PlatformEvent.h"
46#include "ReferrerPolicy.h"
47#include "Region.h"
48#include "RegistrableDomain.h"
49#include "RenderPtr.h"
50#include "ScriptExecutionContext.h"
51#include "SecurityPolicyViolationEvent.h"
52#include "StringWithDirection.h"
53#include "StyleColor.h"
54#include "Supplementable.h"
55#include "TextResourceDecoder.h"
56#include "Timer.h"
57#include "TreeScope.h"
58#include "UserActionElementSet.h"
59#include "ViewportArguments.h"
60#include "VisibilityState.h"
61#include <pal/SessionID.h>
62#include <wtf/Deque.h>
63#include <wtf/Forward.h>
64#include <wtf/HashCountedSet.h>
65#include <wtf/HashSet.h>
66#include <wtf/Logger.h>
67#include <wtf/ObjectIdentifier.h>
68#include <wtf/UniqueRef.h>
69#include <wtf/WeakHashSet.h>
70#include <wtf/WeakPtr.h>
71#include <wtf/text/AtomicStringHash.h>
72
73#if PLATFORM(IOS_FAMILY)
74#include "EventTrackingRegions.h"
75#endif
76
77#if ENABLE(IOS_TOUCH_EVENTS)
78#include <wtf/ThreadingPrimitives.h>
79#endif
80
81namespace JSC {
82class ExecState;
83class InputCursor;
84}
85
86namespace WebCore {
87
88class ApplicationStateChangeListener;
89class AXObjectCache;
90class Attr;
91class CDATASection;
92class CSSCustomPropertyValue;
93class CSSFontSelector;
94class CSSStyleDeclaration;
95class CSSStyleSheet;
96class CachedCSSStyleSheet;
97class CachedFrameBase;
98class CachedResourceLoader;
99class CachedScript;
100class CanvasRenderingContext2D;
101class CharacterData;
102class Comment;
103class ConstantPropertyMap;
104class ContentChangeObserver;
105class DOMImplementation;
106class DOMSelection;
107class DOMWindow;
108class DOMWrapperWorld;
109class Database;
110class DatabaseThread;
111class DocumentFragment;
112class DocumentLoader;
113class DocumentMarkerController;
114class DocumentParser;
115class DocumentSharedObjectPool;
116class DocumentTimeline;
117class DocumentType;
118class EditingBehavior;
119class ExtensionStyleSheets;
120class FloatQuad;
121class FloatRect;
122class FontFaceSet;
123class FormController;
124class Frame;
125class FrameView;
126class FullscreenManager;
127class HTMLAllCollection;
128class HTMLBodyElement;
129class HTMLCanvasElement;
130class HTMLCollection;
131class HTMLDocument;
132class HTMLElement;
133class HTMLFrameOwnerElement;
134class HTMLHeadElement;
135class HTMLIFrameElement;
136class HTMLImageElement;
137class HTMLMapElement;
138class HTMLMediaElement;
139class HTMLPictureElement;
140class HTMLScriptElement;
141class HitTestRequest;
142class HitTestResult;
143class ImageBitmapRenderingContext;
144class IntPoint;
145class JSNode;
146class LayoutPoint;
147class LayoutRect;
148class LiveNodeList;
149class Locale;
150class Location;
151class MediaCanStartListener;
152class MediaPlaybackTarget;
153class MediaPlaybackTargetClient;
154class MediaQueryList;
155class MediaQueryMatcher;
156class MouseEventWithHitTestResults;
157class NodeFilter;
158class NodeIterator;
159class Page;
160class PaintWorkletGlobalScope;
161class PlatformMouseEvent;
162class ProcessingInstruction;
163class QualifiedName;
164class Quirks;
165class Range;
166class RenderTreeBuilder;
167class RenderView;
168class RequestAnimationFrameCallback;
169class SVGDocumentExtensions;
170class SVGSVGElement;
171class SVGUseElement;
172class SWClientConnection;
173class ScriptElementData;
174class ScriptModuleLoader;
175class ScriptRunner;
176class ScriptableDocumentParser;
177class ScriptedAnimationController;
178class SecurityOrigin;
179class SegmentedString;
180class SelectorQuery;
181class SelectorQueryCache;
182class SerializedScriptValue;
183class Settings;
184class StringCallback;
185class StyleResolver;
186class StyleSheet;
187class StyleSheetContents;
188class StyleSheetList;
189class Text;
190class TextResourceDecoder;
191class TreeWalker;
192class UndoManager;
193class VisibilityChangeClient;
194class VisitedLinkState;
195class WebAnimation;
196class WebGL2RenderingContext;
197class WebGLRenderingContext;
198class GPUCanvasContext;
199class WindowProxy;
200class Worklet;
201class XPathEvaluator;
202class XPathExpression;
203class XPathNSResolver;
204class XPathResult;
205
206template<typename> class ExceptionOr;
207
208enum CollectionType;
209enum class ShouldOpenExternalURLsPolicy : uint8_t;
210
211enum class RouteSharingPolicy : uint8_t;
212
213using PlatformDisplayID = uint32_t;
214
215#if ENABLE(XSLT)
216class TransformSource;
217#endif
218
219#if ENABLE(DASHBOARD_SUPPORT)
220struct AnnotatedRegionValue;
221#endif
222
223#if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
224class Touch;
225class TouchList;
226#endif
227
228#if ENABLE(DEVICE_ORIENTATION)
229#if PLATFORM(IOS_FAMILY)
230class DeviceMotionClient;
231class DeviceMotionController;
232class DeviceOrientationClient;
233class DeviceOrientationController;
234#endif
235class DeviceOrientationAndMotionAccessController;
236#endif
237
238#if ENABLE(TEXT_AUTOSIZING)
239class TextAutoSizing;
240#endif
241
242#if ENABLE(MEDIA_SESSION)
243class MediaSession;
244#endif
245
246#if ENABLE(ATTACHMENT_ELEMENT)
247class HTMLAttachmentElement;
248#endif
249
250#if ENABLE(INTERSECTION_OBSERVER)
251class IntersectionObserver;
252#endif
253
254#if ENABLE(RESIZE_OBSERVER)
255class ResizeObserver;
256#endif
257
258namespace Style {
259class Scope;
260};
261
262const uint64_t HTMLMediaElementInvalidID = 0;
263
264enum PageshowEventPersistence { PageshowEventNotPersisted, PageshowEventPersisted };
265
266enum NodeListInvalidationType {
267 DoNotInvalidateOnAttributeChanges,
268 InvalidateOnClassAttrChange,
269 InvalidateOnIdNameAttrChange,
270 InvalidateOnNameAttrChange,
271 InvalidateOnForTypeAttrChange,
272 InvalidateForFormControls,
273 InvalidateOnHRefAttrChange,
274 InvalidateOnAnyAttrChange,
275};
276const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
277
278enum class EventHandlerRemoval { One, All };
279typedef HashCountedSet<Node*> EventTargetSet;
280
281enum DocumentClass {
282 DefaultDocumentClass = 0,
283 HTMLDocumentClass = 1,
284 XHTMLDocumentClass = 1 << 1,
285 ImageDocumentClass = 1 << 2,
286 PluginDocumentClass = 1 << 3,
287 MediaDocumentClass = 1 << 4,
288 SVGDocumentClass = 1 << 5,
289 TextDocumentClass = 1 << 6,
290 XMLDocumentClass = 1 << 7,
291};
292typedef unsigned char DocumentClassFlags;
293
294enum class DocumentCompatibilityMode : unsigned char {
295 NoQuirksMode = 1,
296 QuirksMode = 1 << 1,
297 LimitedQuirksMode = 1 << 2
298};
299
300enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
301
302enum class SelectionRestorationMode { Restore, SetDefault };
303
304enum class HttpEquivPolicy {
305 Enabled,
306 DisabledBySettings,
307 DisabledByContentDispositionAttachmentSandbox
308};
309
310enum class CustomElementNameValidationStatus {
311 Valid,
312 FirstCharacterIsNotLowercaseASCIILetter,
313 ContainsNoHyphen,
314 ContainsUppercaseASCIILetter,
315 ContainsDisallowedCharacter,
316 ConflictsWithStandardElementName
317};
318
319using RenderingContext = Variant<
320#if ENABLE(WEBGL)
321 RefPtr<WebGLRenderingContext>,
322#endif
323#if ENABLE(WEBGL2)
324 RefPtr<WebGL2RenderingContext>,
325#endif
326#if ENABLE(WEBGPU)
327 RefPtr<GPUCanvasContext>,
328#endif
329 RefPtr<ImageBitmapRenderingContext>,
330 RefPtr<CanvasRenderingContext2D>
331>;
332
333class DocumentParserYieldToken {
334 WTF_MAKE_FAST_ALLOCATED;
335public:
336 WEBCORE_EXPORT DocumentParserYieldToken(Document&);
337 WEBCORE_EXPORT ~DocumentParserYieldToken();
338
339private:
340 WeakPtr<Document> m_document;
341};
342
343class Document
344 : public ContainerNode
345 , public TreeScope
346 , public ScriptExecutionContext
347 , public FontSelectorClient
348 , public CanMakeWeakPtr<Document>
349 , public FrameDestructionObserver
350 , public Supplementable<Document>
351 , public Logger::Observer {
352 WTF_MAKE_ISO_ALLOCATED(Document);
353public:
354 static Ref<Document> create(const URL&);
355 static Ref<Document> createNonRenderedPlaceholder(Frame&, const URL&);
356 static Ref<Document> create(Document&);
357
358 virtual ~Document();
359
360 // Nodes belonging to this document increase referencingNodeCount -
361 // these are enough to keep the document from being destroyed, but
362 // not enough to keep it from removing its children. This allows a
363 // node that outlives its document to still have a valid document
364 // pointer without introducing reference cycles.
365 void incrementReferencingNodeCount()
366 {
367 ASSERT(!m_deletionHasBegun);
368 ++m_referencingNodeCount;
369 }
370
371 void decrementReferencingNodeCount()
372 {
373 ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
374 --m_referencingNodeCount;
375 if (!m_referencingNodeCount && !refCount()) {
376#if !ASSERT_DISABLED
377 m_deletionHasBegun = true;
378#endif
379 m_refCountAndParentBit = s_refCountIncrement; // Avoid double destruction through use of Ref<T>/RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.)
380 delete this;
381 }
382 }
383
384 unsigned referencingNodeCount() const { return m_referencingNodeCount; }
385
386 void removedLastRef();
387
388 DocumentIdentifier identifier() const { return m_identifier; }
389
390 using DocumentsMap = HashMap<DocumentIdentifier, Document*>;
391 WEBCORE_EXPORT static DocumentsMap::ValuesIteratorRange allDocuments();
392 WEBCORE_EXPORT static DocumentsMap& allDocumentsMap();
393
394 WEBCORE_EXPORT ElementIdentifier identifierForElement(Element&);
395 WEBCORE_EXPORT Element* searchForElementByIdentifier(const ElementIdentifier&);
396 void identifiedElementWasRemovedFromDocument(Element&);
397
398 MediaQueryMatcher& mediaQueryMatcher();
399
400 using ContainerNode::ref;
401 using ContainerNode::deref;
402 using TreeScope::rootNode;
403
404 bool canContainRangeEndPoint() const final { return true; }
405
406 Element* elementForAccessKey(const String& key);
407 void invalidateAccessKeyCache();
408
409 ExceptionOr<SelectorQuery&> selectorQueryForString(const String&);
410 void clearSelectorQueryCache();
411
412 void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
413 WEBCORE_EXPORT ViewportArguments viewportArguments() const;
414
415 OptionSet<DisabledAdaptations> disabledAdaptations() const { return m_disabledAdaptations; }
416#ifndef NDEBUG
417 bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
418#endif
419
420 void setReferrerPolicy(ReferrerPolicy);
421 ReferrerPolicy referrerPolicy() const { return m_referrerPolicy.valueOr(ReferrerPolicy::NoReferrerWhenDowngrade); }
422
423 WEBCORE_EXPORT DocumentType* doctype() const;
424
425 WEBCORE_EXPORT DOMImplementation& implementation();
426
427 Element* documentElement() const { return m_documentElement.get(); }
428 static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
429
430 WEBCORE_EXPORT Element* activeElement();
431 WEBCORE_EXPORT bool hasFocus() const;
432
433 bool hasManifest() const;
434
435 WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementForBindings(const AtomicString& tagName);
436 WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
437 WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
438 WEBCORE_EXPORT Ref<Comment> createComment(const String& data);
439 WEBCORE_EXPORT ExceptionOr<Ref<CDATASection>> createCDATASection(const String& data);
440 WEBCORE_EXPORT ExceptionOr<Ref<ProcessingInstruction>> createProcessingInstruction(const String& target, const String& data);
441 WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttribute(const String& name);
442 WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttributeNS(const AtomicString& namespaceURI, const String& qualifiedName, bool shouldIgnoreNamespaceChecks = false);
443 WEBCORE_EXPORT ExceptionOr<Ref<Node>> importNode(Node& nodeToImport, bool deep);
444 WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementNS(const AtomicString& namespaceURI, const String& qualifiedName);
445 WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
446
447 static CustomElementNameValidationStatus validateCustomElementName(const AtomicString&);
448
449 WEBCORE_EXPORT RefPtr<Range> caretRangeFromPoint(int x, int y);
450 RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
451
452 WEBCORE_EXPORT Element* scrollingElementForAPI();
453 Element* scrollingElement();
454
455 enum ReadyState { Loading, Interactive, Complete };
456 ReadyState readyState() const { return m_readyState; }
457
458 WEBCORE_EXPORT String defaultCharsetForLegacyBindings() const;
459
460 String charset() const { return Document::encoding(); }
461 WEBCORE_EXPORT String characterSetWithUTF8Fallback() const;
462 TextEncoding textEncoding() const;
463
464 AtomicString encoding() const { return textEncoding().domName(); }
465
466 WEBCORE_EXPORT void setCharset(const String&); // Used by ObjC / GOBject bindings only.
467
468 void setContent(const String&);
469
470 String suggestedMIMEType() const;
471
472 void overrideMIMEType(const String&);
473 WEBCORE_EXPORT String contentType() const;
474
475 String contentLanguage() const { return m_contentLanguage; }
476 void setContentLanguage(const String&);
477
478 String xmlEncoding() const { return m_xmlEncoding; }
479 String xmlVersion() const { return m_xmlVersion; }
480 enum class StandaloneStatus : uint8_t { Unspecified, Standalone, NotStandalone };
481 bool xmlStandalone() const { return m_xmlStandalone == StandaloneStatus::Standalone; }
482 StandaloneStatus xmlStandaloneStatus() const { return m_xmlStandalone; }
483 bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
484
485 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
486 WEBCORE_EXPORT ExceptionOr<void> setXMLVersion(const String&);
487 WEBCORE_EXPORT void setXMLStandalone(bool);
488 void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration; }
489
490 String documentURI() const { return m_documentURI; }
491 WEBCORE_EXPORT void setDocumentURI(const String&);
492
493 WEBCORE_EXPORT VisibilityState visibilityState() const;
494 void visibilityStateChanged();
495 WEBCORE_EXPORT bool hidden() const;
496
497 void setTimerThrottlingEnabled(bool);
498 bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
499
500 WEBCORE_EXPORT ExceptionOr<Ref<Node>> adoptNode(Node& source);
501
502 WEBCORE_EXPORT Ref<HTMLCollection> images();
503 WEBCORE_EXPORT Ref<HTMLCollection> embeds();
504 WEBCORE_EXPORT Ref<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
505 WEBCORE_EXPORT Ref<HTMLCollection> applets();
506 WEBCORE_EXPORT Ref<HTMLCollection> links();
507 WEBCORE_EXPORT Ref<HTMLCollection> forms();
508 WEBCORE_EXPORT Ref<HTMLCollection> anchors();
509 WEBCORE_EXPORT Ref<HTMLCollection> scripts();
510 Ref<HTMLCollection> all();
511 Ref<HTMLCollection> allFilteredByName(const AtomicString&);
512
513 Ref<HTMLCollection> windowNamedItems(const AtomicString&);
514 Ref<HTMLCollection> documentNamedItems(const AtomicString&);
515
516 // Other methods (not part of DOM)
517 bool isSynthesized() const { return m_isSynthesized; }
518 bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
519 bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
520 bool isXMLDocument() const { return m_documentClasses & XMLDocumentClass; }
521 bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
522 bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
523 bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
524 bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
525 bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
526 bool hasSVGRootNode() const;
527 virtual bool isFrameSet() const { return false; }
528
529 static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
530 static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
531
532 bool isSrcdocDocument() const { return m_isSrcdocDocument; }
533
534 bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
535
536 StyleResolver& userAgentShadowTreeStyleResolver();
537
538 CSSFontSelector& fontSelector() { return m_fontSelector; }
539
540 WEBCORE_EXPORT bool haveStylesheetsLoaded() const;
541 bool isIgnoringPendingStylesheets() const { return m_ignorePendingStylesheets; }
542
543 WEBCORE_EXPORT StyleSheetList& styleSheets();
544
545 Style::Scope& styleScope() { return *m_styleScope; }
546 const Style::Scope& styleScope() const { return *m_styleScope; }
547 ExtensionStyleSheets& extensionStyleSheets() { return *m_extensionStyleSheets; }
548 const ExtensionStyleSheets& extensionStyleSheets() const { return *m_extensionStyleSheets; }
549
550 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
551 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
552
553 void evaluateMediaQueryList();
554
555 FormController& formController();
556 Vector<String> formElementsState() const;
557 void setStateForNewFormElements(const Vector<String>&);
558
559 WEBCORE_EXPORT FrameView* view() const; // Can be null.
560 WEBCORE_EXPORT Page* page() const; // Can be null.
561 const Settings& settings() const { return m_settings.get(); }
562 Settings& mutableSettings() { return m_settings.get(); }
563 EditingBehavior editingBehavior() const;
564
565 const Quirks& quirks() const { return m_quirks; }
566
567 float deviceScaleFactor() const;
568
569 WEBCORE_EXPORT bool useSystemAppearance() const;
570 WEBCORE_EXPORT bool useInactiveAppearance() const;
571 WEBCORE_EXPORT bool useDarkAppearance(const RenderStyle*) const;
572
573 OptionSet<StyleColor::Options> styleColorOptions(const RenderStyle*) const;
574
575 WEBCORE_EXPORT Ref<Range> createRange();
576
577 // The last bool parameter is for ObjC bindings.
578 WEBCORE_EXPORT Ref<NodeIterator> createNodeIterator(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
579
580 // The last bool parameter is for ObjC bindings.
581 WEBCORE_EXPORT Ref<TreeWalker> createTreeWalker(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
582
583 // Special support for editing
584 WEBCORE_EXPORT Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
585 Ref<Text> createEditingTextNode(const String&);
586
587 enum class ResolveStyleType { Normal, Rebuild };
588 void resolveStyle(ResolveStyleType = ResolveStyleType::Normal);
589 WEBCORE_EXPORT bool updateStyleIfNeeded();
590 bool needsStyleRecalc() const;
591 unsigned lastStyleUpdateSizeForTesting() const { return m_lastStyleUpdateSizeForTesting; }
592
593 WEBCORE_EXPORT void updateLayout();
594
595 // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads,
596 // so calling this may cause a flash of unstyled content (FOUC).
597 enum class RunPostLayoutTasks { Asynchronously, Synchronously };
598 WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
599
600 std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle, PseudoId = PseudoId::None);
601
602 // Returns true if page box (margin boxes and page borders) is visible.
603 WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);
604
605 // Returns the preferred page size and margins in pixels, assuming 96
606 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
607 // marginLeft must be initialized to the default values that are used if
608 // auto is specified.
609 WEBCORE_EXPORT void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
610
611 CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader; }
612
613 void didBecomeCurrentDocumentInFrame();
614 void destroyRenderTree();
615 void prepareForDestruction();
616
617 // Override ScriptExecutionContext methods to do additional work
618 WEBCORE_EXPORT bool shouldBypassMainWorldContentSecurityPolicy() const final;
619 void suspendActiveDOMObjects(ReasonForSuspension) final;
620 void resumeActiveDOMObjects(ReasonForSuspension) final;
621 void stopActiveDOMObjects() final;
622
623 void suspendDeviceMotionAndOrientationUpdates();
624 void resumeDeviceMotionAndOrientationUpdates();
625
626 RenderView* renderView() const { return m_renderView.get(); }
627
628 bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
629 bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
630
631 bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
632
633 AXObjectCache* existingAXObjectCache() const;
634 WEBCORE_EXPORT AXObjectCache* axObjectCache() const;
635 void clearAXObjectCache();
636
637 Optional<uint64_t> pageID() const;
638 // to get visually ordered hebrew and arabic pages right
639 void setVisuallyOrdered();
640 bool visuallyOrdered() const { return m_visuallyOrdered; }
641
642 WEBCORE_EXPORT DocumentLoader* loader() const;
643
644 WEBCORE_EXPORT ExceptionOr<RefPtr<WindowProxy>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstDOMWindow, const String& url, const AtomicString& name, const String& features);
645 WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String&, const String&);
646
647 // FIXME: We should rename this at some point and give back the name 'open' to the HTML specified ones.
648 WEBCORE_EXPORT ExceptionOr<void> open(Document* responsibleDocument = nullptr);
649 void implicitOpen();
650
651 WEBCORE_EXPORT ExceptionOr<void> closeForBindings();
652
653 // FIXME: We should rename this at some point and give back the name 'close' to the HTML specified one.
654 WEBCORE_EXPORT void close();
655 // In some situations (see the code), we ignore document.close().
656 // explicitClose() bypass these checks and actually tries to close the
657 // input stream.
658 void explicitClose();
659 // implicitClose() actually does the work of closing the input stream.
660 void implicitClose();
661
662 void cancelParsing();
663
664 ExceptionOr<void> write(Document* responsibleDocument, SegmentedString&&);
665 WEBCORE_EXPORT ExceptionOr<void> write(Document* responsibleDocument, Vector<String>&&);
666 WEBCORE_EXPORT ExceptionOr<void> writeln(Document* responsibleDocument, Vector<String>&&);
667
668 bool wellFormed() const { return m_wellFormed; }
669
670 const URL& url() const final { return m_url; }
671 void setURL(const URL&);
672 const URL& urlForBindings() const { return m_url.isEmpty() ? WTF::blankURL() : m_url; }
673
674 // To understand how these concepts relate to one another, please see the
675 // comments surrounding their declaration.
676 const URL& baseURL() const { return m_baseURL; }
677 void setBaseURLOverride(const URL&);
678 const URL& baseURLOverride() const { return m_baseURLOverride; }
679 const URL& baseElementURL() const { return m_baseElementURL; }
680 const String& baseTarget() const { return m_baseTarget; }
681 void processBaseElement();
682
683 WEBCORE_EXPORT URL completeURL(const String&) const final;
684 URL completeURL(const String&, const URL& baseURLOverride) const;
685 WEBCORE_EXPORT PAL::SessionID sessionID() const final;
686
687 String userAgent(const URL&) const final;
688
689 void disableEval(const String& errorMessage) final;
690 void disableWebAssembly(const String& errorMessage) final;
691
692#if ENABLE(INDEXED_DATABASE)
693 IDBClient::IDBConnectionProxy* idbConnectionProxy() final;
694#endif
695 SocketProvider* socketProvider() final;
696
697 bool canNavigate(Frame* targetFrame, const URL& destinationURL = URL());
698
699 bool usesStyleBasedEditability() const;
700 void setHasElementUsingStyleBasedEditability();
701
702 virtual Ref<DocumentParser> createParser();
703 DocumentParser* parser() const { return m_parser.get(); }
704 ScriptableDocumentParser* scriptableDocumentParser() const;
705
706 bool printing() const { return m_printing; }
707 void setPrinting(bool p) { m_printing = p; }
708
709 bool paginatedForScreen() const { return m_paginatedForScreen; }
710 void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
711
712 bool paginated() const { return printing() || paginatedForScreen(); }
713
714 void setCompatibilityMode(DocumentCompatibilityMode);
715 void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
716 static ptrdiff_t compatibilityModeMemoryOffset() { return OBJECT_OFFSETOF(Document, m_compatibilityMode); }
717
718 WEBCORE_EXPORT String compatMode() const;
719
720 bool inQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::QuirksMode; }
721 bool inLimitedQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::LimitedQuirksMode; }
722 bool inNoQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::NoQuirksMode; }
723
724 void setReadyState(ReadyState);
725 void setParsing(bool);
726 bool parsing() const { return m_bParsing; }
727 Seconds minimumLayoutDelay();
728
729 bool shouldScheduleLayout();
730 bool isLayoutTimerActive();
731 Seconds timeSinceDocumentCreation() const;
732
733 void setTextColor(const Color& color) { m_textColor = color; }
734 const Color& textColor() const { return m_textColor; }
735
736 const Color& linkColor() const { return m_linkColor; }
737 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
738 const Color& activeLinkColor() const { return m_activeLinkColor; }
739 void setLinkColor(const Color& c) { m_linkColor = c; }
740 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
741 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
742 void resetLinkColor();
743 void resetVisitedLinkColor();
744 void resetActiveLinkColor();
745 VisitedLinkState& visitedLinkState() const { return *m_visitedLinkState; }
746
747 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
748
749 enum class FocusRemovalEventsMode { Dispatch, DoNotDispatch };
750 WEBCORE_EXPORT bool setFocusedElement(Element*, FocusDirection = FocusDirectionNone,
751 FocusRemovalEventsMode = FocusRemovalEventsMode::Dispatch);
752 Element* focusedElement() const { return m_focusedElement.get(); }
753 UserActionElementSet& userActionElements() { return m_userActionElements; }
754 const UserActionElementSet& userActionElements() const { return m_userActionElements; }
755
756 void setFocusNavigationStartingNode(Node*);
757 Element* focusNavigationStartingNode(FocusDirection) const;
758
759 enum class NodeRemoval { Node, ChildrenOfNode };
760 void adjustFocusedNodeOnNodeRemoval(Node&, NodeRemoval = NodeRemoval::Node);
761 void adjustFocusNavigationNodeOnNodeRemoval(Node&, NodeRemoval = NodeRemoval::Node);
762
763 void hoveredElementDidDetach(Element&);
764 void elementInActiveChainDidDetach(Element&);
765
766 void updateHoverActiveState(const HitTestRequest&, Element*);
767
768 // Updates for :target (CSS3 selector).
769 void setCSSTarget(Element*);
770 Element* cssTarget() const { return m_cssTarget; }
771 static ptrdiff_t cssTargetMemoryOffset() { return OBJECT_OFFSETOF(Document, m_cssTarget); }
772
773 WEBCORE_EXPORT void scheduleFullStyleRebuild();
774 void scheduleStyleRecalc();
775 void unscheduleStyleRecalc();
776 bool hasPendingStyleRecalc() const;
777 bool hasPendingFullStyleRebuild() const;
778
779 void registerNodeListForInvalidation(LiveNodeList&);
780 void unregisterNodeListForInvalidation(LiveNodeList&);
781 WEBCORE_EXPORT void registerCollection(HTMLCollection&);
782 void unregisterCollection(HTMLCollection&);
783 void collectionCachedIdNameMap(const HTMLCollection&);
784 void collectionWillClearIdNameMap(const HTMLCollection&);
785 bool shouldInvalidateNodeListAndCollectionCaches() const;
786 bool shouldInvalidateNodeListAndCollectionCachesForAttribute(const QualifiedName& attrName) const;
787
788 template <typename InvalidationFunction>
789 void invalidateNodeListAndCollectionCaches(InvalidationFunction);
790
791 void attachNodeIterator(NodeIterator&);
792 void detachNodeIterator(NodeIterator&);
793 void moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
794 {
795 if (!m_nodeIterators.isEmpty())
796 moveNodeIteratorsToNewDocumentSlowCase(node, newDocument);
797 }
798
799 void attachRange(Range&);
800 void detachRange(Range&);
801
802 void updateRangesAfterChildrenChanged(ContainerNode&);
803 // nodeChildrenWillBeRemoved is used when removing all node children at once.
804 void nodeChildrenWillBeRemoved(ContainerNode&);
805 // nodeWillBeRemoved is only safe when removing one node at a time.
806 void nodeWillBeRemoved(Node&);
807
808 enum class AcceptChildOperation { Replace, InsertOrAdd };
809 bool canAcceptChild(const Node& newChild, const Node* refChild, AcceptChildOperation) const;
810
811 void textInserted(Node&, unsigned offset, unsigned length);
812 void textRemoved(Node&, unsigned offset, unsigned length);
813 void textNodesMerged(Text& oldNode, unsigned offset);
814 void textNodeSplit(Text& oldNode);
815
816 void createDOMWindow();
817 void takeDOMWindowFrom(Document&);
818
819 DOMWindow* domWindow() const { return m_domWindow.get(); }
820 // In DOM Level 2, the Document's DOMWindow is called the defaultView.
821 WEBCORE_EXPORT WindowProxy* windowProxy() const;
822
823 bool hasBrowsingContext() const { return !!frame(); }
824
825 Document& contextDocument() const;
826 void setContextDocument(Document& document) { m_contextDocument = makeWeakPtr(document); }
827
828 // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
829 void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld&);
830 void setWindowAttributeEventListener(const AtomicString& eventType, RefPtr<EventListener>&&, DOMWrapperWorld&);
831 EventListener* getWindowAttributeEventListener(const AtomicString& eventType, DOMWrapperWorld&);
832 WEBCORE_EXPORT void dispatchWindowEvent(Event&, EventTarget* = nullptr);
833 void dispatchWindowLoadEvent();
834
835 WEBCORE_EXPORT ExceptionOr<Ref<Event>> createEvent(const String& eventType);
836
837 // keep track of what types of event listeners are registered, so we don't
838 // dispatch events unnecessarily
839 enum ListenerType {
840 DOMSUBTREEMODIFIED_LISTENER = 1,
841 DOMNODEINSERTED_LISTENER = 1 << 1,
842 DOMNODEREMOVED_LISTENER = 1 << 2,
843 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
844 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
845 DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
846 OVERFLOWCHANGED_LISTENER = 1 << 6,
847 ANIMATIONEND_LISTENER = 1 << 7,
848 ANIMATIONSTART_LISTENER = 1 << 8,
849 ANIMATIONITERATION_LISTENER = 1 << 9,
850 TRANSITIONEND_LISTENER = 1 << 10,
851 BEFORELOAD_LISTENER = 1 << 11,
852 SCROLL_LISTENER = 1 << 12,
853 FORCEWILLBEGIN_LISTENER = 1 << 13,
854 FORCECHANGED_LISTENER = 1 << 14,
855 FORCEDOWN_LISTENER = 1 << 15,
856 FORCEUP_LISTENER = 1 << 16,
857 RESIZE_LISTENER = 1 << 17
858 };
859
860 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
861 bool hasListenerTypeForEventType(PlatformEvent::Type) const;
862 void addListenerTypeIfNeeded(const AtomicString& eventType);
863
864 bool hasMutationObserversOfType(MutationObserver::MutationType type) const
865 {
866 return m_mutationObserverTypes & type;
867 }
868 bool hasMutationObservers() const { return m_mutationObserverTypes; }
869 void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
870
871 CSSStyleDeclaration* getOverrideStyle(Element*, const String&) { return nullptr; }
872
873 // Handles an HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
874 // when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
875 // tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
876 // specified in an HTML file.
877 void processHttpEquiv(const String& equiv, const String& content, bool isInDocumentHead);
878
879#if PLATFORM(IOS_FAMILY)
880 void processFormatDetection(const String&);
881
882 // Called when <meta name="apple-mobile-web-app-orientations"> changes.
883 void processWebAppOrientations();
884
885 WEBCORE_EXPORT ContentChangeObserver& contentChangeObserver();
886#endif
887
888 void processViewport(const String& features, ViewportArguments::Type origin);
889 void processDisabledAdaptations(const String& adaptations);
890 void updateViewportArguments();
891 void processReferrerPolicy(const String& policy, ReferrerPolicySource);
892
893#if ENABLE(DARK_MODE_CSS)
894 void processColorScheme(const String& colorScheme);
895#endif
896
897 // Returns the owning element in the parent document.
898 // Returns nullptr if this is the top level document.
899 HTMLFrameOwnerElement* ownerElement() const;
900
901 // Used by DOM bindings; no direction known.
902 const String& title() const { return m_title.string; }
903 WEBCORE_EXPORT void setTitle(const String&);
904
905 WEBCORE_EXPORT const AtomicString& dir() const;
906 WEBCORE_EXPORT void setDir(const AtomicString&);
907
908 void titleElementAdded(Element& titleElement);
909 void titleElementRemoved(Element& titleElement);
910 void titleElementTextChanged(Element& titleElement);
911
912 WEBCORE_EXPORT ExceptionOr<String> cookie();
913 WEBCORE_EXPORT ExceptionOr<void> setCookie(const String&);
914
915 WEBCORE_EXPORT String referrer() const;
916
917 WEBCORE_EXPORT String origin() const final;
918
919 WEBCORE_EXPORT String domain() const;
920 ExceptionOr<void> setDomain(const String& newDomain);
921
922 void overrideLastModified(const Optional<WallTime>&);
923 WEBCORE_EXPORT String lastModified() const;
924
925 // The cookieURL is used to query the cookie database for this document's
926 // cookies. For example, if the cookie URL is http://example.com, we'll
927 // use the non-Secure cookies for example.com when computing
928 // document.cookie.
929 //
930 // Q: How is the cookieURL different from the document's URL?
931 // A: The two URLs are the same almost all the time. However, if one
932 // document inherits the security context of another document, it
933 // inherits its cookieURL but not its URL.
934 //
935 const URL& cookieURL() const { return m_cookieURL; }
936 void setCookieURL(const URL&);
937
938 // The firstPartyForCookies is used to compute whether this document
939 // appears in a "third-party" context for the purpose of third-party
940 // cookie blocking. The document is in a third-party context if the
941 // cookieURL and the firstPartyForCookies are from different hosts.
942 //
943 // Note: Some ports (including possibly Apple's) only consider the
944 // document in a third-party context if the cookieURL and the
945 // firstPartyForCookies have a different registry-controlled
946 // domain.
947 //
948 const URL& firstPartyForCookies() const { return m_firstPartyForCookies; }
949 void setFirstPartyForCookies(const URL& url) { m_firstPartyForCookies = url; }
950
951 bool isFullyActive() const;
952
953 // The full URL corresponding to the "site for cookies" in the Same-Site Cookies spec.,
954 // <https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00>. It is either
955 // the URL of the top-level document or the null URL depending on whether the registrable
956 // domain of this document's URL matches the registrable domain of its parent's/opener's
957 // URL. For the top-level document, it is set to the document's URL.
958 const URL& siteForCookies() const { return m_siteForCookies; }
959 void setSiteForCookies(const URL& url) { m_siteForCookies = url; }
960
961 // The following implements the rule from HTML 4 for what valid names are.
962 // To get this right for all the XML cases, we probably have to improve this or move it
963 // and make it sensitive to the type of document.
964 static bool isValidName(const String&);
965
966 // The following breaks a qualified name into a prefix and a local name.
967 // It also does a validity check, and returns an error if the qualified name is invalid.
968 static ExceptionOr<std::pair<AtomicString, AtomicString>> parseQualifiedName(const String& qualifiedName);
969 static ExceptionOr<QualifiedName> parseQualifiedName(const AtomicString& namespaceURI, const String& qualifiedName);
970
971 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
972 static bool hasValidNamespaceForElements(const QualifiedName&);
973 static bool hasValidNamespaceForAttributes(const QualifiedName&);
974
975 // This is the "HTML body element" as defined by CSSOM View spec, the first body child of the
976 // document element. See http://dev.w3.org/csswg/cssom-view/#the-html-body-element.
977 WEBCORE_EXPORT HTMLBodyElement* body() const;
978
979 // This is the "body element" as defined by HTML5, the first body or frameset child of the
980 // document element. See https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2.
981 WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
982 WEBCORE_EXPORT ExceptionOr<void> setBodyOrFrameset(RefPtr<HTMLElement>&&);
983
984 Location* location() const;
985
986 WEBCORE_EXPORT HTMLHeadElement* head();
987
988 DocumentMarkerController& markers() const { return *m_markers; }
989
990 WEBCORE_EXPORT bool execCommand(const String& command, bool userInterface = false, const String& value = String());
991 WEBCORE_EXPORT bool queryCommandEnabled(const String& command);
992 WEBCORE_EXPORT bool queryCommandIndeterm(const String& command);
993 WEBCORE_EXPORT bool queryCommandState(const String& command);
994 WEBCORE_EXPORT bool queryCommandSupported(const String& command);
995 WEBCORE_EXPORT String queryCommandValue(const String& command);
996
997 UndoManager& undoManager() const { return m_undoManager.get(); }
998
999 // designMode support
1000 enum InheritedBool { off = false, on = true, inherit };
1001 void setDesignMode(InheritedBool value);
1002 InheritedBool getDesignMode() const;
1003 bool inDesignMode() const;
1004 WEBCORE_EXPORT String designMode() const;
1005 WEBCORE_EXPORT void setDesignMode(const String&);
1006
1007 Document* parentDocument() const;
1008 WEBCORE_EXPORT Document& topDocument() const;
1009
1010 ScriptRunner& scriptRunner() { return *m_scriptRunner; }
1011 ScriptModuleLoader& moduleLoader() { return *m_moduleLoader; }
1012
1013 HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
1014 void pushCurrentScript(HTMLScriptElement*);
1015 void popCurrentScript();
1016
1017 bool shouldDeferAsynchronousScriptsUntilParsingFinishes() const;
1018
1019#if ENABLE(XSLT)
1020 void scheduleToApplyXSLTransforms();
1021 void applyPendingXSLTransformsNowIfScheduled();
1022 RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
1023 void setTransformSourceDocument(Document* document) { m_transformSourceDocument = document; }
1024
1025 void setTransformSource(std::unique_ptr<TransformSource>);
1026 TransformSource* transformSource() const { return m_transformSource.get(); }
1027#endif
1028
1029 void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
1030 uint64_t domTreeVersion() const { return m_domTreeVersion; }
1031
1032 WEBCORE_EXPORT String originIdentifierForPasteboard();
1033
1034 // XPathEvaluator methods
1035 WEBCORE_EXPORT ExceptionOr<Ref<XPathExpression>> createExpression(const String& expression, RefPtr<XPathNSResolver>&&);
1036 WEBCORE_EXPORT Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
1037 WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(const String& expression, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
1038
1039 bool hasNodesWithNonFinalStyle() const { return m_hasNodesWithNonFinalStyle; }
1040 void setHasNodesWithNonFinalStyle() { m_hasNodesWithNonFinalStyle = true; }
1041 bool hasNodesWithMissingStyle() const { return m_hasNodesWithMissingStyle; }
1042 void setHasNodesWithMissingStyle() { m_hasNodesWithMissingStyle = true; }
1043
1044 // Extension for manipulating canvas drawing contexts for use in CSS
1045 Optional<RenderingContext> getCSSCanvasContext(const String& type, const String& name, int width, int height);
1046 HTMLCanvasElement* getCSSCanvasElement(const String& name);
1047 String nameForCSSCanvasElement(const HTMLCanvasElement&) const;
1048
1049 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
1050 void parseDNSPrefetchControlHeader(const String&);
1051
1052 WEBCORE_EXPORT void postTask(Task&&) final; // Executes the task on context's thread asynchronously.
1053
1054 ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
1055 void suspendScriptedAnimationControllerCallbacks();
1056 void resumeScriptedAnimationControllerCallbacks();
1057
1058 void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
1059 void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
1060
1061 void windowScreenDidChange(PlatformDisplayID);
1062
1063 void finishedParsing();
1064
1065 enum PageCacheState { NotInPageCache, AboutToEnterPageCache, InPageCache };
1066
1067 PageCacheState pageCacheState() const { return m_pageCacheState; }
1068 void setPageCacheState(PageCacheState);
1069
1070 void registerForDocumentSuspensionCallbacks(Element&);
1071 void unregisterForDocumentSuspensionCallbacks(Element&);
1072
1073 void documentWillBecomeInactive();
1074 void suspend(ReasonForSuspension);
1075 void resume(ReasonForSuspension);
1076
1077 void registerForMediaVolumeCallbacks(Element&);
1078 void unregisterForMediaVolumeCallbacks(Element&);
1079 void mediaVolumeDidChange();
1080
1081 bool audioPlaybackRequiresUserGesture() const;
1082 bool videoPlaybackRequiresUserGesture() const;
1083
1084#if ENABLE(MEDIA_SESSION)
1085 MediaSession& defaultMediaSession();
1086#endif
1087
1088 void registerForPrivateBrowsingStateChangedCallbacks(Element&);
1089 void unregisterForPrivateBrowsingStateChangedCallbacks(Element&);
1090 void storageBlockingStateDidChange();
1091 void privateBrowsingStateDidChange();
1092
1093#if ENABLE(VIDEO_TRACK)
1094 void registerForCaptionPreferencesChangedCallbacks(Element&);
1095 void unregisterForCaptionPreferencesChangedCallbacks(Element&);
1096 void captionPreferencesChanged();
1097#endif
1098
1099#if ENABLE(MEDIA_CONTROLS_SCRIPT)
1100 void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement&);
1101 void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement&);
1102 void pageScaleFactorChangedAndStable();
1103 void registerForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
1104 void unregisterForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
1105 void userInterfaceLayoutDirectionChanged();
1106#endif
1107
1108 void registerForVisibilityStateChangedCallbacks(VisibilityChangeClient&);
1109 void unregisterForVisibilityStateChangedCallbacks(VisibilityChangeClient&);
1110
1111#if ENABLE(VIDEO)
1112 void registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1113 void unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1114 void allowsMediaDocumentInlinePlaybackChanged();
1115
1116 void stopAllMediaPlayback();
1117 void suspendAllMediaPlayback();
1118 void resumeAllMediaPlayback();
1119 void suspendAllMediaBuffering();
1120 void resumeAllMediaBuffering();
1121#endif
1122
1123 WEBCORE_EXPORT void setShouldCreateRenderers(bool);
1124 bool shouldCreateRenderers();
1125
1126 void setDecoder(RefPtr<TextResourceDecoder>&&);
1127 TextResourceDecoder* decoder() const { return m_decoder.get(); }
1128
1129 WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
1130
1131#if ENABLE(DASHBOARD_SUPPORT)
1132 void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
1133 WEBCORE_EXPORT const Vector<AnnotatedRegionValue>& annotatedRegions() const;
1134#endif
1135
1136 enum class AnnotationsAction { Invalidate, Update };
1137 void invalidateRenderingDependentRegions(AnnotationsAction = AnnotationsAction::Invalidate);
1138 void invalidateScrollbarDependentRegions();
1139 void updateZOrderDependentRegions();
1140
1141 void removeAllEventListeners() final;
1142
1143 WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
1144 WEBCORE_EXPORT SVGDocumentExtensions& accessSVGExtensions();
1145
1146 void addSVGUseElement(SVGUseElement&);
1147 void removeSVGUseElement(SVGUseElement&);
1148 HashSet<SVGUseElement*> const svgUseElements() const { return m_svgUseElements; }
1149
1150 void initSecurityContext();
1151 void initContentSecurityPolicy();
1152
1153 void updateURLForPushOrReplaceState(const URL&);
1154 void statePopped(Ref<SerializedScriptValue>&&);
1155
1156 bool processingLoadEvent() const { return m_processingLoadEvent; }
1157 bool loadEventFinished() const { return m_loadEventFinished; }
1158
1159 bool isContextThread() const final;
1160 bool isSecureContext() const final;
1161 bool isJSExecutionForbidden() const final { return false; }
1162
1163 void enqueueWindowEvent(Ref<Event>&&);
1164 void enqueueDocumentEvent(Ref<Event>&&);
1165 void enqueueOverflowEvent(Ref<Event>&&);
1166 void dispatchPageshowEvent(PageshowEventPersistence);
1167 WEBCORE_EXPORT void enqueueSecurityPolicyViolationEvent(SecurityPolicyViolationEvent::Init&&);
1168 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
1169 void dispatchPopstateEvent(RefPtr<SerializedScriptValue>&& stateObject);
1170 DocumentEventQueue& eventQueue() const final { return m_eventQueue; }
1171
1172 WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener&);
1173 WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener&);
1174 MediaCanStartListener* takeAnyMediaCanStartListener();
1175
1176#if ENABLE(FULLSCREEN_API)
1177 FullscreenManager& fullscreenManager() { return m_fullscreenManager; }
1178 const FullscreenManager& fullscreenManager() const { return m_fullscreenManager; }
1179#endif
1180
1181#if ENABLE(POINTER_LOCK)
1182 WEBCORE_EXPORT void exitPointerLock();
1183#endif
1184
1185 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
1186 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
1187 void decrementLoadEventDelayCount();
1188 bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
1189 void checkCompleted();
1190
1191#if ENABLE(IOS_TOUCH_EVENTS)
1192#include <WebKitAdditions/DocumentIOS.h>
1193#endif
1194
1195#if ENABLE(DEVICE_ORIENTATION)
1196#if PLATFORM(IOS_FAMILY)
1197 DeviceMotionController& deviceMotionController() const;
1198 DeviceOrientationController& deviceOrientationController() const;
1199 WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
1200#endif
1201
1202 DeviceOrientationAndMotionAccessController& deviceOrientationAndMotionAccessController();
1203#endif // ENABLE(DEVICE_ORIENTATION)
1204
1205 const DocumentTiming& timing() const { return m_documentTiming; }
1206
1207 WEBCORE_EXPORT double monotonicTimestamp() const;
1208
1209 int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
1210 void cancelAnimationFrame(int id);
1211
1212 EventTarget* errorEventTarget() final;
1213 void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) final;
1214
1215 void initDNSPrefetch();
1216
1217 void didAddWheelEventHandler(Node&);
1218 void didRemoveWheelEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1219
1220 MonotonicTime lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
1221 bool hasHadUserInteraction() const { return static_cast<bool>(m_lastHandledUserGestureTimestamp); }
1222 void updateLastHandledUserGestureTimestamp(MonotonicTime);
1223 bool processingUserGestureForMedia() const;
1224 void userActivatedMediaFinishedPlaying() { m_userActivatedMediaFinishedPlayingTimestamp = MonotonicTime::now(); }
1225
1226 void setUserDidInteractWithPage(bool userDidInteractWithPage) { ASSERT(&topDocument() == this); m_userDidInteractWithPage = userDidInteractWithPage; }
1227 bool userDidInteractWithPage() const { ASSERT(&topDocument() == this); return m_userDidInteractWithPage; }
1228
1229 // Used for testing. Count handlers in the main document, and one per frame which contains handlers.
1230 WEBCORE_EXPORT unsigned wheelEventHandlerCount() const;
1231 WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
1232
1233 WEBCORE_EXPORT void startTrackingStyleRecalcs();
1234 WEBCORE_EXPORT unsigned styleRecalcCount() const;
1235
1236#if ENABLE(TOUCH_EVENTS)
1237 bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
1238 bool touchEventTargetsContain(Node& node) const { return m_touchEventTargets ? m_touchEventTargets->contains(&node) : false; }
1239#else
1240 bool hasTouchEventHandlers() const { return false; }
1241 bool touchEventTargetsContain(Node&) const { return false; }
1242#endif
1243#if PLATFORM(IOS_FAMILY) && ENABLE(POINTER_EVENTS)
1244 void updateTouchActionElements(Element&, const RenderStyle&);
1245 const HashSet<RefPtr<Element>>* touchActionElements() const { return m_touchActionElements.get(); }
1246#endif
1247
1248 void didAddTouchEventHandler(Node&);
1249 void didRemoveTouchEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1250
1251 void didRemoveEventTargetNode(Node&);
1252
1253 const EventTargetSet* touchEventTargets() const
1254 {
1255#if ENABLE(TOUCH_EVENTS)
1256 return m_touchEventTargets.get();
1257#else
1258 return nullptr;
1259#endif
1260 }
1261
1262 const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
1263
1264 typedef std::pair<Region, bool> RegionFixedPair;
1265 RegionFixedPair absoluteEventRegionForNode(Node&);
1266 RegionFixedPair absoluteRegionForEventTargets(const EventTargetSet*);
1267
1268 LayoutRect absoluteEventHandlerBounds(bool&) final;
1269
1270 bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
1271
1272 bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
1273
1274 void suspendScheduledTasks(ReasonForSuspension);
1275 void resumeScheduledTasks(ReasonForSuspension);
1276
1277#if ENABLE(CSS_DEVICE_ADAPTATION)
1278 IntSize initialViewportSize() const;
1279#endif
1280
1281 void convertAbsoluteToClientQuads(Vector<FloatQuad>&, const RenderStyle&);
1282 void convertAbsoluteToClientRects(Vector<FloatRect>&, const RenderStyle&);
1283 void convertAbsoluteToClientRect(FloatRect&, const RenderStyle&);
1284
1285 bool hasActiveParser();
1286 void incrementActiveParserCount() { ++m_activeParserCount; }
1287 void decrementActiveParserCount();
1288
1289 std::unique_ptr<DocumentParserYieldToken> createParserYieldToken()
1290 {
1291 return std::make_unique<DocumentParserYieldToken>(*this);
1292 }
1293
1294 bool hasActiveParserYieldToken() const { return m_parserYieldTokenCount; }
1295
1296 DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
1297
1298 void invalidateMatchedPropertiesCacheAndForceStyleRecalc();
1299
1300 void didRemoveAllPendingStylesheet();
1301 void didClearStyleResolver();
1302
1303 bool inStyleRecalc() const { return m_inStyleRecalc; }
1304 bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
1305 bool isResolvingTreeStyle() const { return m_isResolvingTreeStyle; }
1306 void setIsResolvingTreeStyle(bool);
1307
1308 void updateTextRenderer(Text&, unsigned offsetOfReplacedText, unsigned lengthOfReplacedText);
1309
1310 // Return a Locale for the default locale if the argument is null or empty.
1311 Locale& getCachedLocale(const AtomicString& locale = nullAtom());
1312
1313 const Document* templateDocument() const;
1314 Document& ensureTemplateDocument();
1315 void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = makeWeakPtr(templateDocumentHost); }
1316 Document* templateDocumentHost() { return m_templateDocumentHost.get(); }
1317
1318 void didAssociateFormControl(Element&);
1319 bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; }
1320 void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
1321 void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
1322
1323 void getParserLocation(String& url, unsigned& line, unsigned& column) const;
1324
1325 WEBCORE_EXPORT void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) final;
1326
1327 // The following addConsoleMessage function is deprecated.
1328 // Callers should try to create the ConsoleMessage themselves.
1329 WEBCORE_EXPORT void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) final;
1330
1331 // The following addMessage function is deprecated.
1332 // Callers should try to create the ConsoleMessage themselves.
1333 void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) final;
1334
1335 SecurityOrigin& securityOrigin() const { return *SecurityContext::securityOrigin(); }
1336 SecurityOrigin& topOrigin() const final { return topDocument().securityOrigin(); }
1337
1338 Ref<FontFaceSet> fonts();
1339
1340 void ensurePlugInsInjectedScript(DOMWrapperWorld&);
1341
1342 void setVisualUpdatesAllowedByClient(bool);
1343
1344#if ENABLE(WEB_CRYPTO)
1345 bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) final;
1346 bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) final;
1347#endif
1348
1349 void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
1350 bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
1351 void updateViewportUnitsOnResize();
1352
1353 WEBCORE_EXPORT void addAudioProducer(MediaProducer&);
1354 WEBCORE_EXPORT void removeAudioProducer(MediaProducer&);
1355 MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
1356 void noteUserInteractionWithMediaElement();
1357 bool isCapturing() const { return MediaProducer::isCapturing(m_mediaState); }
1358 WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
1359 void pageMutedStateDidChange();
1360
1361#if ENABLE(WIRELESS_PLAYBACK_TARGET)
1362 void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1363 void removePlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1364 void showPlaybackTargetPicker(MediaPlaybackTargetClient&, bool, RouteSharingPolicy, const String&);
1365 void playbackTargetPickerClientStateDidChange(MediaPlaybackTargetClient&, MediaProducer::MediaStateFlags);
1366
1367 void setPlaybackTarget(uint64_t, Ref<MediaPlaybackTarget>&&);
1368 void playbackTargetAvailabilityDidChange(uint64_t, bool);
1369 void setShouldPlayToPlaybackTarget(uint64_t, bool);
1370#endif
1371
1372 ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicyToPropagate() const;
1373 bool shouldEnforceContentDispositionAttachmentSandbox() const;
1374 void applyContentDispositionAttachmentSandbox();
1375
1376 void addViewportDependentPicture(HTMLPictureElement&);
1377 void removeViewportDependentPicture(HTMLPictureElement&);
1378
1379 void addAppearanceDependentPicture(HTMLPictureElement&);
1380 void removeAppearanceDependentPicture(HTMLPictureElement&);
1381
1382 void scheduleRenderingUpdate();
1383
1384#if ENABLE(INTERSECTION_OBSERVER)
1385 void addIntersectionObserver(IntersectionObserver&);
1386 void removeIntersectionObserver(IntersectionObserver&);
1387 unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
1388 void updateIntersectionObservations();
1389#endif
1390
1391#if ENABLE(RESIZE_OBSERVER)
1392 void addResizeObserver(ResizeObserver&);
1393 void removeResizeObserver(ResizeObserver&);
1394 bool hasResizeObservers();
1395 // Return the minDepth of the active observations.
1396 size_t gatherResizeObservations(size_t deeperThan);
1397 void deliverResizeObservations();
1398 bool hasSkippedResizeObservations() const;
1399 void setHasSkippedResizeObservations(bool);
1400 void updateResizeObservations(Page&);
1401#endif
1402
1403#if ENABLE(MEDIA_STREAM)
1404 void setHasCaptureMediaStreamTrack() { m_hasHadCaptureMediaStreamTrack = true; }
1405 bool hasHadCaptureMediaStreamTrack() const { return m_hasHadCaptureMediaStreamTrack; }
1406 void setDeviceIDHashSalt(const String&);
1407 String deviceIDHashSalt() const { return m_idHashSalt; }
1408 void stopMediaCapture();
1409 void registerForMediaStreamStateChangeCallbacks(HTMLMediaElement&);
1410 void unregisterForMediaStreamStateChangeCallbacks(HTMLMediaElement&);
1411 void mediaStreamCaptureStateChanged();
1412#endif
1413
1414// FIXME: Find a better place for this functionality.
1415#if ENABLE(TELEPHONE_NUMBER_DETECTION)
1416 // These functions provide a two-level setting:
1417 // - A user-settable wantsTelephoneNumberParsing (at the Page / WebView level)
1418 // - A read-only telephoneNumberParsingAllowed which is set by the
1419 // document if it has the appropriate meta tag.
1420 // - isTelephoneNumberParsingEnabled() == isTelephoneNumberParsingAllowed() && page()->settings()->isTelephoneNumberParsingEnabled()
1421 WEBCORE_EXPORT bool isTelephoneNumberParsingAllowed() const;
1422 WEBCORE_EXPORT bool isTelephoneNumberParsingEnabled() const;
1423#endif
1424
1425 using ContainerNode::setAttributeEventListener;
1426 void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld& isolatedWorld);
1427
1428 DOMSelection* getSelection();
1429
1430 void didInsertInDocumentShadowRoot(ShadowRoot&);
1431 void didRemoveInDocumentShadowRoot(ShadowRoot&);
1432 const HashSet<ShadowRoot*>& inDocumentShadowRoots() const { return m_inDocumentShadowRoots; }
1433
1434 void attachToCachedFrame(CachedFrameBase&);
1435 void detachFromCachedFrame(CachedFrameBase&);
1436
1437 ConstantPropertyMap& constantProperties() const { return *m_constantPropertyMap; }
1438
1439 void orientationChanged(int orientation);
1440 OrientationNotifier& orientationNotifier() { return m_orientationNotifier; }
1441
1442 WEBCORE_EXPORT const AtomicString& bgColor() const;
1443 WEBCORE_EXPORT void setBgColor(const String&);
1444 WEBCORE_EXPORT const AtomicString& fgColor() const;
1445 WEBCORE_EXPORT void setFgColor(const String&);
1446 WEBCORE_EXPORT const AtomicString& alinkColor() const;
1447 WEBCORE_EXPORT void setAlinkColor(const String&);
1448 WEBCORE_EXPORT const AtomicString& linkColorForBindings() const;
1449 WEBCORE_EXPORT void setLinkColorForBindings(const String&);
1450 WEBCORE_EXPORT const AtomicString& vlinkColor() const;
1451 WEBCORE_EXPORT void setVlinkColor(const String&);
1452
1453 // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-clear, this method does nothing.
1454 void clear() { }
1455 // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-captureevents, this method does nothing.
1456 void captureEvents() { }
1457 // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents, this method does nothing.
1458 void releaseEvents() { }
1459
1460#if ENABLE(TEXT_AUTOSIZING)
1461 TextAutoSizing& textAutoSizing();
1462#endif
1463
1464 // For debugging rdar://problem/49877867.
1465 void setMayBeDetachedFromFrame(bool mayBeDetachedFromFrame) { m_mayBeDetachedFromFrame = mayBeDetachedFromFrame; }
1466
1467 Logger& logger();
1468
1469 WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
1470
1471 WEBCORE_EXPORT DocumentTimeline& timeline();
1472 DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
1473 Vector<RefPtr<WebAnimation>> getAnimations();
1474
1475#if ENABLE(ATTACHMENT_ELEMENT)
1476 void registerAttachmentIdentifier(const String&);
1477 void didInsertAttachmentElement(HTMLAttachmentElement&);
1478 void didRemoveAttachmentElement(HTMLAttachmentElement&);
1479 WEBCORE_EXPORT RefPtr<HTMLAttachmentElement> attachmentForIdentifier(const String&) const;
1480 const HashMap<String, Ref<HTMLAttachmentElement>>& attachmentElementsByIdentifier() const { return m_attachmentIdentifierToElementMap; }
1481#endif
1482
1483#if ENABLE(SERVICE_WORKER)
1484 void setServiceWorkerConnection(SWClientConnection*);
1485#endif
1486
1487 void addApplicationStateChangeListener(ApplicationStateChangeListener&);
1488 void removeApplicationStateChangeListener(ApplicationStateChangeListener&);
1489 void forEachApplicationStateChangeListener(const Function<void(ApplicationStateChangeListener&)>&);
1490
1491#if ENABLE(IOS_TOUCH_EVENTS)
1492 bool handlingTouchEvent() const { return m_handlingTouchEvent; }
1493#endif
1494
1495#if ENABLE(RESOURCE_LOAD_STATISTICS)
1496 bool hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
1497 void setHasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
1498#endif
1499
1500 String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&);
1501
1502 void registerArticleElement(Element&);
1503 void unregisterArticleElement(Element&);
1504 void updateMainArticleElementAfterLayout();
1505 bool hasMainArticleElement() const { return !!m_mainArticleElement; }
1506
1507 const CSSRegisteredCustomPropertySet& getCSSRegisteredCustomPropertySet() const { return m_CSSRegisteredPropertySet; }
1508 bool registerCSSProperty(CSSRegisteredCustomProperty&&);
1509
1510#if ENABLE(CSS_PAINTING_API)
1511 Worklet& ensurePaintWorklet();
1512 PaintWorkletGlobalScope* paintWorkletGlobalScopeForName(const String& name);
1513 void setPaintWorkletGlobalScopeForName(const String& name, Ref<PaintWorkletGlobalScope>&&);
1514#endif
1515
1516 WEBCORE_EXPORT bool hasEvaluatedUserAgentScripts() const;
1517 WEBCORE_EXPORT bool isRunningUserScripts() const;
1518 WEBCORE_EXPORT void setAsRunningUserScripts();
1519 void setHasEvaluatedUserAgentScripts();
1520#if ENABLE(APPLE_PAY)
1521 WEBCORE_EXPORT bool hasStartedApplePaySession() const;
1522 WEBCORE_EXPORT void setHasStartedApplePaySession();
1523#endif
1524
1525 void frameWasDisconnectedFromOwner();
1526
1527protected:
1528 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
1529 Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
1530
1531 void clearXMLVersion() { m_xmlVersion = String(); }
1532
1533 virtual Ref<Document> cloneDocumentWithoutChildren() const;
1534
1535private:
1536 friend class DocumentParserYieldToken;
1537 friend class Node;
1538 friend class ThrowOnDynamicMarkupInsertionCountIncrementer;
1539 friend class IgnoreOpensDuringUnloadCountIncrementer;
1540 friend class IgnoreDestructiveWriteCountIncrementer;
1541
1542 bool shouldInheritContentSecurityPolicyFromOwner() const;
1543
1544 void updateTitleElement(Element& changingTitleElement);
1545 void willDetachPage() final;
1546 void frameDestroyed() final;
1547
1548 void commonTeardown();
1549
1550 RenderObject* renderer() const = delete;
1551 void setRenderer(RenderObject*) = delete;
1552
1553 void createRenderTree();
1554 void detachParser();
1555
1556 // FontSelectorClient
1557 void fontsNeedUpdate(FontSelector&) final;
1558
1559 bool isDocument() const final { return true; }
1560
1561 void childrenChanged(const ChildChange&) final;
1562
1563 String nodeName() const final;
1564 NodeType nodeType() const final;
1565 bool childTypeAllowed(NodeType) const final;
1566 Ref<Node> cloneNodeInternal(Document&, CloningOperation) final;
1567 void cloneDataFromDocument(const Document&);
1568
1569 void refScriptExecutionContext() final { ref(); }
1570 void derefScriptExecutionContext() final { deref(); }
1571
1572 Seconds minimumDOMTimerInterval() const final;
1573
1574 Seconds domTimerAlignmentInterval(bool hasReachedMaxNestingLevel) const final;
1575
1576 void updateTitleFromTitleElement();
1577 void updateTitle(const StringWithDirection&);
1578 void updateBaseURL();
1579
1580 void invalidateAccessKeyCacheSlowCase();
1581 void buildAccessKeyCache();
1582
1583 void moveNodeIteratorsToNewDocumentSlowCase(Node&, Document&);
1584
1585 void loadEventDelayTimerFired();
1586
1587 void pendingTasksTimerFired();
1588 bool isCookieAverse() const;
1589
1590 void detachFromFrame();
1591
1592 template<CollectionType> Ref<HTMLCollection> ensureCachedCollection();
1593
1594 void dispatchDisabledAdaptationsDidChangeForMainFrame();
1595
1596 void setVisualUpdatesAllowed(ReadyState);
1597 void setVisualUpdatesAllowed(bool);
1598 void visualUpdatesSuppressionTimerFired();
1599
1600 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
1601
1602 void didAssociateFormControlsTimerFired();
1603
1604 void wheelEventHandlersChanged();
1605
1606#if ENABLE(DASHBOARD_SUPPORT)
1607 void setAnnotatedRegionsDirty(bool f = true) { m_annotatedRegionsDirty = f; }
1608 bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
1609 bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
1610 void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
1611 void updateAnnotatedRegions();
1612#endif
1613
1614 HttpEquivPolicy httpEquivPolicy() const;
1615 AXObjectCache* existingAXObjectCacheSlow() const;
1616
1617 // DOM Cookies caching.
1618 const String& cachedDOMCookies() const { return m_cachedDOMCookies; }
1619 void setCachedDOMCookies(const String&);
1620 bool isDOMCookieCacheValid() const { return m_cookieCacheExpiryTimer.isActive(); }
1621 void invalidateDOMCookieCache();
1622 void didLoadResourceSynchronously() final;
1623
1624 void checkViewportDependentPictures();
1625 void checkAppearanceDependentPictures();
1626
1627 bool canNavigateInternal(Frame& targetFrame);
1628 bool isNavigationBlockedByThirdPartyIFrameRedirectBlocking(Frame& targetFrame, const URL& destinationURL);
1629
1630#if ENABLE(INTERSECTION_OBSERVER)
1631 void notifyIntersectionObserversTimerFired();
1632#endif
1633
1634#if USE(QUICK_LOOK)
1635 bool shouldEnforceQuickLookSandbox() const;
1636 void applyQuickLookSandbox();
1637#endif
1638
1639 bool shouldEnforceHTTP09Sandbox() const;
1640
1641 void platformSuspendOrStopActiveDOMObjects();
1642
1643 bool isBodyPotentiallyScrollable(HTMLBodyElement&);
1644
1645 const Ref<Settings> m_settings;
1646
1647 UniqueRef<Quirks> m_quirks;
1648
1649 std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
1650
1651 RefPtr<DOMWindow> m_domWindow;
1652 WeakPtr<Document> m_contextDocument;
1653
1654 Ref<CachedResourceLoader> m_cachedResourceLoader;
1655 RefPtr<DocumentParser> m_parser;
1656
1657 unsigned m_parserYieldTokenCount { 0 };
1658
1659 // Document URLs.
1660 URL m_url; // Document.URL: The URL from which this document was retrieved.
1661 URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
1662 URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
1663 URL m_baseElementURL; // The URL set by the <base> element.
1664 URL m_cookieURL; // The URL to use for cookie access.
1665 URL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
1666 URL m_siteForCookies; // The policy URL for Same-Site cookies.
1667
1668 // Document.documentURI:
1669 // Although URL-like, Document.documentURI can actually be set to any
1670 // string by content. Document.documentURI affects m_baseURL unless the
1671 // document contains a <base> element, in which case the <base> element
1672 // takes precedence.
1673 //
1674 // This property is read-only from JavaScript, but writable from Objective C.
1675 String m_documentURI;
1676
1677 String m_baseTarget;
1678
1679 // MIME type of the document in case it was cloned or created by XHR.
1680 String m_overriddenMIMEType;
1681
1682 std::unique_ptr<DOMImplementation> m_implementation;
1683
1684 RefPtr<Node> m_focusNavigationStartingNode;
1685 RefPtr<Element> m_focusedElement;
1686 RefPtr<Element> m_hoveredElement;
1687 RefPtr<Element> m_activeElement;
1688 RefPtr<Element> m_documentElement;
1689 UserActionElementSet m_userActionElements;
1690
1691 uint64_t m_domTreeVersion;
1692 static uint64_t s_globalTreeVersion;
1693
1694 String m_uniqueIdentifier;
1695
1696 HashSet<NodeIterator*> m_nodeIterators;
1697 HashSet<Range*> m_ranges;
1698
1699 std::unique_ptr<Style::Scope> m_styleScope;
1700 std::unique_ptr<ExtensionStyleSheets> m_extensionStyleSheets;
1701 RefPtr<StyleSheetList> m_styleSheetList;
1702
1703 std::unique_ptr<FormController> m_formController;
1704
1705 Color m_textColor { Color::black };
1706 Color m_linkColor;
1707 Color m_visitedLinkColor;
1708 Color m_activeLinkColor;
1709 const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
1710
1711 StringWithDirection m_title;
1712 StringWithDirection m_rawTitle;
1713 RefPtr<Element> m_titleElement;
1714
1715 std::unique_ptr<AXObjectCache> m_axObjectCache;
1716 const std::unique_ptr<DocumentMarkerController> m_markers;
1717
1718 Timer m_styleRecalcTimer;
1719
1720 Element* m_cssTarget { nullptr };
1721
1722 RefPtr<SerializedScriptValue> m_pendingStateObject;
1723 MonotonicTime m_documentCreationTime;
1724 bool m_overMinimumLayoutThreshold { false };
1725
1726 std::unique_ptr<ScriptRunner> m_scriptRunner;
1727 std::unique_ptr<ScriptModuleLoader> m_moduleLoader;
1728
1729 Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
1730
1731#if ENABLE(XSLT)
1732 void applyPendingXSLTransformsTimerFired();
1733
1734 std::unique_ptr<TransformSource> m_transformSource;
1735 RefPtr<Document> m_transformSourceDocument;
1736 Timer m_applyPendingXSLTransformsTimer;
1737 bool m_hasPendingXSLTransforms { false };
1738#endif
1739
1740 String m_xmlEncoding;
1741 String m_xmlVersion;
1742 StandaloneStatus m_xmlStandalone { StandaloneStatus::Unspecified };
1743 bool m_hasXMLDeclaration { false };
1744
1745 String m_contentLanguage;
1746
1747 RefPtr<TextResourceDecoder> m_decoder;
1748
1749 HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
1750 HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
1751 unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
1752
1753 RefPtr<XPathEvaluator> m_xpathEvaluator;
1754
1755 std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1756 HashSet<SVGUseElement*> m_svgUseElements;
1757
1758#if ENABLE(DARK_MODE_CSS)
1759 OptionSet<ColorScheme> m_colorScheme;
1760 bool m_allowsColorSchemeTransformations { true };
1761#endif
1762
1763#if ENABLE(DASHBOARD_SUPPORT)
1764 Vector<AnnotatedRegionValue> m_annotatedRegions;
1765 bool m_hasAnnotatedRegions { false };
1766 bool m_annotatedRegionsDirty { false };
1767#endif
1768
1769 HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
1770
1771 HashSet<Element*> m_documentSuspensionCallbackElements;
1772 HashSet<Element*> m_mediaVolumeCallbackElements;
1773 HashSet<Element*> m_privateBrowsingStateChangedElements;
1774#if ENABLE(VIDEO_TRACK)
1775 HashSet<Element*> m_captionPreferencesChangedElements;
1776#endif
1777
1778 Element* m_mainArticleElement { nullptr };
1779 HashSet<Element*> m_articleElements;
1780
1781#if ENABLE(MEDIA_CONTROLS_SCRIPT)
1782 HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
1783 HashSet<HTMLMediaElement*> m_userInterfaceLayoutDirectionChangedElements;
1784#endif
1785
1786 HashSet<VisibilityChangeClient*> m_visibilityStateCallbackClients;
1787#if ENABLE(VIDEO)
1788 HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
1789#endif
1790
1791 std::unique_ptr<HashMap<String, Element*, ASCIICaseInsensitiveHash>> m_accessKeyCache;
1792
1793 std::unique_ptr<ConstantPropertyMap> m_constantPropertyMap;
1794
1795 std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
1796
1797 DocumentClassFlags m_documentClasses;
1798
1799 RenderPtr<RenderView> m_renderView;
1800 mutable DocumentEventQueue m_eventQueue;
1801
1802 HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
1803
1804#if ENABLE(FULLSCREEN_API)
1805 UniqueRef<FullscreenManager> m_fullscreenManager;
1806#endif
1807
1808 HashSet<HTMLPictureElement*> m_viewportDependentPictures;
1809 HashSet<HTMLPictureElement*> m_appearanceDependentPictures;
1810
1811#if ENABLE(INTERSECTION_OBSERVER)
1812 Vector<WeakPtr<IntersectionObserver>> m_intersectionObservers;
1813 Vector<WeakPtr<IntersectionObserver>> m_intersectionObserversWithPendingNotifications;
1814 Timer m_intersectionObserversNotifyTimer;
1815#endif
1816
1817#if ENABLE(RESIZE_OBSERVER)
1818 Vector<WeakPtr<ResizeObserver>> m_resizeObservers;
1819#endif
1820
1821 Timer m_loadEventDelayTimer;
1822
1823 ViewportArguments m_viewportArguments;
1824 OptionSet<DisabledAdaptations> m_disabledAdaptations;
1825
1826 DocumentTiming m_documentTiming;
1827
1828 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
1829
1830#if ENABLE(TOUCH_EVENTS)
1831 std::unique_ptr<EventTargetSet> m_touchEventTargets;
1832#endif
1833#if PLATFORM(IOS_FAMILY) && ENABLE(POINTER_EVENTS)
1834 std::unique_ptr<HashSet<RefPtr<Element>>> m_touchActionElements;
1835#endif
1836 std::unique_ptr<EventTargetSet> m_wheelEventTargets;
1837
1838 MonotonicTime m_lastHandledUserGestureTimestamp;
1839 MonotonicTime m_userActivatedMediaFinishedPlayingTimestamp;
1840
1841 void clearScriptedAnimationController();
1842 RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
1843
1844 void notifyMediaCaptureOfVisibilityChanged();
1845
1846 void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) final;
1847
1848#if ENABLE(DEVICE_ORIENTATION)
1849#if PLATFORM(IOS_FAMILY)
1850 std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
1851 std::unique_ptr<DeviceMotionController> m_deviceMotionController;
1852 std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
1853 std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
1854#endif
1855 std::unique_ptr<DeviceOrientationAndMotionAccessController> m_deviceOrientationAndMotionAccessController;
1856#endif
1857
1858 GenericTaskQueue<Timer> m_logMessageTaskQueue;
1859
1860 Timer m_pendingTasksTimer;
1861 Vector<Task> m_pendingTasks;
1862
1863#if ENABLE(TEXT_AUTOSIZING)
1864 std::unique_ptr<TextAutoSizing> m_textAutoSizing;
1865#endif
1866
1867 Timer m_visualUpdatesSuppressionTimer;
1868
1869 void clearSharedObjectPool();
1870 Timer m_sharedObjectPoolClearTimer;
1871
1872 std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
1873
1874 typedef HashMap<AtomicString, std::unique_ptr<Locale>> LocaleIdentifierToLocaleMap;
1875 LocaleIdentifierToLocaleMap m_localeCache;
1876
1877 RefPtr<Document> m_templateDocument;
1878 WeakPtr<Document> m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
1879
1880 Ref<CSSFontSelector> m_fontSelector;
1881
1882 WeakHashSet<MediaProducer> m_audioProducers;
1883
1884 HashSet<ShadowRoot*> m_inDocumentShadowRoots;
1885
1886#if ENABLE(WIRELESS_PLAYBACK_TARGET)
1887 typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
1888 TargetIdToClientMap m_idToClientMap;
1889 typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
1890 TargetClientToIdMap m_clientToIDMap;
1891#endif
1892
1893#if ENABLE(MEDIA_SESSION)
1894 RefPtr<MediaSession> m_defaultMediaSession;
1895#endif
1896
1897#if ENABLE(INDEXED_DATABASE)
1898 RefPtr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
1899#endif
1900
1901#if ENABLE(ATTACHMENT_ELEMENT)
1902 HashMap<String, Ref<HTMLAttachmentElement>> m_attachmentIdentifierToElementMap;
1903#endif
1904
1905 Timer m_didAssociateFormControlsTimer;
1906 Timer m_cookieCacheExpiryTimer;
1907
1908 RefPtr<SocketProvider> m_socketProvider;
1909
1910 String m_cachedDOMCookies;
1911
1912 Optional<WallTime> m_overrideLastModified;
1913
1914 HashSet<RefPtr<Element>> m_associatedFormControls;
1915 unsigned m_disabledFieldsetElementsCount { 0 };
1916
1917 unsigned m_listenerTypes { 0 };
1918 unsigned m_referencingNodeCount { 0 };
1919 int m_loadEventDelayCount { 0 };
1920 unsigned m_lastStyleUpdateSizeForTesting { 0 };
1921
1922 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter
1923 unsigned m_throwOnDynamicMarkupInsertionCount { 0 };
1924
1925 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#ignore-opens-during-unload-counter
1926 unsigned m_ignoreOpensDuringUnloadCount { 0 };
1927
1928 // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#ignore-destructive-writes-counter
1929 unsigned m_ignoreDestructiveWriteCount { 0 };
1930
1931 unsigned m_activeParserCount { 0 };
1932 unsigned m_styleRecalcCount { 0 };
1933
1934 unsigned m_writeRecursionDepth { 0 };
1935
1936 InheritedBool m_designMode { inherit };
1937 MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
1938 bool m_userHasInteractedWithMediaElement { false };
1939 PageCacheState m_pageCacheState { NotInPageCache };
1940 Optional<ReferrerPolicy> m_referrerPolicy;
1941 ReadyState m_readyState { Complete };
1942
1943 MutationObserverOptions m_mutationObserverTypes { 0 };
1944
1945 bool m_writeRecursionIsTooDeep { false };
1946 bool m_wellFormed { false };
1947 bool m_createRenderers { true };
1948
1949 bool m_hasNodesWithNonFinalStyle { false };
1950 bool m_hasNodesWithMissingStyle { false };
1951 // But sometimes you need to ignore pending stylesheet count to
1952 // force an immediate layout when requested by JS.
1953 bool m_ignorePendingStylesheets { false };
1954
1955 bool m_hasElementUsingStyleBasedEditability { false };
1956 bool m_focusNavigationStartingNodeIsRemoved { false };
1957
1958 bool m_printing { false };
1959 bool m_paginatedForScreen { false };
1960
1961 DocumentCompatibilityMode m_compatibilityMode { DocumentCompatibilityMode::NoQuirksMode };
1962 bool m_compatibilityModeLocked { false }; // This is cheaper than making setCompatibilityMode virtual.
1963
1964 // FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
1965 // is almost a duplication of this data, so that should probably get merged in too.
1966 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadDispatched are roughly the same
1967 // and should be merged.
1968 bool m_processingLoadEvent { false };
1969 bool m_loadEventFinished { false };
1970
1971 bool m_visuallyOrdered { false };
1972 bool m_bParsing { false }; // FIXME: rename
1973
1974 bool m_needsFullStyleRebuild { false };
1975 bool m_inStyleRecalc { false };
1976 bool m_closeAfterStyleRecalc { false };
1977 bool m_inRenderTreeUpdate { false };
1978 bool m_isResolvingTreeStyle { false };
1979
1980 bool m_gotoAnchorNeededAfterStylesheetsLoad { false };
1981 bool m_isDNSPrefetchEnabled { false };
1982 bool m_haveExplicitlyDisabledDNSPrefetch { false };
1983
1984 bool m_isSynthesized { false };
1985 bool m_isNonRenderedPlaceholder { false };
1986
1987 bool m_sawElementsInKnownNamespaces { false };
1988 bool m_isSrcdocDocument { false };
1989
1990 bool m_hasInjectedPlugInsScript { false };
1991 bool m_renderTreeBeingDestroyed { false };
1992 bool m_hasPreparedForDestruction { false };
1993
1994 bool m_hasStyleWithViewportUnits { false };
1995 bool m_isTimerThrottlingEnabled { false };
1996 bool m_isSuspended { false };
1997
1998 bool m_scheduledTasksAreSuspended { false };
1999 bool m_visualUpdatesAllowed { true };
2000
2001 bool m_areDeviceMotionAndOrientationUpdatesSuspended { false };
2002 bool m_userDidInteractWithPage { false };
2003
2004#if ENABLE(TELEPHONE_NUMBER_DETECTION)
2005 bool m_isTelephoneNumberParsingAllowed { true };
2006#endif
2007
2008#if ENABLE(MEDIA_STREAM)
2009 HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
2010 String m_idHashSalt;
2011 bool m_hasHadCaptureMediaStreamTrack { false };
2012#endif
2013
2014#ifndef NDEBUG
2015 bool m_didDispatchViewportPropertiesChanged { false };
2016#endif
2017
2018 OrientationNotifier m_orientationNotifier;
2019 mutable PAL::SessionID m_sessionID;
2020 mutable RefPtr<Logger> m_logger;
2021 RefPtr<StringCallback> m_consoleMessageListener;
2022
2023 static bool hasEverCreatedAnAXObjectCache;
2024
2025 RefPtr<DocumentTimeline> m_timeline;
2026 DocumentIdentifier m_identifier;
2027
2028#if ENABLE(SERVICE_WORKER)
2029 RefPtr<SWClientConnection> m_serviceWorkerConnection;
2030#endif
2031
2032 HashSet<ApplicationStateChangeListener*> m_applicationStateChangeListeners;
2033
2034#if ENABLE(RESOURCE_LOAD_STATISTICS)
2035 RegistrableDomain m_registrableDomainRequestedPageSpecificStorageAccessWithUserInteraction { };
2036#endif
2037
2038 CSSRegisteredCustomPropertySet m_CSSRegisteredPropertySet;
2039
2040#if ENABLE(CSS_PAINTING_API)
2041 RefPtr<Worklet> m_paintWorklet;
2042 HashMap<String, Ref<PaintWorkletGlobalScope>> m_paintWorkletGlobalScopes;
2043#endif
2044
2045 bool m_hasEvaluatedUserAgentScripts { false };
2046 bool m_isRunningUserScripts { false };
2047 bool m_mayBeDetachedFromFrame { true };
2048#if ENABLE(APPLE_PAY)
2049 bool m_hasStartedApplePaySession { false };
2050#endif
2051
2052 Ref<UndoManager> m_undoManager;
2053#if PLATFORM(IOS_FAMILY)
2054 std::unique_ptr<ContentChangeObserver> m_contentChangeObserver;
2055#endif
2056
2057 HashMap<Element*, ElementIdentifier> m_identifiedElementsMap;
2058};
2059
2060Element* eventTargetElementForDocument(Document*);
2061
2062inline TextEncoding Document::textEncoding() const
2063{
2064 if (auto* decoder = this->decoder())
2065 return decoder->encoding();
2066 return TextEncoding();
2067}
2068
2069inline const Document* Document::templateDocument() const
2070{
2071 return m_templateDocumentHost ? this : m_templateDocument.get();
2072}
2073
2074inline AXObjectCache* Document::existingAXObjectCache() const
2075{
2076 if (!hasEverCreatedAnAXObjectCache)
2077 return nullptr;
2078 return existingAXObjectCacheSlow();
2079}
2080
2081inline Ref<Document> Document::create(const URL& url)
2082{
2083 return adoptRef(*new Document(nullptr, url));
2084}
2085
2086inline Ref<Document> Document::createNonRenderedPlaceholder(Frame& frame, const URL& url)
2087{
2088 return adoptRef(*new Document(&frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
2089}
2090
2091inline void Document::invalidateAccessKeyCache()
2092{
2093 if (UNLIKELY(m_accessKeyCache))
2094 invalidateAccessKeyCacheSlowCase();
2095}
2096
2097// These functions are here because they require the Document class definition and we want to inline them.
2098
2099inline ScriptExecutionContext* Node::scriptExecutionContext() const
2100{
2101 return &document().contextDocument();
2102}
2103
2104inline ActiveDOMObject::ActiveDOMObject(Document& document)
2105 : ActiveDOMObject(static_cast<ScriptExecutionContext*>(&document.contextDocument()))
2106{
2107}
2108
2109} // namespace WebCore
2110
2111SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
2112 static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
2113 static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
2114SPECIALIZE_TYPE_TRAITS_END()
2115