summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/Document.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/Document.h')
-rw-r--r--Source/WebCore/dom/Document.h1385
1 files changed, 722 insertions, 663 deletions
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index cf6f997af..f865de791 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2011 Google Inc. All rights reserved.
@@ -25,48 +25,60 @@
*
*/
-#ifndef Document_h
-#define Document_h
+#pragma once
#include "CollectionType.h"
#include "Color.h"
#include "ContainerNode.h"
#include "DocumentEventQueue.h"
-#include "DocumentStyleSheetCollection.h"
#include "DocumentTiming.h"
+#include "ExceptionOr.h"
#include "FocusDirection.h"
-#include "HitTestRequest.h"
-#include "IconURL.h"
-#include "InspectorCounters.h"
+#include "FontSelectorClient.h"
+#include "FrameDestructionObserver.h"
+#include "MediaProducer.h"
#include "MutationObserver.h"
#include "PageVisibilityState.h"
-#include "PlatformScreen.h"
-#include "QualifiedName.h"
+#include "PlatformEvent.h"
#include "ReferrerPolicy.h"
+#include "Region.h"
#include "RenderPtr.h"
#include "ScriptExecutionContext.h"
#include "StringWithDirection.h"
-#include "StyleResolveTree.h"
+#include "StyleChange.h"
+#include "Supplementable.h"
+#include "TextResourceDecoder.h"
#include "Timer.h"
#include "TreeScope.h"
#include "UserActionElementSet.h"
#include "ViewportArguments.h"
#include <chrono>
+#include <memory>
#include <wtf/Deque.h>
+#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/WeakPtr.h>
+#include <wtf/text/AtomicStringHash.h>
+
+#if PLATFORM(IOS)
+#include "EventTrackingRegions.h"
+#endif
+
+namespace JSC {
+class ExecState;
+class InputCursor;
+}
namespace WebCore {
class AXObjectCache;
class Attr;
class CDATASection;
+class CSSFontSelector;
class CSSStyleDeclaration;
class CSSStyleSheet;
class CachedCSSStyleSheet;
+class CachedFrameBase;
class CachedResourceLoader;
class CachedScript;
class CanvasRenderingContext;
@@ -84,20 +96,18 @@ class DocumentLoader;
class DocumentMarkerController;
class DocumentParser;
class DocumentSharedObjectPool;
-class DocumentStyleSheetCollection;
class DocumentType;
-class Element;
-class EntityReference;
-class Event;
-class EventListener;
-class FloatRect;
+class ExtensionStyleSheets;
class FloatQuad;
+class FloatRect;
+class FontFaceSet;
class FormController;
class Frame;
class FrameView;
+class HTMLAllCollection;
+class HTMLBodyElement;
class HTMLCanvasElement;
class HTMLCollection;
-class HTMLAllCollection;
class HTMLDocument;
class HTMLElement;
class HTMLFrameOwnerElement;
@@ -105,17 +115,21 @@ class HTMLHeadElement;
class HTMLIFrameElement;
class HTMLImageElement;
class HTMLMapElement;
-class HTMLNameCollection;
+class HTMLMediaElement;
+class HTMLPictureElement;
class HTMLScriptElement;
class HitTestRequest;
class HitTestResult;
class IntPoint;
+class JSNode;
class LayoutPoint;
class LayoutRect;
class LiveNodeList;
-class JSNode;
class Locale;
+class Location;
class MediaCanStartListener;
+class MediaPlaybackTarget;
+class MediaPlaybackTargetClient;
class MediaQueryList;
class MediaQueryMatcher;
class MouseEventWithHitTestResults;
@@ -125,17 +139,23 @@ class NodeIterator;
class Page;
class PlatformMouseEvent;
class ProcessingInstruction;
+class QualifiedName;
class Range;
-class RegisteredEventListener;
-class RenderView;
class RenderFullScreen;
-class ScriptableDocumentParser;
+class RenderView;
+class RequestAnimationFrameCallback;
+class SVGDocumentExtensions;
+class SVGSVGElement;
class ScriptElementData;
+class ScriptModuleLoader;
class ScriptRunner;
+class ScriptableDocumentParser;
+class ScriptedAnimationController;
class SecurityOrigin;
+class SegmentedString;
+class SelectorQuery;
class SelectorQueryCache;
class SerializedScriptValue;
-class SegmentedString;
class Settings;
class StyleResolver;
class StyleSheet;
@@ -145,16 +165,14 @@ class Text;
class TextResourceDecoder;
class TreeWalker;
class VisitedLinkState;
-class WebKitNamedFlow;
-class XMLHttpRequest;
class XPathEvaluator;
class XPathExpression;
class XPathNSResolver;
class XPathResult;
-#if ENABLE(SVG)
-class SVGDocumentExtensions;
-#endif
+enum class ShouldOpenExternalURLsPolicy;
+
+using PlatformDisplayID = uint32_t;
#if ENABLE(XSLT)
class TransformSource;
@@ -164,33 +182,15 @@ class TransformSource;
struct AnnotatedRegionValue;
#endif
-#if ENABLE(TOUCH_EVENTS)
-#if PLATFORM(IOS)
+#if ENABLE(IOS_TOUCH_EVENTS)
#include <WebKitAdditions/DocumentIOSForward.h>
-#endif // PLATFORM(IOS)
-class Touch;
-class TouchList;
-#endif
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-class RequestAnimationFrameCallback;
-class ScriptedAnimationController;
-#endif
-
-#if ENABLE(TEXT_AUTOSIZING)
-class TextAutosizer;
-#endif
-
-#if ENABLE(CSP_NEXT)
-class DOMSecurityPolicy;
#endif
-#if ENABLE(FONT_LOAD_EVENTS)
-class FontLoader;
+#if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
+class Touch;
+class TouchList;
#endif
-typedef int ExceptionCode;
-
#if PLATFORM(IOS)
class DeviceMotionClient;
class DeviceMotionController;
@@ -198,7 +198,7 @@ class DeviceOrientationClient;
class DeviceOrientationController;
#endif
-#if ENABLE(IOS_TEXT_AUTOSIZING)
+#if ENABLE(TEXT_AUTOSIZING)
struct TextAutoSizingHash;
class TextAutoSizingKey;
class TextAutoSizingValue;
@@ -210,26 +210,35 @@ struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
};
#endif
+#if ENABLE(MEDIA_SESSION)
+class MediaSession;
+#endif
+
+namespace Style {
+class Scope;
+};
+
+const uint64_t HTMLMediaElementInvalidID = 0;
+
enum PageshowEventPersistence {
PageshowEventNotPersisted = 0,
PageshowEventPersisted = 1
};
-enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
-
enum NodeListInvalidationType {
DoNotInvalidateOnAttributeChanges = 0,
InvalidateOnClassAttrChange,
InvalidateOnIdNameAttrChange,
InvalidateOnNameAttrChange,
- InvalidateOnForAttrChange,
+ InvalidateOnForTypeAttrChange,
InvalidateForFormControls,
InvalidateOnHRefAttrChange,
InvalidateOnAnyAttrChange,
};
const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
-typedef HashCountedSet<Node*> TouchEventTargetSet;
+enum class EventHandlerRemoval { One, All };
+typedef HashCountedSet<Node*> EventTargetSet;
enum DocumentClass {
DefaultDocumentClass = 0,
@@ -239,117 +248,103 @@ enum DocumentClass {
PluginDocumentClass = 1 << 3,
MediaDocumentClass = 1 << 4,
SVGDocumentClass = 1 << 5,
+ TextDocumentClass = 1 << 6,
+ XMLDocumentClass = 1 << 7,
};
typedef unsigned char DocumentClassFlags;
-class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
+enum class DocumentCompatibilityMode : unsigned char {
+ NoQuirksMode = 1,
+ QuirksMode = 1 << 1,
+ LimitedQuirksMode = 1 << 2
+};
+
+enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
+
+enum class SelectionRestorationMode {
+ Restore,
+ SetDefault,
+};
+
+enum class HttpEquivPolicy {
+ Enabled,
+ DisabledBySettings,
+ DisabledByContentDispositionAttachmentSandbox
+};
+
+enum class CustomElementNameValidationStatus { Valid, ConflictsWithBuiltinNames, NoHyphen, ContainsUpperCase };
+
+class Document
+ : public ContainerNode
+ , public TreeScope
+ , public ScriptExecutionContext
+ , public FontSelectorClient
+ , public FrameDestructionObserver
+ , public Supplementable<Document> {
public:
- static PassRefPtr<Document> create(Frame* frame, const URL& url)
+ static Ref<Document> create(Frame* frame, const URL& url)
{
- return adoptRef(new Document(frame, url));
+ return adoptRef(*new Document(frame, url));
}
- static PassRefPtr<Document> createXHTML(Frame* frame, const URL& url)
+
+ static Ref<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
+ {
+ return adoptRef(*new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
+ }
+ static Ref<Document> create(Document&);
+
+ virtual ~Document();
+
+ // Nodes belonging to this document increase referencingNodeCount -
+ // these are enough to keep the document from being destroyed, but
+ // not enough to keep it from removing its children. This allows a
+ // node that outlives its document to still have a valid document
+ // pointer without introducing reference cycles.
+ void incrementReferencingNodeCount()
{
- return adoptRef(new Document(frame, url, XHTMLDocumentClass));
+ ASSERT(!m_deletionHasBegun);
+ ++m_referencingNodeCount;
}
- static PassRefPtr<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
+
+ void decrementReferencingNodeCount()
{
- return adoptRef(new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
+ ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
+ --m_referencingNodeCount;
+ if (!m_referencingNodeCount && !refCount()) {
+#if !ASSERT_DISABLED
+ m_deletionHasBegun = true;
+#endif
+ delete this;
+ }
}
- virtual ~Document();
+
+ unsigned referencingNodeCount() const { return m_referencingNodeCount; }
+
+ void removedLastRef();
+
+ WEBCORE_EXPORT static HashSet<Document*>& allDocuments();
MediaQueryMatcher& mediaQueryMatcher();
using ContainerNode::ref;
using ContainerNode::deref;
+ using TreeScope::rootNode;
- virtual bool canContainRangeEndPoint() const override { return true; }
+ bool canContainRangeEndPoint() const final { return true; }
Element* getElementByAccessKey(const String& key);
void invalidateAccessKeyMap();
- void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
- void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
- HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
+ void addImageElementByUsemap(const AtomicStringImpl&, HTMLImageElement&);
+ void removeImageElementByUsemap(const AtomicStringImpl&, HTMLImageElement&);
+ HTMLImageElement* imageElementByUsemap(const AtomicStringImpl&) const;
- SelectorQueryCache& selectorQueryCache();
+ ExceptionOr<SelectorQuery&> selectorQueryForString(const String&);
+ void clearSelectorQueryCache();
// DOM methods & attributes for Document
- DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(drop);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(drag);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(input);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(keypress);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(keyup);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mousedown);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseenter);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseleave);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mousemove);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseout);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseover);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseup);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(mousewheel);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
-
- DEFINE_ATTRIBUTE_EVENT_LISTENER(blur);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(focus);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
-
- // WebKit extensions
- DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(reset);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(selectionchange);
-#if ENABLE(TOUCH_EVENTS)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
-#endif
-#if ENABLE(IOS_GESTURE_EVENTS)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(gesturestart);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(gesturechange);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(gestureend);
-#endif
-#if ENABLE(FULLSCREEN_API)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
-#endif
-#if ENABLE(POINTER_LOCK)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockchange);
- DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockerror);
-#endif
-#if ENABLE(PAGE_VISIBILITY_API)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(visibilitychange);
-#endif
-#if ENABLE(CSP_NEXT)
- DEFINE_ATTRIBUTE_EVENT_LISTENER(securitypolicyviolation);
-#endif
-
void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
ViewportArguments viewportArguments() const { return m_viewportArguments; }
#ifndef NDEBUG
@@ -359,63 +354,66 @@ public:
void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
- DocumentType* doctype() const;
+ WEBCORE_EXPORT DocumentType* doctype() const;
- DOMImplementation* implementation();
+ WEBCORE_EXPORT DOMImplementation& implementation();
Element* documentElement() const
{
return m_documentElement.get();
}
+ static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
+
+ WEBCORE_EXPORT Element* activeElement();
+ WEBCORE_EXPORT bool hasFocus() const;
bool hasManifest() const;
- virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
- PassRefPtr<DocumentFragment> createDocumentFragment();
- PassRefPtr<Text> createTextNode(const String& data);
- PassRefPtr<Comment> createComment(const String& data);
- PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
- PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
- PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
- PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
- PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
- PassRefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, true, ec); }
- PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
- PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
- PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
-
- bool cssStickyPositionEnabled() const;
- bool cssRegionsEnabled() const;
- bool cssCompositingEnabled() const;
+ WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementForBindings(const AtomicString& tagName);
+ WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
+ WEBCORE_EXPORT Ref<Text> createTextNode(const String& data);
+ WEBCORE_EXPORT Ref<Comment> createComment(const String& data);
+ WEBCORE_EXPORT ExceptionOr<Ref<CDATASection>> createCDATASection(const String& data);
+ WEBCORE_EXPORT ExceptionOr<Ref<ProcessingInstruction>> createProcessingInstruction(const String& target, const String& data);
+ WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttribute(const String& name);
+ WEBCORE_EXPORT ExceptionOr<Ref<Attr>> createAttributeNS(const AtomicString& namespaceURI, const String& qualifiedName, bool shouldIgnoreNamespaceChecks = false);
+ WEBCORE_EXPORT ExceptionOr<Ref<Node>> importNode(Node& nodeToImport, bool deep);
+ WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementNS(const AtomicString& namespaceURI, const String& qualifiedName);
+ WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
+
+ static CustomElementNameValidationStatus validateCustomElementName(const AtomicString&);
+
+ bool isCSSGridLayoutEnabled() const;
#if ENABLE(CSS_REGIONS)
- PassRefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
+ RefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
#endif
- NamedFlowCollection* namedFlows();
+ NamedFlowCollection& namedFlows();
- bool regionBasedColumnsEnabled() const;
+ WEBCORE_EXPORT RefPtr<Range> caretRangeFromPoint(int x, int y);
+ RefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
- bool cssGridLayoutEnabled() const;
+ WEBCORE_EXPORT Element* scrollingElement();
- Element* elementFromPoint(int x, int y) const;
- PassRefPtr<Range> caretRangeFromPoint(int x, int y);
+ WEBCORE_EXPORT String readyState() const;
- String readyState() const;
+ WEBCORE_EXPORT String defaultCharsetForLegacyBindings() const;
- String defaultCharset() const;
-
- String inputEncoding() const { return Document::encoding(); }
String charset() const { return Document::encoding(); }
- String characterSet() const { return Document::encoding(); }
+ WEBCORE_EXPORT String characterSetWithUTF8Fallback() const;
+ TextEncoding textEncoding() const;
- String encoding() const;
+ AtomicString encoding() const { return textEncoding().domName(); }
- void setCharset(const String&);
+ WEBCORE_EXPORT void setCharset(const String&); // Used by ObjC / GOBject bindings only.
void setContent(const String&);
String suggestedMIMEType() const;
+ void overrideMIMEType(const String&);
+ WEBCORE_EXPORT String contentType() const;
+
String contentLanguage() const { return m_contentLanguage; }
void setContentLanguage(const String&);
@@ -427,174 +425,166 @@ public:
bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
- void setXMLVersion(const String&, ExceptionCode&);
- void setXMLStandalone(bool, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<void> setXMLVersion(const String&);
+ WEBCORE_EXPORT void setXMLStandalone(bool);
void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
String documentURI() const { return m_documentURI; }
- void setDocumentURI(const String&);
+ WEBCORE_EXPORT void setDocumentURI(const String&);
- virtual URL baseURI() const override;
+#if ENABLE(WEB_REPLAY)
+ JSC::InputCursor& inputCursor();
+ void setInputCursor(Ref<JSC::InputCursor>&&);
+#endif
-#if ENABLE(PAGE_VISIBILITY_API)
+ using VisibilityState = PageVisibilityState;
+ WEBCORE_EXPORT VisibilityState visibilityState() const;
void visibilityStateChanged();
- String visibilityState() const;
- bool hidden() const;
-#endif
+ WEBCORE_EXPORT bool hidden() const;
-#if ENABLE(CSP_NEXT)
- DOMSecurityPolicy* securityPolicy();
-#endif
+ void setTimerThrottlingEnabled(bool);
+ bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
- PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<Node>> adoptNode(Node& source);
- PassRefPtr<HTMLCollection> images();
- PassRefPtr<HTMLCollection> embeds();
- PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
- PassRefPtr<HTMLCollection> applets();
- PassRefPtr<HTMLCollection> links();
- PassRefPtr<HTMLCollection> forms();
- PassRefPtr<HTMLCollection> anchors();
- PassRefPtr<HTMLCollection> scripts();
- PassRefPtr<HTMLCollection> all();
+ WEBCORE_EXPORT Ref<HTMLCollection> images();
+ WEBCORE_EXPORT Ref<HTMLCollection> embeds();
+ WEBCORE_EXPORT Ref<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
+ WEBCORE_EXPORT Ref<HTMLCollection> applets();
+ WEBCORE_EXPORT Ref<HTMLCollection> links();
+ WEBCORE_EXPORT Ref<HTMLCollection> forms();
+ WEBCORE_EXPORT Ref<HTMLCollection> anchors();
+ WEBCORE_EXPORT Ref<HTMLCollection> scripts();
+ Ref<HTMLCollection> all();
- PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
- PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
+ Ref<HTMLCollection> windowNamedItems(const AtomicString& name);
+ Ref<HTMLCollection> documentNamedItems(const AtomicString& name);
// Other methods (not part of DOM)
bool isSynthesized() const { return m_isSynthesized; }
bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
+ bool isXMLDocument() const { return m_documentClasses & XMLDocumentClass; }
bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
-#if ENABLE(SVG)
+ bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
bool hasSVGRootNode() const;
-#else
- static bool hasSVGRootNode() { return false; }
-#endif
virtual bool isFrameSet() const { return false; }
- bool isSrcdocDocument() const { return m_isSrcdocDocument; }
-
- StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
+ static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
+ static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
- bool isViewSource() const { return m_isViewSource; }
- void setIsViewSource(bool);
+ bool isSrcdocDocument() const { return m_isSrcdocDocument; }
bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
- StyleResolver& ensureStyleResolver()
- {
- if (!m_styleResolver)
- createStyleResolver();
- return *m_styleResolver;
- }
+ StyleResolver& userAgentShadowTreeStyleResolver();
- void notifyRemovePendingSheetIfNeeded();
+ CSSFontSelector& fontSelector() { return m_fontSelector; }
- bool haveStylesheetsLoaded() const;
+ WEBCORE_EXPORT bool haveStylesheetsLoaded() const;
- // This is a DOM function.
- StyleSheetList* styleSheets();
+ WEBCORE_EXPORT StyleSheetList& styleSheets();
- DocumentStyleSheetCollection& styleSheetCollection() { return m_styleSheetCollection; }
+ Style::Scope& styleScope() { return *m_styleScope; }
+ const Style::Scope& styleScope() const { return *m_styleScope; }
+ ExtensionStyleSheets& extensionStyleSheets() { return *m_extensionStyleSheets; }
+ const ExtensionStyleSheets& extensionStyleSheets() const { return *m_extensionStyleSheets; }
bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
- /**
- * Called when one or more stylesheets in the document may have been added, removed or changed.
- *
- * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
- * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
- * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
- * constructed from these which is used to create the a new style selector which collates all of the stylesheets
- * found and is used to calculate the derived styles for all rendering objects.
- */
- void styleResolverChanged(StyleResolverUpdateFlag);
-
- void scheduleOptimizedStyleSheetUpdate();
-
- void didAccessStyleResolver();
-
void evaluateMediaQueryList();
FormController& formController();
Vector<String> formElementsState() const;
void setStateForNewFormElements(const Vector<String>&);
- FrameView* view() const; // can be NULL
- Frame* frame() const { return m_frame; } // can be NULL
- Page* page() const; // can be NULL
- Settings* settings() const; // can be NULL
+ WEBCORE_EXPORT FrameView* view() const; // can be NULL
+ WEBCORE_EXPORT Page* page() const; // can be NULL
+ const Settings& settings() const { return m_settings.get(); }
+ Settings& mutableSettings() { return m_settings.get(); }
float deviceScaleFactor() const;
- PassRefPtr<Range> createRange();
+ WEBCORE_EXPORT Ref<Range> createRange();
- PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
- PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
+ // The last bool parameter is for ObjC bindings.
+ WEBCORE_EXPORT Ref<NodeIterator> createNodeIterator(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
- PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
- PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
+ // The last bool parameter is for ObjC bindings.
+ WEBCORE_EXPORT Ref<TreeWalker> createTreeWalker(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
// Special support for editing
- PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
- PassRefPtr<Text> createEditingTextNode(const String&);
+ WEBCORE_EXPORT Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
+ Ref<Text> createEditingTextNode(const String&);
void recalcStyle(Style::Change = Style::NoChange);
- void updateStyleIfNeeded();
- void updateLayout();
- enum RunPostLayoutTasks {
- RunPostLayoutTasksAsynchronously,
- RunPostLayoutTasksSynchronously,
+ WEBCORE_EXPORT void updateStyleIfNeeded();
+ bool needsStyleRecalc() const;
+ unsigned lastStyleUpdateSizeForTesting() const { return m_lastStyleUpdateSizeForTesting; }
+
+ WEBCORE_EXPORT void updateLayout();
+
+ // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads,
+ // so calling this may cause a flash of unstyled content (FOUC).
+ enum class RunPostLayoutTasks {
+ Asynchronously,
+ Synchronously,
};
- void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasksAsynchronously);
- PassRef<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
+ WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
+
+ std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle);
// Returns true if page box (margin boxes and page borders) is visible.
- bool isPageBoxVisible(int pageIndex);
+ WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);
// Returns the preferred page size and margins in pixels, assuming 96
// pixels per inch. pageSize, marginTop, marginRight, marginBottom,
// marginLeft must be initialized to the default values that are used if
// auto is specified.
- void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
+ WEBCORE_EXPORT void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
- CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader.get(); }
+ CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader; }
void didBecomeCurrentDocumentInFrame();
void destroyRenderTree();
- void disconnectFromFrame();
void prepareForDestruction();
+ void didBecomeCurrentDocumentInView();
// Override ScriptExecutionContext methods to do additional work
- virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
- virtual void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
- virtual void stopActiveDOMObjects() override;
+ bool shouldBypassMainWorldContentSecurityPolicy() const final;
+ void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) final;
+ void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) final;
+ void stopActiveDOMObjects() final;
+
+ void suspendDeviceMotionAndOrientationUpdates();
+ void resumeDeviceMotionAndOrientationUpdates();
RenderView* renderView() const { return m_renderView.get(); }
bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
-
+
+ bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
+
AXObjectCache* existingAXObjectCache() const;
- AXObjectCache* axObjectCache() const;
+ WEBCORE_EXPORT AXObjectCache* axObjectCache() const;
void clearAXObjectCache();
// to get visually ordered hebrew and arabic pages right
void setVisuallyOrdered();
bool visuallyOrdered() const { return m_visuallyOrdered; }
- DocumentLoader* loader() const;
+ WEBCORE_EXPORT DocumentLoader* loader() const;
- void open(Document* ownerDocument = 0);
+ WEBCORE_EXPORT void open(Document* ownerDocument = nullptr);
void implicitOpen();
// close() is the DOM API document.close()
- void close();
+ WEBCORE_EXPORT void close();
// In some situations (see the code), we ignore document.close().
// explicitClose() bypass these checks and actually tries to close the
// input stream.
@@ -604,14 +594,15 @@ public:
void cancelParsing();
- void write(const SegmentedString& text, Document* ownerDocument = 0);
- void write(const String& text, Document* ownerDocument = 0);
- void writeln(const String& text, Document* ownerDocument = 0);
+ void write(SegmentedString&& text, Document* ownerDocument = nullptr);
+ WEBCORE_EXPORT void write(const String& text, Document* ownerDocument = nullptr);
+ WEBCORE_EXPORT void writeln(const String& text, Document* ownerDocument = nullptr);
bool wellFormed() const { return m_wellFormed; }
- virtual const URL& url() const override final { return m_url; }
+ const URL& url() const final { return m_url; }
void setURL(const URL&);
+ const URL& urlForBindings() const { return m_url.isEmpty() ? blankURL() : m_url; }
// To understand how these concepts relate to one another, please see the
// comments surrounding their declaration.
@@ -622,19 +613,27 @@ public:
const String& baseTarget() const { return m_baseTarget; }
void processBaseElement();
- virtual URL completeURL(const String&) const override final;
+ WEBCORE_EXPORT URL completeURL(const String&) const final;
URL completeURL(const String&, const URL& baseURLOverride) const;
- virtual String userAgent(const URL&) const override;
+ String userAgent(const URL&) const final;
- virtual void disableEval(const String& errorMessage) override;
+ void disableEval(const String& errorMessage) final;
+
+#if ENABLE(INDEXED_DATABASE)
+ IDBClient::IDBConnectionProxy* idbConnectionProxy() final;
+#endif
+#if ENABLE(WEB_SOCKETS)
+ SocketProvider* socketProvider() final;
+#endif
bool canNavigate(Frame* targetFrame);
Frame* findUnsafeParentScrollPropagationBoundary();
- CSSStyleSheet& elementSheet();
+ bool usesStyleBasedEditability() const;
+ void setHasElementUsingStyleBasedEditability();
- virtual PassRefPtr<DocumentParser> createParser();
+ virtual Ref<DocumentParser> createParser();
DocumentParser* parser() const { return m_parser.get(); }
ScriptableDocumentParser* scriptableDocumentParser() const;
@@ -646,17 +645,15 @@ public:
bool paginated() const { return printing() || paginatedForScreen(); }
- enum CompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
-
- void setCompatibilityMode(CompatibilityMode m);
+ void setCompatibilityMode(DocumentCompatibilityMode);
void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
- CompatibilityMode compatibilityMode() const { return m_compatibilityMode; }
+ static ptrdiff_t compatibilityModeMemoryOffset() { return OBJECT_OFFSETOF(Document, m_compatibilityMode); }
- String compatMode() const;
+ WEBCORE_EXPORT String compatMode() const;
- bool inQuirksMode() const { return m_compatibilityMode == QuirksMode; }
- bool inLimitedQuirksMode() const { return m_compatibilityMode == LimitedQuirksMode; }
- bool inNoQuirksMode() const { return m_compatibilityMode == NoQuirksMode; }
+ bool inQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::QuirksMode; }
+ bool inLimitedQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::LimitedQuirksMode; }
+ bool inNoQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::NoQuirksMode; }
enum ReadyState {
Loading,
@@ -666,14 +663,14 @@ public:
void setReadyState(ReadyState);
void setParsing(bool);
bool parsing() const { return m_bParsing; }
- std::chrono::milliseconds minimumLayoutDelay();
+ Seconds minimumLayoutDelay();
bool shouldScheduleLayout();
bool isLayoutTimerActive();
- std::chrono::milliseconds elapsedTime() const;
+ Seconds timeSinceDocumentCreation() const;
void setTextColor(const Color& color) { m_textColor = color; }
- Color textColor() const { return m_textColor; }
+ const Color& textColor() const { return m_textColor; }
const Color& linkColor() const { return m_linkColor; }
const Color& visitedLinkColor() const { return m_visitedLinkColor; }
@@ -688,52 +685,49 @@ public:
MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
- /* Newly proposed CSS3 mechanism for selecting alternate
- stylesheets using the DOM. May be subject to change as
- spec matures. - dwh
- */
- String preferredStylesheetSet() const;
- String selectedStylesheetSet() const;
- void setSelectedStylesheetSet(const String&);
+ WEBCORE_EXPORT String preferredStylesheetSet() const;
+ WEBCORE_EXPORT String selectedStylesheetSet() const;
+ WEBCORE_EXPORT void setSelectedStylesheetSet(const String&);
- bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
+ enum class FocusRemovalEventsMode { Dispatch, DoNotDispatch };
+ WEBCORE_EXPORT bool setFocusedElement(Element*, FocusDirection = FocusDirectionNone,
+ FocusRemovalEventsMode = FocusRemovalEventsMode::Dispatch);
Element* focusedElement() const { return m_focusedElement.get(); }
UserActionElementSet& userActionElements() { return m_userActionElements; }
const UserActionElementSet& userActionElements() const { return m_userActionElements; }
- // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough
- // for WebCore to ignore the autofocus attribute on any form controls
- bool ignoreAutofocus() const { return m_ignoreAutofocus; };
- void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
+ void setFocusNavigationStartingNode(Node*);
+ Element* focusNavigationStartingNode(FocusDirection) const;
- void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
+ void removeFocusedNodeOfSubtree(Node&, bool amongChildrenOnly = false);
void hoveredElementDidDetach(Element*);
void elementInActiveChainDidDetach(Element*);
- void updateHoverActiveState(const HitTestRequest&, Element*, const PlatformMouseEvent* = 0, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
+ void updateHoverActiveState(const HitTestRequest&, Element*);
// Updates for :target (CSS3 selector).
void setCSSTarget(Element*);
Element* cssTarget() const { return m_cssTarget; }
-
- void scheduleForcedStyleRecalc();
+ static ptrdiff_t cssTargetMemoryOffset() { return OBJECT_OFFSETOF(Document, m_cssTarget); }
+
+ WEBCORE_EXPORT void scheduleForcedStyleRecalc();
void scheduleStyleRecalc();
void unscheduleStyleRecalc();
bool hasPendingStyleRecalc() const;
bool hasPendingForcedStyleRecalc() const;
- void styleRecalcTimerFired(Timer<Document>&);
- void optimizedStyleSheetUpdateTimerFired(Timer<Document>&);
- void registerNodeList(LiveNodeList&);
- void unregisterNodeList(LiveNodeList&);
- void registerCollection(HTMLCollection&);
+ void registerNodeListForInvalidation(LiveNodeList&);
+ void unregisterNodeListForInvalidation(LiveNodeList&);
+ WEBCORE_EXPORT void registerCollection(HTMLCollection&);
void unregisterCollection(HTMLCollection&);
+ void collectionCachedIdNameMap(const HTMLCollection&);
+ void collectionWillClearIdNameMap(const HTMLCollection&);
bool shouldInvalidateNodeListAndCollectionCaches(const QualifiedName* attrName = nullptr) const;
void invalidateNodeListAndCollectionCaches(const QualifiedName* attrName);
void attachNodeIterator(NodeIterator*);
void detachNodeIterator(NodeIterator*);
- void moveNodeIteratorsToNewDocument(Node*, Document*);
+ void moveNodeIteratorsToNewDocument(Node&, Document&);
void attachRange(Range*);
void detachRange(Range*);
@@ -742,8 +736,10 @@ public:
// nodeChildrenWillBeRemoved is used when removing all node children at once.
void nodeChildrenWillBeRemoved(ContainerNode&);
// nodeWillBeRemoved is only safe when removing one node at a time.
- void nodeWillBeRemoved(Node*);
- bool canReplaceChild(Node* newChild, Node* oldChild);
+ void nodeWillBeRemoved(Node&);
+ void removeFocusNavigationNodeOfSubtree(Node&, bool amongChildrenOnly = false);
+ enum class AcceptChildOperation { Replace, InsertOrAdd };
+ bool canAcceptChild(const Node& newChild, const Node* refChild, AcceptChildOperation) const;
void textInserted(Node*, unsigned offset, unsigned length);
void textRemoved(Node*, unsigned offset, unsigned length);
@@ -757,14 +753,17 @@ public:
// In DOM Level 2, the Document's DOMWindow is called the defaultView.
DOMWindow* defaultView() const { return domWindow(); }
+ Document& contextDocument() const;
+ void setContextDocument(Document& document) { m_contextDocument = document.createWeakPtr(); }
+
// Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
- void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
- void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
- EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
- void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0);
+ void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld&);
+ void setWindowAttributeEventListener(const AtomicString& eventType, RefPtr<EventListener>&&, DOMWrapperWorld&);
+ EventListener* getWindowAttributeEventListener(const AtomicString& eventType, DOMWrapperWorld&);
+ WEBCORE_EXPORT void dispatchWindowEvent(Event&, EventTarget* = nullptr);
void dispatchWindowLoadEvent();
- PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<Ref<Event>> createEvent(const String& eventType);
// keep track of what types of event listeners are registered, so we don't
// dispatch events unnecessarily
@@ -781,11 +780,15 @@ public:
ANIMATIONITERATION_LISTENER = 1 << 9,
TRANSITIONEND_LISTENER = 1 << 10,
BEFORELOAD_LISTENER = 1 << 11,
- SCROLL_LISTENER = 1 << 12
- // 3 bits remaining
+ SCROLL_LISTENER = 1 << 12,
+ FORCEWILLBEGIN_LISTENER = 1 << 13,
+ FORCECHANGED_LISTENER = 1 << 14,
+ FORCEDOWN_LISTENER = 1 << 15,
+ FORCEUP_LISTENER = 1 << 16
};
bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
+ bool hasListenerTypeForEventType(PlatformEvent::Type) const;
void addListenerTypeIfNeeded(const AtomicString& eventType);
bool hasMutationObserversOfType(MutationObserver::MutationType type) const
@@ -795,18 +798,13 @@ public:
bool hasMutationObservers() const { return m_mutationObserverTypes; }
void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
- CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
+ WEBCORE_EXPORT CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
- /**
- * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
- * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
- * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
- * specified in a HTML file.
- *
- * @param equiv The http header name (value of the meta tag's "equiv" attribute)
- * @param content The header value (value of the meta tag's "content" attribute)
- */
- void processHttpEquiv(const String& equiv, const String& content);
+ // Handles an HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
+ // when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
+ // tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
+ // specified in an HTML file.
+ void processHttpEquiv(const String& equiv, const String& content, bool isInDocumentHead);
#if PLATFORM(IOS)
void processFormatDetection(const String&);
@@ -823,25 +821,28 @@ public:
// Returns 0 if this is the top level document.
HTMLFrameOwnerElement* ownerElement() const;
- HTMLIFrameElement* seamlessParentIFrame() const;
- bool shouldDisplaySeamlesslyWithParent() const;
-
// Used by DOM bindings; no direction known.
- String title() const { return m_title.string(); }
- void setTitle(const String&);
+ const String& title() const { return m_title.string; }
+ WEBCORE_EXPORT void setTitle(const String&);
- void setTitleElement(const StringWithDirection&, Element* titleElement);
- void removeTitle(Element* titleElement);
+ WEBCORE_EXPORT const AtomicString& dir() const;
+ WEBCORE_EXPORT void setDir(const AtomicString&);
- String cookie(ExceptionCode&) const;
- void setCookie(const String&, ExceptionCode&);
+ void titleElementAdded(Element& titleElement);
+ void titleElementRemoved(Element& titleElement);
+ void titleElementTextChanged(Element& titleElement);
- String referrer() const;
+ WEBCORE_EXPORT ExceptionOr<String> cookie();
+ WEBCORE_EXPORT ExceptionOr<void> setCookie(const String&);
- String domain() const;
- void setDomain(const String& newDomain, ExceptionCode&);
+ WEBCORE_EXPORT String referrer() const;
- String lastModified() const;
+ WEBCORE_EXPORT String origin() const;
+
+ WEBCORE_EXPORT String domain() const;
+ ExceptionOr<void> setDomain(const String& newDomain);
+
+ WEBCORE_EXPORT String lastModified();
// The cookieURL is used to query the cookie database for this document's
// cookies. For example, if the cookie URL is http://example.com, we'll
@@ -854,7 +855,7 @@ public:
// inherits its cookieURL but not its URL.
//
const URL& cookieURL() const { return m_cookieURL; }
- void setCookieURL(const URL& url) { m_cookieURL = url; }
+ void setCookieURL(const URL&);
// The firstPartyForCookies is used to compute whether this document
// appears in a "third-party" context for the purpose of third-party
@@ -875,54 +876,55 @@ public:
static bool isValidName(const String&);
// The following breaks a qualified name into a prefix and a local name.
- // It also does a validity check, and returns false if the qualified name
- // is invalid. It also sets ExceptionCode when name is invalid.
- static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
+ // It also does a validity check, and returns an error if the qualified name is invalid.
+ static ExceptionOr<std::pair<AtomicString, AtomicString>> parseQualifiedName(const String& qualifiedName);
+ static ExceptionOr<QualifiedName> parseQualifiedName(const AtomicString& namespaceURI, const String& qualifiedName);
// Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
static bool hasValidNamespaceForElements(const QualifiedName&);
static bool hasValidNamespaceForAttributes(const QualifiedName&);
- HTMLElement* body() const;
- void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
+ WEBCORE_EXPORT HTMLBodyElement* body() const;
+ WEBCORE_EXPORT HTMLElement* bodyOrFrameset() const;
+ WEBCORE_EXPORT ExceptionOr<void> setBodyOrFrameset(RefPtr<HTMLElement>&&);
- HTMLHeadElement* head();
+ Location* location() const;
- DocumentMarkerController& markers() const { return *m_markers; }
+ WEBCORE_EXPORT HTMLHeadElement* head();
- bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
- bool writingModeSetOnDocumentElement() const { return m_writingModeSetOnDocumentElement; }
- void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
- void setWritingModeSetOnDocumentElement(bool b) { m_writingModeSetOnDocumentElement = b; }
+ DocumentMarkerController& markers() const { return *m_markers; }
- bool execCommand(const String& command, bool userInterface = false, const String& value = String());
- bool queryCommandEnabled(const String& command);
- bool queryCommandIndeterm(const String& command);
- bool queryCommandState(const String& command);
- bool queryCommandSupported(const String& command);
- String queryCommandValue(const String& command);
+ WEBCORE_EXPORT bool execCommand(const String& command, bool userInterface = false, const String& value = String());
+ WEBCORE_EXPORT bool queryCommandEnabled(const String& command);
+ WEBCORE_EXPORT bool queryCommandIndeterm(const String& command);
+ WEBCORE_EXPORT bool queryCommandState(const String& command);
+ WEBCORE_EXPORT bool queryCommandSupported(const String& command);
+ WEBCORE_EXPORT String queryCommandValue(const String& command);
// designMode support
enum InheritedBool { off = false, on = true, inherit };
void setDesignMode(InheritedBool value);
InheritedBool getDesignMode() const;
bool inDesignMode() const;
+ WEBCORE_EXPORT String designMode() const;
+ WEBCORE_EXPORT void setDesignMode(const String&);
Document* parentDocument() const;
- Document& topDocument() const;
+ WEBCORE_EXPORT Document& topDocument() const;
ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
+ ScriptModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
- HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : 0; }
- void pushCurrentScript(PassRefPtr<HTMLScriptElement>);
+ HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
+ void pushCurrentScript(HTMLScriptElement*);
void popCurrentScript();
#if ENABLE(XSLT)
void applyXSLTransform(ProcessingInstruction* pi);
- PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
+ RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
- void setTransformSource(PassOwnPtr<TransformSource>);
+ void setTransformSource(std::unique_ptr<TransformSource>);
TransformSource* transformSource() const { return m_transformSource.get(); }
#endif
@@ -930,16 +932,9 @@ public:
uint64_t domTreeVersion() const { return m_domTreeVersion; }
// XPathEvaluator methods
- PassRefPtr<XPathExpression> createExpression(const String& expression,
- XPathNSResolver* resolver,
- ExceptionCode& ec);
- PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
- PassRefPtr<XPathResult> evaluate(const String& expression,
- Node* contextNode,
- XPathNSResolver* resolver,
- unsigned short type,
- XPathResult* result,
- ExceptionCode& ec);
+ WEBCORE_EXPORT ExceptionOr<Ref<XPathExpression>> createExpression(const String& expression, RefPtr<XPathNSResolver>&&);
+ WEBCORE_EXPORT Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
+ WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(const String& expression, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
@@ -948,15 +943,9 @@ public:
bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
- const Vector<IconURL>& shortcutIconURLs();
- const Vector<IconURL>& iconURLs(int iconTypesMask);
- void addIconURL(const String& url, const String& mimeType, const String& size, IconType);
-
- void updateFocusAppearanceSoon(bool restorePreviousSelection);
+ void updateFocusAppearanceSoon(SelectionRestorationMode);
void cancelFocusAppearanceUpdate();
- void resetHiddenFocusElementSoon();
-
// Extension for manipulating canvas drawing contexts for use in CSS
CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
@@ -964,32 +953,42 @@ public:
bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
void parseDNSPrefetchControlHeader(const String&);
- virtual void postTask(PassOwnPtr<Task>) override; // Executes the task on context's thread asynchronously.
+ void postTask(Task&&) final; // Executes the task on context's thread asynchronously.
+ ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
void suspendScriptedAnimationControllerCallbacks();
void resumeScriptedAnimationControllerCallbacks();
- virtual void scriptedAnimationControllerSetThrottled(bool);
+ void scriptedAnimationControllerSetThrottled(bool);
void windowScreenDidChange(PlatformDisplayID);
void finishedParsing();
- bool inPageCache() const { return m_inPageCache; }
- void setInPageCache(bool flag);
+ enum PageCacheState { NotInPageCache, AboutToEnterPageCache, InPageCache };
+
+ PageCacheState pageCacheState() const { return m_pageCacheState; }
+ void setPageCacheState(PageCacheState);
- // Elements can register themselves for the "documentWillSuspendForPageCache()" and
- // "documentDidResumeFromPageCache()" callbacks
- void registerForPageCacheSuspensionCallbacks(Element*);
- void unregisterForPageCacheSuspensionCallbacks(Element*);
+ // Elements can register themselves for the "suspend()" and
+ // "resume()" callbacks
+ void registerForDocumentSuspensionCallbacks(Element*);
+ void unregisterForDocumentSuspensionCallbacks(Element*);
void documentWillBecomeInactive();
- void documentWillSuspendForPageCache();
- void documentDidResumeFromPageCache();
+ void suspend(ActiveDOMObject::ReasonForSuspension);
+ void resume(ActiveDOMObject::ReasonForSuspension);
void registerForMediaVolumeCallbacks(Element*);
void unregisterForMediaVolumeCallbacks(Element*);
void mediaVolumeDidChange();
+ bool audioPlaybackRequiresUserGesture() const;
+ bool videoPlaybackRequiresUserGesture() const;
+
+#if ENABLE(MEDIA_SESSION)
+ MediaSession& defaultMediaSession();
+#endif
+
void registerForPrivateBrowsingStateChangedCallbacks(Element*);
void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
void storageBlockingStateDidChange();
@@ -1001,27 +1000,31 @@ public:
void captionPreferencesChanged();
#endif
-#if ENABLE(PAGE_VISIBILITY_API)
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+ void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
+ void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
+ void pageScaleFactorChangedAndStable();
+ void registerForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
+ void unregisterForUserInterfaceLayoutDirectionChangedCallbacks(HTMLMediaElement&);
+ void userInterfaceLayoutDirectionChanged();
+#endif
+
void registerForVisibilityStateChangedCallbacks(Element*);
void unregisterForVisibilityStateChangedCallbacks(Element*);
+
+#if ENABLE(VIDEO)
+ void registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
+ void unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement&);
+ void allowsMediaDocumentInlinePlaybackChanged();
#endif
- void setShouldCreateRenderers(bool);
+ WEBCORE_EXPORT void setShouldCreateRenderers(bool);
bool shouldCreateRenderers();
- void setDecoder(PassRefPtr<TextResourceDecoder>);
+ void setDecoder(RefPtr<TextResourceDecoder>&&);
TextResourceDecoder* decoder() const { return m_decoder.get(); }
- String displayStringModifiedByEncoding(const String&) const;
- PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
- void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
- {
- displayBufferModifiedByEncodingInternal(buffer, len);
- }
- void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
- {
- displayBufferModifiedByEncodingInternal(buffer, len);
- }
+ WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
// Quirk for the benefit of Apple's Dictionary application.
void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
@@ -1032,97 +1035,89 @@ public:
bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
- const Vector<AnnotatedRegionValue>& annotatedRegions() const;
+ WEBCORE_EXPORT const Vector<AnnotatedRegionValue>& annotatedRegions() const;
void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
#endif
- virtual void removeAllEventListeners() override;
+ void removeAllEventListeners() final;
-#if ENABLE(SVG)
- const SVGDocumentExtensions* svgExtensions();
- SVGDocumentExtensions* accessSVGExtensions();
-#endif
+ WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
+ WEBCORE_EXPORT SVGDocumentExtensions& accessSVGExtensions();
void initSecurityContext();
void initContentSecurityPolicy();
void updateURLForPushOrReplaceState(const URL&);
- void statePopped(PassRefPtr<SerializedScriptValue>);
+ void statePopped(Ref<SerializedScriptValue>&&);
bool processingLoadEvent() const { return m_processingLoadEvent; }
bool loadEventFinished() const { return m_loadEventFinished; }
- virtual bool isContextThread() const override;
- virtual bool isJSExecutionForbidden() const override { return false; }
+ bool isContextThread() const final;
+ bool isJSExecutionForbidden() const final { return false; }
- bool containsValidityStyleRules() const { return m_containsValidityStyleRules; }
- void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; }
-
- void enqueueWindowEvent(PassRefPtr<Event>);
- void enqueueDocumentEvent(PassRefPtr<Event>);
- void enqueueOverflowEvent(PassRefPtr<Event>);
- void enqueuePageshowEvent(PageshowEventPersistence);
+ void enqueueWindowEvent(Ref<Event>&&);
+ void enqueueDocumentEvent(Ref<Event>&&);
+ void enqueueOverflowEvent(Ref<Event>&&);
+ void dispatchPageshowEvent(PageshowEventPersistence);
void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
- void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
- virtual DocumentEventQueue& eventQueue() const override { return m_eventQueue; }
+ void dispatchPopstateEvent(RefPtr<SerializedScriptValue>&& stateObject);
+ DocumentEventQueue& eventQueue() const final { return m_eventQueue; }
- void addMediaCanStartListener(MediaCanStartListener*);
- void removeMediaCanStartListener(MediaCanStartListener*);
+ WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener*);
+ WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener*);
MediaCanStartListener* takeAnyMediaCanStartListener();
- const QualifiedName& idAttributeName() const { return m_idAttributeName; }
-
#if ENABLE(FULLSCREEN_API)
bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() && m_areKeysEnabledInFullScreen; }
Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
-
+ Element* webkitCurrentFullScreenElementForBindings() const { return ancestorElementInThisScope(webkitCurrentFullScreenElement()); }
+
enum FullScreenCheckType {
EnforceIFrameAllowFullScreenRequirement,
ExemptIFrameAllowFullScreenRequirement,
};
- void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
- void webkitCancelFullScreen();
+ void requestFullScreenForElement(Element*, FullScreenCheckType);
+ WEBCORE_EXPORT void webkitCancelFullScreen();
- void webkitWillEnterFullScreenForElement(Element*);
- void webkitDidEnterFullScreenForElement(Element*);
- void webkitWillExitFullScreenForElement(Element*);
- void webkitDidExitFullScreenForElement(Element*);
+ WEBCORE_EXPORT void webkitWillEnterFullScreenForElement(Element*);
+ WEBCORE_EXPORT void webkitDidEnterFullScreenForElement(Element*);
+ WEBCORE_EXPORT void webkitWillExitFullScreenForElement(Element*);
+ WEBCORE_EXPORT void webkitDidExitFullScreenForElement(Element*);
void setFullScreenRenderer(RenderFullScreen*);
RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
void fullScreenRendererDestroyed();
- void fullScreenChangeDelayTimerFired(Timer<Document>&);
+ void fullScreenChangeDelayTimerFired();
bool fullScreenIsAllowedForElement(Element*) const;
void fullScreenElementRemoved();
- void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
+ void removeFullScreenElementOfSubtree(Node&, bool amongChildrenOnly = false);
bool isAnimatingFullScreen() const;
- void setAnimatingFullScreen(bool);
+ WEBCORE_EXPORT void setAnimatingFullScreen(bool);
- // W3C API
- bool webkitFullscreenEnabled() const;
- Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : 0; }
- void webkitExitFullscreen();
+ WEBCORE_EXPORT bool webkitFullscreenEnabled() const;
+ Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : nullptr; }
+ Element* webkitFullscreenElementForBindings() const { return ancestorElementInThisScope(webkitFullscreenElement()); }
+ WEBCORE_EXPORT void webkitExitFullscreen();
#endif
#if ENABLE(POINTER_LOCK)
- void webkitExitPointerLock();
- Element* webkitPointerLockElement() const;
+ WEBCORE_EXPORT void exitPointerLock();
#endif
// Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
void decrementLoadEventDelayCount();
bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
+ void checkCompleted();
-#if ENABLE(TOUCH_EVENTS)
-#if PLATFORM(IOS)
+#if ENABLE(IOS_TOUCH_EVENTS)
#include <WebKitAdditions/DocumentIOS.h>
-#else
- PassRefPtr<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const;
-#endif // PLATFORM(IOS)
+#elif ENABLE(TOUCH_EVENTS)
+ Ref<Touch> createTouch(DOMWindow*, EventTarget*, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force) const;
#endif
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
@@ -1131,26 +1126,27 @@ public:
#endif
#if ENABLE(WEB_TIMING)
- const DocumentTiming* timing() const { return &m_documentTiming; }
+ const DocumentTiming& timing() const { return m_documentTiming; }
#endif
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
+ double monotonicTimestamp() const;
+
+ int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
void cancelAnimationFrame(int id);
- void serviceScriptedAnimations(double monotonicAnimationStartTime);
-#endif
+ void serviceScriptedAnimations(double timestamp);
- virtual EventTarget* errorEventTarget() override;
- virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) override;
+ void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
+
+ EventTarget* errorEventTarget() final;
+ void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) final;
void initDNSPrefetch();
- unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
- void didAddWheelEventHandler();
- void didRemoveWheelEventHandler();
+ void didAddWheelEventHandler(Node&);
+ void didRemoveWheelEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
double lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
- void resetLastHandledUserGestureTimestamp();
+ void updateLastHandledUserGestureTimestamp();
#if ENABLE(TOUCH_EVENTS)
bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
@@ -1158,18 +1154,36 @@ public:
bool hasTouchEventHandlers() const { return false; }
#endif
- void didAddTouchEventHandler(Node*);
- void didRemoveTouchEventHandler(Node*);
+ void setUserDidInteractWithPage(bool userDidInteractWithPage) { ASSERT(&topDocument() == this); m_userDidInteractWithPage = userDidInteractWithPage; }
+ bool userDidInteractWithPage() const { ASSERT(&topDocument() == this); return m_userDidInteractWithPage; }
-#if ENABLE(TOUCH_EVENTS)
- void didRemoveEventTargetNode(Node*);
-#endif
+ // Used for testing. Count handlers in the main document, and one per frame which contains handlers.
+ WEBCORE_EXPORT unsigned wheelEventHandlerCount() const;
+ WEBCORE_EXPORT unsigned touchEventHandlerCount() const;
+
+ WEBCORE_EXPORT void startTrackingStyleRecalcs();
+ WEBCORE_EXPORT unsigned styleRecalcCount() const;
+
+ void didAddTouchEventHandler(Node&);
+ void didRemoveTouchEventHandler(Node&, EventHandlerRemoval = EventHandlerRemoval::One);
+ void didRemoveEventTargetNode(Node&);
+
+ const EventTargetSet* touchEventTargets() const
+ {
#if ENABLE(TOUCH_EVENTS)
- const TouchEventTargetSet* touchEventTargets() const { return m_touchEventTargets.get(); }
+ return m_touchEventTargets.get();
#else
- const TouchEventTargetSet* touchEventTargets() const { return 0; }
+ return nullptr;
#endif
+ }
+
+ const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
+
+ typedef std::pair<Region, bool> RegionFixedPair;
+ RegionFixedPair absoluteRegionForEventTargets(const EventTargetSet*);
+
+ LayoutRect absoluteEventHandlerBounds(bool&) final;
bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
@@ -1182,10 +1196,6 @@ public:
IntSize initialViewportSize() const;
#endif
-#if ENABLE(TEXT_AUTOSIZING)
- TextAutosizer* textAutosizer() { return m_textAutosizer.get(); }
-#endif
-
void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&);
void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&);
@@ -1196,47 +1206,105 @@ public:
DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
void didRemoveAllPendingStylesheet();
- void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
- void clearStyleResolver();
- void notifySeamlessChildDocumentsOfStylesheetUpdate() const;
+ void didClearStyleResolver();
- bool inStyleRecalc() { return m_inStyleRecalc; }
+ bool inStyleRecalc() const { return m_inStyleRecalc; }
+ bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
// Return a Locale for the default locale if the argument is null or empty.
Locale& getCachedLocale(const AtomicString& locale = nullAtom);
-#if ENABLE(TEMPLATE_ELEMENT)
const Document* templateDocument() const;
- Document* ensureTemplateDocument();
+ Document& ensureTemplateDocument();
void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = templateDocumentHost; }
Document* templateDocumentHost() { return m_templateDocumentHost; }
-#endif
void didAssociateFormControl(Element*);
+ bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; }
+ void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
+ void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
- virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override;
+ WEBCORE_EXPORT void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) final;
- virtual SecurityOrigin* topOrigin() const override;
+ SecurityOrigin& securityOrigin() const { return *SecurityContext::securityOrigin(); }
+ SecurityOrigin& topOrigin() const final { return topDocument().securityOrigin(); }
-#if ENABLE(FONT_LOAD_EVENTS)
- PassRefPtr<FontLoader> fontloader();
-#endif
+ Ref<FontFaceSet> fonts();
void ensurePlugInsInjectedScript(DOMWrapperWorld&);
void setVisualUpdatesAllowedByClient(bool);
+#if ENABLE(SUBTLE_CRYPTO)
+ bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) final;
+ bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) final;
+#endif
+
+ void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
+ bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
+ void updateViewportUnitsOnResize();
+
+ WEBCORE_EXPORT void addAudioProducer(MediaProducer*);
+ WEBCORE_EXPORT void removeAudioProducer(MediaProducer*);
+ MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
+ WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
+ void pageMutedStateDidChange();
+ WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+ void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&);
+ void removePlaybackTargetPickerClient(MediaPlaybackTargetClient&);
+ void showPlaybackTargetPicker(MediaPlaybackTargetClient&, bool);
+ void playbackTargetPickerClientStateDidChange(MediaPlaybackTargetClient&, MediaProducer::MediaStateFlags);
+
+ void setPlaybackTarget(uint64_t, Ref<MediaPlaybackTarget>&&);
+ void playbackTargetAvailabilityDidChange(uint64_t, bool);
+ void setShouldPlayToPlaybackTarget(uint64_t, bool);
+#endif
+
+ ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicyToPropagate() const;
+ bool shouldEnforceContentDispositionAttachmentSandbox() const;
+ void applyContentDispositionAttachmentSandbox();
+
+ void addViewportDependentPicture(HTMLPictureElement&);
+ void removeViewportDependentPicture(HTMLPictureElement&);
+
+#if ENABLE(MEDIA_STREAM)
+ void setHasActiveMediaStreamTrack() { m_hasHadActiveMediaStreamTrack = true; }
+ bool hasHadActiveMediaStreamTrack() const { return m_hasHadActiveMediaStreamTrack; }
+#endif
+
+ using ContainerNode::setAttributeEventListener;
+ void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld& isolatedWorld);
+
+ DOMSelection* getSelection();
+
+ void didInsertInDocumentShadowRoot(ShadowRoot&);
+ void didRemoveInDocumentShadowRoot(ShadowRoot&);
+ const HashSet<ShadowRoot*>& inDocumentShadowRoots() const { return m_inDocumentShadowRoots; }
+
+ void attachToCachedFrame(CachedFrameBase&);
+ void detachFromCachedFrame(CachedFrameBase&);
+
protected:
enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
void clearXMLVersion() { m_xmlVersion = String(); }
- virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const;
+ virtual Ref<Document> cloneDocumentWithoutChildren() const;
private:
friend class Node;
friend class IgnoreDestructiveWriteCountIncrementer;
+ friend class IgnoreOpensDuringUnloadCountIncrementer;
+
+ bool shouldInheritContentSecurityPolicyFromOwner() const;
+
+ void detachFromFrame() { observeFrame(nullptr); }
+
+ void updateTitleElement(Element* newTitleElement);
+ void frameDestroyed() final;
void commonTeardown();
@@ -1246,56 +1314,40 @@ private:
void createRenderTree();
void detachParser();
- virtual void dropChildren() override;
+ // FontSelectorClient
+ void fontsNeedUpdate(FontSelector&) final;
- typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
- void processArguments(const String& features, void* data, ArgumentsCallback);
+ bool isDocument() const final { return true; }
- virtual bool isDocument() const override { return true; }
+ void childrenChanged(const ChildChange&) final;
- virtual void childrenChanged(const ChildChange&) override;
-
- virtual String nodeName() const override;
- virtual NodeType nodeType() const override;
- virtual bool childTypeAllowed(NodeType) const override;
- virtual PassRefPtr<Node> cloneNode(bool deep) override;
+ String nodeName() const final;
+ NodeType nodeType() const final;
+ bool childTypeAllowed(NodeType) const final;
+ Ref<Node> cloneNodeInternal(Document&, CloningOperation) final;
void cloneDataFromDocument(const Document&);
- virtual void refScriptExecutionContext() override { ref(); }
- virtual void derefScriptExecutionContext() override { deref(); }
+ void refScriptExecutionContext() final { ref(); }
+ void derefScriptExecutionContext() final { deref(); }
- virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack>, JSC::ExecState* = 0, unsigned long requestIdentifier = 0) override;
+ void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) final;
- virtual double minimumTimerInterval() const override;
+ std::chrono::milliseconds minimumTimerInterval() const final;
- virtual double timerAlignmentInterval() const override;
+ std::chrono::milliseconds timerAlignmentInterval(bool hasReachedMaxNestingLevel) const final;
+ void updateTitleFromTitleElement();
void updateTitle(const StringWithDirection&);
- void updateFocusAppearanceTimerFired(Timer<Document>&);
+ void updateFocusAppearanceTimerFired();
void updateBaseURL();
- void resetHiddenFocusElementTimer(Timer<Document>&);
-
void buildAccessKeyMap(TreeScope* root);
- void createStyleResolver();
-
- void seamlessParentUpdatedStylesheets();
+ void loadEventDelayTimerFired();
- void loadEventDelayTimerFired(Timer<Document>&);
+ void pendingTasksTimerFired();
- void pendingTasksTimerFired(Timer<Document>&);
-
- static void didReceiveTask(void*);
-
- template <typename CharacterType>
- void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
-
-#if ENABLE(PAGE_VISIBILITY_API)
- PageVisibilityState pageVisibilityState() const;
-#endif
-
- PassRefPtr<HTMLCollection> ensureCachedCollection(CollectionType);
+ template<CollectionType> Ref<HTMLCollection> ensureCachedCollection();
#if ENABLE(FULLSCREEN_API)
void dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>&, const AtomicString& eventName, bool shouldNotifyMediaElement);
@@ -1307,19 +1359,39 @@ private:
void setVisualUpdatesAllowed(ReadyState);
void setVisualUpdatesAllowed(bool);
- void visualUpdatesSuppressionTimerFired(Timer<Document>&);
+ void visualUpdatesSuppressionTimerFired();
void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
- void didAssociateFormControlsTimerFired(Timer<Document>&);
+ void didAssociateFormControlsTimerFired();
+
+ void wheelEventHandlersChanged();
+
+ HttpEquivPolicy httpEquivPolicy() const;
+ AXObjectCache* existingAXObjectCacheSlow() const;
- void styleResolverThrowawayTimerFired(DeferrableOneShotTimer<Document>&);
- DeferrableOneShotTimer<Document> m_styleResolverThrowawayTimer;
+ // DOM Cookies caching.
+ const String& cachedDOMCookies() const { return m_cachedDOMCookies; }
+ void setCachedDOMCookies(const String&);
+ bool isDOMCookieCacheValid() const { return m_cookieCacheExpiryTimer.isActive(); }
+ void invalidateDOMCookieCache();
+ void didLoadResourceSynchronously() final;
- OwnPtr<StyleResolver> m_styleResolver;
- bool m_didCalculateStyleResolver;
+ void checkViewportDependentPictures();
+
+#if USE(QUICK_LOOK)
+ bool shouldEnforceQuickLookSandbox() const;
+ void applyQuickLookSandbox();
+#endif
+
+ bool shouldEnforceHTTP09Sandbox() const;
+
+ unsigned m_referencingNodeCount;
+
+ const Ref<Settings> m_settings;
+
+ std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
bool m_hasNodesWithPlaceholderStyle;
- bool m_needsNotifyRemoveAllPendingStylesheet;
// But sometimes you need to ignore pending stylesheet count to
// force an immediate layout when requested by JS.
bool m_ignorePendingStylesheets;
@@ -1329,10 +1401,10 @@ private:
// do eventually load.
PendingSheetLayout m_pendingSheetLayout;
- Frame* m_frame;
RefPtr<DOMWindow> m_domWindow;
+ WeakPtr<Document> m_contextDocument;
- RefPtr<CachedResourceLoader> m_cachedResourceLoader;
+ Ref<CachedResourceLoader> m_cachedResourceLoader;
RefPtr<DocumentParser> m_parser;
unsigned m_activeParserCount;
@@ -1357,20 +1429,23 @@ private:
String m_baseTarget;
- OwnPtr<DOMImplementation> m_implementation;
+ // MIME type of the document in case it was cloned or created by XHR.
+ String m_overriddenMIMEType;
- RefPtr<CSSStyleSheet> m_elementSheet;
+ std::unique_ptr<DOMImplementation> m_implementation;
+
+ bool m_hasElementUsingStyleBasedEditability { false };
bool m_printing;
bool m_paginatedForScreen;
- bool m_ignoreAutofocus;
-
- CompatibilityMode m_compatibilityMode;
+ DocumentCompatibilityMode m_compatibilityMode;
bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
Color m_textColor;
+ bool m_focusNavigationStartingNodeIsRemoved;
+ RefPtr<Node> m_focusNavigationStartingNode;
RefPtr<Element> m_focusedElement;
RefPtr<Element> m_hoveredElement;
RefPtr<Element> m_activeElement;
@@ -1383,70 +1458,75 @@ private:
HashSet<NodeIterator*> m_nodeIterators;
HashSet<Range*> m_ranges;
- unsigned short m_listenerTypes;
+ unsigned m_listenerTypes;
MutationObserverOptions m_mutationObserverTypes;
- DocumentStyleSheetCollection m_styleSheetCollection;
+ std::unique_ptr<Style::Scope> m_styleScope;
+ std::unique_ptr<ExtensionStyleSheets> m_extensionStyleSheets;
RefPtr<StyleSheetList> m_styleSheetList;
- OwnPtr<FormController> m_formController;
+ std::unique_ptr<FormController> m_formController;
Color m_linkColor;
Color m_visitedLinkColor;
Color m_activeLinkColor;
- const OwnPtr<VisitedLinkState> m_visitedLinkState;
+ const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
bool m_visuallyOrdered;
ReadyState m_readyState;
bool m_bParsing;
- Timer<Document> m_optimizedStyleSheetUpdateTimer;
- Timer<Document> m_styleRecalcTimer;
+ Timer m_styleRecalcTimer;
bool m_pendingStyleRecalcShouldForce;
bool m_inStyleRecalc;
bool m_closeAfterStyleRecalc;
+ bool m_inRenderTreeUpdate { false };
+ unsigned m_lastStyleUpdateSizeForTesting { 0 };
bool m_gotoAnchorNeededAfterStylesheetsLoad;
bool m_isDNSPrefetchEnabled;
bool m_haveExplicitlyDisabledDNSPrefetch;
bool m_frameElementsShouldIgnoreScrolling;
- bool m_containsValidityStyleRules;
- bool m_updateFocusAppearanceRestoresSelection;
+ SelectionRestorationMode m_updateFocusAppearanceRestoresSelection;
- // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
- unsigned m_ignoreDestructiveWriteCount;
+ // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-destructive-writes-counter
+ unsigned m_ignoreDestructiveWriteCount { 0 };
+
+ // https://html.spec.whatwg.org/multipage/webappapis.html#ignore-opens-during-unload-counter
+ unsigned m_ignoreOpensDuringUnloadCount { 0 };
+
+ unsigned m_styleRecalcCount { 0 };
StringWithDirection m_title;
StringWithDirection m_rawTitle;
- bool m_titleSetExplicitly;
RefPtr<Element> m_titleElement;
- OwnPtr<AXObjectCache> m_axObjectCache;
- const OwnPtr<DocumentMarkerController> m_markers;
+ std::unique_ptr<AXObjectCache> m_axObjectCache;
+ const std::unique_ptr<DocumentMarkerController> m_markers;
- Timer<Document> m_updateFocusAppearanceTimer;
- Timer<Document> m_resetHiddenFocusElementTimer;
+ Timer m_updateFocusAppearanceTimer;
Element* m_cssTarget;
// FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
// is almost a duplication of this data, so that should probably get merged in too.
- // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
+ // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadDispatched are roughly the same
// and should be merged.
bool m_processingLoadEvent;
bool m_loadEventFinished;
RefPtr<SerializedScriptValue> m_pendingStateObject;
- std::chrono::steady_clock::time_point m_startTime;
+ MonotonicTime m_documentCreationTime;
bool m_overMinimumLayoutThreshold;
std::unique_ptr<ScriptRunner> m_scriptRunner;
+ std::unique_ptr<ScriptModuleLoader> m_moduleLoader;
Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
#if ENABLE(XSLT)
- OwnPtr<TransformSource> m_transformSource;
+ std::unique_ptr<TransformSource> m_transformSource;
RefPtr<Document> m_transformSourceDocument;
#endif
@@ -1463,14 +1543,11 @@ private:
HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
-
unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
RefPtr<XPathEvaluator> m_xpathEvaluator;
-#if ENABLE(SVG)
- OwnPtr<SVGDocumentExtensions> m_svgExtensions;
-#endif
+ std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
#if ENABLE(DASHBOARD_SUPPORT)
Vector<AnnotatedRegionValue> m_annotatedRegions;
@@ -1481,8 +1558,7 @@ private:
HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
bool m_createRenderers;
- bool m_inPageCache;
- Vector<IconURL> m_iconURLs;
+ PageCacheState m_pageCacheState { NotInPageCache };
HashSet<Element*> m_documentSuspensionCallbackElements;
HashSet<Element*> m_mediaVolumeCallbackElements;
@@ -1491,23 +1567,28 @@ private:
HashSet<Element*> m_captionPreferencesChangedElements;
#endif
-#if ENABLE(PAGE_VISIBILITY_API)
+#if ENABLE(MEDIA_CONTROLS_SCRIPT)
+ HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
+ HashSet<HTMLMediaElement*> m_userInterfaceLayoutDirectionChangedElements;
+#endif
+
HashSet<Element*> m_visibilityStateCallbackElements;
+#if ENABLE(VIDEO)
+ HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
#endif
- HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
+ HashMap<StringImpl*, Element*, ASCIICaseInsensitiveHash> m_elementsByAccessKey;
bool m_accessKeyMapValid;
DocumentOrderedMap m_imagesByUsemap;
- OwnPtr<SelectorQueryCache> m_selectorQueryCache;
+ std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
DocumentClassFlags m_documentClasses;
bool m_isSynthesized;
bool m_isNonRenderedPlaceholder;
- bool m_isViewSource;
bool m_sawElementsInKnownNamespaces;
bool m_isSrcdocDocument;
@@ -1518,31 +1599,28 @@ private:
HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
- QualifiedName m_idAttributeName;
-
#if ENABLE(FULLSCREEN_API)
bool m_areKeysEnabledInFullScreen;
RefPtr<Element> m_fullScreenElement;
Vector<RefPtr<Element>> m_fullScreenElementStack;
RenderFullScreen* m_fullScreenRenderer;
- Timer<Document> m_fullScreenChangeDelayTimer;
+ Timer m_fullScreenChangeDelayTimer;
Deque<RefPtr<Node>> m_fullScreenChangeEventTargetQueue;
Deque<RefPtr<Node>> m_fullScreenErrorEventTargetQueue;
bool m_isAnimatingFullScreen;
LayoutRect m_savedPlaceholderFrameRect;
- RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
+ std::unique_ptr<RenderStyle> m_savedPlaceholderRenderStyle;
#endif
+ HashSet<HTMLPictureElement*> m_viewportDependentPictures;
+
int m_loadEventDelayCount;
- Timer<Document> m_loadEventDelayTimer;
+ Timer m_loadEventDelayTimer;
ViewportArguments m_viewportArguments;
ReferrerPolicy m_referrerPolicy;
- bool m_directionSetOnDocumentElement;
- bool m_writingModeSetOnDocumentElement;
-
#if ENABLE(WEB_TIMING)
DocumentTiming m_documentTiming;
#endif
@@ -1551,28 +1629,25 @@ private:
bool m_writeRecursionIsTooDeep;
unsigned m_writeRecursionDepth;
- unsigned m_wheelEventHandlerCount;
#if ENABLE(TOUCH_EVENTS)
- OwnPtr<TouchEventTargetSet> m_touchEventTargets;
+ std::unique_ptr<EventTargetSet> m_touchEventTargets;
#endif
+ std::unique_ptr<EventTargetSet> m_wheelEventTargets;
double m_lastHandledUserGestureTimestamp;
-#if ENABLE(REQUEST_ANIMATION_FRAME)
void clearScriptedAnimationController();
RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
-#endif
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
- // FIXME: Use std::unique_ptr instead of OwnPtr after we upstream DeviceMotionClientIOS.{h, mm}.
- OwnPtr<DeviceMotionClient> m_deviceMotionClient;
- OwnPtr<DeviceMotionController> m_deviceMotionController;
- OwnPtr<DeviceOrientationClient> m_deviceOrientationClient;
- OwnPtr<DeviceOrientationController> m_deviceOrientationController;
+ std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
+ std::unique_ptr<DeviceMotionController> m_deviceMotionController;
+ std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
+ std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
#endif
// FIXME: Find a better place for this functionality.
-#if PLATFORM(IOS)
+#if ENABLE(TELEPHONE_NUMBER_DETECTION)
public:
// These functions provide a two-level setting:
@@ -1581,8 +1656,8 @@ public:
// document if it has the appropriate meta tag.
// - isTelephoneNumberParsingEnabled() == isTelephoneNumberParsingAllowed() && page()->settings()->isTelephoneNumberParsingEnabled()
- bool isTelephoneNumberParsingAllowed() const;
- bool isTelephoneNumberParsingEnabled() const;
+ WEBCORE_EXPORT bool isTelephoneNumberParsingAllowed() const;
+ WEBCORE_EXPORT bool isTelephoneNumberParsingEnabled() const;
private:
friend void setParserFeature(const String& key, const String& value, Document*, void* userData);
@@ -1591,148 +1666,132 @@ private:
bool m_isTelephoneNumberParsingAllowed;
#endif
- Timer<Document> m_pendingTasksTimer;
- Vector<OwnPtr<Task>> m_pendingTasks;
+ Timer m_pendingTasksTimer;
+ Vector<Task> m_pendingTasks;
-#if ENABLE(IOS_TEXT_AUTOSIZING)
+#if ENABLE(TEXT_AUTOSIZING)
public:
- void addAutoSizingNode(Node*, float size);
- void validateAutoSizingNodes();
- void resetAutoSizingNodes();
+ void addAutoSizedNode(Text&, float size);
+ void updateAutoSizedNodes();
+ void clearAutoSizedNodes();
private:
- typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
+ using TextAutoSizingMap = HashMap<TextAutoSizingKey, std::unique_ptr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits>;
TextAutoSizingMap m_textAutoSizedNodes;
#endif
-#if ENABLE(TEXT_AUTOSIZING)
- OwnPtr<TextAutosizer> m_textAutosizer;
-#endif
-
void platformSuspendOrStopActiveDOMObjects();
bool m_scheduledTasksAreSuspended;
bool m_visualUpdatesAllowed;
- Timer<Document> m_visualUpdatesSuppressionTimer;
+ Timer m_visualUpdatesSuppressionTimer;
RefPtr<NamedFlowCollection> m_namedFlows;
-#if ENABLE(CSP_NEXT)
- RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
-#endif
-
- void sharedObjectPoolClearTimerFired(Timer<Document>&);
- Timer<Document> m_sharedObjectPoolClearTimer;
+ void clearSharedObjectPool();
+ Timer m_sharedObjectPoolClearTimer;
- OwnPtr<DocumentSharedObjectPool> m_sharedObjectPool;
+ std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
#ifndef NDEBUG
bool m_didDispatchViewportPropertiesChanged;
#endif
- typedef HashMap<AtomicString, OwnPtr<Locale>> LocaleIdentifierToLocaleMap;
+ typedef HashMap<AtomicString, std::unique_ptr<Locale>> LocaleIdentifierToLocaleMap;
LocaleIdentifierToLocaleMap m_localeCache;
-#if ENABLE(TEMPLATE_ELEMENT)
RefPtr<Document> m_templateDocument;
Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
-#endif
-#if ENABLE(FONT_LOAD_EVENTS)
- RefPtr<FontLoader> m_fontloader;
+ Ref<CSSFontSelector> m_fontSelector;
+
+#if ENABLE(WEB_REPLAY)
+ Ref<JSC::InputCursor> m_inputCursor;
#endif
- Timer<Document> m_didAssociateFormControlsTimer;
+ Timer m_didAssociateFormControlsTimer;
+ Timer m_cookieCacheExpiryTimer;
+ String m_cachedDOMCookies;
HashSet<RefPtr<Element>> m_associatedFormControls;
+ unsigned m_disabledFieldsetElementsCount;
bool m_hasInjectedPlugInsScript;
- bool m_renderTreeBeingDestroyed;
-};
-
-inline void Document::notifyRemovePendingSheetIfNeeded()
-{
- if (m_needsNotifyRemoveAllPendingStylesheet)
- didRemoveAllPendingStylesheet();
-}
+ bool m_renderTreeBeingDestroyed { false };
+ bool m_hasPreparedForDestruction { false };
-#if ENABLE(TEMPLATE_ELEMENT)
-inline const Document* Document::templateDocument() const
-{
- // If DOCUMENT does not have a browsing context, Let TEMPLATE CONTENTS OWNER be DOCUMENT and abort these steps.
- if (!m_frame)
- return this;
+ bool m_hasStyleWithViewportUnits;
+ bool m_isTimerThrottlingEnabled { false };
+ bool m_isSuspended { false };
- return m_templateDocument.get();
-}
-#endif
+ HashSet<MediaProducer*> m_audioProducers;
+ MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
-// Put these methods here, because they require the Document definition, but we really want to inline them.
+ HashSet<ShadowRoot*> m_inDocumentShadowRoots;
-inline bool Node::isDocumentNode() const
-{
- return this == documentInternal();
-}
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+ typedef HashMap<uint64_t, WebCore::MediaPlaybackTargetClient*> TargetIdToClientMap;
+ TargetIdToClientMap m_idToClientMap;
+ typedef HashMap<WebCore::MediaPlaybackTargetClient*, uint64_t> TargetClientToIdMap;
+ TargetClientToIdMap m_clientToIDMap;
+#endif
-inline Node::Node(Document* document, ConstructionType type)
- : m_nodeFlags(type)
- , m_parentNode(0)
- , m_treeScope(document ? document : &TreeScope::noDocumentInstance())
- , m_previous(0)
- , m_next(0)
-{
- m_treeScope->selfOnlyRef();
+#if ENABLE(MEDIA_SESSION)
+ RefPtr<MediaSession> m_defaultMediaSession;
+#endif
+ bool m_areDeviceMotionAndOrientationUpdatesSuspended { false };
+ bool m_userDidInteractWithPage { false };
-#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
- trackForDebugging();
+#if ENABLE(MEDIA_STREAM)
+ bool m_hasHadActiveMediaStreamTrack { false };
#endif
- InspectorCounters::incrementCounter(InspectorCounters::NodeCounter);
-}
+#if ENABLE(INDEXED_DATABASE)
+ RefPtr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
+#endif
+#if ENABLE(WEB_SOCKETS)
+ RefPtr<SocketProvider> m_socketProvider;
+#endif
-inline ScriptExecutionContext* Node::scriptExecutionContext() const
-{
- return &document();
-}
+ static bool hasEverCreatedAnAXObjectCache;
+};
Element* eventTargetElementForDocument(Document*);
-inline Document& toDocument(ScriptExecutionContext& scriptExecutionContext)
+inline TextEncoding Document::textEncoding() const
{
- ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext.isDocument());
- return static_cast<Document&>(scriptExecutionContext);
+ if (auto* decoder = this->decoder())
+ return decoder->encoding();
+ return TextEncoding();
}
-inline const Document& toDocument(const ScriptExecutionContext& scriptExecutionContext)
+inline const Document* Document::templateDocument() const
{
- ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext.isDocument());
- return static_cast<const Document&>(scriptExecutionContext);
+ return m_templateDocumentHost ? this : m_templateDocument.get();
}
-inline Document* toDocument(ScriptExecutionContext* scriptExecutionContext)
+inline AXObjectCache* Document::existingAXObjectCache() const
{
- ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
- return static_cast<Document*>(scriptExecutionContext);
+ if (!hasEverCreatedAnAXObjectCache)
+ return nullptr;
+ return existingAXObjectCacheSlow();
}
-inline const Document* toDocument(const ScriptExecutionContext* scriptExecutionContext)
+// These functions are here because they require the Document class definition and we want to inline them.
+
+inline bool Node::isDocumentNode() const
{
- ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
- return static_cast<const Document*>(scriptExecutionContext);
+ return this == &document();
}
-inline bool isDocument(const Node& node) { return node.isDocumentNode(); }
-void isDocument(const Document&); // Catch unnecessary runtime check of type known at compile time.
-
-NODE_TYPE_CASTS(Document)
-
-#define DOCUMENT_TYPE_CASTS(ToClassName) \
- TYPE_CASTS_BASE(ToClassName, Document, document, WebCore::is##ToClassName(*document), WebCore::is##ToClassName(document))
+inline ScriptExecutionContext* Node::scriptExecutionContext() const
+{
+ return &document().contextDocument();
+}
} // namespace WebCore
-namespace WTF {
-inline WebCore::Document* getPtr(WebCore::Document& p) { return &p; }
-}
-
-#endif // Document_h
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Document)
+ static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
+ static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
+SPECIALIZE_TYPE_TRAITS_END()