зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1555216 - Cache owner doc in the BindContext. r=bzbarsky
And use it to avoid some pointer chases per the review comments of D32949. Differential Revision: https://phabricator.services.mozilla.com/D33288
This commit is contained in:
Родитель
abecd6b5f9
Коммит
6ada67c323
|
@ -18,6 +18,12 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
struct MOZ_STACK_CLASS BindContext final {
|
||||
// The document that owns the tree we're getting bound to.
|
||||
//
|
||||
// This is mostly an optimization to avoid silly pointer-chases to get the
|
||||
// OwnerDoc().
|
||||
Document& OwnerDoc() const { return mDoc; }
|
||||
|
||||
// Whether our subtree root is changing as a result of this operation.
|
||||
bool SubtreeRootChanges() const { return mSubtreeRootChanges; }
|
||||
|
||||
|
@ -31,7 +37,8 @@ struct MOZ_STACK_CLASS BindContext final {
|
|||
// FIXME(emilio, bug 1555944): nsIContent::GetBindingParent() should return an
|
||||
// Element*.
|
||||
explicit BindContext(nsINode& aParentNode)
|
||||
: mSubtreeRootChanges(true),
|
||||
: mDoc(*aParentNode.OwnerDoc()),
|
||||
mSubtreeRootChanges(true),
|
||||
mBindingParent(aParentNode.IsContent()
|
||||
? static_cast<Element*>(
|
||||
aParentNode.AsContent()->GetBindingParent())
|
||||
|
@ -44,22 +51,27 @@ struct MOZ_STACK_CLASS BindContext final {
|
|||
//
|
||||
// This constructor is only meant to be used in that situation.
|
||||
explicit BindContext(ShadowRoot& aShadowRoot)
|
||||
: mSubtreeRootChanges(false),
|
||||
: mDoc(*aShadowRoot.OwnerDoc()),
|
||||
mSubtreeRootChanges(false),
|
||||
mBindingParent(aShadowRoot.Host()) {}
|
||||
|
||||
// This constructor is meant to be used when inserting native-anonymous
|
||||
// children into a subtree.
|
||||
enum ForNativeAnonymous { ForNativeAnonymous };
|
||||
BindContext(Element& aParentElement, enum ForNativeAnonymous)
|
||||
: mSubtreeRootChanges(true),
|
||||
: mDoc(*aParentElement.OwnerDoc()),
|
||||
mSubtreeRootChanges(true),
|
||||
mBindingParent(&aParentElement) {}
|
||||
|
||||
// This is meant to be used to bind XBL anonymous content.
|
||||
BindContext(nsXBLBinding& aBinding, Element& aParentElement)
|
||||
: mSubtreeRootChanges(true),
|
||||
: mDoc(*aParentElement.OwnerDoc()),
|
||||
mSubtreeRootChanges(true),
|
||||
mBindingParent(aBinding.GetBoundElement()) {}
|
||||
|
||||
private:
|
||||
Document& mDoc;
|
||||
|
||||
// Whether the bind operation will change the subtree root of the content
|
||||
// we're binding.
|
||||
const bool mSubtreeRootChanges;
|
||||
|
|
|
@ -392,6 +392,7 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
"Must have content or document parent!");
|
||||
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
|
||||
"Must have the same owner document");
|
||||
MOZ_ASSERT(OwnerDoc() == &aContext.OwnerDoc(), "These should match too");
|
||||
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
|
||||
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
|
||||
// Note that as we recurse into the kids, they'll have a non-null parent. So
|
||||
|
@ -455,7 +456,7 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
// FIXME(emilio): This should probably be dependent on composed doc, not
|
||||
// uncomposed.
|
||||
if (mText.IsBidi()) {
|
||||
OwnerDoc()->SetBidiEnabled();
|
||||
aContext.OwnerDoc().SetBidiEnabled();
|
||||
}
|
||||
} else {
|
||||
SetFlags(NODE_IS_IN_SHADOW_TREE);
|
||||
|
|
|
@ -1581,6 +1581,7 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
"Must have content or document parent!");
|
||||
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
|
||||
"Must have the same owner document");
|
||||
MOZ_ASSERT(OwnerDoc() == &aContext.OwnerDoc(), "These should match too");
|
||||
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
|
||||
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
|
||||
// Note that as we recurse into the kids, they'll have a non-null parent. So
|
||||
|
@ -1694,7 +1695,7 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
// also need to be told that they are moving.
|
||||
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
|
||||
nsXBLBinding* binding =
|
||||
OwnerDoc()->BindingManager()->GetBindingWithContent(this);
|
||||
aContext.OwnerDoc().BindingManager()->GetBindingWithContent(this);
|
||||
|
||||
if (binding) {
|
||||
binding->BindAnonymousContent(binding->GetAnonymousContent(), this);
|
||||
|
@ -1745,7 +1746,7 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
pseudoType == PseudoStyleType::after ||
|
||||
pseudoType == PseudoStyleType::marker) &&
|
||||
EffectSet::GetEffectSet(this, pseudoType)) {
|
||||
if (nsPresContext* presContext = OwnerDoc()->GetPresContext()) {
|
||||
if (nsPresContext* presContext = aContext.OwnerDoc().GetPresContext()) {
|
||||
presContext->EffectCompositor()->RequestRestyle(
|
||||
this, pseudoType, EffectCompositor::RestyleType::Standard,
|
||||
EffectCompositor::CascadeLevel::Animations);
|
||||
|
|
|
@ -1613,7 +1613,8 @@ void nsImageLoadingContent::NotifyOwnerDocumentActivityChanged() {
|
|||
void nsImageLoadingContent::BindToTree(BindContext& aContext,
|
||||
nsINode& aParent) {
|
||||
// We may be getting connected, if so our image should be tracked,
|
||||
if (GetOurCurrentDoc()) {
|
||||
// NOTE(emilio): Using aParent to avoid silly virtual call.
|
||||
if (aParent.IsInComposedDoc()) {
|
||||
TrackImage(mCurrentRequest);
|
||||
TrackImage(mPendingRequest);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIExternalProtocolHandler.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -568,8 +569,8 @@ nsresult nsObjectLoadingContent::BindToTree(BindContext& aContext,
|
|||
nsImageLoadingContent::BindToTree(aContext, aParent);
|
||||
// NOTE(emilio): Using aParent to avoid silly QI.
|
||||
// FIXME(emilio): Should probably use composed doc?
|
||||
if (Document* doc = aParent.GetUncomposedDoc()) {
|
||||
doc->AddPlugin(this);
|
||||
if (aParent.IsInUncomposedDoc()) {
|
||||
aContext.OwnerDoc().AddPlugin(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/HTMLAnchorElement.h"
|
||||
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLAnchorElementBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
|
@ -101,9 +102,8 @@ nsresult HTMLAnchorElement::BindToTree(BindContext& aContext,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Prefetch links
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
doc->RegisterPendingLinkUpdate(this);
|
||||
if (IsInComposedDoc()) {
|
||||
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
|
||||
TryDNSPrefetch();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/dom/HTMLAreaElement.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLAnchorElement.h"
|
||||
#include "mozilla/dom/HTMLAreaElementBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
|
@ -71,9 +72,8 @@ nsresult HTMLAreaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
doc->RegisterPendingLinkUpdate(this);
|
||||
if (IsInComposedDoc()) {
|
||||
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "HTMLBodyElement.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLBodyElementBinding.h"
|
||||
#include "mozilla/MappedDeclarations.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
|
@ -286,7 +287,7 @@ bool HTMLBodyElement::IsEventAttributeNameInternal(nsAtom* aName) {
|
|||
nsresult HTMLBodyElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
||||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return mAttrs.ForceMapped(this, OwnerDoc());
|
||||
return mAttrs.ForceMapped(this, &aContext.OwnerDoc());
|
||||
}
|
||||
|
||||
nsresult HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLEmbedElement.h"
|
||||
#include "mozilla/dom/HTMLEmbedElementBinding.h"
|
||||
#include "mozilla/dom/ElementInlines.h"
|
||||
|
@ -80,17 +81,17 @@ nsresult HTMLEmbedElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
rv = nsObjectLoadingContent::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Don't kick off load from being bound to a plugin document - the plugin
|
||||
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
||||
// initial load.
|
||||
//
|
||||
// FIXME(emilio): Seems a bit wasteful to add the runnable unconditionally
|
||||
// otherwise?
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(GetUncomposedDoc());
|
||||
if (!pluginDoc) {
|
||||
void (HTMLEmbedElement::*start)() = &HTMLEmbedElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod("dom::HTMLEmbedElement::BindToTree", this, start));
|
||||
if (IsInComposedDoc()) {
|
||||
// Don't kick off load from being bound to a plugin document - the plugin
|
||||
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
||||
// initial load.
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc =
|
||||
do_QueryInterface(&aContext.OwnerDoc());
|
||||
if (!pluginDoc) {
|
||||
void (HTMLEmbedElement::*start)() = &HTMLEmbedElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod("dom::HTMLEmbedElement::BindToTree", this, start));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/nsCSPUtils.h"
|
||||
#include "mozilla/dom/nsCSPContext.h"
|
||||
#include "mozilla/dom/nsMixedContentBlocker.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "nsIFormControlFrame.h"
|
||||
#include "nsError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
@ -255,9 +257,8 @@ nsresult HTMLFormElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(GetUncomposedDoc()));
|
||||
if (htmlDoc) {
|
||||
htmlDoc->AddedForm();
|
||||
if (IsInUncomposedDoc() && aContext.OwnerDoc().IsHTMLOrXHTML()) {
|
||||
aContext.OwnerDoc().AsHTMLDocument()->AddedForm();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
#include "mozilla/dom/HTMLImageElementBinding.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsPresContext.h"
|
||||
|
@ -500,9 +501,8 @@ nsresult HTMLImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
UpdateFormOwner();
|
||||
|
||||
if (HaveSrcsetOrInPicture()) {
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc && !mInDocResponsiveContent) {
|
||||
doc->AddResponsiveContent(this);
|
||||
if (IsInComposedDoc() && !mInDocResponsiveContent) {
|
||||
aContext.OwnerDoc().AddResponsiveContent(this);
|
||||
mInDocResponsiveContent = true;
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ nsresult HTMLImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
// If loading is temporarily disabled, don't even launch MaybeLoadImage.
|
||||
// Otherwise MaybeLoadImage may run later when someone has reenabled
|
||||
// loading.
|
||||
if (LoadingEnabled() && OwnerDoc()->ShouldLoadImages()) {
|
||||
if (LoadingEnabled() && aContext.OwnerDoc().ShouldLoadImages()) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod<bool>("dom::HTMLImageElement::MaybeLoadImage", this,
|
||||
&HTMLImageElement::MaybeLoadImage, false));
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/HTMLLinkElementBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -122,9 +123,9 @@ nsresult HTMLLinkElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (Document* doc = GetComposedDoc()) {
|
||||
if (!doc->NodePrincipal()->IsSystemPrincipal()) {
|
||||
doc->RegisterPendingLinkUpdate(this);
|
||||
if (IsInComposedDoc()) {
|
||||
if (!aContext.OwnerDoc().NodePrincipal()->IsSystemPrincipal()) {
|
||||
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
|
||||
}
|
||||
TryDNSPrefetchOrPreconnectOrPrefetchOrPreloadOrPrerender();
|
||||
}
|
||||
|
@ -139,7 +140,7 @@ nsresult HTMLLinkElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
if (IsInUncomposedDoc() &&
|
||||
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
|
||||
eIgnoreCase)) {
|
||||
OwnerDoc()->LocalizationLinkAdded(this);
|
||||
aContext.OwnerDoc().LocalizationLinkAdded(this);
|
||||
}
|
||||
|
||||
LinkAdded();
|
||||
|
|
|
@ -74,23 +74,23 @@ nsresult HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|||
nsresult HTMLMetaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
||||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
Document* document = GetUncomposedDoc();
|
||||
if (!document) {
|
||||
if (!IsInUncomposedDoc()) {
|
||||
return rv;
|
||||
}
|
||||
Document& doc = aContext.OwnerDoc();
|
||||
if (AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport,
|
||||
eIgnoreCase)) {
|
||||
nsAutoString content;
|
||||
GetContent(content);
|
||||
nsContentUtils::ProcessViewportInfo(document, content);
|
||||
nsContentUtils::ProcessViewportInfo(&doc, content);
|
||||
}
|
||||
|
||||
if (StaticPrefs::security_csp_enable() && !document->IsLoadedAsData() &&
|
||||
if (StaticPrefs::security_csp_enable() && !doc.IsLoadedAsData() &&
|
||||
AttrValueIs(kNameSpaceID_None, nsGkAtoms::httpEquiv, nsGkAtoms::headerCSP,
|
||||
eIgnoreCase)) {
|
||||
// only accept <meta http-equiv="Content-Security-Policy" content=""> if it
|
||||
// appears in the <head> element.
|
||||
Element* headElt = document->GetHeadElement();
|
||||
Element* headElt = doc.GetHeadElement();
|
||||
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
|
||||
nsAutoString content;
|
||||
GetContent(content);
|
||||
|
@ -98,18 +98,17 @@ nsresult HTMLMetaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
|
||||
content);
|
||||
|
||||
if (nsCOMPtr<nsIContentSecurityPolicy> csp = document->GetCsp()) {
|
||||
if (nsCOMPtr<nsIContentSecurityPolicy> csp = doc.GetCsp()) {
|
||||
if (LOG_ENABLED()) {
|
||||
nsAutoCString documentURIspec;
|
||||
nsIURI* documentURI = document->GetDocumentURI();
|
||||
if (documentURI) {
|
||||
if (nsIURI* documentURI = doc.GetDocumentURI()) {
|
||||
documentURI->GetAsciiSpec(documentURIspec);
|
||||
}
|
||||
|
||||
LOG(
|
||||
("HTMLMetaElement %p sets CSP '%s' on document=%p, "
|
||||
"document-uri=%s",
|
||||
this, NS_ConvertUTF16toUTF8(content).get(), document,
|
||||
this, NS_ConvertUTF16toUTF8(content).get(), &doc,
|
||||
documentURIspec.get()));
|
||||
}
|
||||
|
||||
|
@ -121,18 +120,18 @@ nsresult HTMLMetaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
false, // csp via meta tag can not be report only
|
||||
true); // delivered through the meta tag
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (nsPIDOMWindowInner* inner = document->GetInnerWindow()) {
|
||||
if (nsPIDOMWindowInner* inner = doc.GetInnerWindow()) {
|
||||
inner->SetCsp(csp);
|
||||
}
|
||||
document->ApplySettingsFromCSP(false);
|
||||
doc.ApplySettingsFromCSP(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Referrer Policy spec requires a <meta name="referrer" tag to be in the
|
||||
// <head> element.
|
||||
SetMetaReferrer(document);
|
||||
CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaAdded"));
|
||||
SetMetaReferrer(&doc);
|
||||
CreateAndDispatchEvent(&doc, NS_LITERAL_STRING("DOMMetaAdded"));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,15 +208,15 @@ nsresult HTMLObjectElement::BindToTree(BindContext& aContext,
|
|||
// Don't kick off load from being bound to a plugin document - the plugin
|
||||
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
||||
// initial load.
|
||||
//
|
||||
// FIXME(emilio): Seems wasteful to queue the runnable unconditionally
|
||||
// otherwise.
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(GetUncomposedDoc());
|
||||
// If we already have all the children, start the load.
|
||||
if (mIsDoneAddingChildren && !pluginDoc) {
|
||||
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start));
|
||||
if (IsInComposedDoc()) {
|
||||
nsCOMPtr<nsIPluginDocument> pluginDoc =
|
||||
do_QueryInterface(&aContext.OwnerDoc());
|
||||
// If we already have all the children, start the load.
|
||||
if (mIsDoneAddingChildren && !pluginDoc) {
|
||||
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -52,7 +52,7 @@ nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
|
|||
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (GetComposedDoc()) {
|
||||
if (IsInComposedDoc()) {
|
||||
MaybeProcessScript();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLSharedElement.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/HTMLBaseElementBinding.h"
|
||||
#include "mozilla/dom/HTMLDirectoryElementBinding.h"
|
||||
#include "mozilla/dom/HTMLHeadElementBinding.h"
|
||||
|
@ -233,10 +234,10 @@ nsresult HTMLSharedElement::BindToTree(BindContext& aContext,
|
|||
// need to update here.
|
||||
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
||||
SetBaseURIUsingFirstBaseWithHref(OwnerDoc(), this);
|
||||
SetBaseURIUsingFirstBaseWithHref(&aContext.OwnerDoc(), this);
|
||||
}
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
||||
SetBaseTargetUsingFirstBaseWithTarget(OwnerDoc(), this);
|
||||
SetBaseTargetUsingFirstBaseWithTarget(&aContext.OwnerDoc(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsQueryObject.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
@ -422,17 +423,17 @@ nsresult nsGenericHTMLElement::BindToTree(BindContext& aContext,
|
|||
nsresult rv = nsGenericHTMLElementBase::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (Document* doc = GetUncomposedDoc()) {
|
||||
if (IsInUncomposedDoc()) {
|
||||
RegAccessKey();
|
||||
if (HasName() && CanHaveName(NodeInfo()->NameAtom())) {
|
||||
doc->AddToNameTable(this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
|
||||
aContext.OwnerDoc().AddToNameTable(
|
||||
this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue) {
|
||||
if (Document* doc = GetComposedDoc()) {
|
||||
doc->ChangeContentEditableCount(this, +1);
|
||||
}
|
||||
if (HasFlag(NODE_IS_EDITABLE) && GetContentEditableValue() == eTrue &&
|
||||
IsInComposedDoc()) {
|
||||
aContext.OwnerDoc().ChangeContentEditableCount(this, +1);
|
||||
}
|
||||
|
||||
// We need to consider a labels element is moved to another subtree
|
||||
|
@ -1599,7 +1600,7 @@ nsresult nsGenericHTMLFormElement::BindToTree(BindContext& aContext,
|
|||
// preference should be 'true'.
|
||||
if (IsAutofocusable() && HasAttr(kNameSpaceID_None, nsGkAtoms::autofocus) &&
|
||||
StaticPrefs::browser_autofocus() && IsInUncomposedDoc()) {
|
||||
OwnerDoc()->SetAutoFocusElement(this);
|
||||
aContext.OwnerDoc().SetAutoFocusElement(this);
|
||||
}
|
||||
|
||||
// If @form is set, the element *has* to be in a composed document, otherwise
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "nsMathMLElement.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/TextUtils.h"
|
||||
|
@ -81,13 +82,13 @@ nsresult nsMathMLElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
|
||||
// FIXME(emilio): Probably should be composed, this uses all the other link
|
||||
// infrastructure.
|
||||
if (Document* doc = GetUncomposedDoc()) {
|
||||
doc->RegisterPendingLinkUpdate(this);
|
||||
if (IsInUncomposedDoc()) {
|
||||
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
|
||||
}
|
||||
|
||||
// Set the bit in the document for telemetry.
|
||||
if (Document* doc = GetComposedDoc()) {
|
||||
doc->SetMathMLEnabled();
|
||||
if (IsInComposedDoc()) {
|
||||
aContext.OwnerDoc().SetMathMLEnabled();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/SVGAElementBinding.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -160,9 +161,8 @@ nsresult SVGAElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsresult rv = SVGAElementBase::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
doc->RegisterPendingLinkUpdate(this);
|
||||
if (IsInComposedDoc()) {
|
||||
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/SVGAnimationElement.h"
|
||||
#include "mozilla/dom/SVGSVGElement.h"
|
||||
#include "mozilla/dom/BindContext.h"
|
||||
#include "mozilla/dom/ElementInlines.h"
|
||||
#include "mozilla/SMILAnimationController.h"
|
||||
#include "mozilla/SMILAnimationFunction.h"
|
||||
|
@ -139,8 +140,9 @@ nsresult SVGAnimationElement::BindToTree(BindContext& aContext,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Add myself to the animation controller's master set of animation elements.
|
||||
if (Document* doc = GetComposedDoc()) {
|
||||
if (SMILAnimationController* controller = doc->GetAnimationController()) {
|
||||
if (IsInComposedDoc()) {
|
||||
if (SMILAnimationController* controller =
|
||||
aContext.OwnerDoc().GetAnimationController()) {
|
||||
controller->RegisterAnimationElement(this);
|
||||
}
|
||||
const nsAttrValue* href =
|
||||
|
|
|
@ -373,7 +373,7 @@ nsresult SVGSVGElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
// NOTE(emilio): Using aParent because we still haven't called our base class.
|
||||
// FIXME(emilio, bug 1555948): Should probably use IsInComposedDoc()?
|
||||
if (aParent.IsInUncomposedDoc()) {
|
||||
if ((smilController = OwnerDoc()->GetAnimationController())) {
|
||||
if ((smilController = aContext.OwnerDoc().GetAnimationController())) {
|
||||
// SMIL is enabled in this document
|
||||
if (WillBeOutermostSVG(aParent, aContext.GetBindingParent())) {
|
||||
// We'll be the outermost <svg> element. We'll need a time container.
|
||||
|
|
|
@ -621,7 +621,7 @@ void nsXULElement::UpdateEditableState(bool aNotify) {
|
|||
|
||||
class XULInContentErrorReporter : public Runnable {
|
||||
public:
|
||||
explicit XULInContentErrorReporter(Document* aDocument)
|
||||
explicit XULInContentErrorReporter(Document& aDocument)
|
||||
: mozilla::Runnable("XULInContentErrorReporter"), mDocument(aDocument) {}
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
|
@ -630,7 +630,7 @@ class XULInContentErrorReporter : public Runnable {
|
|||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<Document> mDocument;
|
||||
OwningNonNull<Document> mDocument;
|
||||
};
|
||||
|
||||
static bool NeedTooltipSupport(const nsXULElement& aXULElement) {
|
||||
|
@ -648,11 +648,12 @@ nsresult nsXULElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
nsresult rv = nsStyledElement::BindToTree(aContext, aParent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
Document& doc = aContext.OwnerDoc();
|
||||
|
||||
// FIXME(emilio): Could use IsInComposedDoc().
|
||||
Document* doc = OwnerDoc();
|
||||
if (!aContext.GetBindingParent() && IsInUncomposedDoc() &&
|
||||
!doc->IsLoadedAsInteractiveData() && !doc->AllowXULXBL() &&
|
||||
!doc->HasWarnedAbout(Document::eImportXULIntoContent)) {
|
||||
!doc.IsLoadedAsInteractiveData() && !doc.AllowXULXBL() &&
|
||||
!doc.HasWarnedAbout(Document::eImportXULIntoContent)) {
|
||||
nsContentUtils::AddScriptRunner(new XULInContentErrorReporter(doc));
|
||||
}
|
||||
|
||||
|
@ -661,7 +662,7 @@ nsresult nsXULElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!doc->AllowXULXBL() && !doc->IsUnstyledDocument()) {
|
||||
if (!doc.AllowXULXBL() && !doc.IsUnstyledDocument()) {
|
||||
// To save CPU cycles and memory, non-XUL documents only load the user
|
||||
// agent style sheet rules for a minimal set of XUL elements such as
|
||||
// 'scrollbar' that may be created implicitly for their content (those
|
||||
|
@ -691,10 +692,10 @@ nsresult nsXULElement::BindToTree(BindContext& aContext, nsINode& aParent) {
|
|||
}
|
||||
|
||||
if (XULBroadcastManager::MayNeedListener(*this)) {
|
||||
if (!doc->HasXULBroadcastManager()) {
|
||||
doc->InitializeXULBroadcastManager();
|
||||
if (!doc.HasXULBroadcastManager()) {
|
||||
doc.InitializeXULBroadcastManager();
|
||||
}
|
||||
XULBroadcastManager* broadcastManager = doc->GetXULBroadcastManager();
|
||||
XULBroadcastManager* broadcastManager = doc.GetXULBroadcastManager();
|
||||
broadcastManager->AddListener(this);
|
||||
}
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче