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
272 typedef unsigned char DocumentClassFlags;
274 enum class DocumentCompatibilityMode : unsigned char {
277 LimitedQuirksMode = 1 << 2
280 enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
282 enum class SelectionRestorationMode {
287 enum class SelectionRevealMode {
292 enum class HttpEquivPolicy {
295 DisabledByContentDispositionAttachmentSandbox
298 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext, public FontSelectorClient {
300 static Ref<Document> create(Frame* frame, const URL& url)
302 return adoptRef(*new Document(frame, url));
304 static Ref<Document> createXHTML(Frame* frame, const URL& url)
306 return adoptRef(*new Document(frame, url, XHTMLDocumentClass));
308 static Ref<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
310 return adoptRef(*new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
312 static Ref<Document> create(ScriptExecutionContext&);
316 // Nodes belonging to this document increase referencingNodeCount -
317 // these are enough to keep the document from being destroyed, but
318 // not enough to keep it from removing its children. This allows a
319 // node that outlives its document to still have a valid document
320 // pointer without introducing reference cycles.
321 void incrementReferencingNodeCount()
323 ASSERT(!m_deletionHasBegun);
324 ++m_referencingNodeCount;
327 void decrementReferencingNodeCount()
329 ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
330 --m_referencingNodeCount;
331 if (!m_referencingNodeCount && !refCount()) {
333 m_deletionHasBegun = true;
339 unsigned referencingNodeCount() const { return m_referencingNodeCount; }
341 void removedLastRef();
343 WEBCORE_EXPORT static HashSet<Document*>& allDocuments();
345 MediaQueryMatcher& mediaQueryMatcher();
347 using ContainerNode::ref;
348 using ContainerNode::deref;
350 virtual bool canContainRangeEndPoint() const override final { return true; }
352 Element* getElementByAccessKey(const String& key);
353 void invalidateAccessKeyMap();
355 void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
356 void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
357 HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
359 SelectorQuery* selectorQueryForString(const String&, ExceptionCode&);
360 void clearSelectorQueryCache();
362 // DOM methods & attributes for Document
364 void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
365 ViewportArguments viewportArguments() const { return m_viewportArguments; }
367 bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
370 void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
371 ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
373 DocumentType* doctype() const;
375 DOMImplementation& implementation();
377 Element* documentElement() const
379 return m_documentElement.get();
381 static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
383 Element* activeElement();
384 bool hasFocus() const;
386 bool hasManifest() const;
388 WEBCORE_EXPORT RefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
389 WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
390 WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
391 Ref<Comment> createComment(const String& data);
392 RefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
393 RefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
394 RefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
395 RefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
396 RefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
397 RefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, false, ec); }
398 RefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
399 WEBCORE_EXPORT RefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
400 WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
402 bool cssRegionsEnabled() const;
403 bool cssCompositingEnabled() const;
404 #if ENABLE(CSS_REGIONS)
405 RefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
408 NamedFlowCollection& namedFlows();
410 Element* elementFromPoint(int x, int y) { return elementFromPoint(LayoutPoint(x, y)); }
411 Element* elementFromPoint(const LayoutPoint& clientPoint);
413 RefPtr<Range> caretRangeFromPoint(int x, int y);
414 RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
416 Element* scrollingElement();
418 String readyState() const;
420 String defaultCharset() const;
422 String charset() const { return Document::encoding(); }
423 String characterSetWithUTF8Fallback() const;
424 TextEncoding textEncoding() const;
426 AtomicString encoding() const { return textEncoding().domName(); }
428 void setCharset(const String&);
430 void setContent(const String&);
432 String suggestedMIMEType() const;
434 void overrideMIMEType(const String&);
435 String contentType() const;
437 String contentLanguage() const { return m_contentLanguage; }
438 void setContentLanguage(const String&);
440 String xmlEncoding() const { return m_xmlEncoding; }
441 String xmlVersion() const { return m_xmlVersion; }
442 enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
443 bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
444 StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
445 bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
447 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
448 void setXMLVersion(const String&, ExceptionCode&);
449 void setXMLStandalone(bool, ExceptionCode&);
450 void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
452 String documentURI() const { return m_documentURI; }
453 void setDocumentURI(const String&);
455 #if ENABLE(WEB_REPLAY)
456 JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
457 void setInputCursor(PassRefPtr<JSC::InputCursor>);
460 void visibilityStateChanged();
461 String visibilityState() const;
464 void setTimerThrottlingEnabled(bool);
465 bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
468 DOMSecurityPolicy& securityPolicy();
471 RefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
473 Ref<HTMLCollection> images();
474 Ref<HTMLCollection> embeds();
475 Ref<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
476 Ref<HTMLCollection> applets();
477 Ref<HTMLCollection> links();
478 Ref<HTMLCollection> forms();
479 Ref<HTMLCollection> anchors();
480 Ref<HTMLCollection> scripts();
481 Ref<HTMLCollection> all();
483 Ref<HTMLCollection> windowNamedItems(const AtomicString& name);
484 Ref<HTMLCollection> documentNamedItems(const AtomicString& name);
486 // Other methods (not part of DOM)
487 bool isSynthesized() const { return m_isSynthesized; }
488 bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
489 bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
490 bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
491 bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
492 bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
493 bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
494 bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
495 bool hasSVGRootNode() const;
496 virtual bool isFrameSet() const { return false; }
498 static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
499 static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
501 bool isSrcdocDocument() const { return m_isSrcdocDocument; }
503 StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
505 bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
507 StyleResolver& ensureStyleResolver()
509 if (!m_styleResolver)
510 createStyleResolver();
511 return *m_styleResolver;
513 StyleResolver& userAgentShadowTreeStyleResolver();
515 CSSFontSelector& fontSelector();
517 void notifyRemovePendingSheetIfNeeded();
519 WEBCORE_EXPORT bool haveStylesheetsLoaded() const;
521 // This is a DOM function.
522 StyleSheetList& styleSheets();
524 AuthorStyleSheets& authorStyleSheets() { return *m_authorStyleSheets; }
525 const AuthorStyleSheets& authorStyleSheets() const { return *m_authorStyleSheets; }
526 ExtensionStyleSheets& extensionStyleSheets() { return *m_extensionStyleSheets; }
527 const ExtensionStyleSheets& extensionStyleSheets() const { return *m_extensionStyleSheets; }
529 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
530 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
533 * Called when one or more stylesheets in the document may have been added, removed or changed.
535 * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
536 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
537 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
538 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
539 * found and is used to calculate the derived styles for all rendering objects.
541 WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
543 void scheduleOptimizedStyleSheetUpdate();
545 void evaluateMediaQueryList();
547 FormController& formController();
548 Vector<String> formElementsState() const;
549 void setStateForNewFormElements(const Vector<String>&);
551 WEBCORE_EXPORT FrameView* view() const; // can be NULL
552 Frame* frame() const { return m_frame; } // can be NULL
553 WEBCORE_EXPORT Page* page() const; // can be NULL
554 WEBCORE_EXPORT Settings* settings() const; // can be NULL
556 float deviceScaleFactor() const;
558 WEBCORE_EXPORT Ref<Range> createRange();
560 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
561 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
562 RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, ExceptionCode&);
563 RefPtr<NodeIterator> createNodeIterator(Node* root, ExceptionCode&);
565 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
566 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
567 RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, ExceptionCode&);
568 RefPtr<TreeWalker> createTreeWalker(Node* root, ExceptionCode&);
570 // Special support for editing
571 Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
572 Ref<Text> createEditingTextNode(const String&);
574 void recalcStyle(Style::Change = Style::NoChange);
575 WEBCORE_EXPORT void updateStyleIfNeeded();
576 bool needsStyleRecalc() const { return !inPageCache() && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
578 WEBCORE_EXPORT void updateLayout();
580 // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads,
581 // so calling this may cause a flash of unstyled content (FOUC).
582 enum class RunPostLayoutTasks {
586 WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
588 Ref<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, RenderStyle* parentStyle);
590 // Returns true if page box (margin boxes and page borders) is visible.
591 WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);
593 // Returns the preferred page size and margins in pixels, assuming 96
594 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
595 // marginLeft must be initialized to the default values that are used if
596 // auto is specified.
597 WEBCORE_EXPORT void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
599 CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader; }
601 void didBecomeCurrentDocumentInFrame();
602 void destroyRenderTree();
603 void disconnectFromFrame();
604 void prepareForDestruction();
606 // Override ScriptExecutionContext methods to do additional work
607 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override final;
608 virtual void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override final;
609 virtual void stopActiveDOMObjects() override final;
611 void suspendDeviceMotionAndOrientationUpdates();
612 void resumeDeviceMotionAndOrientationUpdates();
614 RenderView* renderView() const { return m_renderView.get(); }
616 bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
617 bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
619 bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
621 AXObjectCache* existingAXObjectCache() const;
622 WEBCORE_EXPORT AXObjectCache* axObjectCache() const;
623 void clearAXObjectCache();
625 // to get visually ordered hebrew and arabic pages right
626 void setVisuallyOrdered();
627 bool visuallyOrdered() const { return m_visuallyOrdered; }
629 WEBCORE_EXPORT DocumentLoader* loader() const;
631 void open(Document* ownerDocument = nullptr);
634 // close() is the DOM API document.close()
636 // In some situations (see the code), we ignore document.close().
637 // explicitClose() bypass these checks and actually tries to close the
639 void explicitClose();
640 // implicitClose() actually does the work of closing the input stream.
641 void implicitClose();
643 void cancelParsing();
645 void write(const SegmentedString& text, Document* ownerDocument = nullptr);
646 void write(const String& text, Document* ownerDocument = nullptr);
647 void writeln(const String& text, Document* ownerDocument = nullptr);
649 bool wellFormed() const { return m_wellFormed; }
651 virtual const URL& url() const override final { return m_url; }
652 void setURL(const 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(PassRefPtr<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(PassRefPtr<HTMLElement>, ExceptionCode&);
929 Location* location() const;
931 WEBCORE_EXPORT HTMLHeadElement* head();
933 DocumentMarkerController& markers() const { return *m_markers; }
935 bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
936 bool writingModeSetOnDocumentElement() const { return m_writingModeSetOnDocumentElement; }
937 void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
938 void setWritingModeSetOnDocumentElement(bool b) { m_writingModeSetOnDocumentElement = b; }
940 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
941 bool queryCommandEnabled(const String& command);
942 bool queryCommandIndeterm(const String& command);
943 bool queryCommandState(const String& command);
944 bool queryCommandSupported(const String& command);
945 String queryCommandValue(const String& command);
947 // designMode support
948 enum InheritedBool { off = false, on = true, inherit };
949 void setDesignMode(InheritedBool value);
950 InheritedBool getDesignMode() const;
951 bool inDesignMode() const;
953 Document* parentDocument() const;
954 Document& topDocument() const;
956 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
957 JSModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
959 HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
960 void pushCurrentScript(PassRefPtr<HTMLScriptElement>);
961 void popCurrentScript();
964 void applyXSLTransform(ProcessingInstruction* pi);
965 RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
966 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
968 void setTransformSource(std::unique_ptr<TransformSource>);
969 TransformSource* transformSource() const { return m_transformSource.get(); }
972 void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
973 uint64_t domTreeVersion() const { return m_domTreeVersion; }
975 // XPathEvaluator methods
976 RefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&);
977 RefPtr<XPathNSResolver> createNSResolver(Node* nodeResolver);
978 RefPtr<XPathResult> evaluate(const String& expression, Node* contextNode, XPathNSResolver*, unsigned short type, XPathResult*, ExceptionCode&);
980 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
982 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
984 bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
985 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
987 void updateFocusAppearanceSoon(SelectionRestorationMode);
988 void cancelFocusAppearanceUpdate();
990 // Extension for manipulating canvas drawing contexts for use in CSS
991 CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
992 HTMLCanvasElement* getCSSCanvasElement(const String& name);
994 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
995 void parseDNSPrefetchControlHeader(const String&);
997 virtual void postTask(Task) override final; // Executes the task on context's thread asynchronously.
999 #if ENABLE(REQUEST_ANIMATION_FRAME)
1000 ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
1002 void suspendScriptedAnimationControllerCallbacks();
1003 void resumeScriptedAnimationControllerCallbacks();
1004 void scriptedAnimationControllerSetThrottled(bool);
1006 void windowScreenDidChange(PlatformDisplayID);
1008 void finishedParsing();
1010 bool inPageCache() const { return m_inPageCache; }
1011 void setInPageCache(bool flag);
1013 // Elements can register themselves for the "suspend()" and
1014 // "resume()" callbacks
1015 void registerForDocumentSuspensionCallbacks(Element*);
1016 void unregisterForDocumentSuspensionCallbacks(Element*);
1018 void documentWillBecomeInactive();
1022 void registerForMediaVolumeCallbacks(Element*);
1023 void unregisterForMediaVolumeCallbacks(Element*);
1024 void mediaVolumeDidChange();
1026 #if ENABLE(MEDIA_SESSION)
1027 MediaSession& defaultMediaSession();
1030 void registerForPrivateBrowsingStateChangedCallbacks(Element*);
1031 void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
1032 void storageBlockingStateDidChange();
1033 void privateBrowsingStateDidChange();
1035 #if ENABLE(VIDEO_TRACK)
1036 void registerForCaptionPreferencesChangedCallbacks(Element*);
1037 void unregisterForCaptionPreferencesChangedCallbacks(Element*);
1038 void captionPreferencesChanged();
1041 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1042 void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1043 void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1044 void pageScaleFactorChangedAndStable();
1047 void registerForVisibilityStateChangedCallbacks(Element*);
1048 void unregisterForVisibilityStateChangedCallbacks(Element*);
1051 void registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1052 void unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
1053 void allowsMediaDocumentInlinePlaybackChanged();
1056 WEBCORE_EXPORT void setShouldCreateRenderers(bool);
1057 bool shouldCreateRenderers();
1059 void setDecoder(PassRefPtr<TextResourceDecoder>);
1060 TextResourceDecoder* decoder() const { return m_decoder.get(); }
1062 WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
1063 RefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
1064 void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
1066 displayBufferModifiedByEncodingInternal(buffer, len);
1068 void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
1070 displayBufferModifiedByEncodingInternal(buffer, len);
1073 // Quirk for the benefit of Apple's Dictionary application.
1074 void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
1075 bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
1077 #if ENABLE(DASHBOARD_SUPPORT)
1078 void setAnnotatedRegionsDirty(bool f) { m_annotatedRegionsDirty = f; }
1079 bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
1080 bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
1081 void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
1082 WEBCORE_EXPORT const Vector<AnnotatedRegionValue>& annotatedRegions() const;
1083 void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
1086 virtual void removeAllEventListeners() override final;
1088 WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
1089 WEBCORE_EXPORT SVGDocumentExtensions& accessSVGExtensions();
1091 void initSecurityContext();
1092 void initContentSecurityPolicy();
1094 void updateURLForPushOrReplaceState(const URL&);
1095 void statePopped(PassRefPtr<SerializedScriptValue>);
1097 bool processingLoadEvent() const { return m_processingLoadEvent; }
1098 bool loadEventFinished() const { return m_loadEventFinished; }
1100 virtual bool isContextThread() const override final;
1101 virtual bool isJSExecutionForbidden() const override final { return false; }
1103 void enqueueWindowEvent(Ref<Event>&&);
1104 void enqueueDocumentEvent(Ref<Event>&&);
1105 void enqueueOverflowEvent(Ref<Event>&&);
1106 void enqueuePageshowEvent(PageshowEventPersistence);
1107 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
1108 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
1109 virtual DocumentEventQueue& eventQueue() const override final { return m_eventQueue; }
1111 WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener*);
1112 WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener*);
1113 MediaCanStartListener* takeAnyMediaCanStartListener();
1115 #if ENABLE(FULLSCREEN_API)
1116 bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
1117 bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() && m_areKeysEnabledInFullScreen; }
1118 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
1120 enum FullScreenCheckType {
1121 EnforceIFrameAllowFullScreenRequirement,
1122 ExemptIFrameAllowFullScreenRequirement,
1125 void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
1126 WEBCORE_EXPORT void webkitCancelFullScreen();
1128 WEBCORE_EXPORT void webkitWillEnterFullScreenForElement(Element*);
1129 WEBCORE_EXPORT void webkitDidEnterFullScreenForElement(Element*);
1130 WEBCORE_EXPORT void webkitWillExitFullScreenForElement(Element*);
1131 WEBCORE_EXPORT void webkitDidExitFullScreenForElement(Element*);
1133 void setFullScreenRenderer(RenderFullScreen*);
1134 RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
1135 void fullScreenRendererDestroyed();
1137 void fullScreenChangeDelayTimerFired();
1138 bool fullScreenIsAllowedForElement(Element*) const;
1139 void fullScreenElementRemoved();
1140 void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
1141 bool isAnimatingFullScreen() const;
1142 WEBCORE_EXPORT void setAnimatingFullScreen(bool);
1145 bool webkitFullscreenEnabled() const;
1146 Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : nullptr; }
1147 void webkitExitFullscreen();
1150 #if ENABLE(POINTER_LOCK)
1151 void exitPointerLock();
1152 Element* pointerLockElement() const;
1155 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
1156 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
1157 void decrementLoadEventDelayCount();
1158 bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
1160 #if ENABLE(IOS_TOUCH_EVENTS)
1161 #include <WebKitAdditions/DocumentIOS.h>
1162 #elif ENABLE(TOUCH_EVENTS)
1163 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;
1166 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1167 DeviceMotionController* deviceMotionController() const;
1168 DeviceOrientationController* deviceOrientationController() const;
1171 #if ENABLE(WEB_TIMING)
1172 const DocumentTiming& timing() const { return m_documentTiming; }
1175 #if ENABLE(REQUEST_ANIMATION_FRAME)
1176 int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
1177 void cancelAnimationFrame(int id);
1178 void serviceScriptedAnimations(double monotonicAnimationStartTime);
1181 void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
1183 virtual EventTarget* errorEventTarget() override final;
1184 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) override final;
1186 void initDNSPrefetch();
1188 void didAddWheelEventHandler(Node&);
1189 void didRemoveWheelEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1191 double lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
1192 void updateLastHandledUserGestureTimestamp();
1194 #if ENABLE(TOUCH_EVENTS)
1195 bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
1197 bool hasTouchEventHandlers() const { return false; }
1200 // Used for testing. Count handlers in the main document, and one per frame which contains handlers.
1201 WEBCORE_EXPORT unsigned wheelEventHandlerCount() const;
1202 WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
1204 WEBCORE_EXPORT void startTrackingStyleRecalcs();
1205 WEBCORE_EXPORT unsigned styleRecalcCount() const;
1207 void didAddTouchEventHandler(Node&);
1208 void didRemoveTouchEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
1210 void didRemoveEventTargetNode(Node&);
1212 const EventTargetSet* touchEventTargets() const
1214 #if ENABLE(TOUCH_EVENTS)
1215 return m_touchEventTargets.get();
1221 #if ENABLE(CUSTOM_ELEMENTS)
1222 CustomElementDefinitions* customElementDefinitions() { return m_customElementDefinitions.get(); }
1223 CustomElementDefinitions& ensureCustomElementDefinitions();
1226 const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
1228 typedef std::pair<Region, bool> RegionFixedPair;
1229 RegionFixedPair absoluteRegionForEventTargets(const EventTargetSet*);
1231 LayoutRect absoluteEventHandlerBounds(bool&) override final;
1233 bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
1235 bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
1237 void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1238 void resumeScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1240 #if ENABLE(CSS_DEVICE_ADAPTATION)
1241 IntSize initialViewportSize() const;
1244 #if ENABLE(TEXT_AUTOSIZING)
1245 TextAutosizer* textAutosizer() { return m_textAutosizer.get(); }
1248 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&);
1249 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&);
1251 bool hasActiveParser();
1252 void incrementActiveParserCount() { ++m_activeParserCount; }
1253 void decrementActiveParserCount();
1255 DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
1257 void didRemoveAllPendingStylesheet();
1258 void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
1259 void clearStyleResolver();
1261 bool inStyleRecalc() { return m_inStyleRecalc; }
1263 // Return a Locale for the default locale if the argument is null or empty.
1264 Locale& getCachedLocale(const AtomicString& locale = nullAtom);
1266 #if ENABLE(TEMPLATE_ELEMENT)
1267 const Document* templateDocument() const;
1268 Document& ensureTemplateDocument();
1269 void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = templateDocumentHost; }
1270 Document* templateDocumentHost() { return m_templateDocumentHost; }
1273 void didAssociateFormControl(Element*);
1274 bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; }
1275 void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
1276 void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
1278 WEBCORE_EXPORT virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override final;
1280 WEBCORE_EXPORT virtual SecurityOrigin* topOrigin() const override final;
1282 #if ENABLE(FONT_LOAD_EVENTS)
1283 RefPtr<FontLoader> fonts();
1286 void ensurePlugInsInjectedScript(DOMWrapperWorld&);
1288 void setVisualUpdatesAllowedByClient(bool);
1290 #if ENABLE(SUBTLE_CRYPTO)
1291 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override final;
1292 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override final;
1295 void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
1296 bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
1297 void updateViewportUnitsOnResize();
1299 WEBCORE_EXPORT void addAudioProducer(MediaProducer*);
1300 WEBCORE_EXPORT void removeAudioProducer(MediaProducer*);
1301 MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
1302 WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
1303 void pageMutedStateDidChange();
1304 WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
1306 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
1307 void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1308 void removePlaybackTargetPickerClient(MediaPlaybackTargetClient&);
1309 void showPlaybackTargetPicker(MediaPlaybackTargetClient&, bool);
1310 void playbackTargetPickerClientStateDidChange(MediaPlaybackTargetClient&, MediaProducer::MediaStateFlags);
1312 void setPlaybackTarget(uint64_t, Ref<MediaPlaybackTarget>&&);
1313 void playbackTargetAvailabilityDidChange(uint64_t, bool);
1314 void setShouldPlayToPlaybackTarget(uint64_t, bool);
1317 ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicyToPropagate() const;
1318 bool shouldEnforceContentDispositionAttachmentSandbox() const;
1319 void applyContentDispositionAttachmentSandbox();
1321 void addViewportDependentPicture(HTMLPictureElement&);
1322 void removeViewportDependentPicture(HTMLPictureElement&);
1324 #if ENABLE(MEDIA_STREAM)
1325 void setHasActiveMediaStreamTrack() { m_hasHadActiveMediaStreamTrack = true; }
1326 bool hasHadActiveMediaStreamTrack() const { return m_hasHadActiveMediaStreamTrack; }
1330 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
1331 Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
1333 void clearXMLVersion() { m_xmlVersion = String(); }
1335 virtual Ref<Document> cloneDocumentWithoutChildren() const;
1339 friend class IgnoreDestructiveWriteCountIncrementer;
1341 void updateTitleElement(Element* newTitleElement);
1343 void commonTeardown();
1345 RenderObject* renderer() const = delete;
1346 void setRenderer(RenderObject*) = delete;
1348 void createRenderTree();
1349 void detachParser();
1351 typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
1352 void processArguments(const String& features, void* data, ArgumentsCallback);
1354 // FontSelectorClient
1355 virtual void fontsNeedUpdate(FontSelector&) override final;
1357 virtual bool isDocument() const override final { return true; }
1359 virtual void childrenChanged(const ChildChange&) override final;
1361 virtual String nodeName() const override final;
1362 virtual NodeType nodeType() const override final;
1363 virtual bool childTypeAllowed(NodeType) const override final;
1364 virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override final;
1365 void cloneDataFromDocument(const Document&);
1367 virtual void refScriptExecutionContext() override final { ref(); }
1368 virtual void derefScriptExecutionContext() override final { deref(); }
1370 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;
1372 virtual double minimumTimerInterval() const override final;
1374 virtual double timerAlignmentInterval(bool hasReachedMaxNestingLevel) const override final;
1376 void updateTitleFromTitleElement();
1377 void updateTitle(const StringWithDirection&);
1378 void updateFocusAppearanceTimerFired();
1379 void updateBaseURL();
1381 void buildAccessKeyMap(TreeScope* root);
1383 void createStyleResolver();
1385 void loadEventDelayTimerFired();
1387 void pendingTasksTimerFired();
1389 template <typename CharacterType>
1390 void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
1392 PageVisibilityState pageVisibilityState() const;
1394 Node* nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint = nullptr);
1396 template <CollectionType collectionType>
1397 Ref<HTMLCollection> ensureCachedCollection();
1399 #if ENABLE(FULLSCREEN_API)
1400 void dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>&, const AtomicString& eventName, bool shouldNotifyMediaElement);
1401 void clearFullscreenElementStack();
1402 void popFullscreenElementStack();
1403 void pushFullscreenElementStack(Element*);
1404 void addDocumentToFullScreenChangeEventQueue(Document*);
1407 void setVisualUpdatesAllowed(ReadyState);
1408 void setVisualUpdatesAllowed(bool);
1409 void visualUpdatesSuppressionTimerFired();
1411 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
1413 void didAssociateFormControlsTimerFired();
1415 void wheelEventHandlersChanged();
1417 HttpEquivPolicy httpEquivPolicy() const;
1419 // DOM Cookies caching.
1420 const String& cachedDOMCookies() const { return m_cachedDOMCookies; }
1421 void setCachedDOMCookies(const String&);
1422 bool isDOMCookieCacheValid() const { return m_cookieCacheExpiryTimer.isActive(); }
1423 void invalidateDOMCookieCache();
1424 virtual void didLoadResourceSynchronously(const ResourceRequest&) override final;
1426 void checkViewportDependentPictures();
1428 unsigned m_referencingNodeCount;
1430 std::unique_ptr<StyleResolver> m_styleResolver;
1431 std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
1432 bool m_didCalculateStyleResolver;
1433 bool m_hasNodesWithPlaceholderStyle;
1434 bool m_needsNotifyRemoveAllPendingStylesheet;
1435 // But sometimes you need to ignore pending stylesheet count to
1436 // force an immediate layout when requested by JS.
1437 bool m_ignorePendingStylesheets;
1439 // If we do ignore the pending stylesheet count, then we need to add a boolean
1440 // to track that this happened so that we can do a full repaint when the stylesheets
1441 // do eventually load.
1442 PendingSheetLayout m_pendingSheetLayout;
1445 RefPtr<DOMWindow> m_domWindow;
1447 Ref<CachedResourceLoader> m_cachedResourceLoader;
1448 RefPtr<DocumentParser> m_parser;
1449 unsigned m_activeParserCount;
1454 URL m_url; // Document.URL: The URL from which this document was retrieved.
1455 URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
1456 URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
1457 URL m_baseElementURL; // The URL set by the <base> element.
1458 URL m_cookieURL; // The URL to use for cookie access.
1459 URL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
1461 // Document.documentURI:
1462 // Although URL-like, Document.documentURI can actually be set to any
1463 // string by content. Document.documentURI affects m_baseURL unless the
1464 // document contains a <base> element, in which case the <base> element
1465 // takes precedence.
1467 // This property is read-only from JavaScript, but writable from Objective C.
1468 String m_documentURI;
1470 String m_baseTarget;
1472 // MIME type of the document in case it was cloned or created by XHR.
1473 String m_overriddenMIMEType;
1475 std::unique_ptr<DOMImplementation> m_implementation;
1477 RefPtr<CSSStyleSheet> m_elementSheet;
1480 bool m_paginatedForScreen;
1482 DocumentCompatibilityMode m_compatibilityMode;
1483 bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
1487 RefPtr<Element> m_focusedElement;
1488 RefPtr<Element> m_hoveredElement;
1489 RefPtr<Element> m_activeElement;
1490 RefPtr<Element> m_documentElement;
1491 UserActionElementSet m_userActionElements;
1493 uint64_t m_domTreeVersion;
1494 static uint64_t s_globalTreeVersion;
1496 HashSet<NodeIterator*> m_nodeIterators;
1497 HashSet<Range*> m_ranges;
1499 unsigned m_listenerTypes;
1501 MutationObserverOptions m_mutationObserverTypes;
1503 std::unique_ptr<AuthorStyleSheets> m_authorStyleSheets;
1504 std::unique_ptr<ExtensionStyleSheets> m_extensionStyleSheets;
1505 RefPtr<StyleSheetList> m_styleSheetList;
1507 std::unique_ptr<FormController> m_formController;
1510 Color m_visitedLinkColor;
1511 Color m_activeLinkColor;
1512 const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
1514 bool m_visuallyOrdered;
1515 ReadyState m_readyState;
1518 Timer m_optimizedStyleSheetUpdateTimer;
1519 Timer m_styleRecalcTimer;
1520 bool m_pendingStyleRecalcShouldForce;
1521 bool m_inStyleRecalc;
1522 bool m_closeAfterStyleRecalc;
1524 bool m_gotoAnchorNeededAfterStylesheetsLoad;
1525 bool m_isDNSPrefetchEnabled;
1526 bool m_haveExplicitlyDisabledDNSPrefetch;
1527 bool m_frameElementsShouldIgnoreScrolling;
1528 SelectionRestorationMode m_updateFocusAppearanceRestoresSelection;
1530 // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
1531 unsigned m_ignoreDestructiveWriteCount;
1533 unsigned m_styleRecalcCount { 0 };
1535 StringWithDirection m_title;
1536 StringWithDirection m_rawTitle;
1537 RefPtr<Element> m_titleElement;
1539 std::unique_ptr<AXObjectCache> m_axObjectCache;
1540 const std::unique_ptr<DocumentMarkerController> m_markers;
1542 Timer m_updateFocusAppearanceTimer;
1544 Element* m_cssTarget;
1546 // FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
1547 // is almost a duplication of this data, so that should probably get merged in too.
1548 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadDispatched are roughly the same
1549 // and should be merged.
1550 bool m_processingLoadEvent;
1551 bool m_loadEventFinished;
1553 RefPtr<SerializedScriptValue> m_pendingStateObject;
1554 std::chrono::steady_clock::time_point m_startTime;
1555 bool m_overMinimumLayoutThreshold;
1557 std::unique_ptr<ScriptRunner> m_scriptRunner;
1558 std::unique_ptr<JSModuleLoader> m_moduleLoader;
1560 Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
1563 std::unique_ptr<TransformSource> m_transformSource;
1564 RefPtr<Document> m_transformSourceDocument;
1567 String m_xmlEncoding;
1568 String m_xmlVersion;
1569 unsigned m_xmlStandalone : 2;
1570 unsigned m_hasXMLDeclaration : 1;
1572 String m_contentLanguage;
1574 RefPtr<TextResourceDecoder> m_decoder;
1576 InheritedBool m_designMode;
1578 HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
1579 HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
1580 #if !ASSERT_DISABLED
1581 bool m_inInvalidateNodeListAndCollectionCaches;
1584 unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
1586 RefPtr<XPathEvaluator> m_xpathEvaluator;
1588 std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1590 #if ENABLE(DASHBOARD_SUPPORT)
1591 Vector<AnnotatedRegionValue> m_annotatedRegions;
1592 bool m_hasAnnotatedRegions;
1593 bool m_annotatedRegionsDirty;
1596 HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
1598 bool m_createRenderers;
1601 HashSet<Element*> m_documentSuspensionCallbackElements;
1602 HashSet<Element*> m_mediaVolumeCallbackElements;
1603 HashSet<Element*> m_privateBrowsingStateChangedElements;
1604 #if ENABLE(VIDEO_TRACK)
1605 HashSet<Element*> m_captionPreferencesChangedElements;
1608 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1609 HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
1612 HashSet<Element*> m_visibilityStateCallbackElements;
1614 HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
1617 HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
1618 bool m_accessKeyMapValid;
1620 DocumentOrderedMap m_imagesByUsemap;
1622 std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
1624 DocumentClassFlags m_documentClasses;
1626 bool m_isSynthesized;
1627 bool m_isNonRenderedPlaceholder;
1629 bool m_sawElementsInKnownNamespaces;
1630 bool m_isSrcdocDocument;
1632 RenderPtr<RenderView> m_renderView;
1633 mutable DocumentEventQueue m_eventQueue;
1635 WeakPtrFactory<Document> m_weakFactory;
1637 HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
1639 #if ENABLE(FULLSCREEN_API)
1640 bool m_areKeysEnabledInFullScreen;
1641 RefPtr<Element> m_fullScreenElement;
1642 Vector<RefPtr<Element>> m_fullScreenElementStack;
1643 RenderFullScreen* m_fullScreenRenderer;
1644 Timer m_fullScreenChangeDelayTimer;
1645 Deque<RefPtr<Node>> m_fullScreenChangeEventTargetQueue;
1646 Deque<RefPtr<Node>> m_fullScreenErrorEventTargetQueue;
1647 bool m_isAnimatingFullScreen;
1648 LayoutRect m_savedPlaceholderFrameRect;
1649 RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
1652 HashSet<HTMLPictureElement*> m_viewportDependentPictures;
1654 int m_loadEventDelayCount;
1655 Timer m_loadEventDelayTimer;
1657 ViewportArguments m_viewportArguments;
1659 ReferrerPolicy m_referrerPolicy;
1661 bool m_directionSetOnDocumentElement;
1662 bool m_writingModeSetOnDocumentElement;
1664 #if ENABLE(WEB_TIMING)
1665 DocumentTiming m_documentTiming;
1668 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
1669 bool m_writeRecursionIsTooDeep;
1670 unsigned m_writeRecursionDepth;
1672 #if ENABLE(TOUCH_EVENTS)
1673 std::unique_ptr<EventTargetSet> m_touchEventTargets;
1675 std::unique_ptr<EventTargetSet> m_wheelEventTargets;
1677 double m_lastHandledUserGestureTimestamp;
1679 #if ENABLE(REQUEST_ANIMATION_FRAME)
1680 void clearScriptedAnimationController();
1681 RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
1684 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1685 std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
1686 std::unique_ptr<DeviceMotionController> m_deviceMotionController;
1687 std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
1688 std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
1691 // FIXME: Find a better place for this functionality.
1692 #if ENABLE(TELEPHONE_NUMBER_DETECTION)
1695 // These functions provide a two-level setting:
1696 // - A user-settable wantsTelephoneNumberParsing (at the Page / WebView level)
1697 // - A read-only telephoneNumberParsingAllowed which is set by the
1698 // document if it has the appropriate meta tag.
1699 // - isTelephoneNumberParsingEnabled() == isTelephoneNumberParsingAllowed() && page()->settings()->isTelephoneNumberParsingEnabled()
1701 WEBCORE_EXPORT bool isTelephoneNumberParsingAllowed() const;
1702 WEBCORE_EXPORT bool isTelephoneNumberParsingEnabled() const;
1705 friend void setParserFeature(const String& key, const String& value, Document*, void* userData);
1706 void setIsTelephoneNumberParsingAllowed(bool);
1708 bool m_isTelephoneNumberParsingAllowed;
1711 Timer m_pendingTasksTimer;
1712 Vector<Task> m_pendingTasks;
1714 #if ENABLE(IOS_TEXT_AUTOSIZING)
1716 void addAutoSizingNode(Node*, float size);
1717 void validateAutoSizingNodes();
1718 void resetAutoSizingNodes();
1721 typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
1722 TextAutoSizingMap m_textAutoSizedNodes;
1725 #if ENABLE(TEXT_AUTOSIZING)
1726 std::unique_ptr<TextAutosizer> m_textAutosizer;
1729 void platformSuspendOrStopActiveDOMObjects();
1731 bool m_scheduledTasksAreSuspended;
1733 bool m_visualUpdatesAllowed;
1734 Timer m_visualUpdatesSuppressionTimer;
1736 RefPtr<NamedFlowCollection> m_namedFlows;
1738 #if ENABLE(CSP_NEXT)
1739 RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
1742 void sharedObjectPoolClearTimerFired();
1743 Timer m_sharedObjectPoolClearTimer;
1745 std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
1748 bool m_didDispatchViewportPropertiesChanged;
1751 typedef HashMap<AtomicString, std::unique_ptr<Locale>> LocaleIdentifierToLocaleMap;
1752 LocaleIdentifierToLocaleMap m_localeCache;
1754 #if ENABLE(TEMPLATE_ELEMENT)
1755 RefPtr<Document> m_templateDocument;
1756 Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
1759 #if ENABLE(CUSTOM_ELEMENTS)
1760 std::unique_ptr<CustomElementDefinitions> m_customElementDefinitions;
1763 RefPtr<CSSFontSelector> m_fontSelector;
1765 #if ENABLE(FONT_LOAD_EVENTS)
1766 RefPtr<FontLoader> m_fontloader;
1769 #if ENABLE(WEB_REPLAY)
1770 RefPtr<JSC::InputCursor> m_inputCursor;
1773 Timer m_didAssociateFormControlsTimer;
1774 Timer m_cookieCacheExpiryTimer;
1775 String m_cachedDOMCookies;
1776 HashSet<RefPtr<Element>> m_associatedFormControls;
1777 unsigned m_disabledFieldsetElementsCount;
1779 bool m_hasInjectedPlugInsScript;
1780 bool m_renderTreeBeingDestroyed;
1781 bool m_hasPreparedForDestruction;
1783 bool m_hasStyleWithViewportUnits;
1784 bool m_isTimerThrottlingEnabled { false };
1785 bool m_isSuspended { false };
1787 HashSet<MediaProducer*> m_audioProducers;
1788 MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
1790 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
1791 typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
1792 TargetIdToClientMap m_idToClientMap;
1793 typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
1794 TargetClientToIdMap m_clientToIDMap;
1797 #if ENABLE(MEDIA_SESSION)
1798 RefPtr<MediaSession> m_defaultMediaSession;
1800 bool m_areDeviceMotionAndOrientationUpdatesSuspended { false };
1802 #if ENABLE(MEDIA_STREAM)
1803 bool m_hasHadActiveMediaStreamTrack { false };
1807 inline void Document::notifyRemovePendingSheetIfNeeded()
1809 if (m_needsNotifyRemoveAllPendingStylesheet)
1810 didRemoveAllPendingStylesheet();
1813 inline TextEncoding Document::textEncoding() const
1815 if (auto* decoder = this->decoder())
1816 return decoder->encoding();
1817 return TextEncoding();
1820 #if ENABLE(TEMPLATE_ELEMENT)
1821 inline const Document* Document::templateDocument() const
1823 // If DOCUMENT does not have a browsing context, Let TEMPLATE CONTENTS OWNER be DOCUMENT and abort these steps.
1827 return m_templateDocument.get();
1831 // Put these methods here, because they require the Document definition, but we really want to inline them.
1833 inline bool Node::isDocumentNode() const
1835 return this == &document();
1838 inline ScriptExecutionContext* Node::scriptExecutionContext() const
1843 Element* eventTargetElementForDocument(Document*);
1845 } // namespace WebCore
1847 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
1848 static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
1849 static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
1850 SPECIALIZE_TYPE_TRAITS_END()
1852 #endif // Document_h