зеркало из https://github.com/mozilla/pjs.git
Replace the broken (since it can return destroyed data) ResolveStyleContextAndGetStyleData with GetXBLBindingURL. b=193847 r+sr=bzbarsky
This commit is contained in:
Родитель
181a903b7a
Коммит
e2875e8fee
|
@ -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<nsIXBLService> 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) {
|
||||
|
|
|
@ -949,18 +949,6 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent,
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent,
|
||||
int aSID,
|
||||
const nsStyleStruct*& aStyleStruct)
|
||||
{
|
||||
nsRefPtr<nsStyleContext> sc = ResolveStyleContextFor(aContent, nsnull);
|
||||
if (!sc) return NS_ERROR_FAILURE;
|
||||
|
||||
aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID);
|
||||
return aStyleStruct ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext)
|
||||
{
|
||||
|
@ -1016,6 +1004,21 @@ nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent,
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsAString& aResult)
|
||||
{
|
||||
nsRefPtr<nsStyleContext> 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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -949,18 +949,6 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent,
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::ResolveStyleContextAndGetStyleData(nsIContent* aContent,
|
||||
int aSID,
|
||||
const nsStyleStruct*& aStyleStruct)
|
||||
{
|
||||
nsRefPtr<nsStyleContext> sc = ResolveStyleContextFor(aContent, nsnull);
|
||||
if (!sc) return NS_ERROR_FAILURE;
|
||||
|
||||
aStyleStruct = sc->GetStyleData((nsStyleStructID) aSID);
|
||||
return aStyleStruct ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsPresContext::ResolveStyleContextForNonElement(nsStyleContext* aParentContext)
|
||||
{
|
||||
|
@ -1016,6 +1004,21 @@ nsPresContext::ProbePseudoStyleContextFor(nsIContent* aParentContent,
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetXBLBindingURL(nsIContent* aContent, nsAString& aResult)
|
||||
{
|
||||
nsRefPtr<nsStyleContext> 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)
|
||||
|
|
|
@ -88,10 +88,6 @@ public:
|
|||
virtual already_AddRefed<nsStyleContext>
|
||||
ResolveStyleContextFor(nsIContent* aContent, nsStyleContext* aParentContext);
|
||||
|
||||
NS_IMETHOD ResolveStyleContextAndGetStyleData(nsIContent* aContent,
|
||||
int aSID,
|
||||
const nsStyleStruct*& aStyleStruct);
|
||||
|
||||
virtual already_AddRefed<nsStyleContext>
|
||||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче