2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2011 Google Inc. All rights reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
31 #include "CollectionType.h"
33 #include "ContainerNode.h"
34 #include "DocumentEventQueue.h"
35 #include "DocumentStyleSheetCollection.h"
36 #include "DocumentTiming.h"
37 #include "FocusDirection.h"
39 #include "MutationObserver.h"
40 #include "PageVisibilityState.h"
41 #include "PlatformScreen.h"
42 #include "ReferrerPolicy.h"
43 #include "RenderPtr.h"
44 #include "ScriptExecutionContext.h"
45 #include "StringWithDirection.h"
46 #include "StyleResolveTree.h"
48 #include "TreeScope.h"
49 #include "UserActionElementSet.h"
50 #include "ViewportArguments.h"
53 #include <wtf/Deque.h>
54 #include <wtf/HashSet.h>
55 #include <wtf/OwnPtr.h>
56 #include <wtf/PassOwnPtr.h>
57 #include <wtf/PassRefPtr.h>
58 #include <wtf/WeakPtr.h>
62 #if ENABLE(WEB_REPLAY)
72 class CSSStyleDeclaration;
74 class CachedCSSStyleSheet;
75 class CachedResourceLoader;
77 class CanvasRenderingContext;
80 class DOMImplementation;
81 class DOMNamedFlowCollection;
84 class DOMWrapperWorld;
87 class DocumentFragment;
89 class DocumentMarkerController;
91 class DocumentSharedObjectPool;
94 class EntityReference;
102 class HTMLCanvasElement;
103 class HTMLCollection;
104 class HTMLAllCollection;
107 class HTMLFrameOwnerElement;
108 class HTMLHeadElement;
109 class HTMLIFrameElement;
110 class HTMLImageElement;
111 class HTMLMapElement;
112 class HTMLMediaElement;
113 class HTMLNameCollection;
114 class HTMLScriptElement;
115 class HitTestRequest;
123 class MediaCanStartListener;
124 class MediaQueryList;
125 class MediaQueryMatcher;
126 class MouseEventWithHitTestResults;
127 class NamedFlowCollection;
131 class PlatformMouseEvent;
132 class ProcessingInstruction;
135 class RegisteredEventListener;
137 class RenderFullScreen;
138 class ScriptableDocumentParser;
139 class ScriptElementData;
141 class SecurityOrigin;
143 class SelectorQueryCache;
144 class SerializedScriptValue;
145 class SegmentedString;
149 class StyleSheetContents;
150 class StyleSheetList;
151 class SVGDocumentExtensions;
153 class TextResourceDecoder;
155 class VisitedLinkState;
156 class WebKitNamedFlow;
157 class XMLHttpRequest;
158 class XPathEvaluator;
159 class XPathExpression;
160 class XPathNSResolver;
164 class TransformSource;
167 #if ENABLE(DASHBOARD_SUPPORT)
168 struct AnnotatedRegionValue;
171 #if ENABLE(IOS_TOUCH_EVENTS)
172 #include <WebKitAdditions/DocumentIOSForward.h>
175 #if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
180 #if ENABLE(REQUEST_ANIMATION_FRAME)
181 class RequestAnimationFrameCallback;
182 class ScriptedAnimationController;
185 #if ENABLE(TEXT_AUTOSIZING)
190 class DOMSecurityPolicy;
193 #if ENABLE(FONT_LOAD_EVENTS)
197 typedef int ExceptionCode;
200 class DeviceMotionClient;
201 class DeviceMotionController;
202 class DeviceOrientationClient;
203 class DeviceOrientationController;
206 #if ENABLE(IOS_TEXT_AUTOSIZING)
207 struct TextAutoSizingHash;
208 class TextAutoSizingKey;
209 class TextAutoSizingValue;
211 struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
212 static const bool emptyValueIsZero = true;
213 static void constructDeletedValue(TextAutoSizingKey& slot);
214 static bool isDeletedValue(const TextAutoSizingKey& value);
218 enum PageshowEventPersistence {
219 PageshowEventNotPersisted = 0,
220 PageshowEventPersisted = 1
223 enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
225 enum NodeListInvalidationType {
226 DoNotInvalidateOnAttributeChanges = 0,
227 InvalidateOnClassAttrChange,
228 InvalidateOnIdNameAttrChange,
229 InvalidateOnNameAttrChange,
230 InvalidateOnForAttrChange,
231 InvalidateForFormControls,
232 InvalidateOnHRefAttrChange,
233 InvalidateOnAnyAttrChange,
235 const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
237 typedef HashCountedSet<Node*> TouchEventTargetSet;
240 DefaultDocumentClass = 0,
241 HTMLDocumentClass = 1,
242 XHTMLDocumentClass = 1 << 1,
243 ImageDocumentClass = 1 << 2,
244 PluginDocumentClass = 1 << 3,
245 MediaDocumentClass = 1 << 4,
246 SVGDocumentClass = 1 << 5,
247 TextDocumentClass = 1 << 6
250 typedef unsigned char DocumentClassFlags;
252 enum class DocumentCompatibilityMode : unsigned char {
255 LimitedQuirksMode = 1 << 2
258 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
260 static PassRefPtr<Document> create(Frame* frame, const URL& url)
262 return adoptRef(new Document(frame, url));
264 static PassRefPtr<Document> createXHTML(Frame* frame, const URL& url)
266 return adoptRef(new Document(frame, url, XHTMLDocumentClass));
268 static PassRefPtr<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url)
270 return adoptRef(new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
272 static PassRefPtr<Document> create(ScriptExecutionContext&);
276 // Nodes belonging to this document increase referencingNodeCount -
277 // these are enough to keep the document from being destroyed, but
278 // not enough to keep it from removing its children. This allows a
279 // node that outlives its document to still have a valid document
280 // pointer without introducing reference cycles.
281 void incrementReferencingNodeCount()
283 ASSERT(!m_deletionHasBegun);
284 ++m_referencingNodeCount;
287 void decrementReferencingNodeCount()
289 ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
290 --m_referencingNodeCount;
291 if (!m_referencingNodeCount && !refCount()) {
293 m_deletionHasBegun = true;
299 unsigned referencingNodeCount() const { return m_referencingNodeCount; }
301 void removedLastRef();
303 WEBCORE_EXPORT static HashSet<Document*>& allDocuments();
305 MediaQueryMatcher& mediaQueryMatcher();
307 using ContainerNode::ref;
308 using ContainerNode::deref;
310 virtual bool canContainRangeEndPoint() const override { return true; }
312 Element* getElementByAccessKey(const String& key);
313 void invalidateAccessKeyMap();
315 void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
316 void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
317 HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
319 SelectorQuery* selectorQueryForString(const String&, ExceptionCode&);
320 void clearSelectorQueryCache();
322 // DOM methods & attributes for Document
324 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
325 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
326 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
327 DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu);
328 DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick);
329 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter);
330 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover);
331 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave);
332 DEFINE_ATTRIBUTE_EVENT_LISTENER(drop);
333 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart);
334 DEFINE_ATTRIBUTE_EVENT_LISTENER(drag);
335 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend);
336 DEFINE_ATTRIBUTE_EVENT_LISTENER(input);
337 DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid);
338 DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown);
339 DEFINE_ATTRIBUTE_EVENT_LISTENER(keypress);
340 DEFINE_ATTRIBUTE_EVENT_LISTENER(keyup);
341 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousedown);
342 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseenter);
343 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseleave);
344 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousemove);
345 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseout);
346 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseover);
347 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseup);
348 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousewheel);
349 DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
350 DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
351 DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
352 #if ENABLE(WILL_REVEAL_EDGE_EVENTS)
353 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealbottom);
354 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealleft);
355 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealright);
356 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitwillrevealtop);
358 DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
360 DEFINE_ATTRIBUTE_EVENT_LISTENER(blur);
361 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
362 DEFINE_ATTRIBUTE_EVENT_LISTENER(focus);
363 DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
364 DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
367 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
368 DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
369 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
370 DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
371 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
372 DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
373 DEFINE_ATTRIBUTE_EVENT_LISTENER(reset);
374 DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
375 DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
376 DEFINE_ATTRIBUTE_EVENT_LISTENER(selectionchange);
377 #if ENABLE(TOUCH_EVENTS)
378 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
379 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
380 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
381 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
383 #if ENABLE(IOS_GESTURE_EVENTS)
384 DEFINE_ATTRIBUTE_EVENT_LISTENER(gesturestart);
385 DEFINE_ATTRIBUTE_EVENT_LISTENER(gesturechange);
386 DEFINE_ATTRIBUTE_EVENT_LISTENER(gestureend);
388 #if ENABLE(FULLSCREEN_API)
389 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
390 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
392 #if ENABLE(POINTER_LOCK)
393 DEFINE_ATTRIBUTE_EVENT_LISTENER(pointerlockchange);
394 DEFINE_ATTRIBUTE_EVENT_LISTENER(pointerlockerror);
397 DEFINE_ATTRIBUTE_EVENT_LISTENER(securitypolicyviolation);
400 void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
401 ViewportArguments viewportArguments() const { return m_viewportArguments; }
403 bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
406 void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
407 ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
409 DocumentType* doctype() const;
411 DOMImplementation& implementation();
413 Element* documentElement() const
415 return m_documentElement.get();
417 static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); }
419 Element* activeElement();
420 bool hasFocus() const;
422 bool hasManifest() const;
424 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
425 WEBCORE_EXPORT PassRefPtr<DocumentFragment> createDocumentFragment();
426 WEBCORE_EXPORT PassRefPtr<Text> createTextNode(const String& data);
427 PassRefPtr<Comment> createComment(const String& data);
428 PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
429 PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
430 PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
431 PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
432 PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
433 PassRefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, true, ec); }
434 PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
435 WEBCORE_EXPORT PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
436 WEBCORE_EXPORT PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
438 bool cssRegionsEnabled() const;
439 bool cssCompositingEnabled() const;
440 #if ENABLE(CSS_REGIONS)
441 PassRefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
444 NamedFlowCollection& namedFlows();
446 Element* elementFromPoint(int x, int y) { return elementFromPoint(LayoutPoint(x, y)); }
447 Element* elementFromPoint(const LayoutPoint& clientPoint);
449 PassRefPtr<Range> caretRangeFromPoint(int x, int y);
450 PassRefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint);
452 String readyState() const;
454 String defaultCharset() const;
456 String inputEncoding() const { return Document::encoding(); }
457 String charset() const { return Document::encoding(); }
458 String characterSet() const { return Document::encoding(); }
460 AtomicString encoding() const;
462 void setCharset(const String&);
464 void setContent(const String&);
466 String suggestedMIMEType() const;
468 String contentLanguage() const { return m_contentLanguage; }
469 void setContentLanguage(const String&);
471 String xmlEncoding() const { return m_xmlEncoding; }
472 String xmlVersion() const { return m_xmlVersion; }
473 enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
474 bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
475 StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
476 bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
478 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
479 void setXMLVersion(const String&, ExceptionCode&);
480 void setXMLStandalone(bool, ExceptionCode&);
481 void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
483 String documentURI() const { return m_documentURI; }
484 void setDocumentURI(const String&);
486 virtual URL baseURI() const override;
488 #if ENABLE(WEB_REPLAY)
489 JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
490 void setInputCursor(PassRefPtr<JSC::InputCursor>);
493 void visibilityStateChanged();
494 String visibilityState() const;
498 DOMSecurityPolicy& securityPolicy();
501 PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
503 PassRefPtr<HTMLCollection> images();
504 PassRefPtr<HTMLCollection> embeds();
505 PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
506 PassRefPtr<HTMLCollection> applets();
507 PassRefPtr<HTMLCollection> links();
508 PassRefPtr<HTMLCollection> forms();
509 PassRefPtr<HTMLCollection> anchors();
510 PassRefPtr<HTMLCollection> scripts();
511 PassRefPtr<HTMLCollection> all();
513 PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
514 PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
516 // Other methods (not part of DOM)
517 bool isSynthesized() const { return m_isSynthesized; }
518 bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; }
519 bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
520 bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
521 bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
522 bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
523 bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
524 bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
525 bool hasSVGRootNode() const;
526 virtual bool isFrameSet() const { return false; }
528 static ptrdiff_t documentClassesMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentClasses); }
529 static uint32_t isHTMLDocumentClassFlag() { return HTMLDocumentClass; }
531 bool isSrcdocDocument() const { return m_isSrcdocDocument; }
533 StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
535 bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
537 StyleResolver& ensureStyleResolver()
539 if (!m_styleResolver)
540 createStyleResolver();
541 return *m_styleResolver;
544 void notifyRemovePendingSheetIfNeeded();
546 bool haveStylesheetsLoaded() const;
548 // This is a DOM function.
549 StyleSheetList& styleSheets();
551 DocumentStyleSheetCollection& styleSheetCollection() { return m_styleSheetCollection; }
553 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
554 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
557 * Called when one or more stylesheets in the document may have been added, removed or changed.
559 * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
560 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
561 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
562 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
563 * found and is used to calculate the derived styles for all rendering objects.
565 WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
567 void scheduleOptimizedStyleSheetUpdate();
569 void evaluateMediaQueryList();
571 FormController& formController();
572 Vector<String> formElementsState() const;
573 void setStateForNewFormElements(const Vector<String>&);
575 WEBCORE_EXPORT FrameView* view() const; // can be NULL
576 Frame* frame() const { return m_frame; } // can be NULL
577 WEBCORE_EXPORT Page* page() const; // can be NULL
578 WEBCORE_EXPORT Settings* settings() const; // can be NULL
580 float deviceScaleFactor() const;
582 WEBCORE_EXPORT PassRefPtr<Range> createRange();
584 PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
585 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
587 PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
588 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
590 // Special support for editing
591 PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
592 PassRefPtr<Text> createEditingTextNode(const String&);
594 void recalcStyle(Style::Change = Style::NoChange);
595 WEBCORE_EXPORT void updateStyleIfNeeded();
596 bool updateStyleIfNeededForNode(const Node&);
598 WEBCORE_EXPORT void updateLayout();
600 // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads,
601 // so calling this may cause a flash of unstyled content (FOUC).
602 enum class RunPostLayoutTasks {
606 WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously);
608 PassRef<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
610 // Returns true if page box (margin boxes and page borders) is visible.
611 WEBCORE_EXPORT bool isPageBoxVisible(int pageIndex);
613 // Returns the preferred page size and margins in pixels, assuming 96
614 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
615 // marginLeft must be initialized to the default values that are used if
616 // auto is specified.
617 WEBCORE_EXPORT void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
619 CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader.get(); }
621 void didBecomeCurrentDocumentInFrame();
622 void destroyRenderTree();
623 void disconnectFromFrame();
624 void prepareForDestruction();
626 // Override ScriptExecutionContext methods to do additional work
627 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
628 virtual void resumeActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) override;
629 virtual void stopActiveDOMObjects() override;
631 RenderView* renderView() const { return m_renderView.get(); }
633 bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
634 bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
636 AXObjectCache* existingAXObjectCache() const;
637 WEBCORE_EXPORT AXObjectCache* axObjectCache() const;
638 void clearAXObjectCache();
640 // to get visually ordered hebrew and arabic pages right
641 void setVisuallyOrdered();
642 bool visuallyOrdered() const { return m_visuallyOrdered; }
644 WEBCORE_EXPORT DocumentLoader* loader() const;
646 void open(Document* ownerDocument = 0);
649 // close() is the DOM API document.close()
651 // In some situations (see the code), we ignore document.close().
652 // explicitClose() bypass these checks and actually tries to close the
654 void explicitClose();
655 // implicitClose() actually does the work of closing the input stream.
656 void implicitClose();
658 void cancelParsing();
660 void write(const SegmentedString& text, Document* ownerDocument = 0);
661 void write(const String& text, Document* ownerDocument = 0);
662 void writeln(const String& text, Document* ownerDocument = 0);
664 bool wellFormed() const { return m_wellFormed; }
666 virtual const URL& url() const override final { return m_url; }
667 void setURL(const URL&);
669 // To understand how these concepts relate to one another, please see the
670 // comments surrounding their declaration.
671 const URL& baseURL() const { return m_baseURL; }
672 void setBaseURLOverride(const URL&);
673 const URL& baseURLOverride() const { return m_baseURLOverride; }
674 const URL& baseElementURL() const { return m_baseElementURL; }
675 const String& baseTarget() const { return m_baseTarget; }
676 void processBaseElement();
678 WEBCORE_EXPORT virtual URL completeURL(const String&) const override final;
679 URL completeURL(const String&, const URL& baseURLOverride) const;
681 virtual String userAgent(const URL&) const override;
683 virtual void disableEval(const String& errorMessage) override;
685 bool canNavigate(Frame* targetFrame);
686 Frame* findUnsafeParentScrollPropagationBoundary();
688 CSSStyleSheet& elementSheet();
690 virtual PassRefPtr<DocumentParser> createParser();
691 DocumentParser* parser() const { return m_parser.get(); }
692 ScriptableDocumentParser* scriptableDocumentParser() const;
694 bool printing() const { return m_printing; }
695 void setPrinting(bool p) { m_printing = p; }
697 bool paginatedForScreen() const { return m_paginatedForScreen; }
698 void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
700 bool paginated() const { return printing() || paginatedForScreen(); }
702 void setCompatibilityMode(DocumentCompatibilityMode);
703 void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
704 static ptrdiff_t compatibilityModeMemoryOffset() { return OBJECT_OFFSETOF(Document, m_compatibilityMode); }
706 String compatMode() const;
708 bool inQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::QuirksMode; }
709 bool inLimitedQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::LimitedQuirksMode; }
710 bool inNoQuirksMode() const { return m_compatibilityMode == DocumentCompatibilityMode::NoQuirksMode; }
717 void setReadyState(ReadyState);
718 void setParsing(bool);
719 bool parsing() const { return m_bParsing; }
720 std::chrono::milliseconds minimumLayoutDelay();
722 bool shouldScheduleLayout();
723 bool isLayoutTimerActive();
724 std::chrono::milliseconds elapsedTime() const;
726 void setTextColor(const Color& color) { m_textColor = color; }
727 Color textColor() const { return m_textColor; }
729 const Color& linkColor() const { return m_linkColor; }
730 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
731 const Color& activeLinkColor() const { return m_activeLinkColor; }
732 void setLinkColor(const Color& c) { m_linkColor = c; }
733 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
734 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
735 void resetLinkColor();
736 void resetVisitedLinkColor();
737 void resetActiveLinkColor();
738 VisitedLinkState& visitedLinkState() const { return *m_visitedLinkState; }
740 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
742 /* Newly proposed CSS3 mechanism for selecting alternate
743 stylesheets using the DOM. May be subject to change as
746 String preferredStylesheetSet() const;
747 String selectedStylesheetSet() const;
748 void setSelectedStylesheetSet(const String&);
750 WEBCORE_EXPORT bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
751 Element* focusedElement() const { return m_focusedElement.get(); }
752 UserActionElementSet& userActionElements() { return m_userActionElements; }
753 const UserActionElementSet& userActionElements() const { return m_userActionElements; }
755 // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough
756 // for WebCore to ignore the autofocus attribute on any form controls
757 bool ignoreAutofocus() const { return m_ignoreAutofocus; };
758 void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
760 void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
761 void hoveredElementDidDetach(Element*);
762 void elementInActiveChainDidDetach(Element*);
764 void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
766 // Updates for :target (CSS3 selector).
767 void setCSSTarget(Element*);
768 Element* cssTarget() const { return m_cssTarget; }
769 static ptrdiff_t cssTargetMemoryOffset() { return OBJECT_OFFSETOF(Document, m_cssTarget); }
771 WEBCORE_EXPORT void scheduleForcedStyleRecalc();
772 void scheduleStyleRecalc();
773 void unscheduleStyleRecalc();
774 bool hasPendingStyleRecalc() const;
775 bool hasPendingForcedStyleRecalc() const;
776 void styleRecalcTimerFired(Timer<Document>&);
777 void optimizedStyleSheetUpdateTimerFired(Timer<Document>&);
779 void registerNodeListForInvalidation(LiveNodeList&);
780 void unregisterNodeListForInvalidation(LiveNodeList&);
781 void registerCollection(HTMLCollection&);
782 void unregisterCollection(HTMLCollection&);
783 void collectionCachedIdNameMap(const HTMLCollection&);
784 void collectionWillClearIdNameMap(const HTMLCollection&);
785 bool shouldInvalidateNodeListAndCollectionCaches(const QualifiedName* attrName = nullptr) const;
786 void invalidateNodeListAndCollectionCaches(const QualifiedName* attrName);
788 void attachNodeIterator(NodeIterator*);
789 void detachNodeIterator(NodeIterator*);
790 void moveNodeIteratorsToNewDocument(Node*, Document*);
792 void attachRange(Range*);
793 void detachRange(Range*);
795 void updateRangesAfterChildrenChanged(ContainerNode&);
796 // nodeChildrenWillBeRemoved is used when removing all node children at once.
797 void nodeChildrenWillBeRemoved(ContainerNode&);
798 // nodeWillBeRemoved is only safe when removing one node at a time.
799 void nodeWillBeRemoved(Node*);
800 bool canReplaceChild(Node* newChild, Node* oldChild);
802 void textInserted(Node*, unsigned offset, unsigned length);
803 void textRemoved(Node*, unsigned offset, unsigned length);
804 void textNodesMerged(Text* oldNode, unsigned offset);
805 void textNodeSplit(Text* oldNode);
807 void createDOMWindow();
808 void takeDOMWindowFrom(Document*);
810 DOMWindow* domWindow() const { return m_domWindow.get(); }
811 // In DOM Level 2, the Document's DOMWindow is called the defaultView.
812 DOMWindow* defaultView() const { return domWindow(); }
814 // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
815 void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
816 void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
817 EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
818 WEBCORE_EXPORT void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0);
819 void dispatchWindowLoadEvent();
821 PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
823 // keep track of what types of event listeners are registered, so we don't
824 // dispatch events unnecessarily
826 DOMSUBTREEMODIFIED_LISTENER = 1,
827 DOMNODEINSERTED_LISTENER = 1 << 1,
828 DOMNODEREMOVED_LISTENER = 1 << 2,
829 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
830 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
831 DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
832 OVERFLOWCHANGED_LISTENER = 1 << 6,
833 ANIMATIONEND_LISTENER = 1 << 7,
834 ANIMATIONSTART_LISTENER = 1 << 8,
835 ANIMATIONITERATION_LISTENER = 1 << 9,
836 TRANSITIONEND_LISTENER = 1 << 10,
837 BEFORELOAD_LISTENER = 1 << 11,
838 SCROLL_LISTENER = 1 << 12
842 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
843 void addListenerTypeIfNeeded(const AtomicString& eventType);
845 bool hasMutationObserversOfType(MutationObserver::MutationType type) const
847 return m_mutationObserverTypes & type;
849 bool hasMutationObservers() const { return m_mutationObserverTypes; }
850 void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
852 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
855 * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
856 * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
857 * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
858 * specified in a HTML file.
860 * @param equiv The http header name (value of the meta tag's "equiv" attribute)
861 * @param content The header value (value of the meta tag's "content" attribute)
863 void processHttpEquiv(const String& equiv, const String& content);
866 void processFormatDetection(const String&);
868 // Called when <meta name="apple-mobile-web-app-orientations"> changes.
869 void processWebAppOrientations();
872 void processViewport(const String& features, ViewportArguments::Type origin);
873 void updateViewportArguments();
874 void processReferrerPolicy(const String& policy);
876 // Returns the owning element in the parent document.
877 // Returns 0 if this is the top level document.
878 HTMLFrameOwnerElement* ownerElement() const;
880 // Used by DOM bindings; no direction known.
881 String title() const { return m_title.string(); }
882 void setTitle(const String&);
884 void setTitleElement(const StringWithDirection&, Element* titleElement);
885 void removeTitle(Element* titleElement);
887 String cookie(ExceptionCode&) const;
888 void setCookie(const String&, ExceptionCode&);
890 String referrer() const;
892 String origin() const;
894 WEBCORE_EXPORT String domain() const;
895 void setDomain(const String& newDomain, ExceptionCode&);
897 String lastModified() const;
899 // The cookieURL is used to query the cookie database for this document's
900 // cookies. For example, if the cookie URL is http://example.com, we'll
901 // use the non-Secure cookies for example.com when computing
904 // Q: How is the cookieURL different from the document's URL?
905 // A: The two URLs are the same almost all the time. However, if one
906 // document inherits the security context of another document, it
907 // inherits its cookieURL but not its URL.
909 const URL& cookieURL() const { return m_cookieURL; }
910 void setCookieURL(const URL& url) { m_cookieURL = url; }
912 // The firstPartyForCookies is used to compute whether this document
913 // appears in a "third-party" context for the purpose of third-party
914 // cookie blocking. The document is in a third-party context if the
915 // cookieURL and the firstPartyForCookies are from different hosts.
917 // Note: Some ports (including possibly Apple's) only consider the
918 // document in a third-party context if the cookieURL and the
919 // firstPartyForCookies have a different registry-controlled
922 const URL& firstPartyForCookies() const { return m_firstPartyForCookies; }
923 void setFirstPartyForCookies(const URL& url) { m_firstPartyForCookies = url; }
925 // The following implements the rule from HTML 4 for what valid names are.
926 // To get this right for all the XML cases, we probably have to improve this or move it
927 // and make it sensitive to the type of document.
928 static bool isValidName(const String&);
930 // The following breaks a qualified name into a prefix and a local name.
931 // It also does a validity check, and returns false if the qualified name
932 // is invalid. It also sets ExceptionCode when name is invalid.
933 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
935 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
936 static bool hasValidNamespaceForElements(const QualifiedName&);
937 static bool hasValidNamespaceForAttributes(const QualifiedName&);
939 WEBCORE_EXPORT HTMLElement* body() const;
940 void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
942 WEBCORE_EXPORT HTMLHeadElement* head();
944 DocumentMarkerController& markers() const { return *m_markers; }
946 bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
947 bool writingModeSetOnDocumentElement() const { return m_writingModeSetOnDocumentElement; }
948 void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
949 void setWritingModeSetOnDocumentElement(bool b) { m_writingModeSetOnDocumentElement = b; }
951 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
952 bool queryCommandEnabled(const String& command);
953 bool queryCommandIndeterm(const String& command);
954 bool queryCommandState(const String& command);
955 bool queryCommandSupported(const String& command);
956 String queryCommandValue(const String& command);
958 // designMode support
959 enum InheritedBool { off = false, on = true, inherit };
960 void setDesignMode(InheritedBool value);
961 InheritedBool getDesignMode() const;
962 bool inDesignMode() const;
964 Document* parentDocument() const;
965 Document& topDocument() const;
967 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
969 HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : 0; }
970 void pushCurrentScript(PassRefPtr<HTMLScriptElement>);
971 void popCurrentScript();
974 void applyXSLTransform(ProcessingInstruction* pi);
975 PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
976 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
978 void setTransformSource(std::unique_ptr<TransformSource>);
979 TransformSource* transformSource() const { return m_transformSource.get(); }
982 void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
983 uint64_t domTreeVersion() const { return m_domTreeVersion; }
985 // XPathEvaluator methods
986 PassRefPtr<XPathExpression> createExpression(const String& expression,
987 XPathNSResolver* resolver,
989 PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
990 PassRefPtr<XPathResult> evaluate(const String& expression,
992 XPathNSResolver* resolver,
997 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
999 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
1001 bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
1002 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
1004 WEBCORE_EXPORT const Vector<IconURL>& shortcutIconURLs();
1005 WEBCORE_EXPORT const Vector<IconURL>& iconURLs(int iconTypesMask);
1006 void addIconURL(const String& url, const String& mimeType, const String& size, IconType);
1008 void updateFocusAppearanceSoon(bool restorePreviousSelection);
1009 void cancelFocusAppearanceUpdate();
1011 // Extension for manipulating canvas drawing contexts for use in CSS
1012 CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
1013 HTMLCanvasElement* getCSSCanvasElement(const String& name);
1015 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
1016 void parseDNSPrefetchControlHeader(const String&);
1018 virtual void postTask(Task) override; // Executes the task on context's thread asynchronously.
1020 void suspendScriptedAnimationControllerCallbacks();
1021 void resumeScriptedAnimationControllerCallbacks();
1022 virtual void scriptedAnimationControllerSetThrottled(bool);
1024 void windowScreenDidChange(PlatformDisplayID);
1026 void finishedParsing();
1028 bool inPageCache() const { return m_inPageCache; }
1029 void setInPageCache(bool flag);
1031 // Elements can register themselves for the "documentWillSuspendForPageCache()" and
1032 // "documentDidResumeFromPageCache()" callbacks
1033 void registerForPageCacheSuspensionCallbacks(Element*);
1034 void unregisterForPageCacheSuspensionCallbacks(Element*);
1036 void documentWillBecomeInactive();
1037 void documentWillSuspendForPageCache();
1038 void documentDidResumeFromPageCache();
1040 void registerForMediaVolumeCallbacks(Element*);
1041 void unregisterForMediaVolumeCallbacks(Element*);
1042 void mediaVolumeDidChange();
1044 void registerForPrivateBrowsingStateChangedCallbacks(Element*);
1045 void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
1046 void storageBlockingStateDidChange();
1047 void privateBrowsingStateDidChange();
1049 #if ENABLE(VIDEO_TRACK)
1050 void registerForCaptionPreferencesChangedCallbacks(Element*);
1051 void unregisterForCaptionPreferencesChangedCallbacks(Element*);
1052 void captionPreferencesChanged();
1055 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1056 void registerForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1057 void unregisterForPageScaleFactorChangedCallbacks(HTMLMediaElement*);
1058 void pageScaleFactorChangedAndStable();
1061 void registerForVisibilityStateChangedCallbacks(Element*);
1062 void unregisterForVisibilityStateChangedCallbacks(Element*);
1064 WEBCORE_EXPORT void setShouldCreateRenderers(bool);
1065 bool shouldCreateRenderers();
1067 void setDecoder(PassRefPtr<TextResourceDecoder>);
1068 TextResourceDecoder* decoder() const { return m_decoder.get(); }
1070 WEBCORE_EXPORT String displayStringModifiedByEncoding(const String&) const;
1071 PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
1072 void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
1074 displayBufferModifiedByEncodingInternal(buffer, len);
1076 void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
1078 displayBufferModifiedByEncodingInternal(buffer, len);
1081 // Quirk for the benefit of Apple's Dictionary application.
1082 void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
1083 bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
1085 #if ENABLE(DASHBOARD_SUPPORT)
1086 WEBCORE_EXPORT void setAnnotatedRegionsDirty(bool f) { m_annotatedRegionsDirty = f; }
1087 bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
1088 bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
1089 void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
1090 WEBCORE_EXPORT const Vector<AnnotatedRegionValue>& annotatedRegions() const;
1091 void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
1094 virtual void removeAllEventListeners() override;
1096 WEBCORE_EXPORT const SVGDocumentExtensions* svgExtensions();
1097 WEBCORE_EXPORT SVGDocumentExtensions& accessSVGExtensions();
1099 void initSecurityContext();
1100 void initContentSecurityPolicy();
1102 void updateURLForPushOrReplaceState(const URL&);
1103 void statePopped(PassRefPtr<SerializedScriptValue>);
1105 bool processingLoadEvent() const { return m_processingLoadEvent; }
1106 bool loadEventFinished() const { return m_loadEventFinished; }
1108 virtual bool isContextThread() const override;
1109 virtual bool isJSExecutionForbidden() const override { return false; }
1111 bool containsValidityStyleRules() const { return m_containsValidityStyleRules; }
1112 void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; }
1114 void enqueueWindowEvent(PassRefPtr<Event>);
1115 void enqueueDocumentEvent(PassRefPtr<Event>);
1116 void enqueueOverflowEvent(PassRefPtr<Event>);
1117 void enqueuePageshowEvent(PageshowEventPersistence);
1118 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
1119 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
1120 virtual DocumentEventQueue& eventQueue() const override { return m_eventQueue; }
1122 WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener*);
1123 WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener*);
1124 MediaCanStartListener* takeAnyMediaCanStartListener();
1126 #if ENABLE(FULLSCREEN_API)
1127 bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
1128 bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() && m_areKeysEnabledInFullScreen; }
1129 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
1131 enum FullScreenCheckType {
1132 EnforceIFrameAllowFullScreenRequirement,
1133 ExemptIFrameAllowFullScreenRequirement,
1136 void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
1137 WEBCORE_EXPORT void webkitCancelFullScreen();
1139 WEBCORE_EXPORT void webkitWillEnterFullScreenForElement(Element*);
1140 WEBCORE_EXPORT void webkitDidEnterFullScreenForElement(Element*);
1141 WEBCORE_EXPORT void webkitWillExitFullScreenForElement(Element*);
1142 WEBCORE_EXPORT void webkitDidExitFullScreenForElement(Element*);
1144 void setFullScreenRenderer(RenderFullScreen*);
1145 RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
1146 void fullScreenRendererDestroyed();
1148 void fullScreenChangeDelayTimerFired(Timer<Document>&);
1149 bool fullScreenIsAllowedForElement(Element*) const;
1150 void fullScreenElementRemoved();
1151 void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
1152 bool isAnimatingFullScreen() const;
1153 WEBCORE_EXPORT void setAnimatingFullScreen(bool);
1156 bool webkitFullscreenEnabled() const;
1157 Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : 0; }
1158 void webkitExitFullscreen();
1161 #if ENABLE(POINTER_LOCK)
1162 void exitPointerLock();
1163 Element* pointerLockElement() const;
1166 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
1167 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
1168 void decrementLoadEventDelayCount();
1169 bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
1171 #if ENABLE(IOS_TOUCH_EVENTS)
1172 #include <WebKitAdditions/DocumentIOS.h>
1173 #elif ENABLE(TOUCH_EVENTS)
1174 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;
1177 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1178 DeviceMotionController* deviceMotionController() const;
1179 DeviceOrientationController* deviceOrientationController() const;
1182 #if ENABLE(WEB_TIMING)
1183 const DocumentTiming& timing() const { return m_documentTiming; }
1186 #if ENABLE(REQUEST_ANIMATION_FRAME)
1187 int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
1188 void cancelAnimationFrame(int id);
1189 void serviceScriptedAnimations(double monotonicAnimationStartTime);
1192 void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
1194 virtual EventTarget* errorEventTarget() override;
1195 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<Inspector::ScriptCallStack>) override;
1197 void initDNSPrefetch();
1199 unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
1200 WEBCORE_EXPORT void didAddWheelEventHandler();
1201 WEBCORE_EXPORT void didRemoveWheelEventHandler();
1203 double lastHandledUserGestureTimestamp() const { return m_lastHandledUserGestureTimestamp; }
1204 void resetLastHandledUserGestureTimestamp();
1206 #if ENABLE(TOUCH_EVENTS)
1207 bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
1209 bool hasTouchEventHandlers() const { return false; }
1212 void didAddTouchEventHandler(Node*);
1213 void didRemoveTouchEventHandler(Node*);
1215 #if ENABLE(TOUCH_EVENTS)
1216 void didRemoveEventTargetNode(Node*);
1219 #if ENABLE(TOUCH_EVENTS)
1220 const TouchEventTargetSet* touchEventTargets() const { return m_touchEventTargets.get(); }
1222 const TouchEventTargetSet* touchEventTargets() const { return 0; }
1225 bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
1227 bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
1229 void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1230 void resumeScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1232 #if ENABLE(CSS_DEVICE_ADAPTATION)
1233 IntSize initialViewportSize() const;
1236 #if ENABLE(TEXT_AUTOSIZING)
1237 TextAutosizer* textAutosizer() { return m_textAutosizer.get(); }
1240 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&);
1241 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&);
1243 bool hasActiveParser();
1244 void incrementActiveParserCount() { ++m_activeParserCount; }
1245 void decrementActiveParserCount();
1247 DocumentSharedObjectPool* sharedObjectPool() { return m_sharedObjectPool.get(); }
1249 void didRemoveAllPendingStylesheet();
1250 void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
1251 void clearStyleResolver();
1253 bool inStyleRecalc() { return m_inStyleRecalc; }
1255 // Return a Locale for the default locale if the argument is null or empty.
1256 Locale& getCachedLocale(const AtomicString& locale = nullAtom);
1258 #if ENABLE(TEMPLATE_ELEMENT)
1259 const Document* templateDocument() const;
1260 Document* ensureTemplateDocument();
1261 void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = templateDocumentHost; }
1262 Document* templateDocumentHost() { return m_templateDocumentHost; }
1265 void didAssociateFormControl(Element*);
1266 bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; }
1267 void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; }
1268 void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; }
1270 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override;
1272 virtual SecurityOrigin* topOrigin() const override;
1274 #if ENABLE(FONT_LOAD_EVENTS)
1275 PassRefPtr<FontLoader> fonts();
1278 void ensurePlugInsInjectedScript(DOMWrapperWorld&);
1280 void setVisualUpdatesAllowedByClient(bool);
1282 #if ENABLE(SUBTLE_CRYPTO)
1283 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override;
1284 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override;
1287 void setHasStyleWithViewportUnits() { m_hasStyleWithViewportUnits = true; }
1288 bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
1289 void updateViewportUnitsOnResize();
1292 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
1293 Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
1295 void clearXMLVersion() { m_xmlVersion = String(); }
1297 virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const;
1301 friend class IgnoreDestructiveWriteCountIncrementer;
1303 void commonTeardown();
1305 RenderObject* renderer() const = delete;
1306 void setRenderer(RenderObject*) = delete;
1308 void createRenderTree();
1309 void detachParser();
1311 typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
1312 void processArguments(const String& features, void* data, ArgumentsCallback);
1314 virtual bool isDocument() const override { return true; }
1316 virtual void childrenChanged(const ChildChange&) override;
1318 virtual String nodeName() const override;
1319 virtual NodeType nodeType() const override;
1320 virtual bool childTypeAllowed(NodeType) const override;
1321 virtual PassRefPtr<Node> cloneNode(bool deep) override;
1322 void cloneDataFromDocument(const Document&);
1324 virtual void refScriptExecutionContext() override { ref(); }
1325 virtual void derefScriptExecutionContext() override { deref(); }
1327 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;
1329 virtual double minimumTimerInterval() const override;
1331 virtual double timerAlignmentInterval() const override;
1333 void updateTitle(const StringWithDirection&);
1334 void updateFocusAppearanceTimerFired(Timer<Document>&);
1335 void updateBaseURL();
1337 void buildAccessKeyMap(TreeScope* root);
1339 void createStyleResolver();
1341 void loadEventDelayTimerFired(Timer<Document>&);
1343 void pendingTasksTimerFired(Timer<Document>&);
1345 template <typename CharacterType>
1346 void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
1348 PageVisibilityState pageVisibilityState() const;
1350 Node* nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint = nullptr);
1352 PassRefPtr<HTMLCollection> ensureCachedCollection(CollectionType);
1354 #if ENABLE(FULLSCREEN_API)
1355 void dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>&, const AtomicString& eventName, bool shouldNotifyMediaElement);
1356 void clearFullscreenElementStack();
1357 void popFullscreenElementStack();
1358 void pushFullscreenElementStack(Element*);
1359 void addDocumentToFullScreenChangeEventQueue(Document*);
1362 void setVisualUpdatesAllowed(ReadyState);
1363 void setVisualUpdatesAllowed(bool);
1364 void visualUpdatesSuppressionTimerFired(Timer<Document>&);
1366 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
1368 void didAssociateFormControlsTimerFired(Timer<Document>&);
1370 unsigned m_referencingNodeCount;
1372 std::unique_ptr<StyleResolver> m_styleResolver;
1373 bool m_didCalculateStyleResolver;
1374 bool m_hasNodesWithPlaceholderStyle;
1375 bool m_needsNotifyRemoveAllPendingStylesheet;
1376 // But sometimes you need to ignore pending stylesheet count to
1377 // force an immediate layout when requested by JS.
1378 bool m_ignorePendingStylesheets;
1380 // If we do ignore the pending stylesheet count, then we need to add a boolean
1381 // to track that this happened so that we can do a full repaint when the stylesheets
1382 // do eventually load.
1383 PendingSheetLayout m_pendingSheetLayout;
1386 RefPtr<DOMWindow> m_domWindow;
1388 RefPtr<CachedResourceLoader> m_cachedResourceLoader;
1389 RefPtr<DocumentParser> m_parser;
1390 unsigned m_activeParserCount;
1395 URL m_url; // Document.URL: The URL from which this document was retrieved.
1396 URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
1397 URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
1398 URL m_baseElementURL; // The URL set by the <base> element.
1399 URL m_cookieURL; // The URL to use for cookie access.
1400 URL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
1402 // Document.documentURI:
1403 // Although URL-like, Document.documentURI can actually be set to any
1404 // string by content. Document.documentURI affects m_baseURL unless the
1405 // document contains a <base> element, in which case the <base> element
1406 // takes precedence.
1408 // This property is read-only from JavaScript, but writable from Objective C.
1409 String m_documentURI;
1411 String m_baseTarget;
1413 std::unique_ptr<DOMImplementation> m_implementation;
1415 RefPtr<CSSStyleSheet> m_elementSheet;
1418 bool m_paginatedForScreen;
1420 bool m_ignoreAutofocus;
1422 DocumentCompatibilityMode m_compatibilityMode;
1423 bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
1427 RefPtr<Element> m_focusedElement;
1428 RefPtr<Element> m_hoveredElement;
1429 RefPtr<Element> m_activeElement;
1430 RefPtr<Element> m_documentElement;
1431 UserActionElementSet m_userActionElements;
1433 uint64_t m_domTreeVersion;
1434 static uint64_t s_globalTreeVersion;
1436 HashSet<NodeIterator*> m_nodeIterators;
1437 HashSet<Range*> m_ranges;
1439 unsigned short m_listenerTypes;
1441 MutationObserverOptions m_mutationObserverTypes;
1443 DocumentStyleSheetCollection m_styleSheetCollection;
1444 RefPtr<StyleSheetList> m_styleSheetList;
1446 std::unique_ptr<FormController> m_formController;
1449 Color m_visitedLinkColor;
1450 Color m_activeLinkColor;
1451 const std::unique_ptr<VisitedLinkState> m_visitedLinkState;
1453 bool m_visuallyOrdered;
1454 ReadyState m_readyState;
1457 Timer<Document> m_optimizedStyleSheetUpdateTimer;
1458 Timer<Document> m_styleRecalcTimer;
1459 bool m_pendingStyleRecalcShouldForce;
1460 bool m_inStyleRecalc;
1461 bool m_closeAfterStyleRecalc;
1463 bool m_gotoAnchorNeededAfterStylesheetsLoad;
1464 bool m_isDNSPrefetchEnabled;
1465 bool m_haveExplicitlyDisabledDNSPrefetch;
1466 bool m_frameElementsShouldIgnoreScrolling;
1467 bool m_containsValidityStyleRules;
1468 bool m_updateFocusAppearanceRestoresSelection;
1470 // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
1471 unsigned m_ignoreDestructiveWriteCount;
1473 StringWithDirection m_title;
1474 StringWithDirection m_rawTitle;
1475 bool m_titleSetExplicitly;
1476 RefPtr<Element> m_titleElement;
1478 std::unique_ptr<AXObjectCache> m_axObjectCache;
1479 const std::unique_ptr<DocumentMarkerController> m_markers;
1481 Timer<Document> m_updateFocusAppearanceTimer;
1483 Element* m_cssTarget;
1485 // FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
1486 // is almost a duplication of this data, so that should probably get merged in too.
1487 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
1488 // and should be merged.
1489 bool m_processingLoadEvent;
1490 bool m_loadEventFinished;
1492 RefPtr<SerializedScriptValue> m_pendingStateObject;
1493 std::chrono::steady_clock::time_point m_startTime;
1494 bool m_overMinimumLayoutThreshold;
1496 std::unique_ptr<ScriptRunner> m_scriptRunner;
1498 Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
1501 std::unique_ptr<TransformSource> m_transformSource;
1502 RefPtr<Document> m_transformSourceDocument;
1505 String m_xmlEncoding;
1506 String m_xmlVersion;
1507 unsigned m_xmlStandalone : 2;
1508 unsigned m_hasXMLDeclaration : 1;
1510 String m_contentLanguage;
1512 RefPtr<TextResourceDecoder> m_decoder;
1514 InheritedBool m_designMode;
1516 HashSet<LiveNodeList*> m_listsInvalidatedAtDocument;
1517 HashSet<HTMLCollection*> m_collectionsInvalidatedAtDocument;
1518 #if !ASSERT_DISABLED
1519 bool m_inInvalidateNodeListAndCollectionCaches;
1522 unsigned m_nodeListAndCollectionCounts[numNodeListInvalidationTypes];
1524 RefPtr<XPathEvaluator> m_xpathEvaluator;
1526 std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1528 #if ENABLE(DASHBOARD_SUPPORT)
1529 Vector<AnnotatedRegionValue> m_annotatedRegions;
1530 bool m_hasAnnotatedRegions;
1531 bool m_annotatedRegionsDirty;
1534 HashMap<String, RefPtr<HTMLCanvasElement>> m_cssCanvasElements;
1536 bool m_createRenderers;
1538 Vector<IconURL> m_iconURLs;
1540 HashSet<Element*> m_documentSuspensionCallbackElements;
1541 HashSet<Element*> m_mediaVolumeCallbackElements;
1542 HashSet<Element*> m_privateBrowsingStateChangedElements;
1543 #if ENABLE(VIDEO_TRACK)
1544 HashSet<Element*> m_captionPreferencesChangedElements;
1547 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
1548 HashSet<HTMLMediaElement*> m_pageScaleFactorChangedElements;
1551 HashSet<Element*> m_visibilityStateCallbackElements;
1553 HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
1554 bool m_accessKeyMapValid;
1556 DocumentOrderedMap m_imagesByUsemap;
1558 std::unique_ptr<SelectorQueryCache> m_selectorQueryCache;
1560 DocumentClassFlags m_documentClasses;
1562 bool m_isSynthesized;
1563 bool m_isNonRenderedPlaceholder;
1565 bool m_sawElementsInKnownNamespaces;
1566 bool m_isSrcdocDocument;
1568 RenderPtr<RenderView> m_renderView;
1569 mutable DocumentEventQueue m_eventQueue;
1571 WeakPtrFactory<Document> m_weakFactory;
1573 HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
1575 #if ENABLE(FULLSCREEN_API)
1576 bool m_areKeysEnabledInFullScreen;
1577 RefPtr<Element> m_fullScreenElement;
1578 Vector<RefPtr<Element>> m_fullScreenElementStack;
1579 RenderFullScreen* m_fullScreenRenderer;
1580 Timer<Document> m_fullScreenChangeDelayTimer;
1581 Deque<RefPtr<Node>> m_fullScreenChangeEventTargetQueue;
1582 Deque<RefPtr<Node>> m_fullScreenErrorEventTargetQueue;
1583 bool m_isAnimatingFullScreen;
1584 LayoutRect m_savedPlaceholderFrameRect;
1585 RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
1588 int m_loadEventDelayCount;
1589 Timer<Document> m_loadEventDelayTimer;
1591 ViewportArguments m_viewportArguments;
1593 ReferrerPolicy m_referrerPolicy;
1595 bool m_directionSetOnDocumentElement;
1596 bool m_writingModeSetOnDocumentElement;
1598 #if ENABLE(WEB_TIMING)
1599 DocumentTiming m_documentTiming;
1602 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
1603 bool m_writeRecursionIsTooDeep;
1604 unsigned m_writeRecursionDepth;
1606 unsigned m_wheelEventHandlerCount;
1607 #if ENABLE(TOUCH_EVENTS)
1608 std::unique_ptr<TouchEventTargetSet> m_touchEventTargets;
1611 double m_lastHandledUserGestureTimestamp;
1613 #if ENABLE(REQUEST_ANIMATION_FRAME)
1614 void clearScriptedAnimationController();
1615 RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
1618 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
1619 std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
1620 std::unique_ptr<DeviceMotionController> m_deviceMotionController;
1621 std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
1622 std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
1625 // FIXME: Find a better place for this functionality.
1626 #if ENABLE(TELEPHONE_NUMBER_DETECTION)
1629 // These functions provide a two-level setting:
1630 // - A user-settable wantsTelephoneNumberParsing (at the Page / WebView level)
1631 // - A read-only telephoneNumberParsingAllowed which is set by the
1632 // document if it has the appropriate meta tag.
1633 // - isTelephoneNumberParsingEnabled() == isTelephoneNumberParsingAllowed() && page()->settings()->isTelephoneNumberParsingEnabled()
1635 WEBCORE_EXPORT bool isTelephoneNumberParsingAllowed() const;
1636 WEBCORE_EXPORT bool isTelephoneNumberParsingEnabled() const;
1639 friend void setParserFeature(const String& key, const String& value, Document*, void* userData);
1640 void setIsTelephoneNumberParsingAllowed(bool);
1642 bool m_isTelephoneNumberParsingAllowed;
1645 Timer<Document> m_pendingTasksTimer;
1646 Vector<Task> m_pendingTasks;
1648 #if ENABLE(IOS_TEXT_AUTOSIZING)
1650 void addAutoSizingNode(Node*, float size);
1651 void validateAutoSizingNodes();
1652 void resetAutoSizingNodes();
1655 typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
1656 TextAutoSizingMap m_textAutoSizedNodes;
1659 #if ENABLE(TEXT_AUTOSIZING)
1660 std::unique_ptr<TextAutosizer> m_textAutosizer;
1663 void platformSuspendOrStopActiveDOMObjects();
1665 bool m_scheduledTasksAreSuspended;
1667 bool m_visualUpdatesAllowed;
1668 Timer<Document> m_visualUpdatesSuppressionTimer;
1670 RefPtr<NamedFlowCollection> m_namedFlows;
1672 #if ENABLE(CSP_NEXT)
1673 RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
1676 void sharedObjectPoolClearTimerFired(Timer<Document>&);
1677 Timer<Document> m_sharedObjectPoolClearTimer;
1679 std::unique_ptr<DocumentSharedObjectPool> m_sharedObjectPool;
1682 bool m_didDispatchViewportPropertiesChanged;
1685 typedef HashMap<AtomicString, OwnPtr<Locale>> LocaleIdentifierToLocaleMap;
1686 LocaleIdentifierToLocaleMap m_localeCache;
1688 #if ENABLE(TEMPLATE_ELEMENT)
1689 RefPtr<Document> m_templateDocument;
1690 Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
1693 #if ENABLE(FONT_LOAD_EVENTS)
1694 RefPtr<FontLoader> m_fontloader;
1697 #if ENABLE(WEB_REPLAY)
1698 RefPtr<JSC::InputCursor> m_inputCursor;
1701 Timer<Document> m_didAssociateFormControlsTimer;
1702 HashSet<RefPtr<Element>> m_associatedFormControls;
1703 unsigned m_disabledFieldsetElementsCount;
1705 bool m_hasInjectedPlugInsScript;
1706 bool m_renderTreeBeingDestroyed;
1707 bool m_hasPreparedForDestruction;
1709 bool m_hasStyleWithViewportUnits;
1712 inline void Document::notifyRemovePendingSheetIfNeeded()
1714 if (m_needsNotifyRemoveAllPendingStylesheet)
1715 didRemoveAllPendingStylesheet();
1718 #if ENABLE(TEMPLATE_ELEMENT)
1719 inline const Document* Document::templateDocument() const
1721 // If DOCUMENT does not have a browsing context, Let TEMPLATE CONTENTS OWNER be DOCUMENT and abort these steps.
1725 return m_templateDocument.get();
1729 // Put these methods here, because they require the Document definition, but we really want to inline them.
1731 inline bool Node::isDocumentNode() const
1733 return this == &document();
1736 inline ScriptExecutionContext* Node::scriptExecutionContext() const
1741 Element* eventTargetElementForDocument(Document*);
1743 SCRIPT_EXECUTION_CONTEXT_TYPE_CASTS(Document)
1745 inline bool isDocument(const Node& node) { return node.isDocumentNode(); }
1746 void isDocument(const Document&); // Catch unnecessary runtime check of type known at compile time.
1748 NODE_TYPE_CASTS(Document)
1750 #define DOCUMENT_TYPE_CASTS(ToClassName) \
1751 TYPE_CASTS_BASE(ToClassName, Document, document, WebCore::is##ToClassName(*document), WebCore::is##ToClassName(document))
1753 } // namespace WebCore
1756 inline WebCore::Document* getPtr(WebCore::Document& p) { return &p; }
1759 #endif // Document_h