mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1074738 - GetCurrentDoc fixes in content/base, r=wchen
--HG-- extra : rebase_source : 5bd87b39f04e5cef229e8e15bc2bf56aef9c5995
This commit is contained in:
parent
af2478ad59
commit
9189d91016
@ -1275,6 +1275,21 @@ private:
|
||||
EventStates mState;
|
||||
};
|
||||
|
||||
class RemoveFromBindingManagerRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
RemoveFromBindingManagerRunnable(nsBindingManager* aManager,
|
||||
nsIContent* aContent,
|
||||
nsIDocument* aDoc);
|
||||
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
virtual ~RemoveFromBindingManagerRunnable();
|
||||
nsRefPtr<nsBindingManager> mManager;
|
||||
nsRefPtr<nsIContent> mContent;
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
};
|
||||
|
||||
class DestinationInsertionPointList : public nsINodeList
|
||||
{
|
||||
public:
|
||||
|
@ -430,7 +430,7 @@ Element::WrapObject(JSContext *aCx)
|
||||
doc = OwnerDoc();
|
||||
}
|
||||
else {
|
||||
doc = GetCurrentDoc();
|
||||
doc = GetComposedDoc();
|
||||
}
|
||||
|
||||
if (!doc) {
|
||||
@ -593,7 +593,7 @@ Element::ScrollIntoView()
|
||||
void
|
||||
Element::ScrollIntoView(bool aTop, const ScrollOptions &aOptions)
|
||||
{
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
nsIDocument *document = GetComposedDoc();
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
@ -767,7 +767,7 @@ Element::AddToIdTable(nsIAtom* aId)
|
||||
ShadowRoot* containingShadow = GetContainingShadow();
|
||||
containingShadow->AddToIdTable(this, aId);
|
||||
} else {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetUncomposedDoc();
|
||||
if (doc && (!IsInAnonymousSubtree() || doc->IsXUL())) {
|
||||
doc->AddToIdTable(this, aId);
|
||||
}
|
||||
@ -790,7 +790,7 @@ Element::RemoveFromIdTable()
|
||||
containingShadow->RemoveFromIdTable(this, id);
|
||||
}
|
||||
} else {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetUncomposedDoc();
|
||||
if (doc && (!IsInAnonymousSubtree() || doc->IsXUL())) {
|
||||
doc->RemoveFromIdTable(this, id);
|
||||
}
|
||||
@ -1197,9 +1197,9 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
|
||||
NS_PRECONDITION((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
|
||||
"Must have the same owner document");
|
||||
NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
|
||||
NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(),
|
||||
"aDocument must be current doc of aParent");
|
||||
NS_PRECONDITION(!GetCurrentDoc(), "Already have a document. Unbind first!");
|
||||
NS_PRECONDITION(!GetUncomposedDoc(), "Already have a document. Unbind first!");
|
||||
// Note that as we recurse into the kids, they'll have a non-null parent. So
|
||||
// only assert if our parent is _changing_ while we have a parent.
|
||||
NS_PRECONDITION(!GetParent() || aParent == GetParent(),
|
||||
@ -1406,7 +1406,7 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
// XXXbz script execution during binding can trigger some of these
|
||||
// postcondition asserts.... But we do want that, since things will
|
||||
// generally be quite broken when that happens.
|
||||
NS_POSTCONDITION(aDocument == GetCurrentDoc(), "Bound to wrong document");
|
||||
NS_POSTCONDITION(aDocument == GetUncomposedDoc(), "Bound to wrong document");
|
||||
NS_POSTCONDITION(aParent == GetParent(), "Bound to wrong parent");
|
||||
NS_POSTCONDITION(aBindingParent == GetBindingParent(),
|
||||
"Bound to wrong binding parent");
|
||||
@ -1414,48 +1414,45 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class RemoveFromBindingManagerRunnable : public nsRunnable {
|
||||
public:
|
||||
RemoveFromBindingManagerRunnable(nsBindingManager* aManager,
|
||||
Element* aElement,
|
||||
nsIDocument* aDoc):
|
||||
mManager(aManager), mElement(aElement), mDoc(aDoc)
|
||||
{}
|
||||
RemoveFromBindingManagerRunnable::RemoveFromBindingManagerRunnable(nsBindingManager* aManager,
|
||||
nsIContent* aContent,
|
||||
nsIDocument* aDoc):
|
||||
mManager(aManager), mContent(aContent), mDoc(aDoc)
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
// It may be the case that the element was removed from the
|
||||
// DOM, causing this runnable to be created, then inserted back
|
||||
// into the document before the this runnable had a chance to
|
||||
// tear down the binding. Only tear down the binding if the element
|
||||
// is still no longer in the DOM. nsXBLService::LoadBinding tears
|
||||
// down the old binding if the element is inserted back into the
|
||||
// DOM and loads a different binding.
|
||||
if (!mElement->IsInDoc()) {
|
||||
mManager->RemovedFromDocumentInternal(mElement, mDoc);
|
||||
}
|
||||
RemoveFromBindingManagerRunnable::~RemoveFromBindingManagerRunnable() {}
|
||||
|
||||
return NS_OK;
|
||||
NS_IMETHODIMP
|
||||
RemoveFromBindingManagerRunnable::Run()
|
||||
{
|
||||
// It may be the case that the element was removed from the
|
||||
// DOM, causing this runnable to be created, then inserted back
|
||||
// into the document before the this runnable had a chance to
|
||||
// tear down the binding. Only tear down the binding if the element
|
||||
// is still no longer in the DOM. nsXBLService::LoadBinding tears
|
||||
// down the old binding if the element is inserted back into the
|
||||
// DOM and loads a different binding.
|
||||
if (!mContent->IsInComposedDoc()) {
|
||||
mManager->RemovedFromDocumentInternal(mContent, mDoc);
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsBindingManager> mManager;
|
||||
nsRefPtr<Element> mElement;
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
};
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Element::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
{
|
||||
NS_PRECONDITION(aDeep || (!GetCurrentDoc() && !GetBindingParent()),
|
||||
NS_PRECONDITION(aDeep || (!GetUncomposedDoc() && !GetBindingParent()),
|
||||
"Shallow unbind won't clear document and binding parent on "
|
||||
"kids!");
|
||||
|
||||
RemoveFromIdTable();
|
||||
|
||||
// Make sure to unbind this node before doing the kids
|
||||
nsIDocument *document =
|
||||
HasFlag(NODE_FORCE_XBL_BINDINGS) ? OwnerDoc() : GetCurrentDoc();
|
||||
nsIDocument* document =
|
||||
HasFlag(NODE_FORCE_XBL_BINDINGS) || IsInShadowTree() ?
|
||||
OwnerDoc() : GetUncomposedDoc();
|
||||
|
||||
if (aNullParent) {
|
||||
if (IsFullScreenAncestor()) {
|
||||
@ -1602,7 +1599,7 @@ Element::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
|
||||
slots->mSMILOverrideStyleRule = aStyleRule;
|
||||
|
||||
if (aNotify) {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetComposedDoc();
|
||||
// Only need to request a restyle if we're in a document. (We might not
|
||||
// be in a document, if we're clearing animation effects on a target node
|
||||
// that's been detached since the previous animation sample.)
|
||||
@ -2020,7 +2017,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIDocument* document = GetCurrentDoc();
|
||||
nsIDocument* document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
nsMutationGuard::DidMutate();
|
||||
@ -2233,7 +2230,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
nsresult rv = BeforeSetAttr(aNameSpaceID, aName, nullptr, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
nsIDocument *document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
if (aNotify) {
|
||||
@ -2622,7 +2619,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
|
||||
WidgetMouseEvent::eLeftButton) {
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler *handler = aVisitor.mPresContext->GetLinkHandler();
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
nsIDocument *document = GetComposedDoc();
|
||||
if (handler && document) {
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
|
@ -203,7 +203,7 @@ nsIContent::GetDesiredIMEState()
|
||||
if (editableAncestor && editableAncestor != this) {
|
||||
return editableAncestor->GetDesiredIMEState();
|
||||
}
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetComposedDoc();
|
||||
if (!doc) {
|
||||
return IMEState(IMEState::DISABLED);
|
||||
}
|
||||
@ -238,10 +238,10 @@ nsIContent::GetEditingHost()
|
||||
// If this isn't editable, return nullptr.
|
||||
NS_ENSURE_TRUE(IsEditableInternal(), nullptr);
|
||||
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetComposedDoc();
|
||||
NS_ENSURE_TRUE(doc, nullptr);
|
||||
// If this is in designMode, we should return <body>
|
||||
if (doc->HasFlag(NODE_IS_EDITABLE)) {
|
||||
if (doc->HasFlag(NODE_IS_EDITABLE) && !IsInShadowTree()) {
|
||||
return doc->GetBodyElement();
|
||||
}
|
||||
|
||||
@ -1501,7 +1501,9 @@ FragmentOrElement::CanSkipInCC(nsINode* aNode)
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIDocument* currentDoc = aNode->GetCurrentDoc();
|
||||
//XXXsmaug Need to figure out in which cases Shadow DOM can be optimized out
|
||||
// from the CC graph.
|
||||
nsIDocument* currentDoc = aNode->GetUncomposedDoc();
|
||||
if (currentDoc &&
|
||||
nsCCUncollectableMarker::InGeneration(currentDoc->GetMarkedCCGeneration())) {
|
||||
return !NeedsScriptTraverse(aNode);
|
||||
@ -1678,7 +1680,7 @@ FragmentOrElement::CanSkip(nsINode* aNode, bool aRemovingAllowed)
|
||||
}
|
||||
|
||||
bool unoptimizable = aNode->UnoptimizableCCNode();
|
||||
nsIDocument* currentDoc = aNode->GetCurrentDoc();
|
||||
nsIDocument* currentDoc = aNode->GetUncomposedDoc();
|
||||
if (currentDoc &&
|
||||
nsCCUncollectableMarker::InGeneration(currentDoc->GetMarkedCCGeneration()) &&
|
||||
(!unoptimizable || NodeHasActiveFrame(currentDoc, aNode) ||
|
||||
@ -1807,7 +1809,7 @@ FragmentOrElement::CanSkipThis(nsINode* aNode)
|
||||
if (aNode->IsBlack()) {
|
||||
return true;
|
||||
}
|
||||
nsIDocument* c = aNode->GetCurrentDoc();
|
||||
nsIDocument* c = aNode->GetUncomposedDoc();
|
||||
return
|
||||
((c && nsCCUncollectableMarker::InGeneration(c->GetMarkedCCGeneration())) ||
|
||||
aNode->InCCBlackTree()) && !NeedsScriptTraverse(aNode);
|
||||
|
@ -77,7 +77,7 @@ Link::LinkState() const
|
||||
|
||||
// If we have not yet registered for notifications and need to,
|
||||
// due to our href changing, register now!
|
||||
if (!mRegistered && mNeedsRegistration && element->IsInDoc()) {
|
||||
if (!mRegistered && mNeedsRegistration && element->IsInComposedDoc()) {
|
||||
// Only try and register once.
|
||||
self->mNeedsRegistration = false;
|
||||
|
||||
@ -94,7 +94,7 @@ Link::LinkState() const
|
||||
self->mRegistered = true;
|
||||
|
||||
// And make sure we are in the document's link map.
|
||||
element->GetCurrentDoc()->AddStyleRelevantLink(self);
|
||||
element->GetComposedDoc()->AddStyleRelevantLink(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,7 +469,7 @@ Link::ResetLinkState(bool aNotify, bool aHasHref)
|
||||
// currently registered; in either case, we should remove ourself
|
||||
// from the doc and the history.
|
||||
if (!mNeedsRegistration && mLinkState != eLinkState_NotLink) {
|
||||
nsIDocument *doc = mElement->GetCurrentDoc();
|
||||
nsIDocument *doc = mElement->GetComposedDoc();
|
||||
if (doc && (mRegistered || mLinkState == eLinkState_Visited)) {
|
||||
// Tell the document to forget about this link if we've registered
|
||||
// with it before.
|
||||
|
@ -78,7 +78,7 @@ nsCCUncollectableMarker::Init()
|
||||
static void
|
||||
MarkUserData(void* aNode, nsIAtom* aKey, void* aValue, void* aData)
|
||||
{
|
||||
nsIDocument* d = static_cast<nsINode*>(aNode)->GetCurrentDoc();
|
||||
nsIDocument* d = static_cast<nsINode*>(aNode)->GetUncomposedDoc();
|
||||
if (d && nsCCUncollectableMarker::InGeneration(d->GetMarkedCCGeneration())) {
|
||||
Element::MarkUserData(aNode, aKey, aValue, aData);
|
||||
}
|
||||
|
@ -431,10 +431,10 @@ nsContentList::nsContentList(nsINode* aRootNode,
|
||||
|
||||
// We only need to flush if we're in an non-HTML document, since the
|
||||
// HTML5 parser doesn't need flushing. Further, if we're not in a
|
||||
// document at all right now (in the GetCurrentDoc() sense), we're
|
||||
// document at all right now (in the GetUncomposedDoc() sense), we're
|
||||
// not parser-created and don't need to be flushing stuff under us
|
||||
// to get our kids right.
|
||||
nsIDocument* doc = mRootNode->GetCurrentDoc();
|
||||
nsIDocument* doc = mRootNode->GetUncomposedDoc();
|
||||
mFlushesNeeded = doc && !doc->IsHTML();
|
||||
}
|
||||
|
||||
@ -464,10 +464,10 @@ nsContentList::nsContentList(nsINode* aRootNode,
|
||||
|
||||
// We only need to flush if we're in an non-HTML document, since the
|
||||
// HTML5 parser doesn't need flushing. Further, if we're not in a
|
||||
// document at all right now (in the GetCurrentDoc() sense), we're
|
||||
// document at all right now (in the GetUncomposedDoc() sense), we're
|
||||
// not parser-created and don't need to be flushing stuff under us
|
||||
// to get our kids right.
|
||||
nsIDocument* doc = mRootNode->GetCurrentDoc();
|
||||
nsIDocument* doc = mRootNode->GetUncomposedDoc();
|
||||
mFlushesNeeded = doc && !doc->IsHTML();
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ nsContentList::Item(uint32_t aIndex, bool aDoFlush)
|
||||
{
|
||||
if (mRootNode && aDoFlush && mFlushesNeeded) {
|
||||
// XXX sXBL/XBL2 issue
|
||||
nsIDocument* doc = mRootNode->GetCurrentDoc();
|
||||
nsIDocument* doc = mRootNode->GetUncomposedDoc();
|
||||
if (doc) {
|
||||
// Flush pending content changes Bug 4891.
|
||||
doc->FlushPendingNotifications(Flush_ContentAndNotify);
|
||||
@ -1004,7 +1004,7 @@ nsContentList::BringSelfUpToDate(bool aDoFlush)
|
||||
{
|
||||
if (mRootNode && aDoFlush && mFlushesNeeded) {
|
||||
// XXX sXBL/XBL2 issue
|
||||
nsIDocument* doc = mRootNode->GetCurrentDoc();
|
||||
nsIDocument* doc = mRootNode->GetUncomposedDoc();
|
||||
if (doc) {
|
||||
// Flush pending content changes Bug 4891.
|
||||
doc->FlushPendingNotifications(Flush_ContentAndNotify);
|
||||
|
@ -1183,7 +1183,7 @@ nsContentSink::StartLayout(bool aIgnorePendingSheets)
|
||||
void
|
||||
nsContentSink::NotifyAppend(nsIContent* aContainer, uint32_t aStartIndex)
|
||||
{
|
||||
if (aContainer->GetCurrentDoc() != mDocument) {
|
||||
if (aContainer->GetUncomposedDoc() != mDocument) {
|
||||
// aContainer is not actually in our document anymore.... Just bail out of
|
||||
// here; notifying on our document for this append would be wrong.
|
||||
return;
|
||||
|
@ -2453,7 +2453,8 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDocument(do_QueryInterface(aContent->GetCurrentDoc()));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDocument =
|
||||
do_QueryInterface(aContent->GetUncomposedDoc());
|
||||
|
||||
KeyAppendInt(partID, aKey); // first append a partID
|
||||
bool generatedUniqueKey = false;
|
||||
@ -2463,7 +2464,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
// If this becomes unnecessary and the following line is removed,
|
||||
// please also remove the corresponding flush operation from
|
||||
// nsHtml5TreeBuilderCppSupplement.h. (Look for "See bug 497861." there.)
|
||||
aContent->GetCurrentDoc()->FlushPendingNotifications(Flush_Content);
|
||||
aContent->GetUncomposedDoc()->FlushPendingNotifications(Flush_Content);
|
||||
|
||||
nsContentList *htmlForms = htmlDocument->GetForms();
|
||||
nsContentList *htmlFormControls = htmlDocument->GetFormControls();
|
||||
@ -2847,7 +2848,7 @@ nsContentUtils::SplitExpatName(const char16_t *aExpatName, nsIAtom **aPrefix,
|
||||
nsPresContext*
|
||||
nsContentUtils::GetContextForContent(const nsIContent* aContent)
|
||||
{
|
||||
nsIDocument* doc = aContent->GetCurrentDoc();
|
||||
nsIDocument* doc = aContent->GetComposedDoc();
|
||||
if (doc) {
|
||||
nsIPresShell *presShell = doc->GetShell();
|
||||
if (presShell) {
|
||||
@ -4404,7 +4405,7 @@ nsContentUtils::SetNodeTextContent(nsIContent* aContent,
|
||||
|
||||
// Might as well stick a batch around this since we're performing several
|
||||
// mutations.
|
||||
mozAutoDocUpdate updateBatch(aContent->GetCurrentDoc(),
|
||||
mozAutoDocUpdate updateBatch(aContent->GetComposedDoc(),
|
||||
UPDATE_CONTENT_MODEL, true);
|
||||
nsAutoMutationBatch mb;
|
||||
|
||||
@ -6104,7 +6105,9 @@ nsContentUtils::IsFocusedContent(const nsIContent* aContent)
|
||||
bool
|
||||
nsContentUtils::IsSubDocumentTabbable(nsIContent* aContent)
|
||||
{
|
||||
nsIDocument* doc = aContent->GetCurrentDoc();
|
||||
//XXXsmaug Shadow DOM spec issue!
|
||||
// We may need to change this to GetComposedDoc().
|
||||
nsIDocument* doc = aContent->GetUncomposedDoc();
|
||||
if (!doc) {
|
||||
return false;
|
||||
}
|
||||
|
@ -6056,7 +6056,8 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
|
||||
}
|
||||
|
||||
EnqueueLifecycleCallback(nsIDocument::eCreated, elem, nullptr, definition);
|
||||
if (elem->GetCurrentDoc()) {
|
||||
//XXXsmaug It is unclear if we should use GetComposedDoc() here.
|
||||
if (elem->GetUncomposedDoc()) {
|
||||
// Normally callbacks can not be enqueued until the created
|
||||
// callback has been invoked, however, the attached callback
|
||||
// in element upgrade is an exception so pretend the created
|
||||
@ -11527,7 +11528,7 @@ public:
|
||||
nsCOMPtr<Element> e = do_QueryReferent(mElement);
|
||||
nsCOMPtr<nsIDocument> d = do_QueryReferent(mDocument);
|
||||
if (!e || !d || gPendingPointerLockRequest != this ||
|
||||
e->GetCurrentDoc() != d) {
|
||||
e->GetUncomposedDoc() != d) {
|
||||
Handled();
|
||||
DispatchPointerLockError(d);
|
||||
return NS_OK;
|
||||
@ -11642,7 +11643,7 @@ nsPointerLockPermissionRequest::Allow(JS::HandleValue aChoices)
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
|
||||
nsDocument* d = static_cast<nsDocument*>(doc.get());
|
||||
if (!e || !d || gPendingPointerLockRequest != this ||
|
||||
e->GetCurrentDoc() != d ||
|
||||
e->GetUncomposedDoc() != d ||
|
||||
(!mUserInputOrChromeCaller && !d->mIsApprovedForFullscreen)) {
|
||||
Handled();
|
||||
DispatchPointerLockError(d);
|
||||
@ -11709,7 +11710,7 @@ nsDocument::Observe(nsISupports *aSubject,
|
||||
bool userInputOrChromeCaller =
|
||||
gPendingPointerLockRequest->mUserInputOrChromeCaller;
|
||||
gPendingPointerLockRequest->Handled();
|
||||
if (doc == this && el && el->GetCurrentDoc() == doc) {
|
||||
if (doc == this && el && el->GetUncomposedDoc() == doc) {
|
||||
nsPointerLockPermissionRequest* clone =
|
||||
new nsPointerLockPermissionRequest(el, userInputOrChromeCaller);
|
||||
gPendingPointerLockRequest = clone;
|
||||
|
@ -332,7 +332,7 @@ IsInvisibleBreak(nsINode *aNode) {
|
||||
}
|
||||
|
||||
// Grab the editor associated with the document
|
||||
nsIDocument *doc = aNode->GetCurrentDoc();
|
||||
nsIDocument *doc = aNode->GetComposedDoc();
|
||||
if (doc) {
|
||||
nsPIDOMWindow *window = doc->GetWindow();
|
||||
if (window) {
|
||||
|
@ -192,7 +192,7 @@ nsFrameLoader::Create(Element* aOwner, bool aNetworkCreated)
|
||||
NS_ENSURE_TRUE(aOwner, nullptr);
|
||||
nsIDocument* doc = aOwner->OwnerDoc();
|
||||
NS_ENSURE_TRUE(!doc->IsResourceDoc() &&
|
||||
((!doc->IsLoadedAsData() && aOwner->GetCurrentDoc()) ||
|
||||
((!doc->IsLoadedAsData() && aOwner->GetUncomposedDoc()) ||
|
||||
doc->IsStaticDocument()),
|
||||
nullptr);
|
||||
|
||||
@ -873,12 +873,12 @@ nsFrameLoader::ShowRemoteFrame(const nsIntSize& size,
|
||||
// want here. For now, hack.
|
||||
if (!mRemoteBrowserShown) {
|
||||
if (!mOwnerContent ||
|
||||
!mOwnerContent->GetCurrentDoc()) {
|
||||
!mOwnerContent->GetUncomposedDoc()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRefPtr<layers::LayerManager> layerManager =
|
||||
nsContentUtils::LayerManagerForDocument(mOwnerContent->GetCurrentDoc());
|
||||
nsContentUtils::LayerManagerForDocument(mOwnerContent->GetUncomposedDoc());
|
||||
if (!layerManager) {
|
||||
// This is just not going to work.
|
||||
return false;
|
||||
@ -1073,8 +1073,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
otherChildDocument->GetParentDocument();
|
||||
|
||||
// Make sure to swap docshells between the two frames.
|
||||
nsIDocument* ourDoc = ourContent->GetCurrentDoc();
|
||||
nsIDocument* otherDoc = otherContent->GetCurrentDoc();
|
||||
nsIDocument* ourDoc = ourContent->GetUncomposedDoc();
|
||||
nsIDocument* otherDoc = otherContent->GetUncomposedDoc();
|
||||
if (!ourDoc || !otherDoc) {
|
||||
// Again, how odd, given that we had docshells
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -297,7 +297,7 @@ nsGenericDOMDataNode::SetTextInternal(uint32_t aOffset, uint32_t aCount,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
nsIDocument *document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
bool haveMutationListeners = aNotify &&
|
||||
@ -465,9 +465,9 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
|
||||
NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
|
||||
"Must have the same owner document");
|
||||
NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
|
||||
NS_PRECONDITION(!aParent || aDocument == aParent->GetUncomposedDoc(),
|
||||
"aDocument must be current doc of aParent");
|
||||
NS_PRECONDITION(!GetCurrentDoc() && !IsInDoc(),
|
||||
NS_PRECONDITION(!GetUncomposedDoc() && !IsInDoc(),
|
||||
"Already have a document. Unbind first!");
|
||||
// Note that as we recurse into the kids, they'll have a non-null parent. So
|
||||
// only assert if our parent is _changing_ while we have a parent.
|
||||
@ -550,7 +550,7 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
|
||||
UpdateEditableState(false);
|
||||
|
||||
NS_POSTCONDITION(aDocument == GetCurrentDoc(), "Bound to wrong document");
|
||||
NS_POSTCONDITION(aDocument == GetUncomposedDoc(), "Bound to wrong document");
|
||||
NS_POSTCONDITION(aParent == GetParent(), "Bound to wrong parent");
|
||||
NS_POSTCONDITION(aBindingParent == GetBindingParent(),
|
||||
"Bound to wrong binding parent");
|
||||
@ -564,14 +564,10 @@ nsGenericDOMDataNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
// Unset frame flags; if we need them again later, they'll get set again.
|
||||
UnsetFlags(NS_CREATE_FRAME_IF_NON_WHITESPACE |
|
||||
NS_REFRAME_IF_WHITESPACE);
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (document) {
|
||||
// Notify XBL- & nsIAnonymousContentCreator-generated
|
||||
// anonymous content that the document is changing.
|
||||
// This is needed to update the insertion point.
|
||||
document->BindingManager()->RemovedFromDocument(this, document);
|
||||
}
|
||||
|
||||
nsIDocument* document =
|
||||
HasFlag(NODE_FORCE_XBL_BINDINGS) || IsInShadowTree() ?
|
||||
OwnerDoc() : GetUncomposedDoc();
|
||||
|
||||
if (aNullParent) {
|
||||
if (GetParent()) {
|
||||
@ -590,6 +586,16 @@ nsGenericDOMDataNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
SetSubtreeRootPointer(aNullParent ? this : mParent->SubtreeRoot());
|
||||
}
|
||||
|
||||
if (document) {
|
||||
// Notify XBL- & nsIAnonymousContentCreator-generated
|
||||
// anonymous content that the document is changing.
|
||||
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
new RemoveFromBindingManagerRunnable(document->BindingManager(), this,
|
||||
document));
|
||||
}
|
||||
}
|
||||
|
||||
nsDataSlots *slots = GetExistingDataSlots();
|
||||
if (slots) {
|
||||
slots->mBindingParent = nullptr;
|
||||
@ -855,7 +861,7 @@ nsGenericDOMDataNode::SplitData(uint32_t aOffset, nsIContent** aReturn,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIDocument* document = GetCurrentDoc();
|
||||
nsIDocument* document = GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, true);
|
||||
|
||||
// Use Clone for creating the new node so that the new node is of same class
|
||||
|
@ -199,7 +199,7 @@ nsINode::IsEditableInternal() const
|
||||
return true;
|
||||
}
|
||||
|
||||
nsIDocument *doc = GetCurrentDoc();
|
||||
nsIDocument *doc = GetUncomposedDoc();
|
||||
|
||||
// Check if the node is in a document and the document is in designMode.
|
||||
return doc && doc->HasFlag(NODE_IS_EDITABLE);
|
||||
@ -1336,7 +1336,7 @@ bool
|
||||
nsINode::Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
if (MOZ_LIKELY(!cb.WantAllTraces())) {
|
||||
nsIDocument *currentDoc = tmp->GetCurrentDoc();
|
||||
nsIDocument *currentDoc = tmp->GetUncomposedDoc();
|
||||
if (currentDoc &&
|
||||
nsCCUncollectableMarker::InGeneration(currentDoc->GetMarkedCCGeneration())) {
|
||||
return false;
|
||||
@ -1498,7 +1498,7 @@ nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
||||
nsMutationGuard::DidMutate();
|
||||
|
||||
// Do this before checking the child-count since this could cause mutations
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
nsIDocument* doc = GetUncomposedDoc();
|
||||
mozAutoDocUpdate updateBatch(GetCrossShadowCurrentDoc(), UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
if (OwnerDoc() != aKid->OwnerDoc()) {
|
||||
@ -1928,7 +1928,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
||||
// Scope for the mutation batch and scriptblocker, so they go away
|
||||
// while kungFuDeathGrip is still alive.
|
||||
{
|
||||
mozAutoDocUpdate batch(newContent->GetCurrentDoc(),
|
||||
mozAutoDocUpdate batch(newContent->GetComposedDoc(),
|
||||
UPDATE_CONTENT_MODEL, true);
|
||||
nsAutoMutationBatch mb(oldParent, true, true);
|
||||
oldParent->RemoveChildAt(removeIndex, true);
|
||||
@ -1993,7 +1993,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
||||
for (nsIContent* child = newContent->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
NS_ASSERTION(child->GetCurrentDoc() == nullptr,
|
||||
NS_ASSERTION(child->GetComposedDoc() == nullptr,
|
||||
"How did we get a child with a current doc?");
|
||||
fragChildren->AppendElement(child);
|
||||
}
|
||||
@ -2006,7 +2006,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
||||
// Scope for the mutation batch and scriptblocker, so they go away
|
||||
// while kungFuDeathGrip is still alive.
|
||||
{
|
||||
mozAutoDocUpdate batch(newContent->GetCurrentDoc(),
|
||||
mozAutoDocUpdate batch(newContent->GetComposedDoc(),
|
||||
UPDATE_CONTENT_MODEL, true);
|
||||
nsAutoMutationBatch mb(newContent, false, true);
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ nsImageLoadingContent::GetOurCurrentDoc()
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
NS_ENSURE_TRUE(thisContent, nullptr);
|
||||
|
||||
return thisContent->GetCurrentDoc();
|
||||
return thisContent->GetComposedDoc();
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
|
@ -20,7 +20,7 @@ nsMappedAttributeElement::SetMappedAttribute(nsIDocument* aDocument,
|
||||
nsAttrValue& aValue,
|
||||
nsresult* aRetval)
|
||||
{
|
||||
NS_PRECONDITION(aDocument == GetCurrentDoc(), "Unexpected document");
|
||||
NS_PRECONDITION(aDocument == GetComposedDoc(), "Unexpected document");
|
||||
nsHTMLStyleSheet* sheet = aDocument ?
|
||||
aDocument->GetAttributeStyleSheet() : nullptr;
|
||||
|
||||
|
@ -209,9 +209,9 @@ CheckPluginStopEvent::Run()
|
||||
// In an active document, but still no frame. Flush layout to see if we can
|
||||
// regain a frame now.
|
||||
LOG(("OBJLC [%p]: CheckPluginStopEvent - No frame, flushing layout", this));
|
||||
nsIDocument* currentDoc = content->GetCurrentDoc();
|
||||
if (currentDoc) {
|
||||
currentDoc->FlushPendingNotifications(Flush_Layout);
|
||||
nsIDocument* composedDoc = content->GetComposedDoc();
|
||||
if (composedDoc) {
|
||||
composedDoc->FlushPendingNotifications(Flush_Layout);
|
||||
if (objLC->mPendingCheckPluginStopEvent != this) {
|
||||
LOG(("OBJLC [%p]: CheckPluginStopEvent - superseded in layout flush",
|
||||
this));
|
||||
@ -239,7 +239,7 @@ class nsSimplePluginEvent : public nsRunnable {
|
||||
public:
|
||||
nsSimplePluginEvent(nsIContent* aTarget, const nsAString &aEvent)
|
||||
: mTarget(aTarget)
|
||||
, mDocument(aTarget->GetCurrentDoc())
|
||||
, mDocument(aTarget->GetComposedDoc())
|
||||
, mEvent(aEvent)
|
||||
{
|
||||
MOZ_ASSERT(aTarget && mDocument);
|
||||
@ -661,7 +661,7 @@ nsObjectLoadingContent::IsSupportedDocument(const nsCString& aMimeType)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav;
|
||||
nsIDocument* currentDoc = thisContent->GetCurrentDoc();
|
||||
nsIDocument* currentDoc = thisContent->GetComposedDoc();
|
||||
if (currentDoc) {
|
||||
webNav = do_GetInterface(currentDoc->GetWindow());
|
||||
}
|
||||
@ -730,7 +730,7 @@ nsObjectLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
/// would keep the docshell around, but trash the frameloader
|
||||
UnloadObject();
|
||||
}
|
||||
nsIDocument* doc = thisContent->GetCurrentDoc();
|
||||
nsIDocument* doc = thisContent->GetComposedDoc();
|
||||
if (doc && doc->IsActive()) {
|
||||
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(doc,
|
||||
NS_LITERAL_STRING("PluginRemoved"));
|
||||
@ -786,7 +786,7 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
|
||||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent *>(this));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = thisContent->GetCurrentDoc();
|
||||
nsCOMPtr<nsIDocument> doc = thisContent->GetComposedDoc();
|
||||
if (!doc || !InActiveDocument(thisContent)) {
|
||||
NS_ERROR("Shouldn't be calling "
|
||||
"InstantiatePluginInstance without an active document");
|
||||
@ -1178,8 +1178,8 @@ nsObjectLoadingContent::OnStopRequest(nsIRequest *aRequest,
|
||||
if (aStatusCode == NS_ERROR_TRACKING_URI) {
|
||||
nsCOMPtr<nsIContent> thisNode =
|
||||
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
||||
if (thisNode) {
|
||||
thisNode->GetCurrentDoc()->AddBlockedTrackingNode(thisNode);
|
||||
if (thisNode && thisNode->IsInComposedDoc()) {
|
||||
thisNode->GetComposedDoc()->AddBlockedTrackingNode(thisNode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2660,7 +2660,7 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
||||
return;
|
||||
}
|
||||
|
||||
nsIDocument* doc = thisContent->GetCurrentDoc();
|
||||
nsIDocument* doc = thisContent->GetComposedDoc();
|
||||
if (!doc) {
|
||||
return; // Nothing to do
|
||||
}
|
||||
@ -3349,7 +3349,7 @@ nsObjectLoadingContent::GetContentDocument()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// XXXbz should this use GetCurrentDoc()? sXBL/XBL2 issue!
|
||||
// XXXbz should this use GetComposedDoc()? sXBL/XBL2 issue!
|
||||
nsIDocument *sub_doc = thisContent->OwnerDoc()->GetSubDocumentFor(thisContent);
|
||||
if (!sub_doc) {
|
||||
return nullptr;
|
||||
|
@ -1084,7 +1084,7 @@ nsRange::IsValidBoundary(nsINode* aNode)
|
||||
|
||||
// Elements etc. must be in document or in document fragment,
|
||||
// text nodes in document, in document fragment or in attribute.
|
||||
nsINode* root = aNode->GetCurrentDoc();
|
||||
nsINode* root = aNode->GetUncomposedDoc();
|
||||
if (root) {
|
||||
return root;
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ nsRange::IsValidBoundary(nsINode* aNode)
|
||||
root = aNode->SubtreeRoot();
|
||||
|
||||
NS_ASSERTION(!root->IsNodeOfType(nsINode::eDOCUMENT),
|
||||
"GetCurrentDoc should have returned a doc");
|
||||
"GetUncomposedDoc should have returned a doc");
|
||||
|
||||
// We allow this because of backward compatibility.
|
||||
return root;
|
||||
|
@ -47,7 +47,7 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
|
||||
return;
|
||||
|
||||
// Get the current document
|
||||
nsIDocument *doc = aFromContent->GetCurrentDoc();
|
||||
nsIDocument *doc = aFromContent->GetComposedDoc();
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
@ -124,7 +124,7 @@ void
|
||||
nsReferencedElement::ResetWithID(nsIContent* aFromContent, const nsString& aID,
|
||||
bool aWatch)
|
||||
{
|
||||
nsIDocument *doc = aFromContent->GetCurrentDoc();
|
||||
nsIDocument *doc = aFromContent->GetComposedDoc();
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user