1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/public/nsIDocument.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2686 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef nsIDocument_h___ 1.9 +#define nsIDocument_h___ 1.10 + 1.11 +#include "mozFlushType.h" // for enum 1.12 +#include "nsAutoPtr.h" // for member 1.13 +#include "nsCOMArray.h" // for member 1.14 +#include "nsCRT.h" // for NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW 1.15 +#include "nsCompatibility.h" // for member 1.16 +#include "nsCOMPtr.h" // for member 1.17 +#include "nsGkAtoms.h" // for static class members 1.18 +#include "nsIDocumentObserver.h" // for typedef (nsUpdateType) 1.19 +#include "nsILoadGroup.h" // for member (in nsCOMPtr) 1.20 +#include "nsINode.h" // for base class 1.21 +#include "nsIScriptGlobalObject.h" // for member (in nsCOMPtr) 1.22 +#include "nsPIDOMWindow.h" // for use in inline functions 1.23 +#include "nsPropertyTable.h" // for member 1.24 +#include "nsTHashtable.h" // for member 1.25 +#include "nsWeakReference.h" 1.26 +#include "mozilla/dom/DocumentBinding.h" 1.27 +#include "mozilla/WeakPtr.h" 1.28 +#include "Units.h" 1.29 +#include "nsExpirationTracker.h" 1.30 +#include "nsClassHashtable.h" 1.31 + 1.32 +class imgIRequest; 1.33 +class nsAString; 1.34 +class nsBindingManager; 1.35 +class nsCSSStyleSheet; 1.36 +class nsIDocShell; 1.37 +class nsDocShell; 1.38 +class nsDOMNavigationTiming; 1.39 +class nsFrameLoader; 1.40 +class nsHTMLCSSStyleSheet; 1.41 +class nsHTMLDocument; 1.42 +class nsHTMLStyleSheet; 1.43 +class nsIAtom; 1.44 +class nsIBFCacheEntry; 1.45 +class nsIBoxObject; 1.46 +class nsIChannel; 1.47 +class nsIContent; 1.48 +class nsIContentSink; 1.49 +class nsIDocShell; 1.50 +class nsIDocumentEncoder; 1.51 +class nsIDocumentObserver; 1.52 +class nsIDOMDocument; 1.53 +class nsIDOMDocumentFragment; 1.54 +class nsIDOMDocumentType; 1.55 +class nsIDOMElement; 1.56 +class nsIDOMNodeFilter; 1.57 +class nsIDOMNodeList; 1.58 +class nsIDOMXPathExpression; 1.59 +class nsIDOMXPathNSResolver; 1.60 +class nsIHTMLCollection; 1.61 +class nsILayoutHistoryState; 1.62 +class nsILoadContext; 1.63 +class nsIObjectLoadingContent; 1.64 +class nsIObserver; 1.65 +class nsIPresShell; 1.66 +class nsIPrincipal; 1.67 +class nsIRequest; 1.68 +class nsIStreamListener; 1.69 +class nsIStructuredCloneContainer; 1.70 +class nsIStyleRule; 1.71 +class nsIStyleSheet; 1.72 +class nsIURI; 1.73 +class nsIVariant; 1.74 +class nsViewManager; 1.75 +class nsPresContext; 1.76 +class nsRange; 1.77 +class nsScriptLoader; 1.78 +class nsSMILAnimationController; 1.79 +class nsStyleSet; 1.80 +class nsTextNode; 1.81 +class nsWindowSizes; 1.82 +class nsSmallVoidArray; 1.83 +class nsDOMCaretPosition; 1.84 +class nsViewportInfo; 1.85 +class nsIGlobalObject; 1.86 +class nsCSSSelectorList; 1.87 + 1.88 +namespace mozilla { 1.89 +class ErrorResult; 1.90 +class EventStates; 1.91 + 1.92 +namespace css { 1.93 +class Loader; 1.94 +class ImageLoader; 1.95 +} // namespace css 1.96 + 1.97 +namespace dom { 1.98 +class Attr; 1.99 +class CDATASection; 1.100 +class Comment; 1.101 +struct CustomElementDefinition; 1.102 +class DocumentFragment; 1.103 +class DocumentType; 1.104 +class DOMImplementation; 1.105 +class DOMStringList; 1.106 +class Element; 1.107 +struct ElementRegistrationOptions; 1.108 +class Event; 1.109 +class EventTarget; 1.110 +class FrameRequestCallback; 1.111 +class HTMLBodyElement; 1.112 +struct LifecycleCallbackArgs; 1.113 +class Link; 1.114 +class GlobalObject; 1.115 +class NodeFilter; 1.116 +class NodeIterator; 1.117 +class ProcessingInstruction; 1.118 +class StyleSheetList; 1.119 +class Touch; 1.120 +class TouchList; 1.121 +class TreeWalker; 1.122 +class UndoManager; 1.123 +class XPathEvaluator; 1.124 +template<typename> class OwningNonNull; 1.125 +template<typename> class Sequence; 1.126 + 1.127 +template<typename, typename> class CallbackObjectHolder; 1.128 +typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder; 1.129 +} // namespace dom 1.130 +} // namespace mozilla 1.131 + 1.132 +#define NS_IDOCUMENT_IID \ 1.133 +{ 0x906d05e7, 0x39af, 0x4ff0, \ 1.134 + { 0xbc, 0xcd, 0x30, 0x0c, 0x7f, 0xeb, 0x86, 0x21 } } 1.135 + 1.136 +// Flag for AddStyleSheet(). 1.137 +#define NS_STYLESHEET_FROM_CATALOG (1 << 0) 1.138 + 1.139 +// Enum for requesting a particular type of document when creating a doc 1.140 +enum DocumentFlavor { 1.141 + DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant 1.142 + DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true 1.143 + DocumentFlavorSVG // SVGDocument 1.144 +}; 1.145 + 1.146 +// Document states 1.147 + 1.148 +// RTL locale: specific to the XUL localedir attribute 1.149 +#define NS_DOCUMENT_STATE_RTL_LOCALE NS_DEFINE_EVENT_STATE_MACRO(0) 1.150 +// Window activation status 1.151 +#define NS_DOCUMENT_STATE_WINDOW_INACTIVE NS_DEFINE_EVENT_STATE_MACRO(1) 1.152 + 1.153 +// Some function forward-declarations 1.154 +class nsContentList; 1.155 + 1.156 +already_AddRefed<nsContentList> 1.157 +NS_GetContentList(nsINode* aRootNode, 1.158 + int32_t aMatchNameSpaceId, 1.159 + const nsAString& aTagname); 1.160 +//---------------------------------------------------------------------- 1.161 + 1.162 +// Document interface. This is implemented by all document objects in 1.163 +// Gecko. 1.164 +class nsIDocument : public nsINode 1.165 +{ 1.166 + typedef mozilla::dom::GlobalObject GlobalObject; 1.167 +public: 1.168 + typedef mozilla::dom::Element Element; 1.169 + 1.170 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID) 1.171 + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW 1.172 + 1.173 +#ifdef MOZILLA_INTERNAL_API 1.174 + nsIDocument(); 1.175 +#endif 1.176 + 1.177 + /** 1.178 + * Let the document know that we're starting to load data into it. 1.179 + * @param aCommand The parser command. Must not be null. 1.180 + * XXXbz It's odd to have that here. 1.181 + * @param aChannel The channel the data will come from. The channel must be 1.182 + * able to report its Content-Type. 1.183 + * @param aLoadGroup The loadgroup this document should use from now on. 1.184 + * Note that the document might not be the only thing using 1.185 + * this loadgroup. 1.186 + * @param aContainer The container this document is in. This may be null. 1.187 + * XXXbz maybe we should make it more explicit (eg make the 1.188 + * container an nsIWebNavigation or nsIDocShell or 1.189 + * something)? 1.190 + * @param [out] aDocListener the listener to pump data from the channel into. 1.191 + * Generally this will be the parser this document 1.192 + * sets up, or some sort of data-handler for media 1.193 + * documents. 1.194 + * @param aReset whether the document should call Reset() on itself. If this 1.195 + * is false, the document will NOT set its principal to the 1.196 + * channel's owner, will not clear any event listeners that are 1.197 + * already set on it, etc. 1.198 + * @param aSink The content sink to use for the data. If this is null and 1.199 + * the document needs a content sink, it will create one based 1.200 + * on whatever it knows about the data it's going to load. 1.201 + * This MUST be null if the underlying document is an HTML 1.202 + * document. Even in the XML case, please don't add new calls 1.203 + * with non-null sink. 1.204 + * 1.205 + * Once this has been called, the document will return false for 1.206 + * MayStartLayout() until SetMayStartLayout(true) is called on it. Making 1.207 + * sure this happens is the responsibility of the caller of 1.208 + * StartDocumentLoad(). 1.209 + */ 1.210 + virtual nsresult StartDocumentLoad(const char* aCommand, 1.211 + nsIChannel* aChannel, 1.212 + nsILoadGroup* aLoadGroup, 1.213 + nsISupports* aContainer, 1.214 + nsIStreamListener **aDocListener, 1.215 + bool aReset, 1.216 + nsIContentSink* aSink = nullptr) = 0; 1.217 + virtual void StopDocumentLoad() = 0; 1.218 + 1.219 + /** 1.220 + * Signal that the document title may have changed 1.221 + * (see nsDocument::GetTitle). 1.222 + * @param aBoundTitleElement true if an HTML or SVG <title> element 1.223 + * has just been bound to the document. 1.224 + */ 1.225 + virtual void NotifyPossibleTitleChange(bool aBoundTitleElement) = 0; 1.226 + 1.227 + /** 1.228 + * Return the URI for the document. May return null. 1.229 + * 1.230 + * The value returned corresponds to the "document's current address" in 1.231 + * HTML5. As such, it may change over the lifetime of the document, for 1.232 + * instance as a result of a call to pushState() or replaceState(). 1.233 + */ 1.234 + nsIURI* GetDocumentURI() const 1.235 + { 1.236 + return mDocumentURI; 1.237 + } 1.238 + 1.239 + /** 1.240 + * Return the original URI of the document. This is the same as the 1.241 + * document's URI unless history.pushState() or replaceState() is invoked on 1.242 + * the document. 1.243 + * 1.244 + * This method corresponds to the "document's address" in HTML5 and, once 1.245 + * set, doesn't change over the lifetime of the document. 1.246 + */ 1.247 + nsIURI* GetOriginalURI() const 1.248 + { 1.249 + return mOriginalURI; 1.250 + } 1.251 + 1.252 + /** 1.253 + * Set the URI for the document. This also sets the document's original URI, 1.254 + * if it's null. 1.255 + */ 1.256 + virtual void SetDocumentURI(nsIURI* aURI) = 0; 1.257 + 1.258 + /** 1.259 + * Set the URI for the document loaded via XHR, when accessed from 1.260 + * chrome privileged script. 1.261 + */ 1.262 + virtual void SetChromeXHRDocURI(nsIURI* aURI) = 0; 1.263 + 1.264 + /** 1.265 + * Set the base URI for the document loaded via XHR, when accessed from 1.266 + * chrome privileged script. 1.267 + */ 1.268 + virtual void SetChromeXHRDocBaseURI(nsIURI* aURI) = 0; 1.269 + 1.270 + /** 1.271 + * Set the principal responsible for this document. 1.272 + */ 1.273 + virtual void SetPrincipal(nsIPrincipal *aPrincipal) = 0; 1.274 + 1.275 + /** 1.276 + * Return the LoadGroup for the document. May return null. 1.277 + */ 1.278 + already_AddRefed<nsILoadGroup> GetDocumentLoadGroup() const 1.279 + { 1.280 + nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup); 1.281 + return group.forget(); 1.282 + } 1.283 + 1.284 + /** 1.285 + * Return the base URI for relative URIs in the document (the document uri 1.286 + * unless it's overridden by SetBaseURI, HTML <base> tags, etc.). The 1.287 + * returned URI could be null if there is no document URI. If the document 1.288 + * is a srcdoc document, return the parent document's base URL. 1.289 + */ 1.290 + nsIURI* GetDocBaseURI() const 1.291 + { 1.292 + if (mIsSrcdocDocument && mParentDocument) { 1.293 + return mParentDocument->GetDocBaseURI(); 1.294 + } 1.295 + return mDocumentBaseURI ? mDocumentBaseURI : mDocumentURI; 1.296 + } 1.297 + virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE; 1.298 + 1.299 + virtual nsresult SetBaseURI(nsIURI* aURI) = 0; 1.300 + 1.301 + /** 1.302 + * Get/Set the base target of a link in a document. 1.303 + */ 1.304 + virtual void GetBaseTarget(nsAString &aBaseTarget) = 0; 1.305 + void SetBaseTarget(const nsString& aBaseTarget) { 1.306 + mBaseTarget = aBaseTarget; 1.307 + } 1.308 + 1.309 + /** 1.310 + * Return a standard name for the document's character set. 1.311 + */ 1.312 + const nsCString& GetDocumentCharacterSet() const 1.313 + { 1.314 + return mCharacterSet; 1.315 + } 1.316 + 1.317 + /** 1.318 + * Set the document's character encoding. |aCharSetID| should be canonical. 1.319 + * That is, callers are responsible for the charset alias resolution. 1.320 + */ 1.321 + virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0; 1.322 + 1.323 + int32_t GetDocumentCharacterSetSource() const 1.324 + { 1.325 + return mCharacterSetSource; 1.326 + } 1.327 + 1.328 + // This method MUST be called before SetDocumentCharacterSet if 1.329 + // you're planning to call both. 1.330 + void SetDocumentCharacterSetSource(int32_t aCharsetSource) 1.331 + { 1.332 + mCharacterSetSource = aCharsetSource; 1.333 + } 1.334 + 1.335 + /** 1.336 + * Add an observer that gets notified whenever the charset changes. 1.337 + */ 1.338 + virtual nsresult AddCharSetObserver(nsIObserver* aObserver) = 0; 1.339 + 1.340 + /** 1.341 + * Remove a charset observer. 1.342 + */ 1.343 + virtual void RemoveCharSetObserver(nsIObserver* aObserver) = 0; 1.344 + 1.345 + /** 1.346 + * This gets fired when the element that an id refers to changes. 1.347 + * This fires at difficult times. It is generally not safe to do anything 1.348 + * which could modify the DOM in any way. Use 1.349 + * nsContentUtils::AddScriptRunner. 1.350 + * @return true to keep the callback in the callback set, false 1.351 + * to remove it. 1.352 + */ 1.353 + typedef bool (* IDTargetObserver)(Element* aOldElement, 1.354 + Element* aNewelement, void* aData); 1.355 + 1.356 + /** 1.357 + * Add an IDTargetObserver for a specific ID. The IDTargetObserver 1.358 + * will be fired whenever the content associated with the ID changes 1.359 + * in the future. If aForImage is true, mozSetImageElement can override 1.360 + * what content is associated with the ID. In that case the IDTargetObserver 1.361 + * will be notified at those times when the result of LookupImageElement 1.362 + * changes. 1.363 + * At most one (aObserver, aData, aForImage) triple can be 1.364 + * registered for each ID. 1.365 + * @return the content currently associated with the ID. 1.366 + */ 1.367 + virtual Element* AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver, 1.368 + void* aData, bool aForImage) = 0; 1.369 + /** 1.370 + * Remove the (aObserver, aData, aForImage) triple for a specific ID, if 1.371 + * registered. 1.372 + */ 1.373 + virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver, 1.374 + void* aData, bool aForImage) = 0; 1.375 + 1.376 + /** 1.377 + * Get the Content-Type of this document. 1.378 + * (This will always return NS_OK, but has this signature to be compatible 1.379 + * with nsIDOMDocument::GetContentType()) 1.380 + */ 1.381 + NS_IMETHOD GetContentType(nsAString& aContentType) = 0; 1.382 + 1.383 + /** 1.384 + * Set the Content-Type of this document. 1.385 + */ 1.386 + virtual void SetContentType(const nsAString& aContentType) = 0; 1.387 + 1.388 + /** 1.389 + * Return the language of this document. 1.390 + */ 1.391 + void GetContentLanguage(nsAString& aContentLanguage) const 1.392 + { 1.393 + CopyASCIItoUTF16(mContentLanguage, aContentLanguage); 1.394 + } 1.395 + 1.396 + // The states BidiEnabled and MathMLEnabled should persist across multiple views 1.397 + // (screen, print) of the same document. 1.398 + 1.399 + /** 1.400 + * Check if the document contains bidi data. 1.401 + * If so, we have to apply the Unicode Bidi Algorithm. 1.402 + */ 1.403 + bool GetBidiEnabled() const 1.404 + { 1.405 + return mBidiEnabled; 1.406 + } 1.407 + 1.408 + /** 1.409 + * Indicate the document contains bidi data. 1.410 + * Currently, we cannot disable bidi, because once bidi is enabled, 1.411 + * it affects a frame model irreversibly, and plays even though 1.412 + * the document no longer contains bidi data. 1.413 + */ 1.414 + void SetBidiEnabled() 1.415 + { 1.416 + mBidiEnabled = true; 1.417 + } 1.418 + 1.419 + /** 1.420 + * Check if the document contains (or has contained) any MathML elements. 1.421 + */ 1.422 + bool GetMathMLEnabled() const 1.423 + { 1.424 + return mMathMLEnabled; 1.425 + } 1.426 + 1.427 + void SetMathMLEnabled() 1.428 + { 1.429 + mMathMLEnabled = true; 1.430 + } 1.431 + 1.432 + /** 1.433 + * Ask this document whether it's the initial document in its window. 1.434 + */ 1.435 + bool IsInitialDocument() const 1.436 + { 1.437 + return mIsInitialDocumentInWindow; 1.438 + } 1.439 + 1.440 + /** 1.441 + * Tell this document that it's the initial document in its window. See 1.442 + * comments on mIsInitialDocumentInWindow for when this should be called. 1.443 + */ 1.444 + void SetIsInitialDocument(bool aIsInitialDocument) 1.445 + { 1.446 + mIsInitialDocumentInWindow = aIsInitialDocument; 1.447 + } 1.448 + 1.449 + 1.450 + /** 1.451 + * Get the bidi options for this document. 1.452 + * @see nsBidiUtils.h 1.453 + */ 1.454 + uint32_t GetBidiOptions() const 1.455 + { 1.456 + return mBidiOptions; 1.457 + } 1.458 + 1.459 + /** 1.460 + * Set the bidi options for this document. This just sets the bits; 1.461 + * callers are expected to take action as needed if they want this 1.462 + * change to actually change anything immediately. 1.463 + * @see nsBidiUtils.h 1.464 + */ 1.465 + void SetBidiOptions(uint32_t aBidiOptions) 1.466 + { 1.467 + mBidiOptions = aBidiOptions; 1.468 + } 1.469 + 1.470 + /** 1.471 + * Get the has mixed active content loaded flag for this document. 1.472 + */ 1.473 + bool GetHasMixedActiveContentLoaded() 1.474 + { 1.475 + return mHasMixedActiveContentLoaded; 1.476 + } 1.477 + 1.478 + /** 1.479 + * Set the has mixed active content loaded flag for this document. 1.480 + */ 1.481 + void SetHasMixedActiveContentLoaded(bool aHasMixedActiveContentLoaded) 1.482 + { 1.483 + mHasMixedActiveContentLoaded = aHasMixedActiveContentLoaded; 1.484 + } 1.485 + 1.486 + /** 1.487 + * Get mixed active content blocked flag for this document. 1.488 + */ 1.489 + bool GetHasMixedActiveContentBlocked() 1.490 + { 1.491 + return mHasMixedActiveContentBlocked; 1.492 + } 1.493 + 1.494 + /** 1.495 + * Set the mixed active content blocked flag for this document. 1.496 + */ 1.497 + void SetHasMixedActiveContentBlocked(bool aHasMixedActiveContentBlocked) 1.498 + { 1.499 + mHasMixedActiveContentBlocked = aHasMixedActiveContentBlocked; 1.500 + } 1.501 + 1.502 + /** 1.503 + * Get the has mixed display content loaded flag for this document. 1.504 + */ 1.505 + bool GetHasMixedDisplayContentLoaded() 1.506 + { 1.507 + return mHasMixedDisplayContentLoaded; 1.508 + } 1.509 + 1.510 + /** 1.511 + * Set the has mixed display content loaded flag for this document. 1.512 + */ 1.513 + void SetHasMixedDisplayContentLoaded(bool aHasMixedDisplayContentLoaded) 1.514 + { 1.515 + mHasMixedDisplayContentLoaded = aHasMixedDisplayContentLoaded; 1.516 + } 1.517 + 1.518 + /** 1.519 + * Get mixed display content blocked flag for this document. 1.520 + */ 1.521 + bool GetHasMixedDisplayContentBlocked() 1.522 + { 1.523 + return mHasMixedDisplayContentBlocked; 1.524 + } 1.525 + 1.526 + /** 1.527 + * Set the mixed display content blocked flag for this document. 1.528 + */ 1.529 + void SetHasMixedDisplayContentBlocked(bool aHasMixedDisplayContentBlocked) 1.530 + { 1.531 + mHasMixedDisplayContentBlocked = aHasMixedDisplayContentBlocked; 1.532 + } 1.533 + 1.534 + /** 1.535 + * Get the sandbox flags for this document. 1.536 + * @see nsSandboxFlags.h for the possible flags 1.537 + */ 1.538 + uint32_t GetSandboxFlags() const 1.539 + { 1.540 + return mSandboxFlags; 1.541 + } 1.542 + 1.543 + /** 1.544 + * Set the sandbox flags for this document. 1.545 + * @see nsSandboxFlags.h for the possible flags 1.546 + */ 1.547 + void SetSandboxFlags(uint32_t sandboxFlags) 1.548 + { 1.549 + mSandboxFlags = sandboxFlags; 1.550 + } 1.551 + 1.552 + /** 1.553 + * Access HTTP header data (this may also get set from other 1.554 + * sources, like HTML META tags). 1.555 + */ 1.556 + virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0; 1.557 + virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0; 1.558 + 1.559 + /** 1.560 + * Create a new presentation shell that will use aContext for its 1.561 + * presentation context (presentation contexts <b>must not</b> be 1.562 + * shared among multiple presentation shells). The caller of this 1.563 + * method is responsible for calling BeginObservingDocument() on the 1.564 + * presshell if the presshell should observe document mutations. 1.565 + */ 1.566 + virtual already_AddRefed<nsIPresShell> CreateShell(nsPresContext* aContext, 1.567 + nsViewManager* aViewManager, 1.568 + nsStyleSet* aStyleSet) = 0; 1.569 + virtual void DeleteShell() = 0; 1.570 + 1.571 + nsIPresShell* GetShell() const 1.572 + { 1.573 + return GetBFCacheEntry() ? nullptr : mPresShell; 1.574 + } 1.575 + 1.576 + void DisallowBFCaching() 1.577 + { 1.578 + NS_ASSERTION(!mBFCacheEntry, "We're already in the bfcache!"); 1.579 + mBFCacheDisallowed = true; 1.580 + } 1.581 + 1.582 + bool IsBFCachingAllowed() const 1.583 + { 1.584 + return !mBFCacheDisallowed; 1.585 + } 1.586 + 1.587 + void SetBFCacheEntry(nsIBFCacheEntry* aEntry) 1.588 + { 1.589 + NS_ASSERTION(IsBFCachingAllowed() || !aEntry, 1.590 + "You should have checked!"); 1.591 + 1.592 + mBFCacheEntry = aEntry; 1.593 + } 1.594 + 1.595 + nsIBFCacheEntry* GetBFCacheEntry() const 1.596 + { 1.597 + return mBFCacheEntry; 1.598 + } 1.599 + 1.600 + /** 1.601 + * Return the parent document of this document. Will return null 1.602 + * unless this document is within a compound document and has a 1.603 + * parent. Note that this parent chain may cross chrome boundaries. 1.604 + */ 1.605 + nsIDocument *GetParentDocument() const 1.606 + { 1.607 + return mParentDocument; 1.608 + } 1.609 + 1.610 + /** 1.611 + * Set the parent document of this document. 1.612 + */ 1.613 + void SetParentDocument(nsIDocument* aParent) 1.614 + { 1.615 + mParentDocument = aParent; 1.616 + } 1.617 + 1.618 + /** 1.619 + * Are plugins allowed in this document ? 1.620 + */ 1.621 + virtual nsresult GetAllowPlugins (bool* aAllowPlugins) = 0; 1.622 + 1.623 + /** 1.624 + * Set the sub document for aContent to aSubDoc. 1.625 + */ 1.626 + virtual nsresult SetSubDocumentFor(Element* aContent, 1.627 + nsIDocument* aSubDoc) = 0; 1.628 + 1.629 + /** 1.630 + * Get the sub document for aContent 1.631 + */ 1.632 + virtual nsIDocument *GetSubDocumentFor(nsIContent *aContent) const = 0; 1.633 + 1.634 + /** 1.635 + * Find the content node for which aDocument is a sub document. 1.636 + */ 1.637 + virtual Element* FindContentForSubDocument(nsIDocument* aDocument) const = 0; 1.638 + 1.639 + /** 1.640 + * Return the doctype for this document. 1.641 + */ 1.642 + mozilla::dom::DocumentType* GetDoctype() const; 1.643 + 1.644 + /** 1.645 + * Return the root element for this document. 1.646 + */ 1.647 + Element* GetRootElement() const; 1.648 + 1.649 + virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) = 0; 1.650 + 1.651 + /** 1.652 + * True iff this doc will ignore manual character encoding overrides. 1.653 + */ 1.654 + virtual bool WillIgnoreCharsetOverride() { 1.655 + return true; 1.656 + } 1.657 + 1.658 + /** 1.659 + * Return whether the document was created by a srcdoc iframe. 1.660 + */ 1.661 + bool IsSrcdocDocument() const { 1.662 + return mIsSrcdocDocument; 1.663 + } 1.664 + 1.665 + /** 1.666 + * Sets whether the document was created by a srcdoc iframe. 1.667 + */ 1.668 + void SetIsSrcdocDocument(bool aIsSrcdocDocument) { 1.669 + mIsSrcdocDocument = aIsSrcdocDocument; 1.670 + } 1.671 + 1.672 + /* 1.673 + * Gets the srcdoc string from within the channel (assuming both exist). 1.674 + * Returns a void string if this isn't a srcdoc document or if 1.675 + * the channel has not been set. 1.676 + */ 1.677 + nsresult GetSrcdocData(nsAString& aSrcdocData); 1.678 + 1.679 + bool DidDocumentOpen() { 1.680 + return mDidDocumentOpen; 1.681 + } 1.682 + 1.683 +protected: 1.684 + virtual Element *GetRootElementInternal() const = 0; 1.685 + 1.686 +private: 1.687 + class SelectorCacheKey 1.688 + { 1.689 + public: 1.690 + SelectorCacheKey(const nsAString& aString) : mKey(aString) 1.691 + { 1.692 + MOZ_COUNT_CTOR(SelectorCacheKey); 1.693 + } 1.694 + 1.695 + nsString mKey; 1.696 + nsExpirationState mState; 1.697 + 1.698 + nsExpirationState* GetExpirationState() { return &mState; } 1.699 + 1.700 + ~SelectorCacheKey() 1.701 + { 1.702 + MOZ_COUNT_DTOR(SelectorCacheKey); 1.703 + } 1.704 + }; 1.705 + 1.706 + class SelectorCacheKeyDeleter; 1.707 + 1.708 +public: 1.709 + class SelectorCache MOZ_FINAL 1.710 + : public nsExpirationTracker<SelectorCacheKey, 4> 1.711 + { 1.712 + public: 1.713 + SelectorCache(); 1.714 + 1.715 + // CacheList takes ownership of aSelectorList. 1.716 + void CacheList(const nsAString& aSelector, nsCSSSelectorList* aSelectorList); 1.717 + 1.718 + virtual void NotifyExpired(SelectorCacheKey* aSelector) MOZ_OVERRIDE; 1.719 + 1.720 + // We do not call MarkUsed because it would just slow down lookups and 1.721 + // because we're OK expiring things after a few seconds even if they're 1.722 + // being used. Returns whether we actually had an entry for aSelector. 1.723 + // If we have an entry and *aList is null, that indicates that aSelector 1.724 + // has already been parsed and is not a syntactically valid selector. 1.725 + bool GetList(const nsAString& aSelector, nsCSSSelectorList** aList) 1.726 + { 1.727 + return mTable.Get(aSelector, aList); 1.728 + } 1.729 + 1.730 + ~SelectorCache() 1.731 + { 1.732 + AgeAllGenerations(); 1.733 + } 1.734 + 1.735 + private: 1.736 + nsClassHashtable<nsStringHashKey, nsCSSSelectorList> mTable; 1.737 + }; 1.738 + 1.739 + SelectorCache& GetSelectorCache() 1.740 + { 1.741 + return mSelectorCache; 1.742 + } 1.743 + // Get the root <html> element, or return null if there isn't one (e.g. 1.744 + // if the root isn't <html>) 1.745 + Element* GetHtmlElement() const; 1.746 + // Returns the first child of GetHtmlContent which has the given tag, 1.747 + // or nullptr if that doesn't exist. 1.748 + Element* GetHtmlChildElement(nsIAtom* aTag); 1.749 + // Get the canonical <body> element, or return null if there isn't one (e.g. 1.750 + // if the root isn't <html> or if the <body> isn't there) 1.751 + mozilla::dom::HTMLBodyElement* GetBodyElement(); 1.752 + // Get the canonical <head> element, or return null if there isn't one (e.g. 1.753 + // if the root isn't <html> or if the <head> isn't there) 1.754 + Element* GetHeadElement() { 1.755 + return GetHtmlChildElement(nsGkAtoms::head); 1.756 + } 1.757 + 1.758 + /** 1.759 + * Accessors to the collection of stylesheets owned by this document. 1.760 + * Style sheets are ordered, most significant last. 1.761 + */ 1.762 + 1.763 + /** 1.764 + * Get the number of stylesheets 1.765 + * 1.766 + * @return the number of stylesheets 1.767 + * @throws no exceptions 1.768 + */ 1.769 + virtual int32_t GetNumberOfStyleSheets() const = 0; 1.770 + 1.771 + /** 1.772 + * Get a particular stylesheet 1.773 + * @param aIndex the index the stylesheet lives at. This is zero-based 1.774 + * @return the stylesheet at aIndex. Null if aIndex is out of range. 1.775 + * @throws no exceptions 1.776 + */ 1.777 + virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0; 1.778 + 1.779 + /** 1.780 + * Insert a sheet at a particular spot in the stylesheet list (zero-based) 1.781 + * @param aSheet the sheet to insert 1.782 + * @param aIndex the index to insert at. This index will be 1.783 + * adjusted for the "special" sheets. 1.784 + * @throws no exceptions 1.785 + */ 1.786 + virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) = 0; 1.787 + 1.788 + /** 1.789 + * Get the index of a particular stylesheet. This will _always_ 1.790 + * consider the "special" sheets as part of the sheet list. 1.791 + * @param aSheet the sheet to get the index of 1.792 + * @return aIndex the index of the sheet in the full list 1.793 + */ 1.794 + virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const = 0; 1.795 + 1.796 + /** 1.797 + * Replace the stylesheets in aOldSheets with the stylesheets in 1.798 + * aNewSheets. The two lists must have equal length, and the sheet 1.799 + * at positon J in the first list will be replaced by the sheet at 1.800 + * position J in the second list. Some sheets in the second list 1.801 + * may be null; if so the corresponding sheets in the first list 1.802 + * will simply be removed. 1.803 + */ 1.804 + virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets, 1.805 + nsCOMArray<nsIStyleSheet>& aNewSheets) = 0; 1.806 + 1.807 + /** 1.808 + * Add a stylesheet to the document 1.809 + */ 1.810 + virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0; 1.811 + 1.812 + /** 1.813 + * Remove a stylesheet from the document 1.814 + */ 1.815 + virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0; 1.816 + 1.817 + /** 1.818 + * Notify the document that the applicable state of the sheet changed 1.819 + * and that observers should be notified and style sets updated 1.820 + */ 1.821 + virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet, 1.822 + bool aApplicable) = 0; 1.823 + 1.824 + /** 1.825 + * Just like the style sheet API, but for "catalog" sheets, 1.826 + * extra sheets inserted at the UA level. 1.827 + */ 1.828 + virtual int32_t GetNumberOfCatalogStyleSheets() const = 0; 1.829 + virtual nsIStyleSheet* GetCatalogStyleSheetAt(int32_t aIndex) const = 0; 1.830 + virtual void AddCatalogStyleSheet(nsCSSStyleSheet* aSheet) = 0; 1.831 + virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) = 0; 1.832 + 1.833 + enum additionalSheetType { 1.834 + eAgentSheet, 1.835 + eUserSheet, 1.836 + eAuthorSheet, 1.837 + SheetTypeCount 1.838 + }; 1.839 + 1.840 + virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) = 0; 1.841 + virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) = 0; 1.842 + virtual nsIStyleSheet* FirstAdditionalAuthorSheet() = 0; 1.843 + 1.844 + /** 1.845 + * Get this document's CSSLoader. This is guaranteed to not return null. 1.846 + */ 1.847 + mozilla::css::Loader* CSSLoader() const { 1.848 + return mCSSLoader; 1.849 + } 1.850 + 1.851 + /** 1.852 + * Get this document's StyleImageLoader. This is guaranteed to not return null. 1.853 + */ 1.854 + mozilla::css::ImageLoader* StyleImageLoader() const { 1.855 + return mStyleImageLoader; 1.856 + } 1.857 + 1.858 + /** 1.859 + * Get the channel that was passed to StartDocumentLoad or Reset for this 1.860 + * document. Note that this may be null in some cases (eg if 1.861 + * StartDocumentLoad or Reset were never called) 1.862 + */ 1.863 + virtual nsIChannel* GetChannel() const = 0; 1.864 + 1.865 + /** 1.866 + * Get this document's attribute stylesheet. May return null if 1.867 + * there isn't one. 1.868 + */ 1.869 + nsHTMLStyleSheet* GetAttributeStyleSheet() const { 1.870 + return mAttrStyleSheet; 1.871 + } 1.872 + 1.873 + /** 1.874 + * Get this document's inline style sheet. May return null if there 1.875 + * isn't one 1.876 + */ 1.877 + nsHTMLCSSStyleSheet* GetInlineStyleSheet() const { 1.878 + return mStyleAttrStyleSheet; 1.879 + } 1.880 + 1.881 + virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; 1.882 + 1.883 + /** 1.884 + * Get/set the object from which the context for the event/script handling can 1.885 + * be got. Normally GetScriptHandlingObject() returns the same object as 1.886 + * GetScriptGlobalObject(), but if the document is loaded as data, 1.887 + * non-null may be returned, even if GetScriptGlobalObject() returns null. 1.888 + * aHasHadScriptHandlingObject is set true if document has had the object 1.889 + * for event/script handling. Do not process any events/script if the method 1.890 + * returns null, but aHasHadScriptHandlingObject is true. 1.891 + */ 1.892 + nsIScriptGlobalObject* 1.893 + GetScriptHandlingObject(bool& aHasHadScriptHandlingObject) const 1.894 + { 1.895 + aHasHadScriptHandlingObject = mHasHadScriptHandlingObject; 1.896 + return mScriptGlobalObject ? mScriptGlobalObject.get() : 1.897 + GetScriptHandlingObjectInternal(); 1.898 + } 1.899 + virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) = 0; 1.900 + 1.901 + /** 1.902 + * Get the object that is used as the scope for all of the content 1.903 + * wrappers whose owner document is this document. Unlike the script global 1.904 + * object, this will only return null when the global object for this 1.905 + * document is truly gone. Use this object when you're trying to find a 1.906 + * content wrapper in XPConnect. 1.907 + */ 1.908 + virtual nsIGlobalObject* GetScopeObject() const = 0; 1.909 + virtual void SetScopeObject(nsIGlobalObject* aGlobal) = 0; 1.910 + 1.911 + /** 1.912 + * Return the window containing the document (the outer window). 1.913 + */ 1.914 + nsPIDOMWindow *GetWindow() const 1.915 + { 1.916 + return mWindow ? mWindow->GetOuterWindow() : GetWindowInternal(); 1.917 + } 1.918 + 1.919 + bool IsInBackgroundWindow() const 1.920 + { 1.921 + nsPIDOMWindow* outer = mWindow ? mWindow->GetOuterWindow() : nullptr; 1.922 + return outer && outer->IsBackground(); 1.923 + } 1.924 + 1.925 + /** 1.926 + * Return the inner window used as the script compilation scope for 1.927 + * this document. If you're not absolutely sure you need this, use 1.928 + * GetWindow(). 1.929 + */ 1.930 + nsPIDOMWindow* GetInnerWindow() const 1.931 + { 1.932 + return mRemovedFromDocShell ? nullptr : mWindow; 1.933 + } 1.934 + 1.935 + /** 1.936 + * Return the outer window ID. 1.937 + */ 1.938 + uint64_t OuterWindowID() const 1.939 + { 1.940 + nsPIDOMWindow *window = GetWindow(); 1.941 + return window ? window->WindowID() : 0; 1.942 + } 1.943 + 1.944 + /** 1.945 + * Return the inner window ID. 1.946 + */ 1.947 + uint64_t InnerWindowID() 1.948 + { 1.949 + nsPIDOMWindow *window = GetInnerWindow(); 1.950 + return window ? window->WindowID() : 0; 1.951 + } 1.952 + 1.953 + /** 1.954 + * Get the script loader for this document 1.955 + */ 1.956 + virtual nsScriptLoader* ScriptLoader() = 0; 1.957 + 1.958 + /** 1.959 + * Add/Remove an element to the document's id and name hashes 1.960 + */ 1.961 + virtual void AddToIdTable(Element* aElement, nsIAtom* aId) = 0; 1.962 + virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId) = 0; 1.963 + virtual void AddToNameTable(Element* aElement, nsIAtom* aName) = 0; 1.964 + virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) = 0; 1.965 + 1.966 + /** 1.967 + * Returns the element which either requested DOM full-screen mode, or 1.968 + * contains the element which requested DOM full-screen mode if the 1.969 + * requestee is in a subdocument. Note this element must be *in* 1.970 + * this document. 1.971 + */ 1.972 + virtual Element* GetFullScreenElement() = 0; 1.973 + 1.974 + /** 1.975 + * Asynchronously requests that the document make aElement the fullscreen 1.976 + * element, and move into fullscreen mode. The current fullscreen element 1.977 + * (if any) is pushed onto the fullscreen element stack, and it can be 1.978 + * returned to fullscreen status by calling RestorePreviousFullScreenState(). 1.979 + * 1.980 + * Note that requesting fullscreen in a document also makes the element which 1.981 + * contains this document in this document's parent document fullscreen. i.e. 1.982 + * the <iframe> or <browser> that contains this document is also mode 1.983 + * fullscreen. This happens recursively in all ancestor documents. 1.984 + */ 1.985 + virtual void AsyncRequestFullScreen(Element* aElement) = 0; 1.986 + 1.987 + /** 1.988 + * Called when a frame in a child process has entered fullscreen or when a 1.989 + * fullscreen frame in a child process changes to another origin. 1.990 + * aFrameElement is the frame element which contains the child-process 1.991 + * fullscreen document, and aNewOrigin is the origin of the new fullscreen 1.992 + * document. 1.993 + */ 1.994 + virtual nsresult RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement, 1.995 + const nsAString& aNewOrigin) = 0; 1.996 + 1.997 + /** 1.998 + * Called when a frame in a remote child document has rolled back fullscreen 1.999 + * so that all its fullscreen element stacks are empty; we must continue the 1.1000 + * rollback in this parent process' doc tree branch which is fullscreen. 1.1001 + * Note that only one branch of the document tree can have its documents in 1.1002 + * fullscreen state at one time. We're in inconsistent state if a 1.1003 + * fullscreen document has a parent and that parent isn't fullscreen. We 1.1004 + * preserve this property across process boundaries. 1.1005 + */ 1.1006 + virtual nsresult RemoteFrameFullscreenReverted() = 0; 1.1007 + 1.1008 + /** 1.1009 + * Restores the previous full-screen element to full-screen status. If there 1.1010 + * is no former full-screen element, this exits full-screen, moving the 1.1011 + * top-level browser window out of full-screen mode. 1.1012 + */ 1.1013 + virtual void RestorePreviousFullScreenState() = 0; 1.1014 + 1.1015 + /** 1.1016 + * Returns true if this document is in full-screen mode. 1.1017 + */ 1.1018 + virtual bool IsFullScreenDoc() = 0; 1.1019 + 1.1020 + /** 1.1021 + * Returns true if this document is a fullscreen leaf document, i.e. it 1.1022 + * is in fullscreen mode and has no fullscreen children. 1.1023 + */ 1.1024 + virtual bool IsFullscreenLeaf() = 0; 1.1025 + 1.1026 + /** 1.1027 + * Returns the document which is at the root of this document's branch 1.1028 + * in the in-process document tree. Returns nullptr if the document isn't 1.1029 + * fullscreen. 1.1030 + */ 1.1031 + virtual nsIDocument* GetFullscreenRoot() = 0; 1.1032 + 1.1033 + /** 1.1034 + * Sets the fullscreen root to aRoot. This stores a weak reference to aRoot 1.1035 + * in this document. 1.1036 + */ 1.1037 + virtual void SetFullscreenRoot(nsIDocument* aRoot) = 0; 1.1038 + 1.1039 + /** 1.1040 + * Sets whether this document is approved for fullscreen mode. 1.1041 + * Documents aren't approved for fullscreen until chrome has sent a 1.1042 + * "fullscreen-approved" notification with a subject which is a pointer 1.1043 + * to the approved document. 1.1044 + */ 1.1045 + virtual void SetApprovedForFullscreen(bool aIsApproved) = 0; 1.1046 + 1.1047 + /** 1.1048 + * Exits documents out of DOM fullscreen mode. 1.1049 + * 1.1050 + * If aDocument is null, all fullscreen documents in all browser windows 1.1051 + * exit fullscreen. 1.1052 + * 1.1053 + * If aDocument is non null, all documents from aDocument's fullscreen root 1.1054 + * to the fullscreen leaf exit fullscreen. 1.1055 + * 1.1056 + * Note that the fullscreen leaf is the bottom-most document which is 1.1057 + * fullscreen, it may have non-fullscreen child documents. The fullscreen 1.1058 + * root is usually the chrome document, but if fullscreen is content-only, 1.1059 + * (see the comment in nsContentUtils.h on IsFullscreenApiContentOnly()) 1.1060 + * the fullscreen root will be a direct child of the chrome document, and 1.1061 + * there may be other branches of the same doctree that are fullscreen. 1.1062 + * 1.1063 + * If aRunAsync is true, fullscreen is executed asynchronously. 1.1064 + * 1.1065 + * Note if aDocument is not fullscreen this function has no effect, even if 1.1066 + * aDocument has fullscreen ancestors. 1.1067 + */ 1.1068 + static void ExitFullscreen(nsIDocument* aDocument, bool aRunAsync); 1.1069 + 1.1070 + virtual void RequestPointerLock(Element* aElement) = 0; 1.1071 + 1.1072 + static void UnlockPointer(nsIDocument* aDoc = nullptr); 1.1073 + 1.1074 + 1.1075 + //---------------------------------------------------------------------- 1.1076 + 1.1077 + // Document notification API's 1.1078 + 1.1079 + /** 1.1080 + * Add a new observer of document change notifications. Whenever 1.1081 + * content is changed, appended, inserted or removed the observers are 1.1082 + * informed. An observer that is already observing the document must 1.1083 + * not be added without being removed first. 1.1084 + */ 1.1085 + virtual void AddObserver(nsIDocumentObserver* aObserver) = 0; 1.1086 + 1.1087 + /** 1.1088 + * Remove an observer of document change notifications. This will 1.1089 + * return false if the observer cannot be found. 1.1090 + */ 1.1091 + virtual bool RemoveObserver(nsIDocumentObserver* aObserver) = 0; 1.1092 + 1.1093 + // Observation hooks used to propagate notifications to document observers. 1.1094 + // BeginUpdate must be called before any batch of modifications of the 1.1095 + // content model or of style data, EndUpdate must be called afterward. 1.1096 + // To make this easy and painless, use the mozAutoDocUpdate helper class. 1.1097 + virtual void BeginUpdate(nsUpdateType aUpdateType) = 0; 1.1098 + virtual void EndUpdate(nsUpdateType aUpdateType) = 0; 1.1099 + virtual void BeginLoad() = 0; 1.1100 + virtual void EndLoad() = 0; 1.1101 + 1.1102 + enum ReadyState { READYSTATE_UNINITIALIZED = 0, READYSTATE_LOADING = 1, READYSTATE_INTERACTIVE = 3, READYSTATE_COMPLETE = 4}; 1.1103 + virtual void SetReadyStateInternal(ReadyState rs) = 0; 1.1104 + ReadyState GetReadyStateEnum() 1.1105 + { 1.1106 + return mReadyState; 1.1107 + } 1.1108 + 1.1109 + // notify that a content node changed state. This must happen under 1.1110 + // a scriptblocker but NOT within a begin/end update. 1.1111 + virtual void ContentStateChanged(nsIContent* aContent, 1.1112 + mozilla::EventStates aStateMask) = 0; 1.1113 + 1.1114 + // Notify that a document state has changed. 1.1115 + // This should only be called by callers whose state is also reflected in the 1.1116 + // implementation of nsDocument::GetDocumentState. 1.1117 + virtual void DocumentStatesChanged(mozilla::EventStates aStateMask) = 0; 1.1118 + 1.1119 + // Observation hooks for style data to propagate notifications 1.1120 + // to document observers 1.1121 + virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet, 1.1122 + nsIStyleRule* aOldStyleRule, 1.1123 + nsIStyleRule* aNewStyleRule) = 0; 1.1124 + virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet, 1.1125 + nsIStyleRule* aStyleRule) = 0; 1.1126 + virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet, 1.1127 + nsIStyleRule* aStyleRule) = 0; 1.1128 + 1.1129 + /** 1.1130 + * Flush notifications for this document and its parent documents 1.1131 + * (since those may affect the layout of this one). 1.1132 + */ 1.1133 + virtual void FlushPendingNotifications(mozFlushType aType) = 0; 1.1134 + 1.1135 + /** 1.1136 + * Calls FlushPendingNotifications on any external resources this document 1.1137 + * has. If this document has no external resources or is an external resource 1.1138 + * itself this does nothing. This should only be called with 1.1139 + * aType >= Flush_Style. 1.1140 + */ 1.1141 + virtual void FlushExternalResources(mozFlushType aType) = 0; 1.1142 + 1.1143 + nsBindingManager* BindingManager() const 1.1144 + { 1.1145 + return mNodeInfoManager->GetBindingManager(); 1.1146 + } 1.1147 + 1.1148 + /** 1.1149 + * Only to be used inside Gecko, you can't really do anything with the 1.1150 + * pointer outside Gecko anyway. 1.1151 + */ 1.1152 + nsNodeInfoManager* NodeInfoManager() const 1.1153 + { 1.1154 + return mNodeInfoManager; 1.1155 + } 1.1156 + 1.1157 + /** 1.1158 + * Reset the document using the given channel and loadgroup. This works 1.1159 + * like ResetToURI, but also sets the document's channel to aChannel. 1.1160 + * The principal of the document will be set from the channel. 1.1161 + */ 1.1162 + virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0; 1.1163 + 1.1164 + /** 1.1165 + * Reset this document to aURI, aLoadGroup, and aPrincipal. aURI must not be 1.1166 + * null. If aPrincipal is null, a codebase principal based on aURI will be 1.1167 + * used. 1.1168 + */ 1.1169 + virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup, 1.1170 + nsIPrincipal* aPrincipal) = 0; 1.1171 + 1.1172 + /** 1.1173 + * Set the container (docshell) for this document. Virtual so that 1.1174 + * docshell can call it. 1.1175 + */ 1.1176 + virtual void SetContainer(nsDocShell* aContainer); 1.1177 + 1.1178 + /** 1.1179 + * Get the container (docshell) for this document. 1.1180 + */ 1.1181 + virtual nsISupports* GetContainer() const; 1.1182 + 1.1183 + /** 1.1184 + * Get the container's load context for this document. 1.1185 + */ 1.1186 + nsILoadContext* GetLoadContext() const; 1.1187 + 1.1188 + /** 1.1189 + * Get docshell the for this document. 1.1190 + */ 1.1191 + nsIDocShell* GetDocShell() const; 1.1192 + 1.1193 + /** 1.1194 + * Set and get XML declaration. If aVersion is null there is no declaration. 1.1195 + * aStandalone takes values -1, 0 and 1 indicating respectively that there 1.1196 + * was no standalone parameter in the declaration, that it was given as no, 1.1197 + * or that it was given as yes. 1.1198 + */ 1.1199 + virtual void SetXMLDeclaration(const char16_t *aVersion, 1.1200 + const char16_t *aEncoding, 1.1201 + const int32_t aStandalone) = 0; 1.1202 + virtual void GetXMLDeclaration(nsAString& aVersion, 1.1203 + nsAString& aEncoding, 1.1204 + nsAString& Standalone) = 0; 1.1205 + 1.1206 + bool IsHTML() const 1.1207 + { 1.1208 + return mIsRegularHTML; 1.1209 + } 1.1210 + bool IsXUL() const 1.1211 + { 1.1212 + return mIsXUL; 1.1213 + } 1.1214 + 1.1215 + virtual bool IsScriptEnabled() = 0; 1.1216 + 1.1217 + /** 1.1218 + * Create an element with the specified name, prefix and namespace ID. 1.1219 + */ 1.1220 + virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix, 1.1221 + int32_t aNamespaceID, 1.1222 + nsIContent** aResult) = 0; 1.1223 + 1.1224 + /** 1.1225 + * Get the security info (i.e. SSL state etc) that the document got 1.1226 + * from the channel/document that created the content of the 1.1227 + * document. 1.1228 + * 1.1229 + * @see nsIChannel 1.1230 + */ 1.1231 + nsISupports *GetSecurityInfo() 1.1232 + { 1.1233 + return mSecurityInfo; 1.1234 + } 1.1235 + 1.1236 + /** 1.1237 + * Returns the default namespace ID used for elements created in this 1.1238 + * document. 1.1239 + */ 1.1240 + int32_t GetDefaultNamespaceID() const 1.1241 + { 1.1242 + return mDefaultElementType; 1.1243 + } 1.1244 + 1.1245 + void DeleteAllProperties(); 1.1246 + void DeleteAllPropertiesFor(nsINode* aNode); 1.1247 + 1.1248 + nsPropertyTable* PropertyTable(uint16_t aCategory) { 1.1249 + if (aCategory == 0) 1.1250 + return &mPropertyTable; 1.1251 + return GetExtraPropertyTable(aCategory); 1.1252 + } 1.1253 + uint32_t GetPropertyTableCount() 1.1254 + { return mExtraPropertyTables.Length() + 1; } 1.1255 + 1.1256 + /** 1.1257 + * Sets the ID used to identify this part of the multipart document 1.1258 + */ 1.1259 + void SetPartID(uint32_t aID) { 1.1260 + mPartID = aID; 1.1261 + } 1.1262 + 1.1263 + /** 1.1264 + * Return the ID used to identify this part of the multipart document 1.1265 + */ 1.1266 + uint32_t GetPartID() const { 1.1267 + return mPartID; 1.1268 + } 1.1269 + 1.1270 + /** 1.1271 + * Sanitize the document by resetting all input elements and forms that have 1.1272 + * autocomplete=off to their default values. 1.1273 + */ 1.1274 + virtual void Sanitize() = 0; 1.1275 + 1.1276 + /** 1.1277 + * Enumerate all subdocuments. 1.1278 + * The enumerator callback should return true to continue enumerating, or 1.1279 + * false to stop. This will never get passed a null aDocument. 1.1280 + */ 1.1281 + typedef bool (*nsSubDocEnumFunc)(nsIDocument *aDocument, void *aData); 1.1282 + virtual void EnumerateSubDocuments(nsSubDocEnumFunc aCallback, 1.1283 + void *aData) = 0; 1.1284 + 1.1285 + /** 1.1286 + * Check whether it is safe to cache the presentation of this document 1.1287 + * and all of its subdocuments. This method checks the following conditions 1.1288 + * recursively: 1.1289 + * - Some document types, such as plugin documents, cannot be safely cached. 1.1290 + * - If there are any pending requests, we don't allow the presentation 1.1291 + * to be cached. Ideally these requests would be suspended and resumed, 1.1292 + * but that is difficult in some cases, such as XMLHttpRequest. 1.1293 + * - If there are any beforeunload or unload listeners, we must fire them 1.1294 + * for correctness, but this likely puts the document into a state where 1.1295 + * it would not function correctly if restored. 1.1296 + * 1.1297 + * |aNewRequest| should be the request for a new document which will 1.1298 + * replace this document in the docshell. The new document's request 1.1299 + * will be ignored when checking for active requests. If there is no 1.1300 + * request associated with the new document, this parameter may be null. 1.1301 + */ 1.1302 + virtual bool CanSavePresentation(nsIRequest *aNewRequest) = 0; 1.1303 + 1.1304 + /** 1.1305 + * Notify the document that its associated ContentViewer is being destroyed. 1.1306 + * This releases circular references so that the document can go away. 1.1307 + * Destroy() is only called on documents that have a content viewer. 1.1308 + */ 1.1309 + virtual void Destroy() = 0; 1.1310 + 1.1311 + /** 1.1312 + * Notify the document that its associated ContentViewer is no longer 1.1313 + * the current viewer for the docshell. The document might still 1.1314 + * be rendered in "zombie state" until the next document is ready. 1.1315 + * The document should save form control state. 1.1316 + */ 1.1317 + virtual void RemovedFromDocShell() = 0; 1.1318 + 1.1319 + /** 1.1320 + * Get the layout history state that should be used to save and restore state 1.1321 + * for nodes in this document. This may return null; if that happens state 1.1322 + * saving and restoration is not possible. 1.1323 + */ 1.1324 + virtual already_AddRefed<nsILayoutHistoryState> GetLayoutHistoryState() const = 0; 1.1325 + 1.1326 + /** 1.1327 + * Methods that can be used to prevent onload firing while an event that 1.1328 + * should block onload is posted. onload is guaranteed to not fire until 1.1329 + * either all calls to BlockOnload() have been matched by calls to 1.1330 + * UnblockOnload() or the load has been stopped altogether (by the user 1.1331 + * pressing the Stop button, say). 1.1332 + */ 1.1333 + virtual void BlockOnload() = 0; 1.1334 + /** 1.1335 + * @param aFireSync whether to fire onload synchronously. If false, 1.1336 + * onload will fire asynchronously after all onload blocks have been 1.1337 + * removed. It will NOT fire from inside UnblockOnload. If true, 1.1338 + * onload may fire from inside UnblockOnload. 1.1339 + */ 1.1340 + virtual void UnblockOnload(bool aFireSync) = 0; 1.1341 + 1.1342 + void BlockDOMContentLoaded() 1.1343 + { 1.1344 + ++mBlockDOMContentLoaded; 1.1345 + } 1.1346 + 1.1347 + virtual void UnblockDOMContentLoaded() = 0; 1.1348 + 1.1349 + /** 1.1350 + * Notification that the page has been shown, for documents which are loaded 1.1351 + * into a DOM window. This corresponds to the completion of document load, 1.1352 + * or to the page's presentation being restored into an existing DOM window. 1.1353 + * This notification fires applicable DOM events to the content window. See 1.1354 + * nsIDOMPageTransitionEvent.idl for a description of the |aPersisted| 1.1355 + * parameter. If aDispatchStartTarget is null, the pageshow event is 1.1356 + * dispatched on the ScriptGlobalObject for this document, otherwise it's 1.1357 + * dispatched on aDispatchStartTarget. 1.1358 + * Note: if aDispatchStartTarget isn't null, the showing state of the 1.1359 + * document won't be altered. 1.1360 + */ 1.1361 + virtual void OnPageShow(bool aPersisted, 1.1362 + mozilla::dom::EventTarget* aDispatchStartTarget) = 0; 1.1363 + 1.1364 + /** 1.1365 + * Notification that the page has been hidden, for documents which are loaded 1.1366 + * into a DOM window. This corresponds to the unloading of the document, or 1.1367 + * to the document's presentation being saved but removed from an existing 1.1368 + * DOM window. This notification fires applicable DOM events to the content 1.1369 + * window. See nsIDOMPageTransitionEvent.idl for a description of the 1.1370 + * |aPersisted| parameter. If aDispatchStartTarget is null, the pagehide 1.1371 + * event is dispatched on the ScriptGlobalObject for this document, 1.1372 + * otherwise it's dispatched on aDispatchStartTarget. 1.1373 + * Note: if aDispatchStartTarget isn't null, the showing state of the 1.1374 + * document won't be altered. 1.1375 + */ 1.1376 + virtual void OnPageHide(bool aPersisted, 1.1377 + mozilla::dom::EventTarget* aDispatchStartTarget) = 0; 1.1378 + 1.1379 + /* 1.1380 + * We record the set of links in the document that are relevant to 1.1381 + * style. 1.1382 + */ 1.1383 + /** 1.1384 + * Notification that an element is a link that is relevant to style. 1.1385 + */ 1.1386 + virtual void AddStyleRelevantLink(mozilla::dom::Link* aLink) = 0; 1.1387 + /** 1.1388 + * Notification that an element is a link and its URI might have been 1.1389 + * changed or the element removed. If the element is still a link relevant 1.1390 + * to style, then someone must ensure that AddStyleRelevantLink is 1.1391 + * (eventually) called on it again. 1.1392 + */ 1.1393 + virtual void ForgetLink(mozilla::dom::Link* aLink) = 0; 1.1394 + 1.1395 + /** 1.1396 + * Resets and removes a box object from the document's box object cache 1.1397 + * 1.1398 + * @param aElement canonical nsIContent pointer of the box object's element 1.1399 + */ 1.1400 + virtual void ClearBoxObjectFor(nsIContent *aContent) = 0; 1.1401 + 1.1402 + /** 1.1403 + * Get the box object for an element. This is not exposed through a 1.1404 + * scriptable interface except for XUL documents. 1.1405 + */ 1.1406 + virtual already_AddRefed<nsIBoxObject> 1.1407 + GetBoxObjectFor(mozilla::dom::Element* aElement, 1.1408 + mozilla::ErrorResult& aRv) = 0; 1.1409 + 1.1410 + /** 1.1411 + * Get the compatibility mode for this document 1.1412 + */ 1.1413 + nsCompatibility GetCompatibilityMode() const { 1.1414 + return mCompatMode; 1.1415 + } 1.1416 + 1.1417 + /** 1.1418 + * Check whether we've ever fired a DOMTitleChanged event for this 1.1419 + * document. 1.1420 + */ 1.1421 + bool HaveFiredDOMTitleChange() const { 1.1422 + return mHaveFiredTitleChange; 1.1423 + } 1.1424 + 1.1425 + /** 1.1426 + * See GetAnonymousElementByAttribute on nsIDOMDocumentXBL. 1.1427 + */ 1.1428 + virtual Element* 1.1429 + GetAnonymousElementByAttribute(nsIContent* aElement, 1.1430 + nsIAtom* aAttrName, 1.1431 + const nsAString& aAttrValue) const = 0; 1.1432 + 1.1433 + /** 1.1434 + * Helper for nsIDOMDocument::elementFromPoint implementation that allows 1.1435 + * ignoring the scroll frame and/or avoiding layout flushes. 1.1436 + * 1.1437 + * @see nsIDOMWindowUtils::elementFromPoint 1.1438 + */ 1.1439 + virtual Element* ElementFromPointHelper(float aX, float aY, 1.1440 + bool aIgnoreRootScrollFrame, 1.1441 + bool aFlushLayout) = 0; 1.1442 + 1.1443 + virtual nsresult NodesFromRectHelper(float aX, float aY, 1.1444 + float aTopSize, float aRightSize, 1.1445 + float aBottomSize, float aLeftSize, 1.1446 + bool aIgnoreRootScrollFrame, 1.1447 + bool aFlushLayout, 1.1448 + nsIDOMNodeList** aReturn) = 0; 1.1449 + 1.1450 + /** 1.1451 + * See FlushSkinBindings on nsBindingManager 1.1452 + */ 1.1453 + virtual void FlushSkinBindings() = 0; 1.1454 + 1.1455 + /** 1.1456 + * To batch DOMSubtreeModified, document needs to be informed when 1.1457 + * a mutation event might be dispatched, even if the event isn't actually 1.1458 + * created because there are no listeners for it. 1.1459 + * 1.1460 + * @param aTarget is the target for the mutation event. 1.1461 + */ 1.1462 + void MayDispatchMutationEvent(nsINode* aTarget) 1.1463 + { 1.1464 + if (mSubtreeModifiedDepth > 0) { 1.1465 + mSubtreeModifiedTargets.AppendObject(aTarget); 1.1466 + } 1.1467 + } 1.1468 + 1.1469 + /** 1.1470 + * Marks as not-going-to-be-collected for the given generation of 1.1471 + * cycle collection. 1.1472 + */ 1.1473 + void MarkUncollectableForCCGeneration(uint32_t aGeneration) 1.1474 + { 1.1475 + mMarkedCCGeneration = aGeneration; 1.1476 + } 1.1477 + 1.1478 + /** 1.1479 + * Gets the cycle collector generation this document is marked for. 1.1480 + */ 1.1481 + uint32_t GetMarkedCCGeneration() 1.1482 + { 1.1483 + return mMarkedCCGeneration; 1.1484 + } 1.1485 + 1.1486 + bool IsLoadedAsData() 1.1487 + { 1.1488 + return mLoadedAsData; 1.1489 + } 1.1490 + 1.1491 + bool IsLoadedAsInteractiveData() 1.1492 + { 1.1493 + return mLoadedAsInteractiveData; 1.1494 + } 1.1495 + 1.1496 + bool MayStartLayout() 1.1497 + { 1.1498 + return mMayStartLayout; 1.1499 + } 1.1500 + 1.1501 + void SetMayStartLayout(bool aMayStartLayout) 1.1502 + { 1.1503 + mMayStartLayout = aMayStartLayout; 1.1504 + } 1.1505 + 1.1506 + already_AddRefed<nsIDocumentEncoder> GetCachedEncoder(); 1.1507 + 1.1508 + void SetCachedEncoder(already_AddRefed<nsIDocumentEncoder> aEncoder); 1.1509 + 1.1510 + // In case of failure, the document really can't initialize the frame loader. 1.1511 + virtual nsresult InitializeFrameLoader(nsFrameLoader* aLoader) = 0; 1.1512 + // In case of failure, the caller must handle the error, for example by 1.1513 + // finalizing frame loader asynchronously. 1.1514 + virtual nsresult FinalizeFrameLoader(nsFrameLoader* aLoader) = 0; 1.1515 + // Removes the frame loader of aShell from the initialization list. 1.1516 + virtual void TryCancelFrameLoaderInitialization(nsIDocShell* aShell) = 0; 1.1517 + // Returns true if the frame loader of aShell is in the finalization list. 1.1518 + virtual bool FrameLoaderScheduledToBeFinalized(nsIDocShell* aShell) = 0; 1.1519 + 1.1520 + /** 1.1521 + * Check whether this document is a root document that is not an 1.1522 + * external resource. 1.1523 + */ 1.1524 + bool IsRootDisplayDocument() const 1.1525 + { 1.1526 + return !mParentDocument && !mDisplayDocument; 1.1527 + } 1.1528 + 1.1529 + bool IsBeingUsedAsImage() const { 1.1530 + return mIsBeingUsedAsImage; 1.1531 + } 1.1532 + 1.1533 + void SetIsBeingUsedAsImage() { 1.1534 + mIsBeingUsedAsImage = true; 1.1535 + } 1.1536 + 1.1537 + bool IsResourceDoc() const { 1.1538 + return IsBeingUsedAsImage() || // Are we a helper-doc for an SVG image? 1.1539 + !!mDisplayDocument; // Are we an external resource doc? 1.1540 + } 1.1541 + 1.1542 + /** 1.1543 + * Get the document for which this document is an external resource. This 1.1544 + * will be null if this document is not an external resource. Otherwise, 1.1545 + * GetDisplayDocument() will return a non-null document, and 1.1546 + * GetDisplayDocument()->GetDisplayDocument() is guaranteed to be null. 1.1547 + */ 1.1548 + nsIDocument* GetDisplayDocument() const 1.1549 + { 1.1550 + return mDisplayDocument; 1.1551 + } 1.1552 + 1.1553 + /** 1.1554 + * Set the display document for this document. aDisplayDocument must not be 1.1555 + * null. 1.1556 + */ 1.1557 + void SetDisplayDocument(nsIDocument* aDisplayDocument) 1.1558 + { 1.1559 + NS_PRECONDITION(!GetShell() && 1.1560 + !GetContainer() && 1.1561 + !GetWindow(), 1.1562 + "Shouldn't set mDisplayDocument on documents that already " 1.1563 + "have a presentation or a docshell or a window"); 1.1564 + NS_PRECONDITION(aDisplayDocument != this, "Should be different document"); 1.1565 + NS_PRECONDITION(!aDisplayDocument->GetDisplayDocument(), 1.1566 + "Display documents should not nest"); 1.1567 + mDisplayDocument = aDisplayDocument; 1.1568 + } 1.1569 + 1.1570 + /** 1.1571 + * A class that represents an external resource load that has begun but 1.1572 + * doesn't have a document yet. Observers can be registered on this object, 1.1573 + * and will be notified after the document is created. Observers registered 1.1574 + * after the document has been created will NOT be notified. When observers 1.1575 + * are notified, the subject will be the newly-created document, the topic 1.1576 + * will be "external-resource-document-created", and the data will be null. 1.1577 + * If document creation fails for some reason, observers will still be 1.1578 + * notified, with a null document pointer. 1.1579 + */ 1.1580 + class ExternalResourceLoad : public nsISupports 1.1581 + { 1.1582 + public: 1.1583 + virtual ~ExternalResourceLoad() {} 1.1584 + 1.1585 + void AddObserver(nsIObserver* aObserver) { 1.1586 + NS_PRECONDITION(aObserver, "Must have observer"); 1.1587 + mObservers.AppendElement(aObserver); 1.1588 + } 1.1589 + 1.1590 + const nsTArray< nsCOMPtr<nsIObserver> > & Observers() { 1.1591 + return mObservers; 1.1592 + } 1.1593 + protected: 1.1594 + nsAutoTArray< nsCOMPtr<nsIObserver>, 8 > mObservers; 1.1595 + }; 1.1596 + 1.1597 + /** 1.1598 + * Request an external resource document for aURI. This will return the 1.1599 + * resource document if available. If one is not available yet, it will 1.1600 + * start loading as needed, and the pending load object will be returned in 1.1601 + * aPendingLoad so that the caller can register an observer to wait for the 1.1602 + * load. If this function returns null and doesn't return a pending load, 1.1603 + * that means that there is no resource document for this URI and won't be 1.1604 + * one in the future. 1.1605 + * 1.1606 + * @param aURI the URI to get 1.1607 + * @param aRequestingNode the node making the request 1.1608 + * @param aPendingLoad the pending load for this request, if any 1.1609 + */ 1.1610 + virtual nsIDocument* 1.1611 + RequestExternalResource(nsIURI* aURI, 1.1612 + nsINode* aRequestingNode, 1.1613 + ExternalResourceLoad** aPendingLoad) = 0; 1.1614 + 1.1615 + /** 1.1616 + * Enumerate the external resource documents associated with this document. 1.1617 + * The enumerator callback should return true to continue enumerating, or 1.1618 + * false to stop. This callback will never get passed a null aDocument. 1.1619 + */ 1.1620 + virtual void EnumerateExternalResources(nsSubDocEnumFunc aCallback, 1.1621 + void* aData) = 0; 1.1622 + 1.1623 + /** 1.1624 + * Return whether the document is currently showing (in the sense of 1.1625 + * OnPageShow() having been called already and OnPageHide() not having been 1.1626 + * called yet. 1.1627 + */ 1.1628 + bool IsShowing() const { return mIsShowing; } 1.1629 + /** 1.1630 + * Return whether the document is currently visible (in the sense of 1.1631 + * OnPageHide having been called and OnPageShow not yet having been called) 1.1632 + */ 1.1633 + bool IsVisible() const { return mVisible; } 1.1634 + 1.1635 + /** 1.1636 + * Return whether the document and all its ancestors are visible in the sense of 1.1637 + * pageshow / hide. 1.1638 + */ 1.1639 + bool IsVisibleConsideringAncestors() const; 1.1640 + 1.1641 + /** 1.1642 + * Return true when this document is active, i.e., the active document 1.1643 + * in a content viewer. Note that this will return true for bfcached 1.1644 + * documents, so this does NOT match the "active document" concept in 1.1645 + * the WHATWG spec. That would correspond to GetInnerWindow() && 1.1646 + * GetInnerWindow()->IsCurrentInnerWindow(). 1.1647 + */ 1.1648 + bool IsActive() const { return mDocumentContainer && !mRemovedFromDocShell; } 1.1649 + 1.1650 + void RegisterFreezableElement(nsIContent* aContent); 1.1651 + bool UnregisterFreezableElement(nsIContent* aContent); 1.1652 + typedef void (* FreezableElementEnumerator)(nsIContent*, void*); 1.1653 + void EnumerateFreezableElements(FreezableElementEnumerator aEnumerator, 1.1654 + void* aData); 1.1655 + 1.1656 + // Indicates whether mAnimationController has been (lazily) initialized. 1.1657 + // If this returns true, we're promising that GetAnimationController() 1.1658 + // will have a non-null return value. 1.1659 + bool HasAnimationController() { return !!mAnimationController; } 1.1660 + 1.1661 + // Getter for this document's SMIL Animation Controller. Performs lazy 1.1662 + // initialization, if this document supports animation and if 1.1663 + // mAnimationController isn't yet initialized. 1.1664 + virtual nsSMILAnimationController* GetAnimationController() = 0; 1.1665 + 1.1666 + // Makes the images on this document capable of having their animation 1.1667 + // active or suspended. An Image will animate as long as at least one of its 1.1668 + // owning Documents needs it to animate; otherwise it can suspend. 1.1669 + virtual void SetImagesNeedAnimating(bool aAnimating) = 0; 1.1670 + 1.1671 + enum SuppressionType { 1.1672 + eAnimationsOnly = 0x1, 1.1673 + 1.1674 + // Note that suppressing events also suppresses animation frames, so 1.1675 + // there's no need to split out events in its own bitmask. 1.1676 + eEvents = 0x3, 1.1677 + }; 1.1678 + 1.1679 + /** 1.1680 + * Prevents user initiated events from being dispatched to the document and 1.1681 + * subdocuments. 1.1682 + */ 1.1683 + virtual void SuppressEventHandling(SuppressionType aWhat, 1.1684 + uint32_t aIncrease = 1) = 0; 1.1685 + 1.1686 + /** 1.1687 + * Unsuppress event handling. 1.1688 + * @param aFireEvents If true, delayed events (focus/blur) will be fired 1.1689 + * asynchronously. 1.1690 + */ 1.1691 + virtual void UnsuppressEventHandlingAndFireEvents(SuppressionType aWhat, 1.1692 + bool aFireEvents) = 0; 1.1693 + 1.1694 + uint32_t EventHandlingSuppressed() const { return mEventsSuppressed; } 1.1695 + uint32_t AnimationsPaused() const { return mAnimationsPaused; } 1.1696 + 1.1697 + bool IsEventHandlingEnabled() { 1.1698 + return !EventHandlingSuppressed() && mScriptGlobalObject; 1.1699 + } 1.1700 + 1.1701 + /** 1.1702 + * Increment the number of external scripts being evaluated. 1.1703 + */ 1.1704 + void BeginEvaluatingExternalScript() { ++mExternalScriptsBeingEvaluated; } 1.1705 + 1.1706 + /** 1.1707 + * Decrement the number of external scripts being evaluated. 1.1708 + */ 1.1709 + void EndEvaluatingExternalScript() { --mExternalScriptsBeingEvaluated; } 1.1710 + 1.1711 + bool IsDNSPrefetchAllowed() const { return mAllowDNSPrefetch; } 1.1712 + 1.1713 + /** 1.1714 + * Returns true if this document is allowed to contain XUL element and 1.1715 + * use non-builtin XBL bindings. 1.1716 + */ 1.1717 + bool AllowXULXBL() { 1.1718 + return mAllowXULXBL == eTriTrue ? true : 1.1719 + mAllowXULXBL == eTriFalse ? false : 1.1720 + InternalAllowXULXBL(); 1.1721 + } 1.1722 + 1.1723 + void ForceEnableXULXBL() { 1.1724 + mAllowXULXBL = eTriTrue; 1.1725 + } 1.1726 + 1.1727 + /** 1.1728 + * Returns the template content owner document that owns the content of 1.1729 + * HTMLTemplateElement. 1.1730 + */ 1.1731 + virtual nsIDocument* GetTemplateContentsOwner() = 0; 1.1732 + 1.1733 + /** 1.1734 + * true when this document is a static clone of a normal document. 1.1735 + * For example print preview and printing use static documents. 1.1736 + */ 1.1737 + bool IsStaticDocument() { return mIsStaticDocument; } 1.1738 + 1.1739 + /** 1.1740 + * Clones the document and subdocuments and stylesheet etc. 1.1741 + * @param aCloneContainer The container for the clone document. 1.1742 + */ 1.1743 + virtual already_AddRefed<nsIDocument> 1.1744 + CreateStaticClone(nsIDocShell* aCloneContainer); 1.1745 + 1.1746 + /** 1.1747 + * If this document is a static clone, this returns the original 1.1748 + * document. 1.1749 + */ 1.1750 + nsIDocument* GetOriginalDocument() 1.1751 + { 1.1752 + MOZ_ASSERT(!mOriginalDocument || !mOriginalDocument->GetOriginalDocument()); 1.1753 + return mOriginalDocument; 1.1754 + } 1.1755 + 1.1756 + /** 1.1757 + * Called by nsParser to preload images. Can be removed and code moved 1.1758 + * to nsPreloadURIs::PreloadURIs() in file nsParser.cpp whenever the 1.1759 + * parser-module is linked with gklayout-module. aCrossOriginAttr should 1.1760 + * be a void string if the attr is not present. 1.1761 + */ 1.1762 + virtual void MaybePreLoadImage(nsIURI* uri, 1.1763 + const nsAString& aCrossOriginAttr) = 0; 1.1764 + 1.1765 + /** 1.1766 + * Called by nsParser to preload style sheets. Can also be merged into the 1.1767 + * parser if and when the parser is merged with libgklayout. aCrossOriginAttr 1.1768 + * should be a void string if the attr is not present. 1.1769 + */ 1.1770 + virtual void PreloadStyle(nsIURI* aURI, const nsAString& aCharset, 1.1771 + const nsAString& aCrossOriginAttr) = 0; 1.1772 + 1.1773 + /** 1.1774 + * Called by the chrome registry to load style sheets. Can be put 1.1775 + * back there if and when when that module is merged with libgklayout. 1.1776 + * 1.1777 + * This always does a synchronous load. If aIsAgentSheet is true, 1.1778 + * it also uses the system principal and enables unsafe rules. 1.1779 + * DO NOT USE FOR UNTRUSTED CONTENT. 1.1780 + */ 1.1781 + virtual nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet, 1.1782 + nsCSSStyleSheet** aSheet) = 0; 1.1783 + 1.1784 + /** 1.1785 + * Returns true if the locale used for the document specifies a direction of 1.1786 + * right to left. For chrome documents, this comes from the chrome registry. 1.1787 + * This is used to determine the current state for the :-moz-locale-dir pseudoclass 1.1788 + * so once can know whether a document is expected to be rendered left-to-right 1.1789 + * or right-to-left. 1.1790 + */ 1.1791 + virtual bool IsDocumentRightToLeft() { return false; } 1.1792 + 1.1793 + enum DocumentTheme { 1.1794 + Doc_Theme_Uninitialized, // not determined yet 1.1795 + Doc_Theme_None, 1.1796 + Doc_Theme_Neutral, 1.1797 + Doc_Theme_Dark, 1.1798 + Doc_Theme_Bright 1.1799 + }; 1.1800 + 1.1801 + /** 1.1802 + * Set the document's pending state object (as serialized using structured 1.1803 + * clone). 1.1804 + */ 1.1805 + void SetStateObject(nsIStructuredCloneContainer *scContainer); 1.1806 + 1.1807 + /** 1.1808 + * Returns Doc_Theme_None if there is no lightweight theme specified, 1.1809 + * Doc_Theme_Dark for a dark theme, Doc_Theme_Bright for a light theme, and 1.1810 + * Doc_Theme_Neutral for any other theme. This is used to determine the state 1.1811 + * of the pseudoclasses :-moz-lwtheme and :-moz-lwtheme-text. 1.1812 + */ 1.1813 + virtual int GetDocumentLWTheme() { return Doc_Theme_None; } 1.1814 + 1.1815 + /** 1.1816 + * Returns the document state. 1.1817 + * Document state bits have the form NS_DOCUMENT_STATE_* and are declared in 1.1818 + * nsIDocument.h. 1.1819 + */ 1.1820 + virtual mozilla::EventStates GetDocumentState() = 0; 1.1821 + 1.1822 + virtual nsISupports* GetCurrentContentSink() = 0; 1.1823 + 1.1824 + /** 1.1825 + * Register/Unregister a hostobject uri as being "owned" by this document. 1.1826 + * I.e. that its lifetime is connected with this document. When the document 1.1827 + * goes away it should "kill" the uri by calling 1.1828 + * nsHostObjectProtocolHandler::RemoveDataEntry 1.1829 + */ 1.1830 + virtual void RegisterHostObjectUri(const nsACString& aUri) = 0; 1.1831 + virtual void UnregisterHostObjectUri(const nsACString& aUri) = 0; 1.1832 + 1.1833 + virtual void SetScrollToRef(nsIURI *aDocumentURI) = 0; 1.1834 + virtual void ScrollToRef() = 0; 1.1835 + virtual void ResetScrolledToRefAlready() = 0; 1.1836 + virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) = 0; 1.1837 + 1.1838 + /** 1.1839 + * This method is similar to GetElementById() from nsIDOMDocument but it 1.1840 + * returns a mozilla::dom::Element instead of a nsIDOMElement. 1.1841 + * It prevents converting nsIDOMElement to mozilla::dom::Element which is 1.1842 + * already converted from mozilla::dom::Element. 1.1843 + */ 1.1844 + virtual Element* GetElementById(const nsAString& aElementId) = 0; 1.1845 + 1.1846 + /** 1.1847 + * This method returns _all_ the elements in this document which 1.1848 + * have id aElementId, if there are any. Otherwise it returns null. 1.1849 + * The entries of the nsSmallVoidArray are Element* 1.1850 + */ 1.1851 + virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const = 0; 1.1852 + 1.1853 + /** 1.1854 + * Lookup an image element using its associated ID, which is usually provided 1.1855 + * by |-moz-element()|. Similar to GetElementById, with the difference that 1.1856 + * elements set using mozSetImageElement have higher priority. 1.1857 + * @param aId the ID associated the element we want to lookup 1.1858 + * @return the element associated with |aId| 1.1859 + */ 1.1860 + virtual Element* LookupImageElement(const nsAString& aElementId) = 0; 1.1861 + 1.1862 + virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() = 0; 1.1863 + 1.1864 + typedef mozilla::dom::CallbackObjectHolder< 1.1865 + mozilla::dom::FrameRequestCallback, 1.1866 + nsIFrameRequestCallback> FrameRequestCallbackHolder; 1.1867 + nsresult ScheduleFrameRequestCallback(const FrameRequestCallbackHolder& aCallback, 1.1868 + int32_t *aHandle); 1.1869 + void CancelFrameRequestCallback(int32_t aHandle); 1.1870 + 1.1871 + typedef nsTArray<FrameRequestCallbackHolder> FrameRequestCallbackList; 1.1872 + /** 1.1873 + * Put this document's frame request callbacks into the provided 1.1874 + * list, and forget about them. 1.1875 + */ 1.1876 + void TakeFrameRequestCallbacks(FrameRequestCallbackList& aCallbacks); 1.1877 + 1.1878 + // This returns true when the document tree is being teared down. 1.1879 + bool InUnlinkOrDeletion() { return mInUnlinkOrDeletion; } 1.1880 + 1.1881 + /* 1.1882 + * Image Tracking 1.1883 + * 1.1884 + * Style and content images register their imgIRequests with their document 1.1885 + * so that the document can efficiently tell all descendant images when they 1.1886 + * are and are not visible. When an image is on-screen, we want to call 1.1887 + * LockImage() on it so that it doesn't do things like discarding frame data 1.1888 + * to save memory. The PresShell informs the document whether its images 1.1889 + * should be locked or not via SetImageLockingState(). 1.1890 + * 1.1891 + * See bug 512260. 1.1892 + */ 1.1893 + 1.1894 + // Add/Remove images from the document image tracker 1.1895 + virtual nsresult AddImage(imgIRequest* aImage) = 0; 1.1896 + // If the REQUEST_DISCARD flag is passed then if the lock count is zero we 1.1897 + // will request the image be discarded now (instead of waiting). 1.1898 + enum { REQUEST_DISCARD = 0x1 }; 1.1899 + virtual nsresult RemoveImage(imgIRequest* aImage, uint32_t aFlags = 0) = 0; 1.1900 + 1.1901 + // Makes the images on this document locked/unlocked. By default, the locking 1.1902 + // state is unlocked/false. 1.1903 + virtual nsresult SetImageLockingState(bool aLocked) = 0; 1.1904 + 1.1905 + virtual nsresult AddPlugin(nsIObjectLoadingContent* aPlugin) = 0; 1.1906 + virtual void RemovePlugin(nsIObjectLoadingContent* aPlugin) = 0; 1.1907 + virtual void GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) = 0; 1.1908 + 1.1909 + virtual nsresult GetStateObject(nsIVariant** aResult) = 0; 1.1910 + 1.1911 + virtual nsDOMNavigationTiming* GetNavigationTiming() const = 0; 1.1912 + 1.1913 + virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) = 0; 1.1914 + 1.1915 + virtual Element* FindImageMap(const nsAString& aNormalizedMapName) = 0; 1.1916 + 1.1917 + // Add aLink to the set of links that need their status resolved. 1.1918 + void RegisterPendingLinkUpdate(mozilla::dom::Link* aLink); 1.1919 + 1.1920 + // Remove aLink from the set of links that need their status resolved. 1.1921 + // This function must be called when links are removed from the document. 1.1922 + void UnregisterPendingLinkUpdate(mozilla::dom::Link* aElement); 1.1923 + 1.1924 + // Update state on links in mLinksToUpdate. This function must 1.1925 + // be called prior to selector matching. 1.1926 + void FlushPendingLinkUpdates(); 1.1927 + 1.1928 +#define DEPRECATED_OPERATION(_op) e##_op, 1.1929 + enum DeprecatedOperations { 1.1930 +#include "nsDeprecatedOperationList.h" 1.1931 + eDeprecatedOperationCount 1.1932 + }; 1.1933 +#undef DEPRECATED_OPERATION 1.1934 + void WarnOnceAbout(DeprecatedOperations aOperation, bool asError = false); 1.1935 + 1.1936 + virtual void PostVisibilityUpdateEvent() = 0; 1.1937 + 1.1938 + bool IsSyntheticDocument() const { return mIsSyntheticDocument; } 1.1939 + 1.1940 + void SetNeedLayoutFlush() { 1.1941 + mNeedLayoutFlush = true; 1.1942 + if (mDisplayDocument) { 1.1943 + mDisplayDocument->SetNeedLayoutFlush(); 1.1944 + } 1.1945 + } 1.1946 + 1.1947 + void SetNeedStyleFlush() { 1.1948 + mNeedStyleFlush = true; 1.1949 + if (mDisplayDocument) { 1.1950 + mDisplayDocument->SetNeedStyleFlush(); 1.1951 + } 1.1952 + } 1.1953 + 1.1954 + // Note: nsIDocument is a sub-class of nsINode, which has a 1.1955 + // SizeOfExcludingThis function. However, because nsIDocument objects can 1.1956 + // only appear at the top of the DOM tree, we have a specialized measurement 1.1957 + // function which returns multiple sizes. 1.1958 + virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const; 1.1959 + // DocAddSizeOfIncludingThis doesn't need to be overridden by sub-classes 1.1960 + // because nsIDocument inherits from nsINode; see the comment above the 1.1961 + // declaration of nsINode::SizeOfIncludingThis. 1.1962 + virtual void DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const; 1.1963 + 1.1964 + bool MayHaveDOMMutationObservers() 1.1965 + { 1.1966 + return mMayHaveDOMMutationObservers; 1.1967 + } 1.1968 + 1.1969 + void SetMayHaveDOMMutationObservers() 1.1970 + { 1.1971 + mMayHaveDOMMutationObservers = true; 1.1972 + } 1.1973 + 1.1974 + bool IsInSyncOperation() 1.1975 + { 1.1976 + return mInSyncOperationCount != 0; 1.1977 + } 1.1978 + 1.1979 + void SetIsInSyncOperation(bool aSync) 1.1980 + { 1.1981 + if (aSync) { 1.1982 + ++mInSyncOperationCount; 1.1983 + } else { 1.1984 + --mInSyncOperationCount; 1.1985 + } 1.1986 + } 1.1987 + 1.1988 + bool CreatingStaticClone() const 1.1989 + { 1.1990 + return mCreatingStaticClone; 1.1991 + } 1.1992 + 1.1993 + /** 1.1994 + * Creates a new element in the HTML namespace with a local name given by 1.1995 + * aTag. 1.1996 + */ 1.1997 + already_AddRefed<Element> CreateHTMLElement(nsIAtom* aTag); 1.1998 + 1.1999 + // WebIDL API 1.2000 + nsIGlobalObject* GetParentObject() const 1.2001 + { 1.2002 + return GetScopeObject(); 1.2003 + } 1.2004 + static already_AddRefed<nsIDocument> 1.2005 + Constructor(const GlobalObject& aGlobal, 1.2006 + mozilla::ErrorResult& rv); 1.2007 + virtual mozilla::dom::DOMImplementation* 1.2008 + GetImplementation(mozilla::ErrorResult& rv) = 0; 1.2009 + void GetURL(nsString& retval) const; 1.2010 + void GetDocumentURI(nsString& retval) const; 1.2011 + // Return the URI for the document. 1.2012 + // The returned value may differ if the document is loaded via XHR, and 1.2013 + // when accessed from chrome privileged script and 1.2014 + // from content privileged script for compatibility. 1.2015 + void GetDocumentURIFromJS(nsString& aDocumentURI) const; 1.2016 + void GetCompatMode(nsString& retval) const; 1.2017 + void GetCharacterSet(nsAString& retval) const; 1.2018 + // Skip GetContentType, because our NS_IMETHOD version above works fine here. 1.2019 + // GetDoctype defined above 1.2020 + Element* GetDocumentElement() const 1.2021 + { 1.2022 + return GetRootElement(); 1.2023 + } 1.2024 + 1.2025 + enum ElementCallbackType { 1.2026 + eCreated, 1.2027 + eAttached, 1.2028 + eDetached, 1.2029 + eAttributeChanged 1.2030 + }; 1.2031 + 1.2032 + /** 1.2033 + * Registers an unresolved custom element that is a candidate for 1.2034 + * upgrade when the definition is registered via registerElement. 1.2035 + * |aTypeName| is the name of the custom element type, if it is not 1.2036 + * provided, then element name is used. |aTypeName| should be provided 1.2037 + * when registering a custom element that extends an existing 1.2038 + * element. e.g. <button is="x-button">. 1.2039 + */ 1.2040 + virtual nsresult RegisterUnresolvedElement(Element* aElement, 1.2041 + nsIAtom* aTypeName = nullptr) = 0; 1.2042 + virtual void EnqueueLifecycleCallback(ElementCallbackType aType, 1.2043 + Element* aCustomElement, 1.2044 + mozilla::dom::LifecycleCallbackArgs* aArgs = nullptr, 1.2045 + mozilla::dom::CustomElementDefinition* aDefinition = nullptr) = 0; 1.2046 + virtual void SwizzleCustomElement(Element* aElement, 1.2047 + const nsAString& aTypeExtension, 1.2048 + uint32_t aNamespaceID, 1.2049 + mozilla::ErrorResult& rv) = 0; 1.2050 + virtual void 1.2051 + RegisterElement(JSContext* aCx, const nsAString& aName, 1.2052 + const mozilla::dom::ElementRegistrationOptions& aOptions, 1.2053 + JS::MutableHandle<JSObject*> aRetval, 1.2054 + mozilla::ErrorResult& rv) = 0; 1.2055 + 1.2056 + /** 1.2057 + * In some cases, new document instances must be associated with 1.2058 + * an existing web components custom element registry as specified. 1.2059 + */ 1.2060 + virtual void UseRegistryFromDocument(nsIDocument* aDocument) = 0; 1.2061 + 1.2062 + already_AddRefed<nsContentList> 1.2063 + GetElementsByTagName(const nsAString& aTagName) 1.2064 + { 1.2065 + return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName); 1.2066 + } 1.2067 + already_AddRefed<nsContentList> 1.2068 + GetElementsByTagNameNS(const nsAString& aNamespaceURI, 1.2069 + const nsAString& aLocalName, 1.2070 + mozilla::ErrorResult& aResult); 1.2071 + already_AddRefed<nsContentList> 1.2072 + GetElementsByClassName(const nsAString& aClasses); 1.2073 + // GetElementById defined above 1.2074 + already_AddRefed<Element> CreateElement(const nsAString& aTagName, 1.2075 + mozilla::ErrorResult& rv); 1.2076 + already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI, 1.2077 + const nsAString& aQualifiedName, 1.2078 + mozilla::ErrorResult& rv); 1.2079 + virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName, 1.2080 + const nsAString& aTypeExtension, 1.2081 + mozilla::ErrorResult& rv) = 0; 1.2082 + virtual already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI, 1.2083 + const nsAString& aQualifiedName, 1.2084 + const nsAString& aTypeExtension, 1.2085 + mozilla::ErrorResult& rv) = 0; 1.2086 + already_AddRefed<mozilla::dom::DocumentFragment> 1.2087 + CreateDocumentFragment() const; 1.2088 + already_AddRefed<nsTextNode> CreateTextNode(const nsAString& aData) const; 1.2089 + already_AddRefed<mozilla::dom::Comment> 1.2090 + CreateComment(const nsAString& aData) const; 1.2091 + already_AddRefed<mozilla::dom::ProcessingInstruction> 1.2092 + CreateProcessingInstruction(const nsAString& target, const nsAString& data, 1.2093 + mozilla::ErrorResult& rv) const; 1.2094 + already_AddRefed<nsINode> 1.2095 + ImportNode(nsINode& aNode, bool aDeep, mozilla::ErrorResult& rv) const; 1.2096 + nsINode* AdoptNode(nsINode& aNode, mozilla::ErrorResult& rv); 1.2097 + already_AddRefed<mozilla::dom::Event> 1.2098 + CreateEvent(const nsAString& aEventType, mozilla::ErrorResult& rv) const; 1.2099 + already_AddRefed<nsRange> CreateRange(mozilla::ErrorResult& rv); 1.2100 + already_AddRefed<mozilla::dom::NodeIterator> 1.2101 + CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow, 1.2102 + mozilla::dom::NodeFilter* aFilter, 1.2103 + mozilla::ErrorResult& rv) const; 1.2104 + already_AddRefed<mozilla::dom::NodeIterator> 1.2105 + CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow, 1.2106 + const mozilla::dom::NodeFilterHolder& aFilter, 1.2107 + mozilla::ErrorResult& rv) const; 1.2108 + already_AddRefed<mozilla::dom::TreeWalker> 1.2109 + CreateTreeWalker(nsINode& aRoot, uint32_t aWhatToShow, 1.2110 + mozilla::dom::NodeFilter* aFilter, mozilla::ErrorResult& rv) const; 1.2111 + already_AddRefed<mozilla::dom::TreeWalker> 1.2112 + CreateTreeWalker(nsINode& aRoot, uint32_t aWhatToShow, 1.2113 + const mozilla::dom::NodeFilterHolder& aFilter, 1.2114 + mozilla::ErrorResult& rv) const; 1.2115 + 1.2116 + // Deprecated WebIDL bits 1.2117 + already_AddRefed<mozilla::dom::CDATASection> 1.2118 + CreateCDATASection(const nsAString& aData, mozilla::ErrorResult& rv); 1.2119 + already_AddRefed<mozilla::dom::Attr> 1.2120 + CreateAttribute(const nsAString& aName, mozilla::ErrorResult& rv); 1.2121 + already_AddRefed<mozilla::dom::Attr> 1.2122 + CreateAttributeNS(const nsAString& aNamespaceURI, 1.2123 + const nsAString& aQualifiedName, 1.2124 + mozilla::ErrorResult& rv); 1.2125 + void GetInputEncoding(nsAString& aInputEncoding); 1.2126 + already_AddRefed<nsIDOMLocation> GetLocation() const; 1.2127 + void GetReferrer(nsAString& aReferrer) const; 1.2128 + void GetLastModified(nsAString& aLastModified) const; 1.2129 + void GetReadyState(nsAString& aReadyState) const; 1.2130 + // Not const because otherwise the compiler can't figure out whether to call 1.2131 + // this GetTitle or the nsAString version from non-const methods, since 1.2132 + // neither is an exact match. 1.2133 + virtual void GetTitle(nsString& aTitle) = 0; 1.2134 + virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv) = 0; 1.2135 + void GetDir(nsAString& aDirection) const; 1.2136 + void SetDir(const nsAString& aDirection); 1.2137 + nsIDOMWindow* GetDefaultView() const 1.2138 + { 1.2139 + return GetWindow(); 1.2140 + } 1.2141 + Element* GetActiveElement(); 1.2142 + bool HasFocus(mozilla::ErrorResult& rv) const; 1.2143 + // Event handlers are all on nsINode already 1.2144 + bool MozSyntheticDocument() const 1.2145 + { 1.2146 + return IsSyntheticDocument(); 1.2147 + } 1.2148 + Element* GetCurrentScript(); 1.2149 + void ReleaseCapture() const; 1.2150 + virtual void MozSetImageElement(const nsAString& aImageElementId, 1.2151 + Element* aElement) = 0; 1.2152 + nsIURI* GetDocumentURIObject() const; 1.2153 + // Not const because all the full-screen goop is not const 1.2154 + virtual bool MozFullScreenEnabled() = 0; 1.2155 + virtual Element* GetMozFullScreenElement(mozilla::ErrorResult& rv) = 0; 1.2156 + bool MozFullScreen() 1.2157 + { 1.2158 + return IsFullScreenDoc(); 1.2159 + } 1.2160 + void MozCancelFullScreen(); 1.2161 + Element* GetMozPointerLockElement(); 1.2162 + void MozExitPointerLock() 1.2163 + { 1.2164 + UnlockPointer(this); 1.2165 + } 1.2166 + bool Hidden() const 1.2167 + { 1.2168 + return mVisibilityState != mozilla::dom::VisibilityState::Visible; 1.2169 + } 1.2170 + bool MozHidden() // Not const because of WarnOnceAbout 1.2171 + { 1.2172 + WarnOnceAbout(ePrefixedVisibilityAPI); 1.2173 + return Hidden(); 1.2174 + } 1.2175 + mozilla::dom::VisibilityState VisibilityState() 1.2176 + { 1.2177 + return mVisibilityState; 1.2178 + } 1.2179 + mozilla::dom::VisibilityState MozVisibilityState() 1.2180 + { 1.2181 + WarnOnceAbout(ePrefixedVisibilityAPI); 1.2182 + return VisibilityState(); 1.2183 + } 1.2184 + virtual mozilla::dom::StyleSheetList* StyleSheets() = 0; 1.2185 + void GetSelectedStyleSheetSet(nsAString& aSheetSet); 1.2186 + virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0; 1.2187 + virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0; 1.2188 + void GetPreferredStyleSheetSet(nsAString& aSheetSet); 1.2189 + virtual mozilla::dom::DOMStringList* StyleSheetSets() = 0; 1.2190 + virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) = 0; 1.2191 + Element* ElementFromPoint(float aX, float aY); 1.2192 + 1.2193 + /** 1.2194 + * Retrieve the location of the caret position (DOM node and character 1.2195 + * offset within that node), given a point. 1.2196 + * 1.2197 + * @param aX Horizontal point at which to determine the caret position, in 1.2198 + * page coordinates. 1.2199 + * @param aY Vertical point at which to determine the caret position, in 1.2200 + * page coordinates. 1.2201 + */ 1.2202 + already_AddRefed<nsDOMCaretPosition> 1.2203 + CaretPositionFromPoint(float aX, float aY); 1.2204 + 1.2205 + // QuerySelector and QuerySelectorAll already defined on nsINode 1.2206 + nsINodeList* GetAnonymousNodes(Element& aElement); 1.2207 + Element* GetAnonymousElementByAttribute(Element& aElement, 1.2208 + const nsAString& aAttrName, 1.2209 + const nsAString& aAttrValue); 1.2210 + Element* GetBindingParent(nsINode& aNode); 1.2211 + void LoadBindingDocument(const nsAString& aURI, mozilla::ErrorResult& rv); 1.2212 + already_AddRefed<nsIDOMXPathExpression> 1.2213 + CreateExpression(const nsAString& aExpression, 1.2214 + nsIDOMXPathNSResolver* aResolver, 1.2215 + mozilla::ErrorResult& rv); 1.2216 + already_AddRefed<nsIDOMXPathNSResolver> 1.2217 + CreateNSResolver(nsINode* aNodeResolver, mozilla::ErrorResult& rv); 1.2218 + already_AddRefed<nsISupports> 1.2219 + Evaluate(const nsAString& aExpression, nsINode* aContextNode, 1.2220 + nsIDOMXPathNSResolver* aResolver, uint16_t aType, 1.2221 + nsISupports* aResult, mozilla::ErrorResult& rv); 1.2222 + // Touch event handlers already on nsINode 1.2223 + already_AddRefed<mozilla::dom::Touch> 1.2224 + CreateTouch(nsIDOMWindow* aView, mozilla::dom::EventTarget* aTarget, 1.2225 + int32_t aIdentifier, int32_t aPageX, int32_t aPageY, 1.2226 + int32_t aScreenX, int32_t aScreenY, int32_t aClientX, 1.2227 + int32_t aClientY, int32_t aRadiusX, int32_t aRadiusY, 1.2228 + float aRotationAngle, float aForce); 1.2229 + already_AddRefed<mozilla::dom::TouchList> CreateTouchList(); 1.2230 + already_AddRefed<mozilla::dom::TouchList> 1.2231 + CreateTouchList(mozilla::dom::Touch& aTouch, 1.2232 + const mozilla::dom::Sequence<mozilla::dom::OwningNonNull<mozilla::dom::Touch> >& aTouches); 1.2233 + already_AddRefed<mozilla::dom::TouchList> 1.2234 + CreateTouchList(const mozilla::dom::Sequence<mozilla::dom::OwningNonNull<mozilla::dom::Touch> >& aTouches); 1.2235 + 1.2236 + void SetStyleSheetChangeEventsEnabled(bool aValue) 1.2237 + { 1.2238 + mStyleSheetChangeEventsEnabled = aValue; 1.2239 + } 1.2240 + 1.2241 + bool StyleSheetChangeEventsEnabled() const 1.2242 + { 1.2243 + return mStyleSheetChangeEventsEnabled; 1.2244 + } 1.2245 + 1.2246 + void ObsoleteSheet(nsIURI *aSheetURI, mozilla::ErrorResult& rv); 1.2247 + 1.2248 + void ObsoleteSheet(const nsAString& aSheetURI, mozilla::ErrorResult& rv); 1.2249 + 1.2250 + // ParentNode 1.2251 + nsIHTMLCollection* Children(); 1.2252 + uint32_t ChildElementCount(); 1.2253 + 1.2254 + virtual nsHTMLDocument* AsHTMLDocument() { return nullptr; } 1.2255 + 1.2256 + virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE; 1.2257 + 1.2258 +private: 1.2259 + uint64_t mWarnedAbout; 1.2260 + SelectorCache mSelectorCache; 1.2261 + 1.2262 +protected: 1.2263 + ~nsIDocument(); 1.2264 + nsPropertyTable* GetExtraPropertyTable(uint16_t aCategory); 1.2265 + 1.2266 + // Never ever call this. Only call GetWindow! 1.2267 + virtual nsPIDOMWindow *GetWindowInternal() const = 0; 1.2268 + 1.2269 + // Never ever call this. Only call GetScriptHandlingObject! 1.2270 + virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const = 0; 1.2271 + 1.2272 + // Never ever call this. Only call AllowXULXBL! 1.2273 + virtual bool InternalAllowXULXBL() = 0; 1.2274 + 1.2275 + /** 1.2276 + * These methods should be called before and after dispatching 1.2277 + * a mutation event. 1.2278 + * To make this easy and painless, use the mozAutoSubtreeModified helper class. 1.2279 + */ 1.2280 + virtual void WillDispatchMutationEvent(nsINode* aTarget) = 0; 1.2281 + virtual void MutationEventDispatched(nsINode* aTarget) = 0; 1.2282 + friend class mozAutoSubtreeModified; 1.2283 + 1.2284 + virtual Element* GetNameSpaceElement() 1.2285 + { 1.2286 + return GetRootElement(); 1.2287 + } 1.2288 + 1.2289 + void SetContentTypeInternal(const nsACString& aType); 1.2290 + 1.2291 + nsCString GetContentTypeInternal() const 1.2292 + { 1.2293 + return mContentType; 1.2294 + } 1.2295 + 1.2296 + mozilla::dom::XPathEvaluator* XPathEvaluator(); 1.2297 + 1.2298 + nsCString mReferrer; 1.2299 + nsString mLastModified; 1.2300 + 1.2301 + nsCOMPtr<nsIURI> mDocumentURI; 1.2302 + nsCOMPtr<nsIURI> mOriginalURI; 1.2303 + nsCOMPtr<nsIURI> mChromeXHRDocURI; 1.2304 + nsCOMPtr<nsIURI> mDocumentBaseURI; 1.2305 + nsCOMPtr<nsIURI> mChromeXHRDocBaseURI; 1.2306 + 1.2307 + nsWeakPtr mDocumentLoadGroup; 1.2308 + 1.2309 + mozilla::WeakPtr<nsDocShell> mDocumentContainer; 1.2310 + 1.2311 + nsCString mCharacterSet; 1.2312 + int32_t mCharacterSetSource; 1.2313 + 1.2314 + // This is just a weak pointer; the parent document owns its children. 1.2315 + nsIDocument* mParentDocument; 1.2316 + 1.2317 + // A reference to the element last returned from GetRootElement(). 1.2318 + mozilla::dom::Element* mCachedRootElement; 1.2319 + 1.2320 + // This is a weak reference, but we hold a strong reference to mNodeInfo, 1.2321 + // which in turn holds a strong reference to this mNodeInfoManager. 1.2322 + nsNodeInfoManager* mNodeInfoManager; 1.2323 + nsRefPtr<mozilla::css::Loader> mCSSLoader; 1.2324 + nsRefPtr<mozilla::css::ImageLoader> mStyleImageLoader; 1.2325 + nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet; 1.2326 + nsRefPtr<nsHTMLCSSStyleSheet> mStyleAttrStyleSheet; 1.2327 + 1.2328 + // The set of all object, embed, applet, video and audio elements for 1.2329 + // which this is the owner document. (They might not be in the document.) 1.2330 + // These are non-owning pointers, the elements are responsible for removing 1.2331 + // themselves when they go away. 1.2332 + nsAutoPtr<nsTHashtable<nsPtrHashKey<nsIContent> > > mFreezableElements; 1.2333 + 1.2334 + // The set of all links that need their status resolved. Links must add themselves 1.2335 + // to this set by calling RegisterPendingLinkUpdate when added to a document and must 1.2336 + // remove themselves by calling UnregisterPendingLinkUpdate when removed from a document. 1.2337 + nsTHashtable<nsPtrHashKey<mozilla::dom::Link> > mLinksToUpdate; 1.2338 + 1.2339 + // SMIL Animation Controller, lazily-initialized in GetAnimationController 1.2340 + nsRefPtr<nsSMILAnimationController> mAnimationController; 1.2341 + 1.2342 + // Table of element properties for this document. 1.2343 + nsPropertyTable mPropertyTable; 1.2344 + nsTArray<nsAutoPtr<nsPropertyTable> > mExtraPropertyTables; 1.2345 + 1.2346 + // Our cached .children collection 1.2347 + nsCOMPtr<nsIHTMLCollection> mChildrenCollection; 1.2348 + 1.2349 + // Compatibility mode 1.2350 + nsCompatibility mCompatMode; 1.2351 + 1.2352 + // Our readyState 1.2353 + ReadyState mReadyState; 1.2354 + 1.2355 + // Our visibility state 1.2356 + mozilla::dom::VisibilityState mVisibilityState; 1.2357 + 1.2358 + // True if BIDI is enabled. 1.2359 + bool mBidiEnabled; 1.2360 + // True if a MathML element has ever been owned by this document. 1.2361 + bool mMathMLEnabled; 1.2362 + 1.2363 + // True if this document is the initial document for a window. This should 1.2364 + // basically be true only for documents that exist in newly-opened windows or 1.2365 + // documents created to satisfy a GetDocument() on a window when there's no 1.2366 + // document in it. 1.2367 + bool mIsInitialDocumentInWindow; 1.2368 + 1.2369 + bool mIsRegularHTML; 1.2370 + bool mIsXUL; 1.2371 + 1.2372 + enum { 1.2373 + eTriUnset = 0, 1.2374 + eTriFalse, 1.2375 + eTriTrue 1.2376 + } mAllowXULXBL; 1.2377 + 1.2378 + // True if we're loaded as data and therefor has any dangerous stuff, such 1.2379 + // as scripts and plugins, disabled. 1.2380 + bool mLoadedAsData; 1.2381 + 1.2382 + // This flag is only set in XMLDocument, for e.g. documents used in XBL. We 1.2383 + // don't want animations to play in such documents, so we need to store the 1.2384 + // flag here so that we can check it in nsDocument::GetAnimationController. 1.2385 + bool mLoadedAsInteractiveData; 1.2386 + 1.2387 + // If true, whoever is creating the document has gotten it to the 1.2388 + // point where it's safe to start layout on it. 1.2389 + bool mMayStartLayout; 1.2390 + 1.2391 + // True iff we've ever fired a DOMTitleChanged event for this document 1.2392 + bool mHaveFiredTitleChange; 1.2393 + 1.2394 + // True iff IsShowing() should be returning true 1.2395 + bool mIsShowing; 1.2396 + 1.2397 + // True iff the document "page" is not hidden (i.e. currently in the 1.2398 + // bfcache) 1.2399 + bool mVisible; 1.2400 + 1.2401 + // True if our content viewer has been removed from the docshell 1.2402 + // (it may still be displayed, but in zombie state). Form control data 1.2403 + // has been saved. 1.2404 + bool mRemovedFromDocShell; 1.2405 + 1.2406 + // True iff DNS prefetch is allowed for this document. Note that if the 1.2407 + // document has no window, DNS prefetch won't be performed no matter what. 1.2408 + bool mAllowDNSPrefetch; 1.2409 + 1.2410 + // True when this document is a static clone of a normal document 1.2411 + bool mIsStaticDocument; 1.2412 + 1.2413 + // True while this document is being cloned to a static document. 1.2414 + bool mCreatingStaticClone; 1.2415 + 1.2416 + // True iff the document is being unlinked or deleted. 1.2417 + bool mInUnlinkOrDeletion; 1.2418 + 1.2419 + // True if document has ever had script handling object. 1.2420 + bool mHasHadScriptHandlingObject; 1.2421 + 1.2422 + // True if we're an SVG document being used as an image. 1.2423 + bool mIsBeingUsedAsImage; 1.2424 + 1.2425 + // True is this document is synthetic : stand alone image, video, audio 1.2426 + // file, etc. 1.2427 + bool mIsSyntheticDocument; 1.2428 + 1.2429 + // True if this document has links whose state needs updating 1.2430 + bool mHasLinksToUpdate; 1.2431 + 1.2432 + // True if a layout flush might not be a no-op 1.2433 + bool mNeedLayoutFlush; 1.2434 + 1.2435 + // True if a style flush might not be a no-op 1.2436 + bool mNeedStyleFlush; 1.2437 + 1.2438 + // True if a DOMMutationObserver is perhaps attached to a node in the document. 1.2439 + bool mMayHaveDOMMutationObservers; 1.2440 + 1.2441 + // True if a document has loaded Mixed Active Script (see nsMixedContentBlocker.cpp) 1.2442 + bool mHasMixedActiveContentLoaded; 1.2443 + 1.2444 + // True if a document has blocked Mixed Active Script (see nsMixedContentBlocker.cpp) 1.2445 + bool mHasMixedActiveContentBlocked; 1.2446 + 1.2447 + // True if a document has loaded Mixed Display/Passive Content (see nsMixedContentBlocker.cpp) 1.2448 + bool mHasMixedDisplayContentLoaded; 1.2449 + 1.2450 + // True if a document has blocked Mixed Display/Passive Content (see nsMixedContentBlocker.cpp) 1.2451 + bool mHasMixedDisplayContentBlocked; 1.2452 + 1.2453 + // True if DisallowBFCaching has been called on this document. 1.2454 + bool mBFCacheDisallowed; 1.2455 + 1.2456 + // If true, we have an input encoding. If this is false, then the 1.2457 + // document was created entirely in memory 1.2458 + bool mHaveInputEncoding; 1.2459 + 1.2460 + bool mHasHadDefaultView; 1.2461 + 1.2462 + // Whether style sheet change events will be dispatched for this document 1.2463 + bool mStyleSheetChangeEventsEnabled; 1.2464 + 1.2465 + // Whether the document was created by a srcdoc iframe. 1.2466 + bool mIsSrcdocDocument; 1.2467 + 1.2468 + // Records whether we've done a document.open. If this is true, it's possible 1.2469 + // for nodes from this document to have outdated wrappers in their wrapper 1.2470 + // caches. 1.2471 + bool mDidDocumentOpen; 1.2472 + 1.2473 +#ifdef DEBUG 1.2474 + /** 1.2475 + * This is true while FlushPendingLinkUpdates executes. Calls to 1.2476 + * [Un]RegisterPendingLinkUpdate will assert when this is true. 1.2477 + */ 1.2478 + bool mIsLinkUpdateRegistrationsForbidden; 1.2479 +#endif 1.2480 + 1.2481 + // The document's script global object, the object from which the 1.2482 + // document can get its script context and scope. This is the 1.2483 + // *inner* window object. 1.2484 + nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject; 1.2485 + 1.2486 + // If mIsStaticDocument is true, mOriginalDocument points to the original 1.2487 + // document. 1.2488 + nsCOMPtr<nsIDocument> mOriginalDocument; 1.2489 + 1.2490 + // The bidi options for this document. What this bitfield means is 1.2491 + // defined in nsBidiUtils.h 1.2492 + uint32_t mBidiOptions; 1.2493 + 1.2494 + // The sandbox flags on the document. These reflect the value of the sandbox attribute of the 1.2495 + // associated IFRAME or CSP-protectable content, if existent. These are set at load time and 1.2496 + // are immutable - see nsSandboxFlags.h for the possible flags. 1.2497 + uint32_t mSandboxFlags; 1.2498 + 1.2499 + nsCString mContentLanguage; 1.2500 + 1.2501 + // The channel that got passed to nsDocument::StartDocumentLoad(), if any. 1.2502 + nsCOMPtr<nsIChannel> mChannel; 1.2503 +private: 1.2504 + nsCString mContentType; 1.2505 +protected: 1.2506 + 1.2507 + // The document's security info 1.2508 + nsCOMPtr<nsISupports> mSecurityInfo; 1.2509 + 1.2510 + // if this document is part of a multipart document, 1.2511 + // the ID can be used to distinguish it from the other parts. 1.2512 + uint32_t mPartID; 1.2513 + 1.2514 + // Cycle collector generation in which we're certain that this document 1.2515 + // won't be collected 1.2516 + uint32_t mMarkedCCGeneration; 1.2517 + 1.2518 + nsIPresShell* mPresShell; 1.2519 + 1.2520 + nsCOMArray<nsINode> mSubtreeModifiedTargets; 1.2521 + uint32_t mSubtreeModifiedDepth; 1.2522 + 1.2523 + // If we're an external resource document, this will be non-null and will 1.2524 + // point to our "display document": the one that all resource lookups should 1.2525 + // go to. 1.2526 + nsCOMPtr<nsIDocument> mDisplayDocument; 1.2527 + 1.2528 + uint32_t mEventsSuppressed; 1.2529 + 1.2530 + uint32_t mAnimationsPaused; 1.2531 + 1.2532 + /** 1.2533 + * The number number of external scripts (ones with the src attribute) that 1.2534 + * have this document as their owner and that are being evaluated right now. 1.2535 + */ 1.2536 + uint32_t mExternalScriptsBeingEvaluated; 1.2537 + 1.2538 + /** 1.2539 + * The current frame request callback handle 1.2540 + */ 1.2541 + int32_t mFrameRequestCallbackCounter; 1.2542 + 1.2543 + // Weak reference to mScriptGlobalObject QI:d to nsPIDOMWindow, 1.2544 + // updated on every set of mSecriptGlobalObject. 1.2545 + nsPIDOMWindow *mWindow; 1.2546 + 1.2547 + nsCOMPtr<nsIDocumentEncoder> mCachedEncoder; 1.2548 + 1.2549 + struct FrameRequest; 1.2550 + 1.2551 + nsTArray<FrameRequest> mFrameRequestCallbacks; 1.2552 + 1.2553 + // This object allows us to evict ourself from the back/forward cache. The 1.2554 + // pointer is non-null iff we're currently in the bfcache. 1.2555 + nsIBFCacheEntry *mBFCacheEntry; 1.2556 + 1.2557 + // Our base target. 1.2558 + nsString mBaseTarget; 1.2559 + 1.2560 + nsCOMPtr<nsIStructuredCloneContainer> mStateObjectContainer; 1.2561 + nsCOMPtr<nsIVariant> mStateObjectCached; 1.2562 + 1.2563 + uint8_t mDefaultElementType; 1.2564 + 1.2565 + uint32_t mInSyncOperationCount; 1.2566 + 1.2567 + nsRefPtr<mozilla::dom::XPathEvaluator> mXPathEvaluator; 1.2568 + 1.2569 + uint32_t mBlockDOMContentLoaded; 1.2570 + bool mDidFireDOMContentLoaded:1; 1.2571 +}; 1.2572 + 1.2573 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID) 1.2574 + 1.2575 +/** 1.2576 + * mozAutoSubtreeModified batches DOM mutations so that a DOMSubtreeModified 1.2577 + * event is dispatched, if necessary, when the outermost mozAutoSubtreeModified 1.2578 + * object is deleted. 1.2579 + */ 1.2580 +class MOZ_STACK_CLASS mozAutoSubtreeModified 1.2581 +{ 1.2582 +public: 1.2583 + /** 1.2584 + * @param aSubTreeOwner The document in which a subtree will be modified. 1.2585 + * @param aTarget The target of the possible DOMSubtreeModified event. 1.2586 + * Can be nullptr, in which case mozAutoSubtreeModified 1.2587 + * is just used to batch DOM mutations. 1.2588 + */ 1.2589 + mozAutoSubtreeModified(nsIDocument* aSubtreeOwner, nsINode* aTarget) 1.2590 + { 1.2591 + UpdateTarget(aSubtreeOwner, aTarget); 1.2592 + } 1.2593 + 1.2594 + ~mozAutoSubtreeModified() 1.2595 + { 1.2596 + UpdateTarget(nullptr, nullptr); 1.2597 + } 1.2598 + 1.2599 + void UpdateTarget(nsIDocument* aSubtreeOwner, nsINode* aTarget) 1.2600 + { 1.2601 + if (mSubtreeOwner) { 1.2602 + mSubtreeOwner->MutationEventDispatched(mTarget); 1.2603 + } 1.2604 + 1.2605 + mTarget = aTarget; 1.2606 + mSubtreeOwner = aSubtreeOwner; 1.2607 + if (mSubtreeOwner) { 1.2608 + mSubtreeOwner->WillDispatchMutationEvent(mTarget); 1.2609 + } 1.2610 + } 1.2611 + 1.2612 +private: 1.2613 + nsCOMPtr<nsINode> mTarget; 1.2614 + nsCOMPtr<nsIDocument> mSubtreeOwner; 1.2615 +}; 1.2616 + 1.2617 +class MOZ_STACK_CLASS nsAutoSyncOperation 1.2618 +{ 1.2619 +public: 1.2620 + nsAutoSyncOperation(nsIDocument* aDocument); 1.2621 + ~nsAutoSyncOperation(); 1.2622 +private: 1.2623 + nsCOMArray<nsIDocument> mDocuments; 1.2624 + uint32_t mMicroTaskLevel; 1.2625 +}; 1.2626 + 1.2627 +// XXX These belong somewhere else 1.2628 +nsresult 1.2629 +NS_NewHTMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false); 1.2630 + 1.2631 +nsresult 1.2632 +NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData = false); 1.2633 + 1.2634 +nsresult 1.2635 +NS_NewSVGDocument(nsIDocument** aInstancePtrResult); 1.2636 + 1.2637 +nsresult 1.2638 +NS_NewImageDocument(nsIDocument** aInstancePtrResult); 1.2639 + 1.2640 +nsresult 1.2641 +NS_NewVideoDocument(nsIDocument** aInstancePtrResult); 1.2642 + 1.2643 +// Note: it's the caller's responsibility to create or get aPrincipal as needed 1.2644 +// -- this method will not attempt to get a principal based on aDocumentURI. 1.2645 +// Also, both aDocumentURI and aBaseURI must not be null. 1.2646 +nsresult 1.2647 +NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult, 1.2648 + const nsAString& aNamespaceURI, 1.2649 + const nsAString& aQualifiedName, 1.2650 + nsIDOMDocumentType* aDoctype, 1.2651 + nsIURI* aDocumentURI, 1.2652 + nsIURI* aBaseURI, 1.2653 + nsIPrincipal* aPrincipal, 1.2654 + bool aLoadedAsData, 1.2655 + nsIGlobalObject* aEventObject, 1.2656 + DocumentFlavor aFlavor); 1.2657 + 1.2658 +// This is used only for xbl documents created from the startup cache. 1.2659 +// Non-cached documents are created in the same manner as xml documents. 1.2660 +nsresult 1.2661 +NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult, 1.2662 + nsIURI* aDocumentURI, 1.2663 + nsIURI* aBaseURI, 1.2664 + nsIPrincipal* aPrincipal); 1.2665 + 1.2666 +nsresult 1.2667 +NS_NewPluginDocument(nsIDocument** aInstancePtrResult); 1.2668 + 1.2669 +inline nsIDocument* 1.2670 +nsINode::GetOwnerDocument() const 1.2671 +{ 1.2672 + nsIDocument* ownerDoc = OwnerDoc(); 1.2673 + 1.2674 + return ownerDoc != this ? ownerDoc : nullptr; 1.2675 +} 1.2676 + 1.2677 +inline nsINode* 1.2678 +nsINode::OwnerDocAsNode() const 1.2679 +{ 1.2680 + return OwnerDoc(); 1.2681 +} 1.2682 + 1.2683 +inline mozilla::dom::ParentObject 1.2684 +nsINode::GetParentObject() const 1.2685 +{ 1.2686 + return GetParentObjectInternal(OwnerDoc()); 1.2687 +} 1.2688 + 1.2689 +#endif /* nsIDocument_h___ */