#ifndef Document_h
#define Document_h
#include "CollectionType.h"
#include "Color.h"
#include "ContainerNode.h"
#include "DocumentEventQueue.h"
#include "DocumentStyleSheetCollection.h"
#include "DocumentTiming.h"
#include "FocusDirection.h"
#include "IconURL.h"
#include "MutationObserver.h"
#include "PageVisibilityState.h"
#include "PlatformScreen.h"
#include "ReferrerPolicy.h"
#include "RenderPtr.h"
#include "ScriptExecutionContext.h"
#include "StringWithDirection.h"
#include "StyleResolveTree.h"
#include "Timer.h"
#include "TreeScope.h"
#include "UserActionElementSet.h"
#include "ViewportArguments.h"
#include <chrono>
#include <memory>
#include <wtf/Deque.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/WeakPtr.h>
namespace JSC {
class ExecState;
#if ENABLE(WEB_REPLAY)
class InputCursor;
#endif
}
namespace WebCore {
class AXObjectCache;
class Attr;
class CDATASection;
class CSSStyleDeclaration;
class CSSStyleSheet;
class CachedCSSStyleSheet;
class CachedResourceLoader;
class CachedScript;
class CanvasRenderingContext;
class CharacterData;
class Comment;
class DOMImplementation;
class DOMNamedFlowCollection;
class DOMSelection;
class DOMWindow;
class DOMWrapperWorld;
class Database;
class DatabaseThread;
class DocumentFragment;
class DocumentLoader;
class DocumentMarkerController;
class DocumentParser;
class DocumentSharedObjectPool;
class DocumentType;
class Element;
class EntityReference;
class Event;
class EventListener;
class FloatRect;
class FloatQuad;
class FormController;
class Frame;
class FrameView;
class HTMLCanvasElement;
class HTMLCollection;
class HTMLAllCollection;
class HTMLDocument;
class HTMLElement;
class HTMLFrameOwnerElement;
class HTMLHeadElement;
class HTMLIFrameElement;
class HTMLImageElement;
class HTMLMapElement;
class HTMLMediaElement;
class HTMLNameCollection;
class HTMLScriptElement;
class HitTestRequest;
class HitTestResult;
class IntPoint;
class LayoutPoint;
class LayoutRect;
class LiveNodeList;
class JSNode;
class Locale;
class MediaCanStartListener;
class MediaQueryList;
class MediaQueryMatcher;
class MouseEventWithHitTestResults;
class NamedFlowCollection;
class NodeFilter;
class NodeIterator;
class Page;
class PlatformMouseEvent;
class ProcessingInstruction;
class QualifiedName;
class Range;
class RegisteredEventListener;
class RenderView;
class RenderFullScreen;
class ScriptableDocumentParser;
class ScriptElementData;
class ScriptRunner;
class SecurityOrigin;
class SelectorQuery;
class SelectorQueryCache;
class SerializedScriptValue;
class SegmentedString;
class Settings;
class StyleResolver;
class StyleSheet;
class StyleSheetContents;
class StyleSheetList;
class SVGDocumentExtensions;
class Text;
class TextResourceDecoder;
class TreeWalker;
class VisitedLinkState;
class WebKitNamedFlow;
class XMLHttpRequest;
class XPathEvaluator;
class XPathExpression;
class XPathNSResolver;
class XPathResult;
#if ENABLE(XSLT)
class TransformSource;
#endif
#if ENABLE(DASHBOARD_SUPPORT)
struct AnnotatedRegionValue;
#endif
#if ENABLE(TOUCH_EVENTS)
#if PLATFORM(IOS)
#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;
#endif
typedef int ExceptionCode;
#if PLATFORM(IOS)
class DeviceMotionClient;
class DeviceMotionController;
class DeviceOrientationClient;
class DeviceOrientationController;
#endif
#if ENABLE(IOS_TEXT_AUTOSIZING)
struct TextAutoSizingHash;
class TextAutoSizingKey;
class TextAutoSizingValue;
struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
static const bool emptyValueIsZero = true;
static void constructDeletedValue(TextAutoSizingKey& slot);
static bool isDeletedValue(const TextAutoSizingKey& value);
};
#endif
enum PageshowEventPersistence {
PageshowEventNotPersisted = 0,
PageshowEventPersisted = 1
};
enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
enum NodeListInvalidationType {
DoNotInvalidateOnAttributeChanges = 0,
InvalidateOnClassAttrChange,
InvalidateOnIdNameAttrChange,
InvalidateOnNameAttrChange,
InvalidateOnForAttrChange,
InvalidateForFormControls,
InvalidateOnHRefAttrChange,
InvalidateOnAnyAttrChange,
};
const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
typedef HashCountedSet<Node*> TouchEventTargetSet;
enum DocumentClass {
DefaultDocumentClass = 0,
HTMLDocumentClass = 1,
XHTMLDocumentClass = 1 << 1,
ImageDocumentClass = 1 << 2,
PluginDocumentClass = 1 << 3,
MediaDocumentClass = 1 << 4,
SVGDocumentClass = 1 << 5,
TextDocumentClass = 1 << 6
};
typedef unsigned char DocumentClassFlags;
enum class DocumentCompatibilityMode : unsigned char {
NoQuirksMode = 1,
QuirksMode = 1 << 1,
LimitedQuirksMode = 1 << 2
};
class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
public:
static PassRefPtr<Document> create(Frame* frame, const URL& url)
{
return adoptRef(new Document(frame, url));
}
static PassRefPtr<Document> createXHTML(Frame* frame, const URL& url)
{
return adoptRef(new Document(frame, url, XHTMLDocumentClass));
}
static PassRefPtr<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
{
return adoptRef(new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
}
static PassRefPtr<Document> create(ScriptExecutionContext&);
virtual ~Document();
void incrementReferencingNodeCount()
{
ASSERT(!m_deletionHasBegun);
++m_referencingNodeCount;
}
void decrementReferencingNodeCount()
{
ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
--m_referencingNodeCount;
if (!m_referencingNodeCount && !refCount()) {
#if !ASSERT_DISABLED
m_deletionHasBegun = true;
#endif
delete this;
}
}
unsigned referencingNodeCount() const { return m_referencingNodeCount; }
void removedLastRef();
static HashSet<Document*>& allDocuments();
MediaQueryMatcher& mediaQueryMatcher();
using ContainerNode::ref;
using ContainerNode::deref;
virtual bool canContainRangeEndPoint() const override { return true; }
Element* getElementByAccessKey(const String& key);
void invalidateAccessKeyMap();
void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
SelectorQuery* selectorQueryForString(const String&, ExceptionCode&);
void clearSelectorQueryCache();
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);
#if ENABLE(WILL_REVEAL_EDGE_EVENTS)
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealbottom);
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealleft);
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealright);
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealtop);
#endif
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);
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(pointerlockchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(pointerlockerror);
#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
bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
#endif
void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
DocumentType* doctype() const;
DOMImplementation* implementation();
Element* documentElement() const
{
return m_documentElement.get();
}
static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
Element* activeElement();
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 cssRegionsEnabled() const;
bool cssCompositingEnabled() const;
#if ENABLE(CSS_REGIONS)
PassRefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
#endif
NamedFlowCollection* namedFlows();
Element* elementFromPoint(int x, int y) const;
PassRefPtr<Range> caretRangeFromPoint(int x, int y);
String readyState() const;
String defaultCharset() const;
String inputEncoding() const { return Document::encoding(); }
String charset() const { return Document::encoding(); }
String characterSet() const { return Document::encoding(); }
AtomicString encoding() const;
void setCharset(const String&);
void setContent(const String&);
String suggestedMIMEType() const;
String contentLanguage() const { return m_contentLanguage; }
void setContentLanguage(const String&);
String xmlEncoding() const { return m_xmlEncoding; }
String xmlVersion() const { return m_xmlVersion; }
enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } void setXMLVersion(const String&, ExceptionCode&);
void setXMLStandalone(bool, ExceptionCode&);
void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
String documentURI() const { return m_documentURI; }
void setDocumentURI(const String&);
virtual URL baseURI() const override;
#if ENABLE(WEB_REPLAY)
JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
void setInputCursor(PassRefPtr<JSC::InputCursor>);
#endif
void visibilityStateChanged();
String visibilityState() const;
bool hidden() const;
#if ENABLE(CSP_NEXT)
DOMSecurityPolicy* securityPolicy();
#endif
PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
PassRefPtr<HTMLCollection> images();
PassRefPtr<HTMLCollection> embeds();
PassRefPtr<HTMLCollection> plugins(); PassRefPtr<HTMLCollection> applets();
PassRefPtr<HTMLCollection> links();
PassRefPtr<HTMLCollection> forms();
PassRefPtr<HTMLCollection> anchors();
PassRefPtr<HTMLCollection> scripts();
PassRefPtr<HTMLCollection> all();
PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
bool isSynthesized() const { return m_isSynthesized; }
bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
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; }
bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
bool hasSVGRootNode() const;
virtual bool isFrameSet() const { return false; }
static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
bool isSrcdocDocument() const { return m_isSrcdocDocument; }
StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
StyleResolver& ensureStyleResolver()
{
if (!m_styleResolver)
createStyleResolver();
return *m_styleResolver;
}
void notifyRemovePendingSheetIfNeeded();
bool haveStylesheetsLoaded() const;
StyleSheetList* styleSheets();
DocumentStyleSheetCollection& styleSheetCollection() { return m_styleSheetCollection; }
bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
void styleResolverChanged(StyleResolverUpdateFlag);
void scheduleOptimizedStyleSheetUpdate();
void evaluateMediaQueryList();
FormController& formController();
Vector<String> formElementsState() const;
void setStateForNewFormElements(const Vector<String>&);
FrameView* view() const; Frame* frame() const { return m_frame; } Page* page() const; Settings* settings() const;
float deviceScaleFactor() const;
PassRefPtr<Range> createRange();
PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
PassRefPtr<Text> createEditingTextNode(const String&);
void recalcStyle(Style::Change = Style::NoChange);
void updateStyleIfNeeded();
bool updateStyleIfNeededForNode(const Node&);
void updateLayout();
enum RunPostLayoutTasks {
RunPostLayoutTasksAsynchronously,
RunPostLayoutTasksSynchronously,
};
void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasksAsynchronously);
PassRef<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
bool isPageBoxVisible(int pageIndex);
void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader.get(); }
void didBecomeCurrentDocumentInFrame();
void destroyRenderTree();
void disconnectFromFrame();
void prepareForDestruction();
virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
virtual void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
virtual void stopActiveDOMObjects() override;
RenderView* renderView() const { return m_renderView.get(); }
bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
AXObjectCache* existingAXObjectCache() const;
AXObjectCache* axObjectCache() const;
void clearAXObjectCache();
void setVisuallyOrdered();
bool visuallyOrdered() const { return m_visuallyOrdered; }
DocumentLoader* loader() const;
void open(Document* ownerDocument = 0);
void implicitOpen();
void close();
void explicitClose();
void implicitClose();
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);
bool wellFormed() const { return m_wellFormed; }
virtual const URL& url() const override final { return m_url; }
void setURL(const URL&);
const URL& baseURL() const { return m_baseURL; }
void setBaseURLOverride(const URL&);
const URL& baseURLOverride() const { return m_baseURLOverride; }
const URL& baseElementURL() const { return m_baseElementURL; }
const String& baseTarget() const { return m_baseTarget; }
void processBaseElement();
virtual URL completeURL(const String&) const override final;
URL completeURL(const String&, const URL& baseURLOverride) const;
virtual String userAgent(const URL&) const override;
virtual void disableEval(const String& errorMessage) override;
bool canNavigate(Frame* targetFrame);
Frame* findUnsafeParentScrollPropagationBoundary();
CSSStyleSheet& elementSheet();
virtual PassRefPtr<DocumentParser> createParser();
DocumentParser* parser() const { return m_parser.get(); }
ScriptableDocumentParser* scriptableDocumentParser() const;
bool printing() const { return m_printing; }
void setPrinting(bool p) { m_printing = p; }
bool paginatedForScreen() const { return m_paginatedForScreen; }
void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
bool paginated() const { return printing() || paginatedForScreen(); }
void setCompatibilityMode(DocumentCompatibilityMode);
void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
static ptrdiff_t compatibilityModeMemoryOffset() { return OBJECT_OFFSETOF(Document, m_compatibilityMode); }
String compatMode() const;
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,
Interactive,
Complete
};
void setReadyState(ReadyState);
void setParsing(bool);
bool parsing() const { return m_bParsing; }
std::chrono::milliseconds minimumLayoutDelay();
bool shouldScheduleLayout();
bool isLayoutTimerActive();
std::chrono::milliseconds elapsedTime() const;
void setTextColor(const Color& color) { m_textColor = color; }
Color textColor() const { return m_textColor; }
const Color& linkColor() const { return m_linkColor; }
const Color& visitedLinkColor() const { return m_visitedLinkColor; }
const Color& activeLinkColor() const { return m_activeLinkColor; }
void setLinkColor(const Color& c) { m_linkColor = c; }
void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
void resetLinkColor();
void resetVisitedLinkColor();
void resetActiveLinkColor();
VisitedLinkState& visitedLinkState() const { return *m_visitedLinkState; }
MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
String preferredStylesheetSet() const;
String selectedStylesheetSet() const;
void setSelectedStylesheetSet(const String&);
bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
Element* focusedElement() const { return m_focusedElement.get(); }
UserActionElementSet& userActionElements() { return m_userActionElements; }
const UserActionElementSet& userActionElements() const { return m_userActionElements; }
bool ignoreAutofocus() const { return m_ignoreAutofocus; };
void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
void hoveredElementDidDetach(Element*);
void elementInActiveChainDidDetach(Element*);
void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
void setCSSTarget(Element*);
Element* cssTarget() const { return m_cssTarget; }
static ptrdiff_t cssTargetMemoryOffset() { return OBJECT_OFFSETOF(Document, m_cssTarget); }
void scheduleForcedStyleRecalc();
void scheduleStyleRecalc();
void unscheduleStyleRecalc();
bool hasPendingStyleRecalc() const;
bool hasPendingForcedStyleRecalc() const;
void styleRecalcTimerFired(Timer<Document>&);
void optimizedStyleSheetUpdateTimerFired(Timer<Document>&);
void registerNodeListForInvalidation(LiveNodeList&);
void unregisterNodeListForInvalidation(LiveNodeList&);
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 attachRange(Range*);
void detachRange(Range*);
void updateRangesAfterChildrenChanged(ContainerNode&);
void nodeChildrenWillBeRemoved(ContainerNode&);
void nodeWillBeRemoved(Node*);
bool canReplaceChild(Node* newChild, Node* oldChild);
void textInserted(Node*, unsigned offset, unsigned length);
void textRemoved(Node*, unsigned offset, unsigned length);
void textNodesMerged(Text* oldNode, unsigned offset);
void textNodeSplit(Text* oldNode);
void createDOMWindow();
void takeDOMWindowFrom(Document*);
DOMWindow* domWindow() const { return m_domWindow.get(); }
DOMWindow* defaultView() const { return domWindow(); }
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 dispatchWindowLoadEvent();
PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
enum ListenerType {
DOMSUBTREEMODIFIED_LISTENER = 1,
DOMNODEINSERTED_LISTENER = 1 << 1,
DOMNODEREMOVED_LISTENER = 1 << 2,
DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
OVERFLOWCHANGED_LISTENER = 1 << 6,
ANIMATIONEND_LISTENER = 1 << 7,
ANIMATIONSTART_LISTENER = 1 << 8,
ANIMATIONITERATION_LISTENER = 1 << 9,
TRANSITIONEND_LISTENER = 1 << 10,
BEFORELOAD_LISTENER = 1 << 11,
SCROLL_LISTENER = 1 << 12
};
bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
void addListenerTypeIfNeeded(const AtomicString& eventType);
bool hasMutationObserversOfType(MutationObserver::MutationType type) const
{
return m_mutationObserverTypes & type;
}
bool hasMutationObservers() const { return m_mutationObserverTypes; }
void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
void processHttpEquiv(const String& equiv, const String& content);
#if PLATFORM(IOS)
void processFormatDetection(const String&);
void processWebAppOrientations();
#endif
void processViewport(const String& features, ViewportArguments::Type origin);
void updateViewportArguments();
void processReferrerPolicy(const String& policy);
HTMLFrameOwnerElement* ownerElement() const;
String title() const { return m_title.string(); }
void setTitle(const String&);
void setTitleElement(const StringWithDirection&, Element* titleElement);
void removeTitle(Element* titleElement);
String cookie(ExceptionCode&) const;
void setCookie(const String&, ExceptionCode&);
String referrer() const;
String origin() const;
String domain() const;
void setDomain(const String& newDomain, ExceptionCode&);
String lastModified() const;
const URL& cookieURL() const { return m_cookieURL; }
void setCookieURL(const URL& url) { m_cookieURL = url; }
const URL& firstPartyForCookies() const { return m_firstPartyForCookies; }
void setFirstPartyForCookies(const URL& url) { m_firstPartyForCookies = url; }
static bool isValidName(const String&);
static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
static bool hasValidNamespaceForElements(const QualifiedName&);
static bool hasValidNamespaceForAttributes(const QualifiedName&);
HTMLElement* body() const;
void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
HTMLHeadElement* head();
DocumentMarkerController& markers() const { return *m_markers; }
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; }
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);
enum InheritedBool { off = false, on = true, inherit };
void setDesignMode(InheritedBool value);
InheritedBool getDesignMode() const;
bool inDesignMode() const;
Document* parentDocument() const;
Document& topDocument() const;
ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : 0; }
void pushCurrentScript(PassRefPtr<HTMLScriptElement>);
void popCurrentScript();
#if ENABLE(XSLT)
void applyXSLTransform(ProcessingInstruction* pi);
PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
void setTransformSource(std::unique_ptr<TransformSource>);
TransformSource* transformSource() const { return m_transformSource.get(); }
#endif
void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
uint64_t domTreeVersion() const { return m_domTreeVersion; }
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);
enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
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 cancelFocusAppearanceUpdate();
CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
void parseDNSPrefetchControlHeader(const String&);
virtual void postTask(Task) override;
void suspendScriptedAnimationControllerCallbacks();
void resumeScriptedAnimationControllerCallbacks();
virtual void scriptedAnimationControllerSetThrottled(bool);
void windowScreenDidChange(PlatformDisplayID);
void finishedParsing();
bool inPageCache() const { return m_inPageCache; }
void setInPageCache(bool flag);
void registerForPageCacheSuspensionCallbacks(Element*);
void unregisterForPageCacheSuspensionCallbacks(Element*);
void documentWillBecomeInactive();
void documentWillSuspendForPageCache();
void documentDidResumeFromPageCache();
void registerForMediaVolumeCallbacks(Element*);
void unregisterForMediaVolumeCallbacks(Element*);
void mediaVolumeDidChange();
void registerForPrivateBrowsingStateChangedCallbacks(Element*);
void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
void storageBlockingStateDidChange();
void privateBrowsingStateDidChange();
#if ENABLE(VIDEO_TRACK)
void registerForCaptionPreferencesChangedCallbacks(Element*);
void unregisterForCaptionPreferencesChangedCallbacks(Element*);
void captionPreferencesChanged();
#endif
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
void pageScaleFactorChangedAndStable();
#endif
void registerForVisibilityStateChangedCallbacks(Element*);
void unregisterForVisibilityStateChangedCallbacks(Element*);
void setShouldCreateRenderers(bool);
bool shouldCreateRenderers();
void setDecoder(PassRefPtr<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);
}
void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
#if ENABLE(DASHBOARD_SUPPORT)
void setAnnotatedRegionsDirty(bool f) { m_annotatedRegionsDirty = f; }
bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
const Vector<AnnotatedRegionValue>& annotatedRegions() const;
void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
#endif
virtual void removeAllEventListeners() override;
const SVGDocumentExtensions* svgExtensions();
SVGDocumentExtensions* accessSVGExtensions();
void initSecurityContext();
void initContentSecurityPolicy();
void updateURLForPushOrReplaceState(const URL&);
void statePopped(PassRefPtr<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 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 enqueueHashchangeEvent(const String& oldURL, const String& newURL);
void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
virtual DocumentEventQueue& eventQueue() const override { return m_eventQueue; }
void addMediaCanStartListener(MediaCanStartListener*);
void removeMediaCanStartListener(MediaCanStartListener*);
MediaCanStartListener* takeAnyMediaCanStartListener();
#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(); }
enum FullScreenCheckType {
EnforceIFrameAllowFullScreenRequirement,
ExemptIFrameAllowFullScreenRequirement,
};
void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
void webkitCancelFullScreen();
void webkitWillEnterFullScreenForElement(Element*);
void webkitDidEnterFullScreenForElement(Element*);
void webkitWillExitFullScreenForElement(Element*);
void webkitDidExitFullScreenForElement(Element*);
void setFullScreenRenderer(RenderFullScreen*);
RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
void fullScreenRendererDestroyed();
void fullScreenChangeDelayTimerFired(Timer<Document>&);
bool fullScreenIsAllowedForElement(Element*) const;
void fullScreenElementRemoved();
void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
bool isAnimatingFullScreen() const;
void setAnimatingFullScreen(bool);
bool webkitFullscreenEnabled() const;
Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : 0; }
void webkitExitFullscreen();
#endif
#if ENABLE(POINTER_LOCK)
void exitPointerLock();
Element* pointerLockElement() const;
#endif
void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
void decrementLoadEventDelayCount();
bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
#if ENABLE(TOUCH_EVENTS)
#if PLATFORM(IOS)
#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)
#endif
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
DeviceMotionController* deviceMotionController() const;
DeviceOrientationController* deviceOrientationController() const;
#endif
#if ENABLE(WEB_TIMING)
const DocumentTiming* timing() const { return &m_documentTiming; }
#endif
#if ENABLE(REQUEST_ANIMATION_FRAME)
int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
void cancelAnimationFrame(int id);
void serviceScriptedAnimations(double monotonicAnimationStartTime);
#endif
void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
virtual EventTarget* errorEventTarget() override;
virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<Inspector::ScriptCallStack>) override;
void initDNSPrefetch();
unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
void didAddWheelEventHandler();
void didRemoveWheelEventHandler();
double lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
void resetLastHandledUserGestureTimestamp();
#if ENABLE(TOUCH_EVENTS)
bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
#else
bool hasTouchEventHandlers() const { return false; }
#endif
void didAddTouchEventHandler(Node*);
void didRemoveTouchEventHandler(Node*);
#if ENABLE(TOUCH_EVENTS)
void didRemoveEventTargetNode(Node*);
#endif
#if ENABLE(TOUCH_EVENTS)
const TouchEventTargetSet* touchEventTargets() const { return m_touchEventTargets.get(); }
#else
const TouchEventTargetSet* touchEventTargets() const { return 0; }
#endif
bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
void resumeScheduledTasks(ActiveDOMObject::ReasonForSuspension);
#if ENABLE(CSS_DEVICE_ADAPTATION)
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&);
bool hasActiveParser();
void incrementActiveParserCount() { ++m_activeParserCount; }
void decrementActiveParserCount();
DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
void didRemoveAllPendingStylesheet();
void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
void clearStyleResolver();
bool inStyleRecalc() { return m_inStyleRecalc; }
Locale& getCachedLocale(const AtomicString& locale = nullAtom);
#if ENABLE(TEMPLATE_ELEMENT)
const Document* templateDocument() const;
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;
virtual SecurityOrigin* topOrigin() const override;
#if ENABLE(FONT_LOAD_EVENTS)
PassRefPtr<FontLoader> fontloader();
#endif
void ensurePlugInsInjectedScript(DOMWrapperWorld&);
void setVisualUpdatesAllowedByClient(bool);
#if ENABLE(SUBTLE_CRYPTO)
virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override;
virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override;
#endif
void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
void updateViewportUnitsOnResize();
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;
private:
friend class Node;
friend class IgnoreDestructiveWriteCountIncrementer;
void commonTeardown();
RenderObject* renderer() const = delete;
void setRenderer(RenderObject*) = delete;
void createRenderTree();
void detachParser();
typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
void processArguments(const String& features, void* data, ArgumentsCallback);
virtual bool isDocument() const override { return true; }
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;
void cloneDataFromDocument(const Document&);
virtual void refScriptExecutionContext() override { ref(); }
virtual void derefScriptExecutionContext() override { deref(); }
virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<Inspector::ScriptCallStack>, JSC::ExecState* = 0, unsigned long requestIdentifier = 0) override;
virtual double minimumTimerInterval() const override;
virtual double timerAlignmentInterval() const override;
void updateTitle(const StringWithDirection&);
void updateFocusAppearanceTimerFired(Timer<Document>&);
void updateBaseURL();
void buildAccessKeyMap(TreeScope* root);
void createStyleResolver();
void loadEventDelayTimerFired(Timer<Document>&);
void pendingTasksTimerFired(Timer<Document>&);
template <typename CharacterType>
void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
PageVisibilityState pageVisibilityState() const;
PassRefPtr<HTMLCollection> ensureCachedCollection(CollectionType);
#if ENABLE(FULLSCREEN_API)
void dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>&, const AtomicString& eventName, bool shouldNotifyMediaElement);
void clearFullscreenElementStack();
void popFullscreenElementStack();
void pushFullscreenElementStack(Element*);
void addDocumentToFullScreenChangeEventQueue(Document*);
#endif
void setVisualUpdatesAllowed(ReadyState);
void setVisualUpdatesAllowed(bool);
void visualUpdatesSuppressionTimerFired(Timer<Document>&);
void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
void didAssociateFormControlsTimerFired(Timer<Document>&);
unsigned m_referencingNodeCount;
std::unique_ptr<StyleResolver> m_styleResolver;
bool m_didCalculateStyleResolver;
bool m_hasNodesWithPlaceholderStyle;
bool m_needsNotifyRemoveAllPendingStylesheet;
bool m_ignorePendingStylesheets;
PendingSheetLayout m_pendingSheetLayout;
Frame* m_frame;
RefPtr<DOMWindow> m_domWindow;
RefPtr<CachedResourceLoader> m_cachedResourceLoader;
RefPtr<DocumentParser> m_parser;
unsigned m_activeParserCount;
bool m_wellFormed;
URL m_url; URL m_baseURL; URL m_baseURLOverride; URL m_baseElementURL; URL m_cookieURL; URL m_firstPartyForCookies;
String m_documentURI;
String m_baseTarget;
std::unique_ptr<DOMImplementation> m_implementation;
RefPtr<CSSStyleSheet> m_elementSheet;
bool m_printing;
bool m_paginatedForScreen;
bool m_ignoreAutofocus;
DocumentCompatibilityMode m_compatibilityMode;
bool m_compatibilityModeLocked;
Color m_textColor;
RefPtr<Element> m_focusedElement;
RefPtr<Element> m_hoveredElement;
RefPtr<Element> m_activeElement;
RefPtr<Element> m_documentElement;
UserActionElementSet m_userActionElements;
uint64_t m_domTreeVersion;
static uint64_t s_globalTreeVersion;
HashSet<NodeIterator*> m_nodeIterators;
HashSet<Range*> m_ranges;
unsigned short m_listenerTypes;
MutationObserverOptions m_mutationObserverTypes;
DocumentStyleSheetCollection m_styleSheetCollection;
RefPtr<StyleSheetList> m_styleSheetList;
std::unique_ptr<FormController> m_formController;
Color m_linkColor;
Color m_visitedLinkColor;
Color m_activeLinkColor;
const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
bool m_visuallyOrdered;
ReadyState m_readyState;
bool m_bParsing;
Timer<Document> m_optimizedStyleSheetUpdateTimer;
Timer<Document> m_styleRecalcTimer;
bool m_pendingStyleRecalcShouldForce;
bool m_inStyleRecalc;
bool m_closeAfterStyleRecalc;
bool m_gotoAnchorNeededAfterStylesheetsLoad;
bool m_isDNSPrefetchEnabled;
bool m_haveExplicitlyDisabledDNSPrefetch;
bool m_frameElementsShouldIgnoreScrolling;
bool m_containsValidityStyleRules;
bool m_updateFocusAppearanceRestoresSelection;
unsigned m_ignoreDestructiveWriteCount;
StringWithDirection m_title;
StringWithDirection m_rawTitle;
bool m_titleSetExplicitly;
RefPtr<Element> m_titleElement;
std::unique_ptr<AXObjectCache> m_axObjectCache;
const std::unique_ptr<DocumentMarkerController> m_markers;
Timer<Document> m_updateFocusAppearanceTimer;
Element* m_cssTarget;
bool m_processingLoadEvent;
bool m_loadEventFinished;
RefPtr<SerializedScriptValue> m_pendingStateObject;
std::chrono::steady_clock::time_point m_startTime;
bool m_overMinimumLayoutThreshold;
std::unique_ptr<ScriptRunner> m_scriptRunner;
Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
#if ENABLE(XSLT)
std::unique_ptr<TransformSource> m_transformSource;
RefPtr<Document> m_transformSourceDocument;
#endif
String m_xmlEncoding;
String m_xmlVersion;
unsigned m_xmlStandalone : 2;
unsigned m_hasXMLDeclaration : 1;
String m_contentLanguage;
RefPtr<TextResourceDecoder> m_decoder;
InheritedBool m_designMode;
HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
#if !ASSERT_DISABLED
bool m_inInvalidateNodeListAndCollectionCaches;
#endif
unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
RefPtr<XPathEvaluator> m_xpathEvaluator;
std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
#if ENABLE(DASHBOARD_SUPPORT)
Vector<AnnotatedRegionValue> m_annotatedRegions;
bool m_hasAnnotatedRegions;
bool m_annotatedRegionsDirty;
#endif
HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
bool m_createRenderers;
bool m_inPageCache;
Vector<IconURL> m_iconURLs;
HashSet<Element*> m_documentSuspensionCallbackElements;
HashSet<Element*> m_mediaVolumeCallbackElements;
HashSet<Element*> m_privateBrowsingStateChangedElements;
#if ENABLE(VIDEO_TRACK)
HashSet<Element*> m_captionPreferencesChangedElements;
#endif
#if ENABLE(MEDIA_CONTROLS_SCRIPT)
HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
#endif
HashSet<Element*> m_visibilityStateCallbackElements;
HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
bool m_accessKeyMapValid;
DocumentOrderedMap m_imagesByUsemap;
std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
DocumentClassFlags m_documentClasses;
bool m_isSynthesized;
bool m_isNonRenderedPlaceholder;
bool m_sawElementsInKnownNamespaces;
bool m_isSrcdocDocument;
RenderPtr<RenderView> m_renderView;
mutable DocumentEventQueue m_eventQueue;
WeakPtrFactory<Document> m_weakFactory;
HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
#if ENABLE(FULLSCREEN_API)
bool m_areKeysEnabledInFullScreen;
RefPtr<Element> m_fullScreenElement;
Vector<RefPtr<Element>> m_fullScreenElementStack;
RenderFullScreen* m_fullScreenRenderer;
Timer<Document> m_fullScreenChangeDelayTimer;
Deque<RefPtr<Node>> m_fullScreenChangeEventTargetQueue;
Deque<RefPtr<Node>> m_fullScreenErrorEventTargetQueue;
bool m_isAnimatingFullScreen;
LayoutRect m_savedPlaceholderFrameRect;
RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
#endif
int m_loadEventDelayCount;
Timer<Document> m_loadEventDelayTimer;
ViewportArguments m_viewportArguments;
ReferrerPolicy m_referrerPolicy;
bool m_directionSetOnDocumentElement;
bool m_writingModeSetOnDocumentElement;
#if ENABLE(WEB_TIMING)
DocumentTiming m_documentTiming;
#endif
RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
bool m_writeRecursionIsTooDeep;
unsigned m_writeRecursionDepth;
unsigned m_wheelEventHandlerCount;
#if ENABLE(TOUCH_EVENTS)
std::unique_ptr<TouchEventTargetSet> m_touchEventTargets;
#endif
double m_lastHandledUserGestureTimestamp;
#if ENABLE(REQUEST_ANIMATION_FRAME)
void clearScriptedAnimationController();
RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
#endif
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
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
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
public:
bool isTelephoneNumberParsingAllowed() const;
bool isTelephoneNumberParsingEnabled() const;
private:
friend void setParserFeature(const String& key, const String& value, Document*, void* userData);
void setIsTelephoneNumberParsingAllowed(bool);
bool m_isTelephoneNumberParsingAllowed;
#endif
Timer<Document> m_pendingTasksTimer;
Vector<Task> m_pendingTasks;
#if ENABLE(IOS_TEXT_AUTOSIZING)
public:
void addAutoSizingNode(Node*, float size);
void validateAutoSizingNodes();
void resetAutoSizingNodes();
private:
typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
TextAutoSizingMap m_textAutoSizedNodes;
#endif
#if ENABLE(TEXT_AUTOSIZING)
std::unique_ptr<TextAutosizer> m_textAutosizer;
#endif
void platformSuspendOrStopActiveDOMObjects();
bool m_scheduledTasksAreSuspended;
bool m_visualUpdatesAllowed;
Timer<Document> m_visualUpdatesSuppressionTimer;
RefPtr<NamedFlowCollection> m_namedFlows;
#if ENABLE(CSP_NEXT)
RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
#endif
void sharedObjectPoolClearTimerFired(Timer<Document>&);
Timer<Document> m_sharedObjectPoolClearTimer;
std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
#ifndef NDEBUG
bool m_didDispatchViewportPropertiesChanged;
#endif
typedef HashMap<AtomicString, OwnPtr<Locale>> LocaleIdentifierToLocaleMap;
LocaleIdentifierToLocaleMap m_localeCache;
#if ENABLE(TEMPLATE_ELEMENT)
RefPtr<Document> m_templateDocument;
Document* m_templateDocumentHost; #endif
#if ENABLE(FONT_LOAD_EVENTS)
RefPtr<FontLoader> m_fontloader;
#endif
#if ENABLE(WEB_REPLAY)
RefPtr<JSC::InputCursor> m_inputCursor;
#endif
Timer<Document> m_didAssociateFormControlsTimer;
HashSet<RefPtr<Element>> m_associatedFormControls;
unsigned m_disabledFieldsetElementsCount;
bool m_hasInjectedPlugInsScript;
bool m_renderTreeBeingDestroyed;
bool m_hasPreparedForDestruction;
bool m_hasStyleWithViewportUnits;
};
inline void Document::notifyRemovePendingSheetIfNeeded()
{
if (m_needsNotifyRemoveAllPendingStylesheet)
didRemoveAllPendingStylesheet();
}
#if ENABLE(TEMPLATE_ELEMENT)
inline const Document* Document::templateDocument() const
{
if (!m_frame)
return this;
return m_templateDocument.get();
}
#endif
inline bool Node::isDocumentNode() const
{
return this == &document();
}
inline Node::Node(Document& document, ConstructionType type)
: m_nodeFlags(type)
, m_parentNode(0)
, m_treeScope(&document)
, m_previous(0)
, m_next(0)
{
document.incrementReferencingNodeCount();
#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
trackForDebugging();
#endif
}
inline ScriptExecutionContext* Node::scriptExecutionContext() const
{
return &document();
}
Element* eventTargetElementForDocument(Document*);
SCRIPT_EXECUTION_CONTEXT_TYPE_CASTS(Document)
inline bool isDocument(const Node& node) { return node.isDocumentNode(); }
void isDocument(const Document&);
NODE_TYPE_CASTS(Document)
#define DOCUMENT_TYPE_CASTS(ToClassName) \
TYPE_CASTS_BASE(ToClassName, Document, document, WebCore::is##ToClassName(*document), WebCore::is##ToClassName(document))
}
namespace WTF {
inline WebCore::Document* getPtr(WebCore::Document& p) { return &p; }
}
#endif // Document_h