diff options
Diffstat (limited to 'dom/xbl')
-rw-r--r-- | dom/xbl/XBLChildrenElement.cpp | 39 | ||||
-rw-r--r-- | dom/xbl/XBLChildrenElement.h | 12 | ||||
-rw-r--r-- | dom/xbl/nsXBLService.cpp | 38 |
3 files changed, 25 insertions, 64 deletions
diff --git a/dom/xbl/XBLChildrenElement.cpp b/dom/xbl/XBLChildrenElement.cpp index e4058a789..f785a3058 100644 --- a/dom/xbl/XBLChildrenElement.cpp +++ b/dom/xbl/XBLChildrenElement.cpp @@ -7,6 +7,7 @@ #include "mozilla/dom/XBLChildrenElement.h" #include "nsCharSeparatedTokenizer.h" #include "mozilla/dom/NodeListBinding.h" +#include "nsAttrValueOrString.h" namespace mozilla { namespace dom { @@ -27,34 +28,24 @@ NS_INTERFACE_MAP_END_INHERITING(Element) NS_IMPL_ELEMENT_CLONE(XBLChildrenElement) nsresult -XBLChildrenElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) +XBLChildrenElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, + const nsAttrValueOrString* aValue, + bool aNotify) { - if (aAttribute == nsGkAtoms::includes && - aNameSpaceID == kNameSpaceID_None) { - mIncludes.Clear(); - } - - return Element::UnsetAttr(aNameSpaceID, aAttribute, aNotify); -} - -bool -XBLChildrenElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aAttribute == nsGkAtoms::includes && - aNamespaceID == kNameSpaceID_None) { - mIncludes.Clear(); - nsCharSeparatedTokenizer tok(aValue, '|', - nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL); - while (tok.hasMoreTokens()) { - mIncludes.AppendElement(NS_Atomize(tok.nextToken())); + if (aNamespaceID == kNameSpaceID_None) { + if (aName == nsGkAtoms::includes) { + mIncludes.Clear(); + if (aValue) { + nsCharSeparatedTokenizer tok(aValue->String(), '|', + nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL); + while (tok.hasMoreTokens()) { + mIncludes.AppendElement(NS_Atomize(tok.nextToken())); + } + } } } - return false; + return nsXMLElement::BeforeSetAttr(aNamespaceID, aName, aValue, aNotify); } } // namespace dom diff --git a/dom/xbl/XBLChildrenElement.h b/dom/xbl/XBLChildrenElement.h index 4714da4a8..c01085474 100644 --- a/dom/xbl/XBLChildrenElement.h +++ b/dom/xbl/XBLChildrenElement.h @@ -37,14 +37,6 @@ public: virtual nsIDOMNode* AsDOMNode() override { return this; } - // nsIContent interface methods - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) override; - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) override; - void AppendInsertedChild(nsIContent* aChild) { mInsertedChildren.AppendElement(aChild); @@ -147,6 +139,10 @@ public: protected: ~XBLChildrenElement(); + virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, + const nsAttrValueOrString* aValue, + bool aNotify) override; + private: nsTArray<nsIContent*> mInsertedChildren; // WEAK nsTArray<nsCOMPtr<nsIAtom> > mIncludes; diff --git a/dom/xbl/nsXBLService.cpp b/dom/xbl/nsXBLService.cpp index 1475b1368..b50b2c6fe 100644 --- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -115,45 +115,19 @@ public: if (!doc) return; - // Destroy the frames for mBoundElement. - nsIContent* destroyedFramesFor = nullptr; - nsIPresShell* shell = doc->GetShell(); - if (shell) { - shell->DestroyFramesFor(mBoundElement, &destroyedFramesFor); - } - MOZ_ASSERT(!mBoundElement->GetPrimaryFrame()); - // Get the binding. bool ready = false; nsXBLService::GetInstance()->BindingReady(mBoundElement, mBindingURI, &ready); if (!ready) return; - // If |mBoundElement| is (in addition to having binding |mBinding|) - // also a descendant of another element with binding |mBinding|, - // then we might have just constructed it due to the - // notification of its parent. (We can know about both if the - // binding loads were triggered from the DOM rather than frame - // construction.) So we have to check both whether the element - // has a primary frame and whether it's in the frame manager maps - // before sending a ContentInserted notification, or bad things - // will happen. - MOZ_ASSERT(shell == doc->GetShell()); - if (shell) { - nsIFrame* childFrame = mBoundElement->GetPrimaryFrame(); - if (!childFrame) { - // Check to see if it's in the undisplayed content map... - nsFrameManager* fm = shell->FrameManager(); - nsStyleContext* sc = fm->GetUndisplayedContent(mBoundElement); - if (!sc) { - // or in the display:contents map. - sc = fm->GetDisplayContentsStyleFor(mBoundElement); - } - if (!sc) { - shell->CreateFramesFor(destroyedFramesFor); - } - } + // Destroy the frames for mBoundElement. Do this after getting the binding, + // since if the binding fetch fails then we don't want to destroy the + // frames. + if (nsIPresShell* shell = doc->GetShell()) { + shell->DestroyFramesForAndRestyle(mBoundElement->AsElement()); } + MOZ_ASSERT(!mBoundElement->GetPrimaryFrame()); } nsXBLBindingRequest(nsIURI* aURI, nsIContent* aBoundElement) |