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-2010, 2012-2013, 2015 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.
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.
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.
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.
31 #include "CollectionType.h"
33 #include "ContainerNode.h"
34 #include "DocumentEventQueue.h"
35 #include "DocumentTiming.h"
36 #include "FocusDirection.h"
37 #include "FontSelector.h"
38 #include "MediaProducer.h"
39 #include "MutationObserver.h"
40 #include "PageVisibilityState.h"
41 #include "PlatformEvent.h"
42 #include "PlatformScreen.h"
43 #include "ReferrerPolicy.h"
45 #include "RenderPtr.h"
46 #include "ScriptExecutionContext.h"
47 #include "StringWithDirection.h"
48 #include "StyleChange.h"
49 #include "TextResourceDecoder.h"
51 #include "TreeScope.h"
52 #include "UserActionElementSet.h"
53 #include "ViewportArguments.h"
56 #include <wtf/Deque.h>
57 #include <wtf/HashSet.h>
58 #include <wtf/PassRefPtr.h>
59 #include <wtf/WeakPtr.h>
63 #if ENABLE(WEB_REPLAY)
72 class AuthorStyleSheets;
74 class CSSFontSelector;
75 class CSSStyleDeclaration;
77 class CachedCSSStyleSheet;
78 class CachedResourceLoader;
80 class CanvasRenderingContext;
83 class DOMImplementation;
84 class DOMNamedFlowCollection;
87 class DOMWrapperWorld;
90 class DocumentFragment;
92 class DocumentMarkerController;
94 class DocumentSharedObjectPool;
97 class EntityReference;
100 class ExtensionStyleSheets;
103 class FormController;
106 class HTMLAllCollection;
107 class HTMLBodyElement;
108 class HTMLCanvasElement;
109 class HTMLCollection;
112 class HTMLFrameOwnerElement;
113 class HTMLHeadElement;
114 class HTMLIFrameElement;
115 class HTMLImageElement;
116 class HTMLMapElement;
117 class HTMLMediaElement;
118 class HTMLPictureElement;
119 class HTMLScriptElement;
120 class HitTestRequest;
126 class JSModuleLoader;
130 class MediaCanStartListener;
131 class MediaPlaybackTarget;
132 class MediaPlaybackTargetClient;
133 class MediaQueryList;
134 class MediaQueryMatcher;
135 class MouseEventWithHitTestResults;
136 class NamedFlowCollection;
140 class PlatformMouseEvent;
141 class ProcessingInstruction;
144 class RegisteredEventListener;
146 class RenderFullScreen;
147 class ScriptableDocumentParser;
148 class ScriptElementData;
150 class SecurityOrigin;
152 class SelectorQueryCache;
153 class SerializedScriptValue;
154 class SegmentedString;
158 class StyleSheetContents;
159 class StyleSheetList;
160 class SVGDocumentExtensions;
162 class TextResourceDecoder;
164 class VisitedLinkState;
165 class WebKitNamedFlow;
166 class XMLHttpRequest;
167 class XPathEvaluator;
168 class XPathExpression;
169 class XPathNSResolver;
172 enum class ShouldOpenExternalURLsPolicy;
175 class TransformSource;
178 #if ENABLE(CUSTOM_ELEMENTS)
179 class CustomElementDefinitions;
182 #if ENABLE(DASHBOARD_SUPPORT)
183 struct AnnotatedRegionValue;
186 #if ENABLE(IOS_TOUCH_EVENTS)
187 #include <WebKitAdditions/DocumentIOSForward.h>
190 #if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
195 #if ENABLE(REQUEST_ANIMATION_FRAME)
196 class RequestAnimationFrameCallback;
197 class ScriptedAnimationController;
200 #if ENABLE(TEXT_AUTOSIZING)
205 class DOMSecurityPolicy;
208 #if ENABLE(FONT_LOAD_EVENTS)
212 typedef int ExceptionCode;
215 class DeviceMotionClient;
216 class DeviceMotionController;
217 class DeviceOrientationClient;
218 class DeviceOrientationController;
221 #if ENABLE(IOS_TEXT_AUTOSIZING)
222 struct TextAutoSizingHash;
223 class TextAutoSizingKey;
224 class TextAutoSizingValue;
226 struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
227 static const bool emptyValueIsZero = true;
228 static void constructDeletedValue(TextAutoSizingKey& slot);
229 static bool isDeletedValue(const TextAutoSizingKey& value);
233 #if ENABLE(MEDIA_SESSION)
237 const uint64_t HTMLMediaElementInvalidID = 0;
239 enum PageshowEventPersistence {
240 PageshowEventNotPersisted = 0,
241 PageshowEventPersisted = 1
244 enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
246 enum NodeListInvalidationType {
247 DoNotInvalidateOnAttributeChanges = 0,
248 InvalidateOnClassAttrChange,
249 InvalidateOnIdNameAttrChange,
250 InvalidateOnNameAttrChange,
251 InvalidateOnForAttrChange,
252 InvalidateForFormControls,
253 InvalidateOnHRefAttrChange,
254 InvalidateOnAnyAttrChange,
256 const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
258 enum class EventHandlerRemoval { One, All };
259 typedef HashCountedSet<Node*> EventTargetSet;
262 DefaultDocumentClass = 0,
263 HTMLDocumentClass = 1,
264 XHTMLDocumentClass = 1 << 1,
265 ImageDocumentClass = 1 << 2,
266 PluginDocumentClass = 1 << 3,
267 MediaDocumentClass = 1 << 4,
268 SVGDocumentClass = 1 << 5,
269 TextDocumentClass = 1 << 6,
270 XMLDocumentClass = 1 << 7,
273 typedef unsigned char DocumentClassFlags;
275 enum class DocumentCompatibilityMode : unsigned char {
278 LimitedQuirksMode = 1 << 2
281 enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
283 enum class SelectionRestorationMode {
288 enum class SelectionRevealMode {
293 enum class HttpEquivPolicy {
296 DisabledByContentDispositionAttachmentSandbox
299 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext, public FontSelectorClient {
301 static Ref<Document> create(Frame* frame, const URL& url)
303 return adoptRef(*new Document(frame, url));
306 static Ref<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
308 return adoptRef(*new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
310 static Ref<Document> create(ScriptExecutionContext&);
314 // Nodes belonging to this document increase referencingNodeCount -
315 // these are enough to keep the document from being destroyed, but
316 // not enough to keep it from removing its children. This allows a
317 // node that outlives its document to still have a valid document
318 // pointer without introducing reference cycles.
319 void incrementReferencingNodeCount()
321 ASSERT(!m_deletionHasBegun);
322 ++m_referencingNodeCount;
325 void decrementReferencingNodeCount()
327 ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
328 --m_referencingNodeCount;
329 if (!m_referencingNodeCount && !refCount()) {
331 m_deletionHasBegun = true;
337 unsigned referencingNodeCount() const { return m_referencingNodeCount; }
339 void removedLastRef();
341 WEBCORE_EXPORT static HashSet<Document*>& allDocuments();
343 MediaQueryMatcher& mediaQueryMatcher();
345 using ContainerNode::ref;
346 using ContainerNode::deref;
348 virtual bool canContainRangeEndPoint() const override final { return true; }
350 Element* getElementByAccessKey(const String& key);
351 void invalidateAccessKeyMap();
353 void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
354 void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
355 HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
357 SelectorQuery* selectorQueryForString(const String&, ExceptionCode&);
358 void clearSelectorQueryCache();
360 // DOM methods & attributes for Document
362 void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
363 ViewportArguments viewportArguments() const { return m_viewportArguments; }
365 bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
368 void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
369 ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
371 DocumentType* doctype() const;
373 DOMImplementation& implementation();
375 Element* documentElement() const
377 return m_documentElement.get();
379 static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
381 Element* activeElement();
382 bool hasFocus() const;
384 bool hasManifest() const;
386 WEBCORE_EXPORT RefPtr<Element> createElementForBindings(const AtomicString& tagName, ExceptionCode&);
387 WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
388 WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
389 Ref<Comment> createComment(const String& data);
390 RefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
391 RefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
392 RefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
393 RefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
394 RefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
395 RefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, false, ec); }
396 RefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
397 WEBCORE_EXPORT RefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
398 WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
400 bool cssRegionsEnabled() const;
401 bool cssCompositingEnabled() const;
402 #if ENABLE(CSS_REGIONS)
403 RefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
406 NamedFlowCollection& namedFlows();
408 Element* elementFromPoint(int x, int y) { return elementFromPoint(LayoutPoint(x, y)); }
409 Element* elementFromPoint(const LayoutPoint& clientPoint);
411 RefPtr<Range> caretRangeFromPoint(int x, int y);
412 RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
414 Element* scrollingElement();
416 String readyState() const;
418 String defaultCharset() const;
420 String charset() const { return Document::encoding(); }
421 String characterSetWithUTF8Fallback() const;
422 TextEncoding textEncoding() const;
424 AtomicString encoding() const { return textEncoding().domName(); }
426 void setCharset(const String&); // Used by ObjC / GOBject bindings only.
428 void setContent(const String&);
430 String suggestedMIMEType() const;
432 void overrideMIMEType(const String&);
433 String contentType() const;
435 String contentLanguage() const { return m_contentLanguage; }
436 void setContentLanguage(const String&);
438 String xmlEncoding() const { return m_xmlEncoding; }
439 String xmlVersion() const { return m_xmlVersion; }
440 enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
441 bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
442 StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
443 bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
445 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
446 void setXMLVersion(const String&, ExceptionCode&);
447 void setXMLStandalone(bool, ExceptionCode&);
448 void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
450 String documentURI() const { return m_documentURI; }
451 void setDocumentURI(const String&);
453 #if ENABLE(WEB_REPLAY)
454 JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
455 void setInputCursor(PassRefPtr<JSC::InputCursor>);
458 void visibilityStateChanged();
459 String visibilityState() const;
462 void setTimerThrottlingEnabled(bool);
463 bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
466 DOMSecurityPolicy& securityPolicy();
469 RefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
471 Ref<HTMLCollection> images();
472 Ref<HTMLCollection> embeds();
473 Ref<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
474 Ref<HTMLCollection> applets();
475 Ref<HTMLCollection> links();
476 Ref<HTMLCollection> forms();
477 Ref<HTMLCollection> anchors();
478 Ref<HTMLCollection> scripts();
479 Ref<HTMLCollection> all();
481 Ref<HTMLCollection> windowNamedItems(const AtomicString& name);
482 Ref<HTMLCollection> documentNamedItems(const AtomicString& name);
484 // Other methods (not part of DOM)
485 bool isSynthesized() const { return m_isSynthesized; }
486 bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
487 bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
488 bool isXMLDocument() const { return m_documentClasses & XMLDocumentClass; }
489 bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
490 bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
491 bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
492 bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
493 bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
494 bool hasSVGRootNode() const;
495 virtual bool isFrameSet() const { return false; }
497 static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
498 static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
500 bool isSrcdocDocument() const { return m_isSrcdocDocument; }
502 StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
504 bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
506 StyleResolver& ensureStyleResolver()
508 if (!m_styleResolver)
509 createStyleResolver();
510 return *m_styleResolver;
512 StyleResolver& userAgentShadowTreeStyleResolver();
514 CSSFontSelector& fontSelector();
516 void notifyRemovePendingSheetIfNeeded();
518 WEBCORE_EXPORT bool haveStylesheetsLoaded() const;
520 // This is a DOM function.
521 StyleSheetList& styleSheets();
523 AuthorStyleSheets& authorStyleSheets() { return *m_authorStyleSheets; }
524 const AuthorStyleSheets& authorStyleSheets() const { return *m_authorStyleSheets; }
525 ExtensionStyleSheets& extensionStyleSheets() { return *m_extensionStyleSheets; }
526 const ExtensionStyleSheets& extensionStyleSheets() const { return *m_extensionStyleSheets; }
528 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
529 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
532 * Called when one or more stylesheets in the document may have been added, removed or changed.
534 * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
535 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
536 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
537 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
538 * found and is used to calculate the derived styles for all rendering objects.
540 WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
542 void scheduleOptimizedStyleSheetUpdate();
544 void evaluateMediaQueryList();
546 FormController& formController();
547 Vector<String> formElementsState() const;
548 void setStateForNewFormElements(const Vector<String>&);
550 WEBCORE_EXPORT FrameView* view() const; // can be NULL
551 Frame* frame() const { return m_frame; } // can be NULL
552 WEBCORE_EXPORT Page* page() const; // can be NULL
553 WEBCORE_EXPORT Settings* settings() const; // can be NULL
555 float deviceScaleFactor() const;
557 WEBCORE_EXPORT Ref<Range> createRange();
559 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
560 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
561 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, ExceptionCode&);
562 RefPtr<NodeIterator> createNodeIterator(Node* root, ExceptionCode&);
564 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
565 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
566 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, ExceptionCode&);
567 RefPtr<TreeWalker> createTreeWalker(Node* root, ExceptionCode&);
569 // Special support for editing
570 Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
571 Ref<Text> createEditingTextNode(const String&);
573 void recalcStyle(Style::Change = Style::NoChange);
574 WEBCORE_EXPORT void updateStyleIfNeeded();
575 bool needsStyleRecalc() const { return !inPageCache() && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
577 WEBCORE_EXPORT void updateLayout();
579 // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads,
580 // so calling this may cause a flash of unstyled content (FOUC).
581 enum class RunPostLayoutTasks {
585 WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
587 Ref<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, RenderStyle* parentStyle);
589 // Returns true if page box (margin boxes and page borders) is visible.
590 WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);
592 // Returns the preferred page size and margins in pixels, assuming 96
593 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
594 // marginLeft must be initialized to the default values that are used if
595 // auto is specified.
596 WEBCORE_EXPORT void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
598 CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader; }
600 void didBecomeCurrentDocumentInFrame();
601 void destroyRenderTree();
602 void disconnectFromFrame();
603 void prepareForDestruction();
605 // Override ScriptExecutionContext methods to do additional work
606 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override final;
607 virtual void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override final;
608 virtual void stopActiveDOMObjects() override final;
610 void suspendDeviceMotionAndOrientationUpdates();
611 void resumeDeviceMotionAndOrientationUpdates();
613 RenderView* renderView() const { return m_renderView.get(); }
615 bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
616 bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
618 bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
620 AXObjectCache* existingAXObjectCache() const;
621 WEBCORE_EXPORT AXObjectCache* axObjectCache() const;
622 void clearAXObjectCache();
624 // to get visually ordered hebrew and arabic pages right
625 void setVisuallyOrdered();
626 bool visuallyOrdered() const { return m_visuallyOrdered; }
628 WEBCORE_EXPORT DocumentLoader* loader() const;
630 void open(Document* ownerDocument = nullptr);
633 // close() is the DOM API document.close()
635 // In some situations (see the code), we ignore document.close().
636 // explicitClose() bypass these checks and actually tries to close the
638 void explicitClose();
639 // implicitClose() actually does the work of closing the input stream.
640 void implicitClose();
642 void cancelParsing();
644 void write(const SegmentedString& text, Document* ownerDocument = nullptr);
645 void write(const String& text, Document* ownerDocument = nullptr);
646 void writeln(const String& text, Document* ownerDocument = nullptr);
648 bool wellFormed() const { return m_wellFormed; }
650 virtual const URL& url() const override final { return m_url; }
651 void setURL(const URL&);
652 const URL& urlForBindings() const { return m_url.isEmpty() ? blankURL() : m_url; }
654 // To understand how these concepts relate to one another, please see the
655 // comments surrounding their declaration.
656 const URL& baseURL() const { return m_baseURL; }
657 void setBaseURLOverride(const URL&);
658 const URL& baseURLOverride() const { return m_baseURLOverride; }
659 const URL& baseElementURL() const { return m_baseElementURL; }
660 const String& baseTarget() const { return m_baseTarget; }
661 void processBaseElement();
663 WEBCORE_EXPORT virtual URL completeURL(const String&) const override final;
664 URL completeURL(const String&, const URL& baseURLOverride) const;
666 virtual String userAgent(const URL&) const override final;
668 virtual void disableEval(const String& errorMessage) override final;
670 bool canNavigate(Frame* targetFrame);
671 Frame* findUnsafeParentScrollPropagationBoundary();
673 CSSStyleSheet& elementSheet();
674 bool usesStyleBasedEditability() const;
676 virtual Ref<DocumentParser> createParser();
677 DocumentParser* parser() const { return m_parser.get(); }
678 ScriptableDocumentParser* scriptableDocumentParser() const;
680 bool printing() const { return m_printing; }
681 void setPrinting(bool p) { m_printing = p; }
683 bool paginatedForScreen() const { return m_paginatedForScreen; }
684 void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
686 bool paginated() const { return printing() || paginatedForScreen(); }
688 void setCompatibilityMode(DocumentCompatibilityMode);
689 void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
690 static ptrdiff_t compatibilityModeMemoryOffset() { return OBJECT_OFFSETOF(Document, m_compatibilityMode); }
692 String compatMode() const;
694 bool inQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::QuirksMode; }
695 bool inLimitedQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::LimitedQuirksMode; }
696 bool inNoQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::NoQuirksMode; }
703 void setReadyState(ReadyState);
704 void setParsing(bool);
705 bool parsing() const { return m_bParsing; }
706 std::chrono::milliseconds minimumLayoutDelay();
708 bool shouldScheduleLayout();
709 bool isLayoutTimerActive();
710 std::chrono::milliseconds elapsedTime() const;
712 void setTextColor(const Color& color) { m_textColor = color; }
713 Color textColor() const { return m_textColor; }
715 const Color& linkColor() const { return m_linkColor; }
716 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
717 const Color& activeLinkColor() const { return m_activeLinkColor; }
718 void setLinkColor(const Color& c) { m_linkColor = c; }
719 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
720 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
721 void resetLinkColor();
722 void resetVisitedLinkColor();
723 void resetActiveLinkColor();
724 VisitedLinkState& visitedLinkState() const { return *m_visitedLinkState; }
726 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
728 /* Newly proposed CSS3 mechanism for selecting alternate
729 stylesheets using the DOM. May be subject to change as
732 String preferredStylesheetSet() const;
733 String selectedStylesheetSet() const;
734 void setSelectedStylesheetSet(const String&);
736 WEBCORE_EXPORT bool setFocusedElement(Element*, FocusDirection = FocusDirectionNone);
737 Element* focusedElement() const { return m_focusedElement.get(); }
738 UserActionElementSet& userActionElements() { return m_userActionElements; }
739 const UserActionElementSet& userActionElements() const { return m_userActionElements; }
741 void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
742 void hoveredElementDidDetach(Element*);
743 void elementInActiveChainDidDetach(Element*);
745 void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
747 // Updates for :target (CSS3 selector).
748 void setCSSTarget(Element*);
749 Element* cssTarget() const { return m_cssTarget; }
750 static ptrdiff_t cssTargetMemoryOffset() { return OBJECT_OFFSETOF(Document, m_cssTarget); }
752 WEBCORE_EXPORT void scheduleForcedStyleRecalc();
753 void scheduleStyleRecalc();
754 void unscheduleStyleRecalc();
755 bool hasPendingStyleRecalc() const;
756 bool hasPendingForcedStyleRecalc() const;
757 void optimizedStyleSheetUpdateTimerFired();
759 void registerNodeListForInvalidation(LiveNodeList&);
760 void unregisterNodeListForInvalidation(LiveNodeList&);
761 void registerCollection(HTMLCollection&);
762 void unregisterCollection(HTMLCollection&);
763 void collectionCachedIdNameMap(const HTMLCollection&);
764 void collectionWillClearIdNameMap(const HTMLCollection&);
765 bool shouldInvalidateNodeListAndCollectionCaches(const QualifiedName* attrName = nullptr) const;
766 void invalidateNodeListAndCollectionCaches(const QualifiedName* attrName);
768 void attachNodeIterator(NodeIterator*);
769 void detachNodeIterator(NodeIterator*);
770 void moveNodeIteratorsToNewDocument(Node*, Document*);
772 void attachRange(Range*);
773 void detachRange(Range*);
775 void updateRangesAfterChildrenChanged(ContainerNode&);
776 // nodeChildrenWillBeRemoved is used when removing all node children at once.
777 void nodeChildrenWillBeRemoved(ContainerNode&);
778 // nodeWillBeRemoved is only safe when removing one node at a time.
779 void nodeWillBeRemoved(Node&);
780 enum class AcceptChildOperation { Replace, InsertOrAdd };
781 bool canAcceptChild(const Node& newChild, const Node* refChild, AcceptChildOperation) const;
783 void textInserted(Node*, unsigned offset, unsigned length);
784 void textRemoved(Node*, unsigned offset, unsigned length);
785 void textNodesMerged(Text* oldNode, unsigned offset);
786 void textNodeSplit(Text* oldNode);
788 void createDOMWindow();
789 void takeDOMWindowFrom(Document*);
791 DOMWindow* domWindow() const { return m_domWindow.get(); }
792 // In DOM Level 2, the Document's DOMWindow is called the defaultView.
793 DOMWindow* defaultView() const { return domWindow(); }
795 // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
796 void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
797 void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
798 EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
799 WEBCORE_EXPORT void dispatchWindowEvent(Event&, EventTarget* = nullptr);
800 void dispatchWindowLoadEvent();
802 RefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
804 // keep track of what types of event listeners are registered, so we don't
805 // dispatch events unnecessarily
807 DOMSUBTREEMODIFIED_LISTENER = 1,
808 DOMNODEINSERTED_LISTENER = 1 << 1,
809 DOMNODEREMOVED_LISTENER = 1 << 2,
810 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
811 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
812 DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
813 OVERFLOWCHANGED_LISTENER = 1 << 6,
814 ANIMATIONEND_LISTENER = 1 << 7,
815 ANIMATIONSTART_LISTENER = 1 << 8,
816 ANIMATIONITERATION_LISTENER = 1 << 9,
817 TRANSITIONEND_LISTENER = 1 << 10,
818 BEFORELOAD_LISTENER = 1 << 11,
819 SCROLL_LISTENER = 1 << 12,
820 FORCEWILLBEGIN_LISTENER = 1 << 13,
821 FORCECHANGED_LISTENER = 1 << 14,
822 FORCEDOWN_LISTENER = 1 << 15,
823 FORCEUP_LISTENER = 1 << 16
826 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
827 bool hasListenerTypeForEventType(PlatformEvent::Type) const;
828 void addListenerTypeIfNeeded(const AtomicString& eventType);
830 bool hasMutationObserversOfType(MutationObserver::MutationType type) const
832 return m_mutationObserverTypes & type;
834 bool hasMutationObservers() const { return m_mutationObserverTypes; }
835 void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
837 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
840 * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
841 * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
842 * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
843 * specified in a HTML file.
845 * @param equiv The http header name (value of the meta tag's "equiv" attribute)
846 * @param content The header value (value of the meta tag's "content" attribute)
848 void processHttpEquiv(const String& equiv, const String& content);
851 void processFormatDetection(const String&);
853 // Called when <meta name="apple-mobile-web-app-orientations"> changes.
854 void processWebAppOrientations();
857 void processViewport(const String& features, ViewportArguments::Type origin);
858 void updateViewportArguments();
859 void processReferrerPolicy(const String& policy);
861 // Returns the owning element in the parent document.
862 // Returns 0 if this is the top level document.
863 HTMLFrameOwnerElement* ownerElement() const;
865 // Used by DOM bindings; no direction known.
866 String title() const { return m_title.string(); }
867 void setTitle(const String&);
869 void titleElementAdded(Element& titleElement);
870 void titleElementRemoved(Element& titleElement);
871 void titleElementTextChanged(Element& titleElement);
873 String cookie(ExceptionCode&);
874 void setCookie(const String&, ExceptionCode&);
876 String referrer() const;
878 String origin() const;
880 WEBCORE_EXPORT String domain() const;
881 void setDomain(const String& newDomain, ExceptionCode&);
883 String lastModified() const;
885 // The cookieURL is used to query the cookie database for this document's
886 // cookies. For example, if the cookie URL is http://example.com, we'll
887 // use the non-Secure cookies for example.com when computing
890 // Q: How is the cookieURL different from the document's URL?
891 // A: The two URLs are the same almost all the time. However, if one
892 // document inherits the security context of another document, it
893 // inherits its cookieURL but not its URL.
895 const URL& cookieURL() const { return m_cookieURL; }
896 void setCookieURL(const URL&);
898 // The firstPartyForCookies is used to compute whether this document
899 // appears in a "third-party" context for the purpose of third-party
900 // cookie blocking. The document is in a third-party context if the
901 // cookieURL and the firstPartyForCookies are from different hosts.
903 // Note: Some ports (including possibly Apple's) only consider the
904 // document in a third-party context if the cookieURL and the
905 // firstPartyForCookies have a different registry-controlled
908 const URL& firstPartyForCookies() const { return m_firstPartyForCookies; }
909 void setFirstPartyForCookies(const URL& url) { m_firstPartyForCookies = url; }
911 // The following implements the rule from HTML 4 for what valid names are.
912 // To get this right for all the XML cases, we probably have to improve this or move it
913 // and make it sensitive to the type of document.
914 static bool isValidName(const String&);
916 // The following breaks a qualified name into a prefix and a local name.
917 // It also does a validity check, and returns false if the qualified name
918 // is invalid. It also sets ExceptionCode when name is invalid.
919 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
921 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
922 static bool hasValidNamespaceForElements(const QualifiedName&);
923 static bool hasValidNamespaceForAttributes(const QualifiedName&);
925 HTMLBodyElement* body() const;
926 WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
927 void setBodyOrFrameset(RefPtr<HTMLElement>&&, ExceptionCode&);
929 Location* location() const;
931 WEBCORE_EXPORT HTMLHeadElement* head();
933 DocumentMarkerController& markers() const { return *m_markers; }
935 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
936 bool queryCommandEnabled(const String& command);
937 bool queryCommandIndeterm(const String& command);
938 bool queryCommandState(const String& command);
939 bool queryCommandSupported(const String& command);
940 String queryCommandValue(const String& command);
942 // designMode support
943 enum InheritedBool { off = false, on = true, inherit };
944 void setDesignMode(InheritedBool value);
945 InheritedBool getDesignMode() const;
946 bool inDesignMode() const;
948 Document* parentDocument() const;
949 Document& topDocument() const;
951 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
952 JSModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
954 HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
955 void pushCurrentScript(HTMLScriptElement*);
956 void popCurrentScript();
959 void applyXSLTransform(ProcessingInstruction* pi);
960 RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
961 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
963 void setTransformSource(std::unique_ptr<TransformSource>);
964 TransformSource* transformSource() const { return m_transformSource.get(); }
967 void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
968 uint64_t domTreeVersion() const { return m_domTreeVersion; }
970 // XPathEvaluator methods
971 RefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&);
972 RefPtr<XPathNSResolver> createNSResolver(Node* nodeResolver);
973 RefPtr<XPathResult> evaluate(const String& expression, Node* contextNode, XPathNSResolver*, unsigned short type, XPathResult*, ExceptionCode&);
975 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
977 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
979 bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
980 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
982 void updateFocusAppearanceSoon(SelectionRestorationMode);
983 void cancelFocusAppearanceUpdate();
985 // Extension for manipulating canvas drawing contexts for use in CSS
986 CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
987 HTMLCanvasElement* getCSSCanvasElement(const String& name);
989 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
990 void parseDNSPrefetchControlHeader(const String&);
992 virtual void postTask(Task) override final; // Executes the task on context's thread asynchronously.
994 #if ENABLE(REQUEST_ANIMATION_FRAME)
995 ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
997 void suspendScriptedAnimationControllerCallbacks();
998 void resumeScriptedAnimationControllerCallbacks();
999 void scriptedAnimationControllerSetThrottled(bool);
1001 void windowScreenDidChange(PlatformDisplayID);
1003 void finishedParsing();
1005 bool inPageCache() const { return m_inPageCache; }
1006 void setInPageCache(bool flag);
1008 // Elements can register themselves for the "suspend()" and
1009 // "resume()" callbacks
1010 void registerForDocumentSuspensionCallbacks(Element*);
1011 void unregisterForDocumentSuspensionCallbacks(Element*);
1013 void documentWillBecomeInactive();
1014 void suspend(ActiveDOMObject::ReasonForSuspension);
1015 void resume(ActiveDOMObject::ReasonForSuspension);
1017 void registerForMediaVolumeCallbacks(Element*);
1018 void unregisterForMediaVolumeCallbacks(Element*);
1019 void mediaVolumeDidChange();
1021 #if ENABLE(MEDIA_SESSION)
1022 MediaSession& defaultMediaSession();
1025 void registerForPrivateBrowsingStateChangedCallbacks(Element*);
1026 void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
1027 void storageBlockingStateDidChange();
1028 void privateBrowsingStateDidChange();
1030 #if ENABLE(VIDEO_TRACK)
1031 void registerForCaptionPreferencesChangedCallbacks(Element*);
1032 void unregisterForCaptionPreferencesChangedCallbacks(Element*);
1033 void captionPreferencesChanged();
1036 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1037 void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1038 void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1039 void pageScaleFactorChangedAndStable();
1042 void registerForVisibilityStateChangedCallbacks(Element*);
1043 void unregisterForVisibilityStateChangedCallbacks(Element*);
1046 void registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1047 void unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1048 void allowsMediaDocumentInlinePlaybackChanged();
1051 WEBCORE_EXPORT void setShouldCreateRenderers(bool);
1052 bool shouldCreateRenderers();
1054 void setDecoder(RefPtr<TextResourceDecoder>&&);
1055 TextResourceDecoder* decoder() const { return m_decoder.get(); }
1057 WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
1058 RefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
1059 void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
1061 displayBufferModifiedByEncodingInternal(buffer, len);
1063 void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
1065 displayBufferModifiedByEncodingInternal(buffer, len);
1068 // Quirk for the benefit of Apple's Dictionary application.
1069 void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
1070 bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
1072 #if ENABLE(DASHBOARD_SUPPORT)
1073 void setAnnotatedRegionsDirty(bool f) { m_annotatedRegionsDirty = f; }
1074 bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
1075 bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
1076 void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
1077 WEBCORE_EXPORT const Vector<AnnotatedRegionValue>& annotatedRegions() const;
1078 void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
1081 virtual void removeAllEventListeners() override final;
1083 WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
1084 WEBCORE_EXPORT SVGDocumentExtensions& accessSVGExtensions();
1086 void initSecurityContext();
1087 void initContentSecurityPolicy();
1089 void updateURLForPushOrReplaceState(const URL&);
1090 void statePopped(PassRefPtr<SerializedScriptValue>);
1092 bool processingLoadEvent() const { return m_processingLoadEvent; }
1093 bool loadEventFinished() const { return m_loadEventFinished; }
1095 virtual bool isContextThread() const override final;
1096 virtual bool isJSExecutionForbidden() const override final { return false; }
1098 void enqueueWindowEvent(Ref<Event>&&);
1099 void enqueueDocumentEvent(Ref<Event>&&);
1100 void enqueueOverflowEvent(Ref<Event>&&);
1101 void enqueuePageshowEvent(PageshowEventPersistence);
1102 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
1103 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
1104 virtual DocumentEventQueue& eventQueue() const override final { return m_eventQueue; }
1106 WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener*);
1107 WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener*);
1108 MediaCanStartListener* takeAnyMediaCanStartListener();
1110 #if ENABLE(FULLSCREEN_API)
1111 bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
1112 bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() && m_areKeysEnabledInFullScreen; }
1113 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
1115 enum FullScreenCheckType {
1116 EnforceIFrameAllowFullScreenRequirement,
1117 ExemptIFrameAllowFullScreenRequirement,
1120 void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
1121 WEBCORE_EXPORT void webkitCancelFullScreen();
1123 WEBCORE_EXPORT void webkitWillEnterFullScreenForElement(Element*);
1124 WEBCORE_EXPORT void webkitDidEnterFullScreenForElement(Element*);
1125 WEBCORE_EXPORT void webkitWillExitFullScreenForElement(Element*);
1126 WEBCORE_EXPORT void webkitDidExitFullScreenForElement(Element*);
1128 void setFullScreenRenderer(RenderFullScreen*);
1129 RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
1130 void fullScreenRendererDestroyed();
1132 void fullScreenChangeDelayTimerFired();
1133 bool fullScreenIsAllowedForElement(Element*) const;
1134 void fullScreenElementRemoved();
1135 void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
1136 bool isAnimatingFullScreen() const;
1137 WEBCORE_EXPORT void setAnimatingFullScreen(bool);
1140 bool webkitFullscreenEnabled() const;
1141 Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : nullptr; }
1142 void webkitExitFullscreen();
1145 #if ENABLE(POINTER_LOCK)
1146 void exitPointerLock();
1147 Element* pointerLockElement() const;
1150 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
1151 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
1152 void decrementLoadEventDelayCount();
1153 bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
1155 #if ENABLE(IOS_TOUCH_EVENTS)
1156 #include <WebKitAdditions/DocumentIOS.h>
1157 #elif ENABLE(TOUCH_EVENTS)
1158 RefPtr<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const;
1161 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1162 DeviceMotionController* deviceMotionController() const;
1163 DeviceOrientationController* deviceOrientationController() const;
1166 #if ENABLE(WEB_TIMING)
1167 const DocumentTiming& timing() const { return m_documentTiming; }
1170 #if ENABLE(REQUEST_ANIMATION_FRAME)
1171 int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
1172 void cancelAnimationFrame(int id);
1173 void serviceScriptedAnimations(double monotonicAnimationStartTime);
1176 void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
1178 virtual EventTarget* errorEventTarget() override final;
1179 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) override final;
1181 void initDNSPrefetch();
1183 void didAddWheelEventHandler(Node&);
1184 void didRemoveWheelEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1186 double lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
1187 void updateLastHandledUserGestureTimestamp();
1189 #if ENABLE(TOUCH_EVENTS)
1190 bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
1192 bool hasTouchEventHandlers() const { return false; }
1195 // Used for testing. Count handlers in the main document, and one per frame which contains handlers.
1196 WEBCORE_EXPORT unsigned wheelEventHandlerCount() const;
1197 WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
1199 WEBCORE_EXPORT void startTrackingStyleRecalcs();
1200 WEBCORE_EXPORT unsigned styleRecalcCount() const;
1202 void didAddTouchEventHandler(Node&);
1203 void didRemoveTouchEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1205 void didRemoveEventTargetNode(Node&);
1207 const EventTargetSet* touchEventTargets() const
1209 #if ENABLE(TOUCH_EVENTS)
1210 return m_touchEventTargets.get();
1216 #if ENABLE(CUSTOM_ELEMENTS)
1217 CustomElementDefinitions* customElementDefinitions() { return m_customElementDefinitions.get(); }
1218 CustomElementDefinitions& ensureCustomElementDefinitions();
1221 const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
1223 typedef std::pair<Region, bool> RegionFixedPair;
1224 RegionFixedPair absoluteRegionForEventTargets(const EventTargetSet*);
1226 LayoutRect absoluteEventHandlerBounds(bool&) override final;
1228 bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
1230 bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
1232 void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1233 void resumeScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1235 #if ENABLE(CSS_DEVICE_ADAPTATION)
1236 IntSize initialViewportSize() const;
1239 #if ENABLE(TEXT_AUTOSIZING)
1240 TextAutosizer* textAutosizer() { return m_textAutosizer.get(); }
1243 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&);
1244 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&);
1246 bool hasActiveParser();
1247 void incrementActiveParserCount() { ++m_activeParserCount; }
1248 void decrementActiveParserCount();
1250 DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
1252 void didRemoveAllPendingStylesheet();
1253 void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
1254 void clearStyleResolver();
1256 bool inStyleRecalc() { return m_inStyleRecalc; }
1258 // Return a Locale for the default locale if the argument is null or empty.
1259 Locale& getCachedLocale(const AtomicString& locale = nullAtom);
1261 #if ENABLE(TEMPLATE_ELEMENT)
1262 const Document* templateDocument() const;
1263 Document& ensureTemplateDocument();
1264 void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = templateDocumentHost; }
1265 Document* templateDocumentHost() { return m_templateDocumentHost; }
1268 void didAssociateFormControl(Element*);
1269 bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; }
1270 void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
1271 void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
1273 WEBCORE_EXPORT virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override final;
1275 WEBCORE_EXPORT virtual SecurityOrigin* topOrigin() const override final;
1277 #if ENABLE(FONT_LOAD_EVENTS)
1278 RefPtr<FontLoader> fonts();
1281 void ensurePlugInsInjectedScript(DOMWrapperWorld&);
1283 void setVisualUpdatesAllowedByClient(bool);
1285 #if ENABLE(SUBTLE_CRYPTO)
1286 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override final;
1287 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override final;
1290 void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
1291 bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
1292 void updateViewportUnitsOnResize();
1294 WEBCORE_EXPORT void addAudioProducer(MediaProducer*);
1295 WEBCORE_EXPORT void removeAudioProducer(MediaProducer*);
1296 MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
1297 WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
1298 void pageMutedStateDidChange();
1299 WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
1301 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
1302 void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1303 void removePlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1304 void showPlaybackTargetPicker(MediaPlaybackTargetClient&, bool);
1305 void playbackTargetPickerClientStateDidChange(MediaPlaybackTargetClient&, MediaProducer::MediaStateFlags);
1307 void setPlaybackTarget(uint64_t, Ref<MediaPlaybackTarget>&&);
1308 void playbackTargetAvailabilityDidChange(uint64_t, bool);
1309 void setShouldPlayToPlaybackTarget(uint64_t, bool);
1312 ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicyToPropagate() const;
1313 bool shouldEnforceContentDispositionAttachmentSandbox() const;
1314 void applyContentDispositionAttachmentSandbox();
1316 void addViewportDependentPicture(HTMLPictureElement&);
1317 void removeViewportDependentPicture(HTMLPictureElement&);
1319 #if ENABLE(MEDIA_STREAM)
1320 void setHasActiveMediaStreamTrack() { m_hasHadActiveMediaStreamTrack = true; }
1321 bool hasHadActiveMediaStreamTrack() const { return m_hasHadActiveMediaStreamTrack; }
1325 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
1326 Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
1328 void clearXMLVersion() { m_xmlVersion = String(); }
1330 virtual Ref<Document> cloneDocumentWithoutChildren() const;
1334 friend class IgnoreDestructiveWriteCountIncrementer;
1335 friend class IgnoreOpensDuringUnloadCountIncrementer;
1337 void updateTitleElement(Element* newTitleElement);
1339 void commonTeardown();
1341 RenderObject* renderer() const = delete;
1342 void setRenderer(RenderObject*) = delete;
1344 void createRenderTree();
1345 void detachParser();
1347 typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
1348 void processArguments(const String& features, void* data, ArgumentsCallback);
1350 // FontSelectorClient
1351 virtual void fontsNeedUpdate(FontSelector&) override final;
1353 virtual bool isDocument() const override final { return true; }
1355 virtual void childrenChanged(const ChildChange&) override final;
1357 virtual String nodeName() const override final;
1358 virtual NodeType nodeType() const override final;
1359 virtual bool childTypeAllowed(NodeType) const override final;
1360 virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override final;
1361 void cloneDataFromDocument(const Document&);
1363 virtual void refScriptExecutionContext() override final { ref(); }
1364 virtual void derefScriptExecutionContext() override final { deref(); }
1366 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) override final;
1368 virtual double minimumTimerInterval() const override final;
1370 virtual double timerAlignmentInterval(bool hasReachedMaxNestingLevel) const override final;
1372 void updateTitleFromTitleElement();
1373 void updateTitle(const StringWithDirection&);
1374 void updateFocusAppearanceTimerFired();
1375 void updateBaseURL();
1377 void buildAccessKeyMap(TreeScope* root);
1379 void createStyleResolver();
1381 void loadEventDelayTimerFired();
1383 void pendingTasksTimerFired();
1385 template <typename CharacterType>
1386 void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
1388 PageVisibilityState pageVisibilityState() const;
1390 Node* nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint = nullptr);
1392 template <CollectionType collectionType>
1393 Ref<HTMLCollection> ensureCachedCollection();
1395 #if ENABLE(FULLSCREEN_API)
1396 void dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>&, const AtomicString& eventName, bool shouldNotifyMediaElement);
1397 void clearFullscreenElementStack();
1398 void popFullscreenElementStack();
1399 void pushFullscreenElementStack(Element*);
1400 void addDocumentToFullScreenChangeEventQueue(Document*);
1403 void setVisualUpdatesAllowed(ReadyState);
1404 void setVisualUpdatesAllowed(bool);
1405 void visualUpdatesSuppressionTimerFired();
1407 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
1409 void didAssociateFormControlsTimerFired();
1411 void wheelEventHandlersChanged();
1413 HttpEquivPolicy httpEquivPolicy() const;
1415 // DOM Cookies caching.
1416 const String& cachedDOMCookies() const { return m_cachedDOMCookies; }
1417 void setCachedDOMCookies(const String&);
1418 bool isDOMCookieCacheValid() const { return m_cookieCacheExpiryTimer.isActive(); }
1419 void invalidateDOMCookieCache();
1420 virtual void didLoadResourceSynchronously(const ResourceRequest&) override final;
1422 void checkViewportDependentPictures();
1424 unsigned m_referencingNodeCount;
1426 std::unique_ptr<StyleResolver> m_styleResolver;
1427 std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
1428 bool m_didCalculateStyleResolver;
1429 bool m_hasNodesWithPlaceholderStyle;
1430 bool m_needsNotifyRemoveAllPendingStylesheet;
1431 // But sometimes you need to ignore pending stylesheet count to
1432 // force an immediate layout when requested by JS.
1433 bool m_ignorePendingStylesheets;
1435 // If we do ignore the pending stylesheet count, then we need to add a boolean
1436 // to track that this happened so that we can do a full repaint when the stylesheets
1437 // do eventually load.
1438 PendingSheetLayout m_pendingSheetLayout;
1441 RefPtr<DOMWindow> m_domWindow;
1443 Ref<CachedResourceLoader> m_cachedResourceLoader;
1444 RefPtr<DocumentParser> m_parser;
1445 unsigned m_activeParserCount;
1450 URL m_url; // Document.URL: The URL from which this document was retrieved.
1451 URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
1452 URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
1453 URL m_baseElementURL; // The URL set by the <base> element.
1454 URL m_cookieURL; // The URL to use for cookie access.
1455 URL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
1457 // Document.documentURI:
1458 // Although URL-like, Document.documentURI can actually be set to any
1459 // string by content. Document.documentURI affects m_baseURL unless the
1460 // document contains a <base> element, in which case the <base> element
1461 // takes precedence.
1463 // This property is read-only from JavaScript, but writable from Objective C.
1464 String m_documentURI;
1466 String m_baseTarget;
1468 // MIME type of the document in case it was cloned or created by XHR.
1469 String m_overriddenMIMEType;
1471 std::unique_ptr<DOMImplementation> m_implementation;
1473 RefPtr<CSSStyleSheet> m_elementSheet;
1476 bool m_paginatedForScreen;
1478 DocumentCompatibilityMode m_compatibilityMode;
1479 bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
1483 RefPtr<Element> m_focusedElement;
1484 RefPtr<Element> m_hoveredElement;
1485 RefPtr<Element> m_activeElement;
1486 RefPtr<Element> m_documentElement;
1487 UserActionElementSet m_userActionElements;
1489 uint64_t m_domTreeVersion;
1490 static uint64_t s_globalTreeVersion;
1492 HashSet<NodeIterator*> m_nodeIterators;
1493 HashSet<Range*> m_ranges;
1495 unsigned m_listenerTypes;
1497 MutationObserverOptions m_mutationObserverTypes;
1499 std::unique_ptr<AuthorStyleSheets> m_authorStyleSheets;
1500 std::unique_ptr<ExtensionStyleSheets> m_extensionStyleSheets;
1501 RefPtr<StyleSheetList> m_styleSheetList;
1503 std::unique_ptr<FormController> m_formController;
1506 Color m_visitedLinkColor;
1507 Color m_activeLinkColor;
1508 const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
1510 bool m_visuallyOrdered;
1511 ReadyState m_readyState;
1514 Timer m_optimizedStyleSheetUpdateTimer;
1515 Timer m_styleRecalcTimer;
1516 bool m_pendingStyleRecalcShouldForce;
1517 bool m_inStyleRecalc;
1518 bool m_closeAfterStyleRecalc;
1520 bool m_gotoAnchorNeededAfterStylesheetsLoad;
1521 bool m_isDNSPrefetchEnabled;
1522 bool m_haveExplicitlyDisabledDNSPrefetch;
1523 bool m_frameElementsShouldIgnoreScrolling;
1524 SelectionRestorationMode m_updateFocusAppearanceRestoresSelection;
1526 // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-destructive-writes-counter
1527 unsigned m_ignoreDestructiveWriteCount { 0 };
1529 // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-opens-during-unload-counter
1530 unsigned m_ignoreOpensDuringUnloadCount { 0 };
1532 unsigned m_styleRecalcCount { 0 };
1534 StringWithDirection m_title;
1535 StringWithDirection m_rawTitle;
1536 RefPtr<Element> m_titleElement;
1538 std::unique_ptr<AXObjectCache> m_axObjectCache;
1539 const std::unique_ptr<DocumentMarkerController> m_markers;
1541 Timer m_updateFocusAppearanceTimer;
1543 Element* m_cssTarget;
1545 // FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
1546 // is almost a duplication of this data, so that should probably get merged in too.
1547 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadDispatched are roughly the same
1548 // and should be merged.
1549 bool m_processingLoadEvent;
1550 bool m_loadEventFinished;
1552 RefPtr<SerializedScriptValue> m_pendingStateObject;
1553 std::chrono::steady_clock::time_point m_startTime;
1554 bool m_overMinimumLayoutThreshold;
1556 std::unique_ptr<ScriptRunner> m_scriptRunner;
1557 std::unique_ptr<JSModuleLoader> m_moduleLoader;
1559 Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
1562 std::unique_ptr<TransformSource> m_transformSource;
1563 RefPtr<Document> m_transformSourceDocument;
1566 String m_xmlEncoding;
1567 String m_xmlVersion;
1568 unsigned m_xmlStandalone : 2;
1569 unsigned m_hasXMLDeclaration : 1;
1571 String m_contentLanguage;
1573 RefPtr<TextResourceDecoder> m_decoder;
1575 InheritedBool m_designMode;
1577 HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
1578 HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
1579 #if !ASSERT_DISABLED
1580 bool m_inInvalidateNodeListAndCollectionCaches;
1583 unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
1585 RefPtr<XPathEvaluator> m_xpathEvaluator;
1587 std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1589 #if ENABLE(DASHBOARD_SUPPORT)
1590 Vector<AnnotatedRegionValue> m_annotatedRegions;
1591 bool m_hasAnnotatedRegions;
1592 bool m_annotatedRegionsDirty;
1595 HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
1597 bool m_createRenderers;
1600 HashSet<Element*> m_documentSuspensionCallbackElements;
1601 HashSet<Element*> m_mediaVolumeCallbackElements;
1602 HashSet<Element*> m_privateBrowsingStateChangedElements;
1603 #if ENABLE(VIDEO_TRACK)
1604 HashSet<Element*> m_captionPreferencesChangedElements;
1607 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1608 HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
1611 HashSet<Element*> m_visibilityStateCallbackElements;
1613 HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
1616 HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
1617 bool m_accessKeyMapValid;
1619 DocumentOrderedMap m_imagesByUsemap;
1621 std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
1623 DocumentClassFlags m_documentClasses;
1625 bool m_isSynthesized;
1626 bool m_isNonRenderedPlaceholder;
1628 bool m_sawElementsInKnownNamespaces;
1629 bool m_isSrcdocDocument;
1631 RenderPtr<RenderView> m_renderView;
1632 mutable DocumentEventQueue m_eventQueue;
1634 WeakPtrFactory<Document> m_weakFactory;
1636 HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
1638 #if ENABLE(FULLSCREEN_API)
1639 bool m_areKeysEnabledInFullScreen;
1640 RefPtr<Element> m_fullScreenElement;
1641 Vector<RefPtr<Element>> m_fullScreenElementStack;
1642 RenderFullScreen* m_fullScreenRenderer;
1643 Timer m_fullScreenChangeDelayTimer;
1644 Deque<RefPtr<Node>> m_fullScreenChangeEventTargetQueue;
1645 Deque<RefPtr<Node>> m_fullScreenErrorEventTargetQueue;
1646 bool m_isAnimatingFullScreen;
1647 LayoutRect m_savedPlaceholderFrameRect;
1648 RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
1651 HashSet<HTMLPictureElement*> m_viewportDependentPictures;
1653 int m_loadEventDelayCount;
1654 Timer m_loadEventDelayTimer;
1656 ViewportArguments m_viewportArguments;
1658 ReferrerPolicy m_referrerPolicy;
1660 #if ENABLE(WEB_TIMING)
1661 DocumentTiming m_documentTiming;
1664 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
1665 bool m_writeRecursionIsTooDeep;
1666 unsigned m_writeRecursionDepth;
1668 #if ENABLE(TOUCH_EVENTS)
1669 std::unique_ptr<EventTargetSet> m_touchEventTargets;
1671 std::unique_ptr<EventTargetSet> m_wheelEventTargets;
1673 double m_lastHandledUserGestureTimestamp;
1675 #if ENABLE(REQUEST_ANIMATION_FRAME)
1676 void clearScriptedAnimationController();
1677 RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
1680 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1681 std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
1682 std::unique_ptr<DeviceMotionController> m_deviceMotionController;
1683 std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
1684 std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
1687 // FIXME: Find a better place for this functionality.
1688 #if ENABLE(TELEPHONE_NUMBER_DETECTION)
1691 // These functions provide a two-level setting:
1692 // - A user-settable wantsTelephoneNumberParsing (at the Page / WebView level)
1693 // - A read-only telephoneNumberParsingAllowed which is set by the
1694 // document if it has the appropriate meta tag.
1695 // - isTelephoneNumberParsingEnabled() == isTelephoneNumberParsingAllowed() && page()->settings()->isTelephoneNumberParsingEnabled()
1697 WEBCORE_EXPORT bool isTelephoneNumberParsingAllowed() const;
1698 WEBCORE_EXPORT bool isTelephoneNumberParsingEnabled() const;
1701 friend void setParserFeature(const String& key, const String& value, Document*, void* userData);
1702 void setIsTelephoneNumberParsingAllowed(bool);
1704 bool m_isTelephoneNumberParsingAllowed;
1707 Timer m_pendingTasksTimer;
1708 Vector<Task> m_pendingTasks;
1710 #if ENABLE(IOS_TEXT_AUTOSIZING)
1712 void addAutoSizingNode(Node*, float size);
1713 void validateAutoSizingNodes();
1714 void resetAutoSizingNodes();
1717 typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
1718 TextAutoSizingMap m_textAutoSizedNodes;
1721 #if ENABLE(TEXT_AUTOSIZING)
1722 std::unique_ptr<TextAutosizer> m_textAutosizer;
1725 void platformSuspendOrStopActiveDOMObjects();
1727 bool m_scheduledTasksAreSuspended;
1729 bool m_visualUpdatesAllowed;
1730 Timer m_visualUpdatesSuppressionTimer;
1732 RefPtr<NamedFlowCollection> m_namedFlows;
1734 #if ENABLE(CSP_NEXT)
1735 RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
1738 void sharedObjectPoolClearTimerFired();
1739 Timer m_sharedObjectPoolClearTimer;
1741 std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
1744 bool m_didDispatchViewportPropertiesChanged;
1747 typedef HashMap<AtomicString, std::unique_ptr<Locale>> LocaleIdentifierToLocaleMap;
1748 LocaleIdentifierToLocaleMap m_localeCache;
1750 #if ENABLE(TEMPLATE_ELEMENT)
1751 RefPtr<Document> m_templateDocument;
1752 Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
1755 #if ENABLE(CUSTOM_ELEMENTS)
1756 std::unique_ptr<CustomElementDefinitions> m_customElementDefinitions;
1759 RefPtr<CSSFontSelector> m_fontSelector;
1761 #if ENABLE(FONT_LOAD_EVENTS)
1762 RefPtr<FontLoader> m_fontloader;
1765 #if ENABLE(WEB_REPLAY)
1766 RefPtr<JSC::InputCursor> m_inputCursor;
1769 Timer m_didAssociateFormControlsTimer;
1770 Timer m_cookieCacheExpiryTimer;
1771 String m_cachedDOMCookies;
1772 HashSet<RefPtr<Element>> m_associatedFormControls;
1773 unsigned m_disabledFieldsetElementsCount;
1775 bool m_hasInjectedPlugInsScript;
1776 bool m_renderTreeBeingDestroyed;
1777 bool m_hasPreparedForDestruction;
1779 bool m_hasStyleWithViewportUnits;
1780 bool m_isTimerThrottlingEnabled { false };
1781 bool m_isSuspended { false };
1783 HashSet<MediaProducer*> m_audioProducers;
1784 MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
1786 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
1787 typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
1788 TargetIdToClientMap m_idToClientMap;
1789 typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
1790 TargetClientToIdMap m_clientToIDMap;
1793 #if ENABLE(MEDIA_SESSION)
1794 RefPtr<MediaSession> m_defaultMediaSession;
1796 bool m_areDeviceMotionAndOrientationUpdatesSuspended { false };
1798 #if ENABLE(MEDIA_STREAM)
1799 bool m_hasHadActiveMediaStreamTrack { false };
1803 inline void Document::notifyRemovePendingSheetIfNeeded()
1805 if (m_needsNotifyRemoveAllPendingStylesheet)
1806 didRemoveAllPendingStylesheet();
1809 inline TextEncoding Document::textEncoding() const
1811 if (auto* decoder = this->decoder())
1812 return decoder->encoding();
1813 return TextEncoding();
1816 #if ENABLE(TEMPLATE_ELEMENT)
1817 inline const Document* Document::templateDocument() const
1819 // If DOCUMENT does not have a browsing context, Let TEMPLATE CONTENTS OWNER be DOCUMENT and abort these steps.
1823 return m_templateDocument.get();
1827 // Put these methods here, because they require the Document definition, but we really want to inline them.
1829 inline bool Node::isDocumentNode() const
1831 return this == &document();
1834 inline ScriptExecutionContext* Node::scriptExecutionContext() const
1839 Element* eventTargetElementForDocument(Document*);
1841 } // namespace WebCore
1843 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
1844 static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
1845 static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
1846 SPECIALIZE_TYPE_TRAITS_END()
1848 #endif // Document_h