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 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 "DOMTimeStamp.h"
35 #include "DocumentEventQueue.h"
36 #include "DocumentTiming.h"
38 #include "InspectorCounters.h"
40 #include "MutationObserver.h"
41 #include "PageVisibilityState.h"
42 #include "PlatformScreen.h"
43 #include "QualifiedName.h"
44 #include "ReferrerPolicy.h"
45 #include "ScriptExecutionContext.h"
46 #include "StringWithDirection.h"
48 #include "TreeScope.h"
49 #include "ViewportArguments.h"
50 #include <wtf/Deque.h>
51 #include <wtf/FixedArray.h>
52 #include <wtf/OwnPtr.h>
53 #include <wtf/PassOwnPtr.h>
54 #include <wtf/PassRefPtr.h>
61 class CSSStyleDeclaration;
63 class CachedCSSStyleSheet;
64 class CachedResourceLoader;
66 class CanvasRenderingContext;
69 class ContextFeatures;
70 class DOMImplementation;
71 class DOMNamedFlowCollection;
76 class DocumentFragment;
78 class DocumentMarkerController;
80 class DocumentStyleSheetCollection;
82 class DocumentWeakReference;
84 class ElementAttributeData;
85 class EntityReference;
93 class HTMLCanvasElement;
95 class HTMLAllCollection;
98 class HTMLFrameOwnerElement;
99 class HTMLHeadElement;
100 class HTMLIFrameElement;
101 class HTMLMapElement;
102 class HTMLNameCollection;
103 class HitTestRequest;
108 class LiveNodeListBase;
109 class DOMWrapperWorld;
112 class MediaCanStartListener;
113 class MediaQueryList;
114 class MediaQueryMatcher;
115 class MouseEventWithHitTestResults;
116 class NamedFlowCollection;
120 class PlatformMouseEvent;
121 class ProcessingInstruction;
123 class RegisteredEventListener;
126 class RenderFullScreen;
127 class ScriptableDocumentParser;
128 class ScriptElementData;
130 class SecurityOrigin;
131 class SelectorQueryCache;
132 class SerializedScriptValue;
133 class SegmentedString;
137 class StyleSheetContents;
138 class StyleSheetList;
140 class TextResourceDecoder;
142 class WebKitNamedFlow;
143 class XMLHttpRequest;
144 class XPathEvaluator;
145 class XPathExpression;
146 class XPathNSResolver;
150 class SVGDocumentExtensions;
154 class TransformSource;
157 #if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
158 struct AnnotatedRegionValue;
161 #if ENABLE(TOUCH_EVENTS)
166 #if ENABLE(REQUEST_ANIMATION_FRAME)
167 class RequestAnimationFrameCallback;
168 class ScriptedAnimationController;
171 #if ENABLE(MICRODATA)
172 class MicroDataItemList;
175 #if ENABLE(LINK_PRERENDER)
179 #if ENABLE(TEXT_AUTOSIZING)
184 class DOMSecurityPolicy;
187 typedef int ExceptionCode;
189 enum PageshowEventPersistence {
190 PageshowEventNotPersisted = 0,
191 PageshowEventPersisted = 1
194 enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded };
196 enum NodeListInvalidationType {
197 DoNotInvalidateOnAttributeChanges = 0,
198 InvalidateOnClassAttrChange,
199 InvalidateOnIdNameAttrChange,
200 InvalidateOnNameAttrChange,
201 InvalidateOnForAttrChange,
202 InvalidateForFormControls,
203 InvalidateOnHRefAttrChange,
204 InvalidateOnItemAttrChange,
205 InvalidateOnAnyAttrChange,
207 const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
209 struct ImmutableAttributeDataCacheEntry;
210 typedef HashMap<unsigned, OwnPtr<ImmutableAttributeDataCacheEntry>, AlreadyHashed> ImmutableAttributeDataCache;
212 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
214 static PassRefPtr<Document> create(Frame* frame, const KURL& url)
216 return adoptRef(new Document(frame, url, false, false));
218 static PassRefPtr<Document> createXHTML(Frame* frame, const KURL& url)
220 return adoptRef(new Document(frame, url, true, false));
224 MediaQueryMatcher* mediaQueryMatcher();
226 using ContainerNode::ref;
227 using ContainerNode::deref;
229 // Nodes belonging to this document hold guard references -
230 // these are enough to keep the document from being destroyed, but
231 // not enough to keep it from removing its children. This allows a
232 // node that outlives its document to still have a valid document
233 // pointer without introducing reference cycles.
236 ASSERT(!m_deletionHasBegun);
242 ASSERT(!m_deletionHasBegun);
244 if (!m_guardRefCount && !refCount()) {
246 m_deletionHasBegun = true;
252 Element* getElementById(const AtomicString& id) const;
254 virtual bool canContainRangeEndPoint() const { return true; }
256 Element* getElementByAccessKey(const String& key);
257 void invalidateAccessKeyMap();
259 SelectorQueryCache* selectorQueryCache();
261 // DOM methods & attributes for Document
263 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
264 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
265 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
266 DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu);
267 DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick);
268 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter);
269 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover);
270 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave);
271 DEFINE_ATTRIBUTE_EVENT_LISTENER(drop);
272 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart);
273 DEFINE_ATTRIBUTE_EVENT_LISTENER(drag);
274 DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend);
275 DEFINE_ATTRIBUTE_EVENT_LISTENER(input);
276 DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid);
277 DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown);
278 DEFINE_ATTRIBUTE_EVENT_LISTENER(keypress);
279 DEFINE_ATTRIBUTE_EVENT_LISTENER(keyup);
280 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousedown);
281 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousemove);
282 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseout);
283 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseover);
284 DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseup);
285 DEFINE_ATTRIBUTE_EVENT_LISTENER(mousewheel);
286 DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
287 DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
288 DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
290 DEFINE_ATTRIBUTE_EVENT_LISTENER(blur);
291 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
292 DEFINE_ATTRIBUTE_EVENT_LISTENER(focus);
293 DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
294 DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
297 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
298 DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
299 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
300 DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
301 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
302 DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
303 DEFINE_ATTRIBUTE_EVENT_LISTENER(reset);
304 DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
305 DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
306 DEFINE_ATTRIBUTE_EVENT_LISTENER(selectionchange);
307 #if ENABLE(TOUCH_EVENTS)
308 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
309 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
310 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
311 DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
313 #if ENABLE(FULLSCREEN_API)
314 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
315 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
317 #if ENABLE(POINTER_LOCK)
318 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockchange);
319 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockerror);
321 #if ENABLE(PAGE_VISIBILITY_API)
322 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitvisibilitychange);
325 void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
326 ViewportArguments viewportArguments() const { return m_viewportArguments; }
328 bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
331 void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
332 ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
334 DocumentType* doctype() const { return m_docType.get(); }
336 DOMImplementation* implementation();
338 Element* documentElement() const
340 return m_documentElement.get();
343 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
344 PassRefPtr<DocumentFragment> createDocumentFragment();
345 PassRefPtr<Text> createTextNode(const String& data);
346 PassRefPtr<Comment> createComment(const String& data);
347 PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
348 PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
349 PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
350 PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
351 PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
352 PassRefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, true, ec); }
353 PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
354 virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
355 PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
357 bool cssStickyPositionEnabled() const;
358 bool cssRegionsEnabled() const;
359 #if ENABLE(CSS_REGIONS)
360 PassRefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
363 NamedFlowCollection* namedFlows();
365 bool regionBasedColumnsEnabled() const;
367 bool cssGridLayoutEnabled() const;
370 * Retrieve all nodes that intersect a rect in the window's document, until it is fully enclosed by
371 * the boundaries of a node.
373 * @param centerX x reference for the rectangle in CSS pixels
374 * @param centerY y reference for the rectangle in CSS pixels
375 * @param topPadding How much to expand the top of the rectangle
376 * @param rightPadding How much to expand the right of the rectangle
377 * @param bottomPadding How much to expand the bottom of the rectangle
378 * @param leftPadding How much to expand the left of the rectangle
379 * @param ignoreClipping whether or not to ignore the root scroll frame when retrieving the element.
380 * If false, this method returns null for coordinates outside of the viewport.
382 PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
383 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent) const;
384 Element* elementFromPoint(int x, int y) const;
385 PassRefPtr<Range> caretRangeFromPoint(int x, int y);
387 String readyState() const;
389 String defaultCharset() const;
391 String inputEncoding() const { return Document::encoding(); }
392 String charset() const { return Document::encoding(); }
393 String characterSet() const { return Document::encoding(); }
395 String encoding() const;
397 void setCharset(const String&);
399 void setContent(const String&);
401 String suggestedMIMEType() const;
403 String contentLanguage() const { return m_contentLanguage; }
404 void setContentLanguage(const String&);
406 String xmlEncoding() const { return m_xmlEncoding; }
407 String xmlVersion() const { return m_xmlVersion; }
408 enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
409 bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
410 StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
411 bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
413 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
414 void setXMLVersion(const String&, ExceptionCode&);
415 void setXMLStandalone(bool, ExceptionCode&);
416 void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
418 String documentURI() const { return m_documentURI; }
419 void setDocumentURI(const String&);
421 virtual KURL baseURI() const;
423 #if ENABLE(PAGE_VISIBILITY_API)
424 String webkitVisibilityState() const;
425 bool webkitHidden() const;
426 void dispatchVisibilityStateChangeEvent();
430 DOMSecurityPolicy* securityPolicy();
433 PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
435 PassRefPtr<HTMLCollection> images();
436 PassRefPtr<HTMLCollection> embeds();
437 PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
438 PassRefPtr<HTMLCollection> applets();
439 PassRefPtr<HTMLCollection> links();
440 PassRefPtr<HTMLCollection> forms();
441 PassRefPtr<HTMLCollection> anchors();
442 PassRefPtr<HTMLCollection> scripts();
443 PassRefPtr<HTMLCollection> all();
445 PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
446 PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
448 // Other methods (not part of DOM)
449 bool isHTMLDocument() const { return m_isHTML; }
450 bool isXHTMLDocument() const { return m_isXHTML; }
451 virtual bool isImageDocument() const { return false; }
453 virtual bool isSVGDocument() const { return false; }
454 bool hasSVGRootNode() const;
456 static bool isSVGDocument() { return false; }
457 static bool hasSVGRootNode() { return false; }
459 virtual bool isPluginDocument() const { return false; }
460 virtual bool isMediaDocument() const { return false; }
461 virtual bool isFrameSet() const { return false; }
463 bool isSrcdocDocument() const { return m_isSrcdocDocument; }
465 StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
467 bool isViewSource() const { return m_isViewSource; }
468 void setIsViewSource(bool);
470 bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
472 StyleResolver* styleResolver()
474 if (!m_styleResolver)
475 createStyleResolver();
476 return m_styleResolver.get();
479 void notifyRemovePendingSheetIfNeeded();
481 bool haveStylesheetsLoaded() const;
483 // This is a DOM function.
484 StyleSheetList* styleSheets();
486 DocumentStyleSheetCollection* styleSheetCollection() { return m_styleSheetCollection.get(); }
488 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
489 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
492 * Called when one or more stylesheets in the document may have been added, removed or changed.
494 * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
495 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
496 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
497 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
498 * found and is used to calculate the derived styles for all rendering objects.
500 void styleResolverChanged(StyleResolverUpdateFlag);
502 void evaluateMediaQueryList();
505 FormController* formController();
506 Vector<String> formElementsState() const;
507 void setStateForNewFormElements(const Vector<String>&);
509 FrameView* view() const; // can be NULL
510 Frame* frame() const { return m_frame; } // can be NULL
511 Page* page() const; // can be NULL
512 Settings* settings() const; // can be NULL
514 PassRefPtr<Range> createRange();
516 PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
517 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
519 PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
520 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
522 // Special support for editing
523 PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
524 PassRefPtr<Text> createEditingTextNode(const String&);
526 void recalcStyle(StyleChange = NoChange);
527 bool childNeedsAndNotInStyleRecalc();
528 void updateStyleIfNeeded();
530 void updateLayoutIgnorePendingStylesheets();
531 PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
532 PassRefPtr<RenderStyle> styleForPage(int pageIndex);
534 // Returns true if page box (margin boxes and page borders) is visible.
535 bool isPageBoxVisible(int pageIndex);
537 // Returns the preferred page size and margins in pixels, assuming 96
538 // pixels per inch. pageSize, marginTop, marginRight, marginBottom,
539 // marginLeft must be initialized to the default values that are used if
540 // auto is specified.
541 void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
543 static void updateStyleForAllDocuments(); // FIXME: Try to reduce the # of calls to this function.
544 CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader.get(); }
546 virtual void attach();
547 virtual void detach();
548 void prepareForDestruction();
550 // Override ScriptExecutionContext methods to do additional work
551 virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) OVERRIDE;
552 virtual void resumeActiveDOMObjects() OVERRIDE;
554 RenderArena* renderArena() { return m_renderArena.get(); }
556 // Implemented in RenderView.h to avoid a cyclic header dependency this just
557 // returns renderer so callers can avoid verbose casts.
558 RenderView* renderView() const;
560 // Shadow the implementations on Node to provide faster access for documents.
561 RenderObject* renderer() const { return m_renderer; }
562 void setRenderer(RenderObject* renderer)
564 m_renderer = renderer;
565 Node::setRenderer(renderer);
568 void clearAXObjectCache();
569 AXObjectCache* axObjectCache() const;
570 bool axObjectCacheExists() const;
572 // to get visually ordered hebrew and arabic pages right
573 void setVisuallyOrdered();
574 bool visuallyOrdered() const { return m_visuallyOrdered; }
576 DocumentLoader* loader() const;
578 void open(Document* ownerDocument = 0);
581 // close() is the DOM API document.close()
583 // In some situations (see the code), we ignore document.close().
584 // explicitClose() bypass these checks and actually tries to close the
586 void explicitClose();
587 // implicitClose() actually does the work of closing the input stream.
588 void implicitClose();
590 void cancelParsing();
592 void write(const SegmentedString& text, Document* ownerDocument = 0);
593 void write(const String& text, Document* ownerDocument = 0);
594 void writeln(const String& text, Document* ownerDocument = 0);
596 bool wellFormed() const { return m_wellFormed; }
598 const KURL& url() const { return m_url; }
599 void setURL(const KURL&);
601 // To understand how these concepts relate to one another, please see the
602 // comments surrounding their declaration.
603 const KURL& baseURL() const { return m_baseURL; }
604 void setBaseURLOverride(const KURL&);
605 const KURL& baseURLOverride() const { return m_baseURLOverride; }
606 const KURL& baseElementURL() const { return m_baseElementURL; }
607 const String& baseTarget() const { return m_baseTarget; }
608 void processBaseElement();
610 KURL completeURL(const String&) const;
611 KURL completeURL(const String&, const KURL& baseURLOverride) const;
613 virtual String userAgent(const KURL&) const;
615 virtual void disableEval(const String& errorMessage);
617 bool canNavigate(Frame* targetFrame);
618 Frame* findUnsafeParentScrollPropagationBoundary();
620 CSSStyleSheet* elementSheet();
622 virtual PassRefPtr<DocumentParser> createParser();
623 DocumentParser* parser() const { return m_parser.get(); }
624 ScriptableDocumentParser* scriptableDocumentParser() const;
626 bool printing() const { return m_printing; }
627 void setPrinting(bool p) { m_printing = p; }
629 bool paginatedForScreen() const { return m_paginatedForScreen; }
630 void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
632 bool paginated() const { return printing() || paginatedForScreen(); }
634 enum CompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
636 virtual void setCompatibilityModeFromDoctype() { }
637 void setCompatibilityMode(CompatibilityMode m);
638 void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
639 CompatibilityMode compatibilityMode() const { return m_compatibilityMode; }
641 String compatMode() const;
643 bool inQuirksMode() const { return m_compatibilityMode == QuirksMode; }
644 bool inLimitedQuirksMode() const { return m_compatibilityMode == LimitedQuirksMode; }
645 bool inNoQuirksMode() const { return m_compatibilityMode == NoQuirksMode; }
652 void setReadyState(ReadyState);
653 void setParsing(bool);
654 bool parsing() const { return m_bParsing; }
655 int minimumLayoutDelay();
657 bool shouldScheduleLayout();
658 bool isLayoutTimerActive();
659 int elapsedTime() const;
661 void setTextColor(const Color& color) { m_textColor = color; }
662 Color textColor() const { return m_textColor; }
664 const Color& linkColor() const { return m_linkColor; }
665 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
666 const Color& activeLinkColor() const { return m_activeLinkColor; }
667 void setLinkColor(const Color& c) { m_linkColor = c; }
668 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
669 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
670 void resetLinkColor();
671 void resetVisitedLinkColor();
672 void resetActiveLinkColor();
674 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
676 /* Newly proposed CSS3 mechanism for selecting alternate
677 stylesheets using the DOM. May be subject to change as
680 String preferredStylesheetSet() const;
681 String selectedStylesheetSet() const;
682 void setSelectedStylesheetSet(const String&);
684 bool setFocusedNode(PassRefPtr<Node>);
685 Node* focusedNode() const { return m_focusedNode.get(); }
687 void getFocusableNodes(Vector<RefPtr<Node> >&);
689 // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough
690 // for WebCore to ignore the autofocus attribute on any form controls
691 bool ignoreAutofocus() const { return m_ignoreAutofocus; };
692 void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
694 void setHoverNode(PassRefPtr<Node>);
695 Node* hoverNode() const { return m_hoverNode.get(); }
697 void setActiveNode(PassRefPtr<Node>);
698 Node* activeNode() const { return m_activeNode.get(); }
700 void focusedNodeRemoved();
701 void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
702 void hoveredNodeDetached(Node*);
703 void activeChainNodeDetached(Node*);
705 void updateHoverActiveState(const HitTestRequest&, HitTestResult&);
707 // Updates for :target (CSS3 selector).
708 void setCSSTarget(Element*);
709 Element* cssTarget() const { return m_cssTarget; }
711 void scheduleForcedStyleRecalc();
712 void scheduleStyleRecalc();
713 void unscheduleStyleRecalc();
714 bool hasPendingStyleRecalc() const;
715 bool hasPendingForcedStyleRecalc() const;
716 void styleRecalcTimerFired(Timer<Document>*);
718 void registerNodeList(LiveNodeListBase*);
719 void unregisterNodeList(LiveNodeListBase*);
720 bool shouldInvalidateNodeListCaches(const QualifiedName* attrName = 0) const;
721 void invalidateNodeListCaches(const QualifiedName* attrName);
723 void attachNodeIterator(NodeIterator*);
724 void detachNodeIterator(NodeIterator*);
725 void moveNodeIteratorsToNewDocument(Node*, Document*);
727 void attachRange(Range*);
728 void detachRange(Range*);
730 void updateRangesAfterChildrenChanged(ContainerNode*);
731 // nodeChildrenWillBeRemoved is used when removing all node children at once.
732 void nodeChildrenWillBeRemoved(ContainerNode*);
733 // nodeWillBeRemoved is only safe when removing one node at a time.
734 void nodeWillBeRemoved(Node*);
735 bool canReplaceChild(Node* newChild, Node* oldChild);
737 void textInserted(Node*, unsigned offset, unsigned length);
738 void textRemoved(Node*, unsigned offset, unsigned length);
739 void textNodesMerged(Text* oldNode, unsigned offset);
740 void textNodeSplit(Text* oldNode);
742 void createDOMWindow();
743 void takeDOMWindowFrom(Document*);
745 DOMWindow* domWindow() const { return m_domWindow.get(); }
746 // In DOM Level 2, the Document's DOMWindow is called the defaultView.
747 DOMWindow* defaultView() const { return domWindow(); }
749 // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
750 void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
751 EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
752 void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0);
753 void dispatchWindowLoadEvent();
755 PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
757 // keep track of what types of event listeners are registered, so we don't
758 // dispatch events unnecessarily
760 DOMSUBTREEMODIFIED_LISTENER = 1,
761 DOMNODEINSERTED_LISTENER = 1 << 1,
762 DOMNODEREMOVED_LISTENER = 1 << 2,
763 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
764 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
765 DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
766 OVERFLOWCHANGED_LISTENER = 1 << 6,
767 ANIMATIONEND_LISTENER = 1 << 7,
768 ANIMATIONSTART_LISTENER = 1 << 8,
769 ANIMATIONITERATION_LISTENER = 1 << 9,
770 TRANSITIONEND_LISTENER = 1 << 10,
771 BEFORELOAD_LISTENER = 1 << 11,
772 SCROLL_LISTENER = 1 << 12
776 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
777 void addListenerTypeIfNeeded(const AtomicString& eventType);
779 #if ENABLE(MUTATION_OBSERVERS)
780 bool hasMutationObserversOfType(MutationObserver::MutationType type) const
782 return m_mutationObserverTypes & type;
784 bool hasMutationObservers() const { return m_mutationObserverTypes; }
785 void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
788 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
790 int nodeAbsIndex(Node*);
791 Node* nodeWithAbsIndex(int absIndex);
794 * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
795 * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
796 * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
797 * specified in a HTML file.
799 * @param equiv The http header name (value of the meta tag's "equiv" attribute)
800 * @param content The header value (value of the meta tag's "content" attribute)
802 void processHttpEquiv(const String& equiv, const String& content);
803 void processViewport(const String& features, ViewportArguments::Type origin);
804 void updateViewportArguments();
805 void processReferrerPolicy(const String& policy);
807 // Returns the owning element in the parent document.
808 // Returns 0 if this is the top level document.
809 HTMLFrameOwnerElement* ownerElement() const;
811 HTMLIFrameElement* seamlessParentIFrame() const;
812 bool shouldDisplaySeamlesslyWithParent() const;
814 // Used by DOM bindings; no direction known.
815 String title() const { return m_title.string(); }
816 void setTitle(const String&);
818 void setTitleElement(const StringWithDirection&, Element* titleElement);
819 void removeTitle(Element* titleElement);
821 String cookie(ExceptionCode&) const;
822 void setCookie(const String&, ExceptionCode&);
824 String referrer() const;
826 String domain() const;
827 void setDomain(const String& newDomain, ExceptionCode&);
829 String lastModified() const;
831 // The cookieURL is used to query the cookie database for this document's
832 // cookies. For example, if the cookie URL is http://example.com, we'll
833 // use the non-Secure cookies for example.com when computing
836 // Q: How is the cookieURL different from the document's URL?
837 // A: The two URLs are the same almost all the time. However, if one
838 // document inherits the security context of another document, it
839 // inherits its cookieURL but not its URL.
841 const KURL& cookieURL() const { return m_cookieURL; }
842 void setCookieURL(const KURL& url) { m_cookieURL = url; }
844 // The firstPartyForCookies is used to compute whether this document
845 // appears in a "third-party" context for the purpose of third-party
846 // cookie blocking. The document is in a third-party context if the
847 // cookieURL and the firstPartyForCookies are from different hosts.
849 // Note: Some ports (including possibly Apple's) only consider the
850 // document in a third-party context if the cookieURL and the
851 // firstPartyForCookies have a different registry-controlled
854 const KURL& firstPartyForCookies() const { return m_firstPartyForCookies; }
855 void setFirstPartyForCookies(const KURL& url) { m_firstPartyForCookies = url; }
857 // The following implements the rule from HTML 4 for what valid names are.
858 // To get this right for all the XML cases, we probably have to improve this or move it
859 // and make it sensitive to the type of document.
860 static bool isValidName(const String&);
862 // The following breaks a qualified name into a prefix and a local name.
863 // It also does a validity check, and returns false if the qualified name
864 // is invalid. It also sets ExceptionCode when name is invalid.
865 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
867 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
868 static bool hasValidNamespaceForElements(const QualifiedName&);
869 static bool hasValidNamespaceForAttributes(const QualifiedName&);
871 HTMLElement* body() const;
872 void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
874 HTMLHeadElement* head();
876 DocumentMarkerController* markers() const { return m_markers.get(); }
878 bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
879 bool writingModeSetOnDocumentElement() const { return m_writingModeSetOnDocumentElement; }
880 void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
881 void setWritingModeSetOnDocumentElement(bool b) { m_writingModeSetOnDocumentElement = b; }
883 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
884 bool queryCommandEnabled(const String& command);
885 bool queryCommandIndeterm(const String& command);
886 bool queryCommandState(const String& command);
887 bool queryCommandSupported(const String& command);
888 String queryCommandValue(const String& command);
890 KURL openSearchDescriptionURL();
892 // designMode support
893 enum InheritedBool { off = false, on = true, inherit };
894 void setDesignMode(InheritedBool value);
895 InheritedBool getDesignMode() const;
896 bool inDesignMode() const;
898 Document* parentDocument() const;
899 Document* topDocument() const;
901 int docID() const { return m_docID; }
903 ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
906 void applyXSLTransform(ProcessingInstruction* pi);
907 PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
908 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
910 void setTransformSource(PassOwnPtr<TransformSource>);
911 TransformSource* transformSource() const { return m_transformSource.get(); }
914 void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
915 uint64_t domTreeVersion() const { return m_domTreeVersion; }
917 void setDocType(PassRefPtr<DocumentType>);
919 // XPathEvaluator methods
920 PassRefPtr<XPathExpression> createExpression(const String& expression,
921 XPathNSResolver* resolver,
923 PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
924 PassRefPtr<XPathResult> evaluate(const String& expression,
926 XPathNSResolver* resolver,
931 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
933 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
935 bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
936 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
938 const Vector<IconURL>& iconURLs();
939 void addIconURL(const String& url, const String& mimeType, const String& size, IconType);
941 void setUseSecureKeyboardEntryWhenActive(bool);
942 bool useSecureKeyboardEntryWhenActive() const;
944 void updateFocusAppearanceSoon(bool restorePreviousSelection);
945 void cancelFocusAppearanceUpdate();
947 // Extension for manipulating canvas drawing contexts for use in CSS
948 CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
949 HTMLCanvasElement* getCSSCanvasElement(const String& name);
951 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
952 void parseDNSPrefetchControlHeader(const String&);
954 virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously.
956 virtual void suspendScriptedAnimationControllerCallbacks();
957 virtual void resumeScriptedAnimationControllerCallbacks();
959 void windowScreenDidChange(PlatformDisplayID);
961 virtual void finishedParsing();
963 bool inPageCache() const { return m_inPageCache; }
964 void setInPageCache(bool flag);
966 // Elements can register themselves for the "documentWillSuspendForPageCache()" and
967 // "documentDidResumeFromPageCache()" callbacks
968 void registerForPageCacheSuspensionCallbacks(Element*);
969 void unregisterForPageCacheSuspensionCallbacks(Element*);
971 void documentWillBecomeInactive();
972 void documentWillSuspendForPageCache();
973 void documentDidResumeFromPageCache();
975 void registerForMediaVolumeCallbacks(Element*);
976 void unregisterForMediaVolumeCallbacks(Element*);
977 void mediaVolumeDidChange();
979 void registerForPrivateBrowsingStateChangedCallbacks(Element*);
980 void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
981 void storageBlockingStateDidChange();
982 void privateBrowsingStateDidChange();
984 void setShouldCreateRenderers(bool);
985 bool shouldCreateRenderers();
987 void setDecoder(PassRefPtr<TextResourceDecoder>);
988 TextResourceDecoder* decoder() const { return m_decoder.get(); }
990 String displayStringModifiedByEncoding(const String&) const;
991 PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
992 void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
994 displayBufferModifiedByEncodingInternal(buffer, len);
996 void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
998 displayBufferModifiedByEncodingInternal(buffer, len);
1001 // Quirk for the benefit of Apple's Dictionary application.
1002 void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
1003 bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
1005 #if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
1006 void setAnnotatedRegionsDirty(bool f) { m_annotatedRegionsDirty = f; }
1007 bool annotatedRegionsDirty() const { return m_annotatedRegionsDirty; }
1008 bool hasAnnotatedRegions () const { return m_hasAnnotatedRegions; }
1009 void setHasAnnotatedRegions(bool f) { m_hasAnnotatedRegions = f; }
1010 const Vector<AnnotatedRegionValue>& annotatedRegions() const;
1011 void setAnnotatedRegions(const Vector<AnnotatedRegionValue>&);
1014 virtual void removeAllEventListeners();
1017 const SVGDocumentExtensions* svgExtensions();
1018 SVGDocumentExtensions* accessSVGExtensions();
1021 void initSecurityContext();
1022 void initContentSecurityPolicy();
1024 void updateURLForPushOrReplaceState(const KURL&);
1025 void statePopped(PassRefPtr<SerializedScriptValue>);
1027 bool processingLoadEvent() const { return m_processingLoadEvent; }
1028 bool loadEventFinished() const { return m_loadEventFinished; }
1030 virtual bool isContextThread() const;
1031 virtual bool isJSExecutionForbidden() const { return false; }
1033 bool containsValidityStyleRules() const { return m_containsValidityStyleRules; }
1034 void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; }
1036 void enqueueWindowEvent(PassRefPtr<Event>);
1037 void enqueueDocumentEvent(PassRefPtr<Event>);
1038 void enqueuePageshowEvent(PageshowEventPersistence);
1039 void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
1040 void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
1041 virtual DocumentEventQueue* eventQueue() const { return m_eventQueue.get(); }
1043 void addMediaCanStartListener(MediaCanStartListener*);
1044 void removeMediaCanStartListener(MediaCanStartListener*);
1045 MediaCanStartListener* takeAnyMediaCanStartListener();
1047 const QualifiedName& idAttributeName() const { return m_idAttributeName; }
1049 #if ENABLE(FULLSCREEN_API)
1050 bool webkitIsFullScreen() const { return m_fullScreenElement.get(); }
1051 bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenElement.get() && m_areKeysEnabledInFullScreen; }
1052 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
1054 enum FullScreenCheckType {
1055 EnforceIFrameAllowFullScreenRequirement,
1056 ExemptIFrameAllowFullScreenRequirement,
1059 void requestFullScreenForElement(Element*, unsigned short flags, FullScreenCheckType);
1060 void webkitCancelFullScreen();
1062 void webkitWillEnterFullScreenForElement(Element*);
1063 void webkitDidEnterFullScreenForElement(Element*);
1064 void webkitWillExitFullScreenForElement(Element*);
1065 void webkitDidExitFullScreenForElement(Element*);
1067 void setFullScreenRenderer(RenderFullScreen*);
1068 RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer; }
1069 void fullScreenRendererDestroyed();
1071 void setFullScreenRendererSize(const IntSize&);
1072 void setFullScreenRendererBackgroundColor(Color);
1074 void fullScreenChangeDelayTimerFired(Timer<Document>*);
1075 bool fullScreenIsAllowedForElement(Element*) const;
1076 void fullScreenElementRemoved();
1077 void removeFullScreenElementOfSubtree(Node*, bool amongChildrenOnly = false);
1078 bool isAnimatingFullScreen() const;
1079 void setAnimatingFullScreen(bool);
1082 bool webkitFullscreenEnabled() const;
1083 Element* webkitFullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().get() : 0; }
1084 void webkitExitFullscreen();
1087 #if ENABLE(POINTER_LOCK)
1088 void webkitExitPointerLock();
1089 Element* webkitPointerLockElement() const;
1092 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
1093 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
1094 void decrementLoadEventDelayCount();
1095 bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
1097 #if ENABLE(TOUCH_EVENTS)
1098 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;
1101 const DocumentTiming* timing() const { return &m_documentTiming; }
1103 #if ENABLE(REQUEST_ANIMATION_FRAME)
1104 int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
1105 void cancelAnimationFrame(int id);
1106 void serviceScriptedAnimations(double monotonicAnimationStartTime);
1109 virtual EventTarget* errorEventTarget();
1110 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>);
1112 void initDNSPrefetch();
1114 unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
1115 void didAddWheelEventHandler();
1116 void didRemoveWheelEventHandler();
1118 #if ENABLE(TOUCH_EVENTS)
1119 unsigned touchEventHandlerCount() const { return m_touchEventHandlerCount; }
1121 unsigned touchEventHandlerCount() const { return 0; }
1124 void didAddTouchEventHandler();
1125 void didRemoveTouchEventHandler();
1127 bool visualUpdatesAllowed() const { return m_visualUpdatesAllowed; }
1129 #if ENABLE(MICRODATA)
1130 PassRefPtr<NodeList> getItems(const String& typeNames);
1133 bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
1135 void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
1136 void resumeScheduledTasks();
1138 IntSize viewportSize() const;
1140 #if ENABLE(LINK_PRERENDER)
1141 Prerenderer* prerenderer() { return m_prerenderer.get(); }
1144 #if ENABLE(TEXT_AUTOSIZING)
1145 TextAutosizer* textAutosizer() { return m_textAutosizer.get(); }
1148 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, RenderObject*);
1149 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, RenderObject*);
1151 void setContextFeatures(PassRefPtr<ContextFeatures>);
1152 ContextFeatures* contextFeatures() { return m_contextFeatures.get(); }
1154 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
1156 PassRefPtr<ElementAttributeData> cachedImmutableAttributeData(const Vector<Attribute>&);
1158 void didRemoveAllPendingStylesheet();
1159 void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
1160 void clearStyleResolver();
1161 void notifySeamlessChildDocumentsOfStylesheetUpdate() const;
1163 bool inStyleRecalc() { return m_inStyleRecalc; }
1165 // Return a Locale for the default locale if the argument is null or empty.
1166 Locale& getCachedLocale(const AtomicString& locale = nullAtom);
1168 #if ENABLE(DIALOG_ELEMENT)
1169 void addToTopLayer(Element*);
1170 void removeFromTopLayer(Element*);
1171 const Vector<RefPtr<Element> >& topLayerElements() const { return m_topLayerElements; }
1175 Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
1177 virtual void didUpdateSecurityOrigin() OVERRIDE;
1179 void clearXMLVersion() { m_xmlVersion = String(); }
1183 friend class IgnoreDestructiveWriteCountIncrementer;
1185 void removedLastRef();
1187 void detachParser();
1189 typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
1190 void processArguments(const String& features, void* data, ArgumentsCallback);
1192 virtual bool isDocument() const { return true; }
1194 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
1196 virtual String nodeName() const;
1197 virtual NodeType nodeType() const;
1198 virtual bool childTypeAllowed(NodeType) const;
1199 virtual PassRefPtr<Node> cloneNode(bool deep);
1201 virtual void refScriptExecutionContext() { ref(); }
1202 virtual void derefScriptExecutionContext() { deref(); }
1204 virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls.
1205 virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
1207 virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);
1209 virtual double minimumTimerInterval() const;
1211 virtual double timerAlignmentInterval() const;
1213 void updateTitle(const StringWithDirection&);
1214 void updateFocusAppearanceTimerFired(Timer<Document>*);
1215 void updateBaseURL();
1217 void buildAccessKeyMap(TreeScope* root);
1219 void createStyleResolver();
1221 void seamlessParentUpdatedStylesheets();
1223 PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
1225 void loadEventDelayTimerFired(Timer<Document>*);
1227 void pendingTasksTimerFired(Timer<Document>*);
1229 static void didReceiveTask(void*);
1231 template <typename CharacterType>
1232 void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
1234 #if ENABLE(PAGE_VISIBILITY_API)
1235 PageVisibilityState visibilityState() const;
1238 PassRefPtr<HTMLCollection> ensureCachedCollection(CollectionType);
1240 #if ENABLE(FULLSCREEN_API)
1241 void clearFullscreenElementStack();
1242 void popFullscreenElementStack();
1243 void pushFullscreenElementStack(Element*);
1244 void addDocumentToFullScreenChangeEventQueue(Document*);
1247 void setVisualUpdatesAllowed(ReadyState);
1248 void setVisualUpdatesAllowed(bool);
1249 void visualUpdatesSuppressionTimerFired(Timer<Document>*);
1251 void addListenerType(ListenerType listenerType) { m_listenerTypes |= listenerType; }
1252 void addMutationEventListenerTypeIfEnabled(ListenerType);
1254 int m_guardRefCount;
1256 OwnPtr<StyleResolver> m_styleResolver;
1257 bool m_didCalculateStyleResolver;
1258 bool m_hasDirtyStyleResolver;
1259 bool m_hasNodesWithPlaceholderStyle;
1260 bool m_needsNotifyRemoveAllPendingStylesheet;
1261 // But sometimes you need to ignore pending stylesheet count to
1262 // force an immediate layout when requested by JS.
1263 bool m_ignorePendingStylesheets;
1265 // If we do ignore the pending stylesheet count, then we need to add a boolean
1266 // to track that this happened so that we can do a full repaint when the stylesheets
1267 // do eventually load.
1268 PendingSheetLayout m_pendingSheetLayout;
1271 RefPtr<DOMWindow> m_domWindow;
1273 RefPtr<CachedResourceLoader> m_cachedResourceLoader;
1274 RefPtr<DocumentParser> m_parser;
1275 RefPtr<ContextFeatures> m_contextFeatures;
1280 KURL m_url; // Document.URL: The URL from which this document was retrieved.
1281 KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
1282 KURL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
1283 KURL m_baseElementURL; // The URL set by the <base> element.
1284 KURL m_cookieURL; // The URL to use for cookie access.
1285 KURL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
1287 // Document.documentURI:
1288 // Although URL-like, Document.documentURI can actually be set to any
1289 // string by content. Document.documentURI affects m_baseURL unless the
1290 // document contains a <base> element, in which case the <base> element
1291 // takes precedence.
1293 // This property is read-only from JavaScript, but writable from Objective C.
1294 String m_documentURI;
1296 String m_baseTarget;
1298 RefPtr<DocumentType> m_docType;
1299 OwnPtr<DOMImplementation> m_implementation;
1301 RefPtr<CSSStyleSheet> m_elemSheet;
1304 bool m_paginatedForScreen;
1306 bool m_ignoreAutofocus;
1308 CompatibilityMode m_compatibilityMode;
1309 bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
1313 RefPtr<Node> m_focusedNode;
1314 RefPtr<Node> m_hoverNode;
1315 RefPtr<Node> m_activeNode;
1316 RefPtr<Element> m_documentElement;
1318 uint64_t m_domTreeVersion;
1319 static uint64_t s_globalTreeVersion;
1321 HashSet<NodeIterator*> m_nodeIterators;
1322 HashSet<Range*> m_ranges;
1324 unsigned short m_listenerTypes;
1326 #if ENABLE(MUTATION_OBSERVERS)
1327 MutationObserverOptions m_mutationObserverTypes;
1331 OwnPtr<DocumentStyleSheetCollection> m_styleSheetCollection;
1332 RefPtr<StyleSheetList> m_styleSheetList;
1334 OwnPtr<FormController> m_formController;
1337 Color m_visitedLinkColor;
1338 Color m_activeLinkColor;
1340 bool m_loadingSheet;
1341 bool m_visuallyOrdered;
1342 ReadyState m_readyState;
1345 Timer<Document> m_styleRecalcTimer;
1346 bool m_pendingStyleRecalcShouldForce;
1347 bool m_inStyleRecalc;
1348 bool m_closeAfterStyleRecalc;
1350 bool m_gotoAnchorNeededAfterStylesheetsLoad;
1351 bool m_isDNSPrefetchEnabled;
1352 bool m_haveExplicitlyDisabledDNSPrefetch;
1353 bool m_frameElementsShouldIgnoreScrolling;
1354 bool m_containsValidityStyleRules;
1355 bool m_updateFocusAppearanceRestoresSelection;
1357 // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
1358 unsigned m_ignoreDestructiveWriteCount;
1360 StringWithDirection m_title;
1361 StringWithDirection m_rawTitle;
1362 bool m_titleSetExplicitly;
1363 RefPtr<Element> m_titleElement;
1365 OwnPtr<RenderArena> m_renderArena;
1367 OwnPtr<AXObjectCache> m_axObjectCache;
1368 OwnPtr<DocumentMarkerController> m_markers;
1370 Timer<Document> m_updateFocusAppearanceTimer;
1372 Element* m_cssTarget;
1374 // FIXME: Merge these 2 variables into an enum. Also, FrameLoader::m_didCallImplicitClose
1375 // is almost a duplication of this data, so that should probably get merged in too.
1376 // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
1377 // and should be merged.
1378 bool m_processingLoadEvent;
1379 bool m_loadEventFinished;
1381 RefPtr<SerializedScriptValue> m_pendingStateObject;
1383 bool m_overMinimumLayoutThreshold;
1385 OwnPtr<ScriptRunner> m_scriptRunner;
1388 OwnPtr<TransformSource> m_transformSource;
1389 RefPtr<Document> m_transformSourceDocument;
1392 int m_docID; // A unique document identifier used for things like document-specific mapped attributes.
1394 String m_xmlEncoding;
1395 String m_xmlVersion;
1396 unsigned m_xmlStandalone : 2;
1397 unsigned m_hasXMLDeclaration : 1;
1399 String m_contentLanguage;
1401 RenderObject* m_savedRenderer;
1403 RefPtr<TextResourceDecoder> m_decoder;
1405 InheritedBool m_designMode;
1407 HashSet<LiveNodeListBase*> m_listsInvalidatedAtDocument;
1408 unsigned m_nodeListCounts[numNodeListInvalidationTypes];
1410 RefPtr<XPathEvaluator> m_xpathEvaluator;
1413 OwnPtr<SVGDocumentExtensions> m_svgExtensions;
1416 #if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
1417 Vector<AnnotatedRegionValue> m_annotatedRegions;
1418 bool m_hasAnnotatedRegions;
1419 bool m_annotatedRegionsDirty;
1422 HashMap<String, RefPtr<HTMLCanvasElement> > m_cssCanvasElements;
1424 bool m_createRenderers;
1426 Vector<IconURL> m_iconURLs;
1428 HashSet<Element*> m_documentSuspensionCallbackElements;
1429 HashSet<Element*> m_mediaVolumeCallbackElements;
1430 HashSet<Element*> m_privateBrowsingStateChangedElements;
1432 HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
1433 bool m_accessKeyMapValid;
1435 OwnPtr<SelectorQueryCache> m_selectorQueryCache;
1437 bool m_useSecureKeyboardEntryWhenActive;
1442 bool m_isViewSource;
1443 bool m_sawElementsInKnownNamespaces;
1444 bool m_isSrcdocDocument;
1446 RenderObject* m_renderer;
1447 RefPtr<DocumentEventQueue> m_eventQueue;
1449 RefPtr<DocumentWeakReference> m_weakReference;
1451 HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
1453 QualifiedName m_idAttributeName;
1455 #if ENABLE(FULLSCREEN_API)
1456 bool m_areKeysEnabledInFullScreen;
1457 RefPtr<Element> m_fullScreenElement;
1458 Vector<RefPtr<Element> > m_fullScreenElementStack;
1459 RenderFullScreen* m_fullScreenRenderer;
1460 Timer<Document> m_fullScreenChangeDelayTimer;
1461 Deque<RefPtr<Node> > m_fullScreenChangeEventTargetQueue;
1462 Deque<RefPtr<Node> > m_fullScreenErrorEventTargetQueue;
1463 bool m_isAnimatingFullScreen;
1464 LayoutRect m_savedPlaceholderFrameRect;
1465 RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;
1468 #if ENABLE(DIALOG_ELEMENT)
1469 Vector<RefPtr<Element> > m_topLayerElements;
1472 int m_loadEventDelayCount;
1473 Timer<Document> m_loadEventDelayTimer;
1475 ViewportArguments m_viewportArguments;
1477 ReferrerPolicy m_referrerPolicy;
1479 bool m_directionSetOnDocumentElement;
1480 bool m_writingModeSetOnDocumentElement;
1482 DocumentTiming m_documentTiming;
1483 RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
1484 bool m_writeRecursionIsTooDeep;
1485 unsigned m_writeRecursionDepth;
1487 unsigned m_wheelEventHandlerCount;
1488 #if ENABLE(TOUCH_EVENTS)
1489 unsigned m_touchEventHandlerCount;
1492 #if ENABLE(REQUEST_ANIMATION_FRAME)
1493 RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
1496 Timer<Document> m_pendingTasksTimer;
1497 Vector<OwnPtr<Task> > m_pendingTasks;
1499 #if ENABLE(LINK_PRERENDER)
1500 OwnPtr<Prerenderer> m_prerenderer;
1503 #if ENABLE(TEXT_AUTOSIZING)
1504 OwnPtr<TextAutosizer> m_textAutosizer;
1507 bool m_scheduledTasksAreSuspended;
1509 bool m_visualUpdatesAllowed;
1510 Timer<Document> m_visualUpdatesSuppressionTimer;
1512 RefPtr<NamedFlowCollection> m_namedFlows;
1514 #if ENABLE(CSP_NEXT)
1515 RefPtr<DOMSecurityPolicy> m_domSecurityPolicy;
1518 ImmutableAttributeDataCache m_immutableAttributeDataCache;
1521 bool m_didDispatchViewportPropertiesChanged;
1524 typedef HashMap<AtomicString, OwnPtr<Locale> > LocaleIdentifierToLocaleMap;
1525 LocaleIdentifierToLocaleMap m_localeCache;
1528 inline void Document::notifyRemovePendingSheetIfNeeded()
1530 if (m_needsNotifyRemoveAllPendingStylesheet)
1531 didRemoveAllPendingStylesheet();
1534 // Put these methods here, because they require the Document definition, but we really want to inline them.
1536 inline bool Node::isDocumentNode() const
1538 return this == m_document;
1541 inline TreeScope* Node::treeScope() const
1543 return hasRareData() ? m_data.m_rareData->treeScope() : documentInternal();
1546 inline Node::Node(Document* document, ConstructionType type)
1548 , m_document(document)
1553 document->guardRef();
1554 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
1555 trackForDebugging();
1557 InspectorCounters::incrementCounter(InspectorCounters::NodeCounter);
1560 Node* eventTargetNodeForDocument(Document*);
1562 } // namespace WebCore
1564 #endif // Document_h