diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index 4184548197f..0672b45aeaa 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -150,8 +150,9 @@ HTMLAnchorElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, NS_ENSURE_SUCCESS(rv, rv); // Prefetch links - if (aDocument) { - aDocument->RegisterPendingLinkUpdate(this); + nsIDocument* doc = GetComposedDoc(); + if (doc) { + doc->RegisterPendingLinkUpdate(this); if (nsHTMLDNSPrefetch::IsAllowed(OwnerDoc())) { nsHTMLDNSPrefetch::PrefetchLow(this); } @@ -181,8 +182,10 @@ HTMLAnchorElement::UnbindFromTree(bool aDeep, bool aNullParent) // If this link is ever reinserted into a document, it might // be under a different xml:base, so forget the cached state now. Link::ResetLinkState(false, Link::ElementHasHref()); - - nsIDocument* doc = GetCurrentDoc(); + + // Note, we need to use OwnerDoc() here, since GetComposedDoc() might + // return null. + nsIDocument* doc = OwnerDoc(); if (doc) { doc->UnregisterPendingLinkUpdate(this); } diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index 94927087c9b..a427d3a19bc 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -135,13 +135,16 @@ HTMLAreaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, bool aCompileEventHandlers) { Link::ResetLinkState(false, Link::ElementHasHref()); - if (aDocument) { - aDocument->RegisterPendingLinkUpdate(this); - } - - return nsGenericHTMLElement::BindToTree(aDocument, aParent, + nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + nsIDocument* doc = GetComposedDoc(); + if (doc) { + doc->RegisterPendingLinkUpdate(this); + } + return rv; } void @@ -150,8 +153,10 @@ HTMLAreaElement::UnbindFromTree(bool aDeep, bool aNullParent) // If this link is ever reinserted into a document, it might // be under a different xml:base, so forget the cached state now. Link::ResetLinkState(false, Link::ElementHasHref()); - - nsIDocument* doc = GetCurrentDoc(); + + // Note, we need to use OwnerDoc() here, since GetComposedDoc() might + // return null. + nsIDocument* doc = OwnerDoc(); if (doc) { doc->UnregisterPendingLinkUpdate(this); } diff --git a/content/html/content/src/HTMLBodyElement.cpp b/content/html/content/src/HTMLBodyElement.cpp index 077d72ff1ca..2027de809ae 100644 --- a/content/html/content/src/HTMLBodyElement.cpp +++ b/content/html/content/src/HTMLBodyElement.cpp @@ -401,7 +401,7 @@ HTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker); if (!mContentStyleRule && IsInDoc()) { - // XXXbz should this use OwnerDoc() or GetCurrentDoc()? + // XXXbz should this use OwnerDoc() or GetComposedDoc()? // sXBL/XBL2 issue! mContentStyleRule = new BodyRule(this); } diff --git a/content/html/content/src/HTMLFormControlsCollection.cpp b/content/html/content/src/HTMLFormControlsCollection.cpp index 54807851cc6..21e24539c78 100644 --- a/content/html/content/src/HTMLFormControlsCollection.cpp +++ b/content/html/content/src/HTMLFormControlsCollection.cpp @@ -113,7 +113,7 @@ void HTMLFormControlsCollection::FlushPendingNotifications() { if (mForm) { - nsIDocument* doc = mForm->GetCurrentDoc(); + nsIDocument* doc = mForm->GetUncomposedDoc(); if (doc) { doc->FlushPendingNotifications(Flush_Content); } diff --git a/content/html/content/src/HTMLFormElement.cpp b/content/html/content/src/HTMLFormElement.cpp index e1d38aedd17..4b931f5329b 100644 --- a/content/html/content/src/HTMLFormElement.cpp +++ b/content/html/content/src/HTMLFormElement.cpp @@ -446,7 +446,7 @@ CollectOrphans(nsINode* aRemovalRoot, void HTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent) { - nsCOMPtr oldDocument = do_QueryInterface(GetCurrentDoc()); + nsCOMPtr oldDocument = do_QueryInterface(GetUncomposedDoc()); // Mark all of our controls as maybe being orphans MarkOrphans(mControls->mElements); @@ -583,7 +583,7 @@ HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent, int32_t aMessage) { // Make sure the presentation is up-to-date - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetComposedDoc(); if (doc) { doc->FlushPendingNotifications(Flush_ContentAndNotify); } @@ -633,7 +633,7 @@ HTMLFormElement::DoReset() nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) { - NS_ASSERTION(GetCurrentDoc(), "Should never get here without a current doc"); + NS_ASSERTION(GetComposedDoc(), "Should never get here without a current doc"); if (mIsSubmitting) { NS_WARNING("Preventing double form submission"); @@ -741,7 +741,7 @@ HTMLFormElement::SubmitSubmission(nsFormSubmission* aFormSubmission) } // If there is no link handler, then we won't actually be able to submit. - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetComposedDoc(); nsCOMPtr container = doc ? doc->GetContainer() : nullptr; nsCOMPtr linkHandler(do_QueryInterface(container)); if (!linkHandler || IsEditable()) { @@ -1801,7 +1801,7 @@ HTMLFormElement::CheckValidFormSubmission() // Don't do validation for a form submit done by a sandboxed document that // doesn't have 'allow-forms', the submit will have been blocked and the // HTML5 spec says we shouldn't validate in this case. - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetComposedDoc(); if (doc && (doc->GetSandboxFlags() & SANDBOXED_FORMS)) { return true; } diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index 13c403e49dd..dfc369c9978 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -1858,7 +1858,8 @@ HTMLInputElement::GetList() const return nullptr; } - nsIDocument* doc = GetCurrentDoc(); + //XXXsmaug How should this all work in case input element is in Shadow DOM. + nsIDocument* doc = GetUncomposedDoc(); if (!doc) { return nullptr; } @@ -2262,8 +2263,8 @@ HTMLInputElement::StepUp(int32_t n, uint8_t optional_argc) void HTMLInputElement::FlushFrames() { - if (GetCurrentDoc()) { - GetCurrentDoc()->FlushPendingNotifications(Flush_Frames); + if (GetComposedDoc()) { + GetComposedDoc()->FlushPendingNotifications(Flush_Frames); } } @@ -3029,7 +3030,8 @@ HTMLInputElement::GetRadioGroupContainer() const return mForm; } - return static_cast(GetCurrentDoc()); + //XXXsmaug It isn't clear how this should work in Shadow DOM. + return static_cast(GetUncomposedDoc()); } already_AddRefed @@ -3964,7 +3966,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) if (fm && IsSingleLineTextControl(false) && !aVisitor.mEvent->AsFocusEvent()->fromRaise && SelectTextFieldOnFocus()) { - nsIDocument* document = GetCurrentDoc(); + nsIDocument* document = GetComposedDoc(); if (document) { uint32_t lastFocusMethod; fm->GetLastFocusMethod(document->GetWindow(), &lastFocusMethod); diff --git a/content/html/content/src/HTMLLabelElement.cpp b/content/html/content/src/HTMLLabelElement.cpp index 3bcfb3fca14..0509dfe1257 100644 --- a/content/html/content/src/HTMLLabelElement.cpp +++ b/content/html/content/src/HTMLLabelElement.cpp @@ -246,7 +246,10 @@ HTMLLabelElement::GetLabeledElement() const // We have a @for. The id has to be linked to an element in the same document // and this element should be a labelable form control. - nsIDocument* doc = GetCurrentDoc(); + //XXXsmaug It is unclear how this should work in case the element is in + // Shadow DOM. + // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=26365. + nsIDocument* doc = GetUncomposedDoc(); if (!doc) { return nullptr; } diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index 5731763602e..6f7b88a6185 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -177,18 +177,15 @@ HTMLLinkElement::UnbindFromTree(bool aDeep, bool aNullParent) // be under a different xml:base, so forget the cached state now. Link::ResetLinkState(false, Link::ElementHasHref()); - // Once we have XPCOMGC we shouldn't need to call UnbindFromTree during Unlink - // and so this messy event dispatch can go away. - nsCOMPtr oldDoc = GetCurrentDoc(); + nsCOMPtr oldDoc = GetUncomposedDoc(); // Check for a ShadowRoot because link elements are inert in a // ShadowRoot. ShadowRoot* oldShadowRoot = GetBindingParent() ? GetBindingParent()->GetShadowRoot() : nullptr; - if (oldDoc && !oldShadowRoot) { - oldDoc->UnregisterPendingLinkUpdate(this); - } + OwnerDoc()->UnregisterPendingLinkUpdate(this); + CreateAndDispatchEvent(oldDoc, NS_LITERAL_STRING("DOMLinkRemoved")); nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); @@ -251,7 +248,7 @@ void HTMLLinkElement::UpdateImport() { // 1. link node should be attached to the document. - nsCOMPtr doc = GetCurrentDoc(); + nsCOMPtr doc = GetUncomposedDoc(); if (!doc) { // We might have been just removed from the document, so // let's remove ourself from the list of link nodes of diff --git a/content/html/content/src/HTMLMenuElement.cpp b/content/html/content/src/HTMLMenuElement.cpp index f6dd5ba2bca..8553534119f 100644 --- a/content/html/content/src/HTMLMenuElement.cpp +++ b/content/html/content/src/HTMLMenuElement.cpp @@ -70,7 +70,7 @@ HTMLMenuElement::SendShowEvent() { NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_DOM_SECURITY_ERR); - nsCOMPtr document = GetCurrentDoc(); + nsCOMPtr document = GetComposedDoc(); if (!document) { return NS_ERROR_FAILURE; } diff --git a/content/html/content/src/HTMLMetaElement.cpp b/content/html/content/src/HTMLMetaElement.cpp index 0d8f0f4ab7c..f6017274f0c 100644 --- a/content/html/content/src/HTMLMetaElement.cpp +++ b/content/html/content/src/HTMLMetaElement.cpp @@ -54,7 +54,7 @@ HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::content) { - nsIDocument *document = GetCurrentDoc(); + nsIDocument *document = GetUncomposedDoc(); CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaChanged")); } } @@ -86,7 +86,7 @@ HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, void HTMLMetaElement::UnbindFromTree(bool aDeep, bool aNullParent) { - nsCOMPtr oldDoc = GetCurrentDoc(); + nsCOMPtr oldDoc = GetUncomposedDoc(); CreateAndDispatchEvent(oldDoc, NS_LITERAL_STRING("DOMMetaRemoved")); nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); } diff --git a/content/html/content/src/HTMLObjectElement.cpp b/content/html/content/src/HTMLObjectElement.cpp index aeca45c0808..658c10a83ec 100644 --- a/content/html/content/src/HTMLObjectElement.cpp +++ b/content/html/content/src/HTMLObjectElement.cpp @@ -200,7 +200,7 @@ HTMLObjectElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, bool HTMLObjectElement::IsFocusableForTabIndex() { - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetComposedDoc(); if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) { return false; } @@ -216,7 +216,7 @@ HTMLObjectElement::IsHTMLFocusable(bool aWithMouse, { // TODO: this should probably be managed directly by IsHTMLFocusable. // See bug 597242. - nsIDocument *doc = GetCurrentDoc(); + nsIDocument *doc = GetComposedDoc(); if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) { if (aTabIndex) { GetTabIndex(aTabIndex); diff --git a/content/html/content/src/HTMLPropertiesCollection.cpp b/content/html/content/src/HTMLPropertiesCollection.cpp index eec2942f2ef..92dcc709269 100644 --- a/content/html/content/src/HTMLPropertiesCollection.cpp +++ b/content/html/content/src/HTMLPropertiesCollection.cpp @@ -43,7 +43,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END HTMLPropertiesCollection::HTMLPropertiesCollection(nsGenericHTMLElement* aRoot) : mRoot(aRoot) - , mDoc(aRoot->GetCurrentDoc()) + , mDoc(aRoot->GetUncomposedDoc()) , mIsDirty(true) { SetIsDOMBinding(); @@ -248,7 +248,7 @@ GetElementByIdForConnectedSubtree(nsIContent* aContent, const nsIAtom* aId) void HTMLPropertiesCollection::CrawlProperties() { - nsIDocument* doc = mRoot->GetCurrentDoc(); + nsIDocument* doc = mRoot->GetUncomposedDoc(); const nsAttrValue* attr = mRoot->GetParsedAttr(nsGkAtoms::itemref); if (attr) { @@ -306,7 +306,7 @@ HTMLPropertiesCollection::GetSupportedNames(unsigned, nsTArray& aNames PropertyNodeList::PropertyNodeList(HTMLPropertiesCollection* aCollection, nsIContent* aParent, const nsAString& aName) : mName(aName), - mDoc(aParent->GetCurrentDoc()), + mDoc(aParent->GetUncomposedDoc()), mCollection(aCollection), mParent(aParent), mIsDirty(true) diff --git a/content/html/content/src/HTMLSharedElement.cpp b/content/html/content/src/HTMLSharedElement.cpp index 9739baecb3c..3ba78e8ae24 100644 --- a/content/html/content/src/HTMLSharedElement.cpp +++ b/content/html/content/src/HTMLSharedElement.cpp @@ -227,9 +227,9 @@ HTMLSharedElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, aNameSpaceID == kNameSpaceID_None && IsInDoc()) { if (aName == nsGkAtoms::href) { - SetBaseURIUsingFirstBaseWithHref(GetCurrentDoc(), this); + SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(), this); } else if (aName == nsGkAtoms::target) { - SetBaseTargetUsingFirstBaseWithTarget(GetCurrentDoc(), this); + SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(), this); } } @@ -250,9 +250,9 @@ HTMLSharedElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, aNameSpaceID == kNameSpaceID_None && IsInDoc()) { if (aName == nsGkAtoms::href) { - SetBaseURIUsingFirstBaseWithHref(GetCurrentDoc(), nullptr); + SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(), nullptr); } else if (aName == nsGkAtoms::target) { - SetBaseTargetUsingFirstBaseWithTarget(GetCurrentDoc(), nullptr); + SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(), nullptr); } } @@ -287,7 +287,7 @@ HTMLSharedElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, void HTMLSharedElement::UnbindFromTree(bool aDeep, bool aNullParent) { - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetUncomposedDoc(); nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); diff --git a/content/html/content/src/HTMLTableElement.cpp b/content/html/content/src/HTMLTableElement.cpp index abfd9f05979..b12020f404c 100644 --- a/content/html/content/src/HTMLTableElement.cpp +++ b/content/html/content/src/HTMLTableElement.cpp @@ -896,7 +896,7 @@ HTMLTableElement::BuildInheritedAttributes() { NS_ASSERTION(mTableInheritedAttributes == TABLE_ATTRS_DIRTY, "potential leak, plus waste of work"); - nsIDocument *document = GetCurrentDoc(); + nsIDocument *document = GetComposedDoc(); nsHTMLStyleSheet* sheet = document ? document->GetAttributeStyleSheet() : nullptr; nsRefPtr newAttrs; diff --git a/content/html/content/src/HTMLTitleElement.cpp b/content/html/content/src/HTMLTitleElement.cpp index 3f2e80ee968..1aa4bb8f4cb 100644 --- a/content/html/content/src/HTMLTitleElement.cpp +++ b/content/html/content/src/HTMLTitleElement.cpp @@ -127,7 +127,7 @@ HTMLTitleElement::DoneAddingChildren(bool aHaveNotified) void HTMLTitleElement::SendTitleChangeEvent(bool aBound) { - nsIDocument* doc = GetCurrentDoc(); + nsIDocument* doc = GetUncomposedDoc(); if (doc) { doc->NotifyPossibleTitleChange(aBound); } diff --git a/content/html/content/src/nsFormSubmission.cpp b/content/html/content/src/nsFormSubmission.cpp index 8fb774b2dba..24336b7fcf4 100644 --- a/content/html/content/src/nsFormSubmission.cpp +++ b/content/html/content/src/nsFormSubmission.cpp @@ -820,7 +820,7 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm, nsFormSubmission** aFormSubmission) { // Get all the information necessary to encode the form data - NS_ASSERTION(aForm->GetCurrentDoc(), + NS_ASSERTION(aForm->GetComposedDoc(), "Should have doc if we're building submission!"); // Get encoding type (default: urlencoded) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 2e048a89ed8..8580903b4f9 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -580,7 +580,8 @@ nsGenericHTMLElement::UnbindFromTree(bool aDeep, bool aNullParent) RemoveFromNameTable(); if (GetContentEditableValue() == eTrue) { - nsCOMPtr htmlDocument = do_QueryInterface(GetCurrentDoc()); + //XXXsmaug Fix this for Shadow DOM, bug 1066965. + nsCOMPtr htmlDocument = do_QueryInterface(GetUncomposedDoc()); if (htmlDocument) { htmlDocument->ChangeContentEditableCount(this, -1); } @@ -780,7 +781,7 @@ nsGenericHTMLElement::GetEventListenerManagerForAttr(nsIAtom* aAttrName, // If we have a document, and it has a window, add the event // listener on the window (the inner window). If not, proceed as // normal. - // XXXbz sXBL/XBL2 issue: should we instead use GetCurrentDoc() here, + // XXXbz sXBL/XBL2 issue: should we instead use GetComposedDoc() here, // override BindToTree for those classes and munge event listeners there? nsIDocument *document = OwnerDoc(); @@ -1772,7 +1773,8 @@ nsGenericHTMLElement::GetContextMenu() const nsAutoString value; GetHTMLAttr(nsGkAtoms::contextmenu, value); if (!value.IsEmpty()) { - nsIDocument* doc = GetCurrentDoc(); + //XXXsmaug How should this work in Shadow DOM? + nsIDocument* doc = GetUncomposedDoc(); if (doc) { return HTMLMenuElement::FromContentOrNull(doc->GetElementById(value)); } @@ -2030,7 +2032,7 @@ nsGenericHTMLFormElement::BindToTree(nsIDocument* aDocument, // wouldn't be possible to find a form ancestor. // We should not call UpdateFormOwner if none of these conditions are // fulfilled. - if (HasAttr(kNameSpaceID_None, nsGkAtoms::form) ? !!GetCurrentDoc() + if (HasAttr(kNameSpaceID_None, nsGkAtoms::form) ? !!GetUncomposedDoc() : !!aParent) { UpdateFormOwner(true, nullptr); } @@ -2182,7 +2184,8 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, if (aName == nsGkAtoms::form) { // We need a new form id observer. - nsIDocument* doc = GetCurrentDoc(); + //XXXsmaug How should this work in Shadow DOM? + nsIDocument* doc = GetUncomposedDoc(); if (doc) { Element* formIdElement = nullptr; if (aValue && !aValue->IsEmptyString()) { @@ -2348,8 +2351,8 @@ nsGenericHTMLFormElement::FocusState() Element* nsGenericHTMLFormElement::AddFormIdObserver() { - NS_ASSERTION(GetCurrentDoc(), "When adding a form id observer, " - "we should be in a document!"); + NS_ASSERTION(GetUncomposedDoc(), "When adding a form id observer, " + "we should be in a document!"); nsAutoString formId; nsIDocument* doc = OwnerDoc(); @@ -2369,8 +2372,8 @@ nsGenericHTMLFormElement::RemoveFormIdObserver() * element actually being in the tree. If it is not and @form value changes, * this method will be called for nothing but removing an observer which does * not exist doesn't cost so much (no entry in the hash table) so having a - * boolean for GetCurrentDoc()/GetOwnerDoc() would make everything look more - * complex for nothing. + * boolean for GetUncomposedDoc()/GetOwnerDoc() would make everything look + * more complex for nothing. */ nsIDocument* doc = OwnerDoc(); @@ -2449,10 +2452,10 @@ nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree, element = aFormIdElement; } - NS_ASSERTION(GetCurrentDoc(), "The element should be in a document " - "when UpdateFormOwner is called!"); - NS_ASSERTION(!GetCurrentDoc() || - element == GetCurrentDoc()->GetElementById(formId), + NS_ASSERTION(GetUncomposedDoc(), "The element should be in a document " + "when UpdateFormOwner is called!"); + NS_ASSERTION(!GetUncomposedDoc() || + element == GetUncomposedDoc()->GetElementById(formId), "element should be equals to the current element " "associated with the id in @form!"); @@ -2765,7 +2768,7 @@ nsGenericHTMLElement::IsCurrentBodyElement() } nsCOMPtr htmlDocument = - do_QueryInterface(GetCurrentDoc()); + do_QueryInterface(GetUncomposedDoc()); if (!htmlDocument) { return false; } @@ -2822,7 +2825,7 @@ nsGenericHTMLElement::RecompileScriptEventListeners() bool nsGenericHTMLElement::IsEditableRoot() const { - nsIDocument *document = GetCurrentDoc(); + nsIDocument *document = GetComposedDoc(); if (!document) { return false; } @@ -2868,7 +2871,8 @@ MakeContentDescendantsEditable(nsIContent *aContent, nsIDocument *aDocument) void nsGenericHTMLElement::ChangeEditableState(int32_t aChange) { - nsIDocument* document = GetCurrentDoc(); + //XXXsmaug Fix this for Shadow DOM, bug 1066965. + nsIDocument* document = GetUncomposedDoc(); if (!document) { return; } diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 11542ef8c38..4bbdb6cbf38 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -1056,7 +1056,7 @@ HTMLContentSink::NotifyInsert(nsIContent* aContent, nsIContent* aChildContent, int32_t aIndexInContainer) { - if (aContent && aContent->GetCurrentDoc() != mDocument) { + if (aContent && aContent->GetUncomposedDoc() != mDocument) { // aContent is not actually in our document anymore.... Just bail out of // here; notifying on our document for this insert would be wrong. return; diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 0678c81353d..d03ca06535f 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1119,7 +1119,7 @@ bool nsHTMLDocument::MatchLinks(nsIContent *aContent, int32_t aNamespaceID, nsIAtom* aAtom, void* aData) { - nsIDocument* doc = aContent->GetCurrentDoc(); + nsIDocument* doc = aContent->GetUncomposedDoc(); if (doc) { NS_ASSERTION(aContent->IsInDoc(), @@ -1128,7 +1128,7 @@ nsHTMLDocument::MatchLinks(nsIContent *aContent, int32_t aNamespaceID, #ifdef DEBUG { nsCOMPtr htmldoc = - do_QueryInterface(aContent->GetCurrentDoc()); + do_QueryInterface(aContent->GetUncomposedDoc()); NS_ASSERTION(htmldoc, "Huh, how did this happen? This should only be used with " "HTML documents!"); @@ -1173,7 +1173,7 @@ nsHTMLDocument::MatchAnchors(nsIContent *aContent, int32_t aNamespaceID, #ifdef DEBUG { nsCOMPtr htmldoc = - do_QueryInterface(aContent->GetCurrentDoc()); + do_QueryInterface(aContent->GetUncomposedDoc()); NS_ASSERTION(htmldoc, "Huh, how did this happen? This should only be used with " "HTML documents!");