diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 3eed25900d6..0d4b4ebe9b9 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -4572,14 +4572,10 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, // the DOM computed style API. We can get rid of this hack if we merge // the jsdom library with layout. - const nsStyleDisplay* display; - pctx->ResolveStyleContextAndGetStyleData(content, eStyleStruct_Display, - (const nsStyleStruct*&) display); - NS_ENSURE_TRUE(display, NS_ERROR_UNEXPECTED); - - if (display->mBinding.IsEmpty()) { + nsAutoString bindingURL; + pctx->GetXBLBindingURL(content, bindingURL); + if (bindingURL.IsEmpty()) { // No binding, nothing left to do here. - return NS_OK; } @@ -4589,7 +4585,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, nsCOMPtr xblService(do_GetService("@mozilla.org/xbl;1")); NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE); - xblService->LoadBindings(content, display->mBinding, PR_FALSE, + xblService->LoadBindings(content, bindingURL, PR_FALSE, getter_AddRefs(binding), &dummy); if (binding) { diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index daa34f750ff..d16fafa0b1e 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -949,18 +949,6 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent, return nsnull; } -NS_IMETHODIMP -nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct) -{ - nsRefPtr sc = ResolveStyleContextFor(aContent, nsnull); - if (!sc) return NS_ERROR_FAILURE; - - aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID); - return aStyleStruct ? NS_OK : NS_ERROR_FAILURE; -} - already_AddRefed nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) { @@ -1016,6 +1004,21 @@ nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, return nsnull; } +NS_IMETHODIMP +nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsAString& aResult) +{ + nsRefPtr sc; + sc = ResolveStyleContextFor(aContent, nsnull); + NS_ENSURE_TRUE(sc, NS_ERROR_FAILURE); + + const nsStyleDisplay* display; + ::GetStyleData(sc.get(), &display); + NS_ENSURE_TRUE(display, NS_ERROR_NULL_POINTER); + + aResult = display->mBinding; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 05af526ea97..56b43d51036 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -197,19 +197,6 @@ public: ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext) = 0; - /** - * Resolve the given style struct for a content node. - * This is probably NOT what you're looking for to find out the style - * properties of an element. From inside layout, you should use the style - * context directly; from outside layout you should use GetStyleData - * for a frame or the DOM computed style interfaces for content nodes. - * aSID should be a nsStyleStructID but isn't due to include ordering - * problems. - */ - NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct) = 0; - /** * Resolve style for a non-element content node (i.e., one that is * guaranteed not to match any rules). Eventually such nodes @@ -260,6 +247,13 @@ public: ProbePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, nsStyleContext* aParentContext) = 0; + + /** + * Resolve a new style context for a content node and return the URL + * for its XBL binding, or the empty string if it has no binding + * specified in CSS. + */ + NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsAString& aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 05af526ea97..56b43d51036 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -197,19 +197,6 @@ public: ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext) = 0; - /** - * Resolve the given style struct for a content node. - * This is probably NOT what you're looking for to find out the style - * properties of an element. From inside layout, you should use the style - * context directly; from outside layout you should use GetStyleData - * for a frame or the DOM computed style interfaces for content nodes. - * aSID should be a nsStyleStructID but isn't due to include ordering - * problems. - */ - NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct) = 0; - /** * Resolve style for a non-element content node (i.e., one that is * guaranteed not to match any rules). Eventually such nodes @@ -260,6 +247,13 @@ public: ProbePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, nsStyleContext* aParentContext) = 0; + + /** + * Resolve a new style context for a content node and return the URL + * for its XBL binding, or the empty string if it has no binding + * specified in CSS. + */ + NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsAString& aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 05af526ea97..56b43d51036 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -197,19 +197,6 @@ public: ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext) = 0; - /** - * Resolve the given style struct for a content node. - * This is probably NOT what you're looking for to find out the style - * properties of an element. From inside layout, you should use the style - * context directly; from outside layout you should use GetStyleData - * for a frame or the DOM computed style interfaces for content nodes. - * aSID should be a nsStyleStructID but isn't due to include ordering - * problems. - */ - NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct) = 0; - /** * Resolve style for a non-element content node (i.e., one that is * guaranteed not to match any rules). Eventually such nodes @@ -260,6 +247,13 @@ public: ProbePseudoStyleContextFor(nsIContent* aParentContent, nsIAtom* aPseudoTag, nsStyleContext* aParentContext) = 0; + + /** + * Resolve a new style context for a content node and return the URL + * for its XBL binding, or the empty string if it has no binding + * specified in CSS. + */ + NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsAString& aResult) = 0; /** * For a given frame tree, get a new style context that is the equivalent diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index daa34f750ff..d16fafa0b1e 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -949,18 +949,6 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent, return nsnull; } -NS_IMETHODIMP -nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct) -{ - nsRefPtr sc = ResolveStyleContextFor(aContent, nsnull); - if (!sc) return NS_ERROR_FAILURE; - - aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID); - return aStyleStruct ? NS_OK : NS_ERROR_FAILURE; -} - already_AddRefed nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext) { @@ -1016,6 +1004,21 @@ nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent, return nsnull; } +NS_IMETHODIMP +nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsAString& aResult) +{ + nsRefPtr sc; + sc = ResolveStyleContextFor(aContent, nsnull); + NS_ENSURE_TRUE(sc, NS_ERROR_FAILURE); + + const nsStyleDisplay* display; + ::GetStyleData(sc.get(), &display); + NS_ENSURE_TRUE(display, NS_ERROR_NULL_POINTER); + + aResult = display->mBinding; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 0f2461430d6..f6cdef87b13 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -88,10 +88,6 @@ public: virtual already_AddRefed ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext); - NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent, - int aSID, - const nsStyleStruct*& aStyleStruct); - virtual already_AddRefed ResolveStyleContextForNonElement(nsStyleContext* aParentContext); @@ -111,6 +107,7 @@ public: nsIAtom* aPseudoTag, nsStyleContext* aParentContext); + NS_IMETHOD GetXBLBindingURL(nsIContent* aContent, nsAString& aResult); NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext); NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult);