зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1298774 - Part 4: Make ShapeStyleSource use css::URLValue for url() storage instead of FragmentOrURL. r=cjku
MozReview-Commit-ID: CQy6ArR48Sp --HG-- extra : rebase_source : 71203745bca616395daeffe5b47b288b0ce67b0b
This commit is contained in:
Родитель
5ed807d5a2
Коммит
f1dcd6fc45
|
@ -4120,12 +4120,8 @@ StyleAnimationValue::ExtractComputedValue(nsCSSPropertyID aProperty,
|
||||||
const StyleShapeSourceType type = clipPath.GetType();
|
const StyleShapeSourceType type = clipPath.GetType();
|
||||||
|
|
||||||
if (type == StyleShapeSourceType::URL) {
|
if (type == StyleShapeSourceType::URL) {
|
||||||
nsIDocument* doc = aStyleContext->PresContext()->Document();
|
|
||||||
RefPtr<mozilla::css::URLValue> url =
|
|
||||||
FragmentOrURLToURLValue(clipPath.GetURL(), doc);
|
|
||||||
|
|
||||||
auto result = MakeUnique<nsCSSValue>();
|
auto result = MakeUnique<nsCSSValue>();
|
||||||
result->SetURLValue(url);
|
result->SetURLValue(clipPath.GetURL());
|
||||||
aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL);
|
aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL);
|
||||||
} else if (type == StyleShapeSourceType::Box) {
|
} else if (type == StyleShapeSourceType::Box) {
|
||||||
aComputedValue.SetIntValue(clipPath.GetReferenceBox(),
|
aComputedValue.SetIntValue(clipPath.GetReferenceBox(),
|
||||||
|
|
|
@ -2407,6 +2407,26 @@ nsComputedDOMStyle::SetValueToFragmentOrURL(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsComputedDOMStyle::SetValueToURLValue(const css::URLValueData* aURL,
|
||||||
|
nsROCSSPrimitiveValue* aValue)
|
||||||
|
{
|
||||||
|
if (aURL && aURL->IsLocalRef()) {
|
||||||
|
nsString fragment;
|
||||||
|
aURL->GetSourceString(fragment);
|
||||||
|
fragment.Insert(u"url(\"", 0);
|
||||||
|
fragment.Append(u"\")");
|
||||||
|
aValue->SetString(fragment);
|
||||||
|
} else {
|
||||||
|
nsCOMPtr<nsIURI> url;
|
||||||
|
if (aURL && (url = aURL->GetURI())) {
|
||||||
|
aValue->SetURI(url);
|
||||||
|
} else {
|
||||||
|
aValue->SetIdent(eCSSKeyword_none);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<CSSValue>
|
already_AddRefed<CSSValue>
|
||||||
nsComputedDOMStyle::DoGetBackgroundPosition()
|
nsComputedDOMStyle::DoGetBackgroundPosition()
|
||||||
{
|
{
|
||||||
|
@ -6030,7 +6050,7 @@ nsComputedDOMStyle::GetShapeSource(
|
||||||
aBoxKeywordTable);
|
aBoxKeywordTable);
|
||||||
case StyleShapeSourceType::URL: {
|
case StyleShapeSourceType::URL: {
|
||||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||||
SetValueToFragmentOrURL(aShapeSource.GetURL(), val);
|
SetValueToURLValue(aShapeSource.GetURL(), val);
|
||||||
return val.forget();
|
return val.forget();
|
||||||
}
|
}
|
||||||
case StyleShapeSourceType::None: {
|
case StyleShapeSourceType::None: {
|
||||||
|
|
|
@ -593,6 +593,8 @@ private:
|
||||||
nsDOMCSSValueList* aValueList);
|
nsDOMCSSValueList* aValueList);
|
||||||
void SetValueToFragmentOrURL(const mozilla::FragmentOrURL* aFragmentOrURL,
|
void SetValueToFragmentOrURL(const mozilla::FragmentOrURL* aFragmentOrURL,
|
||||||
nsROCSSPrimitiveValue* aValue);
|
nsROCSSPrimitiveValue* aValue);
|
||||||
|
void SetValueToURLValue(const mozilla::css::URLValueData* aURL,
|
||||||
|
nsROCSSPrimitiveValue* aValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method to get a percentage base for a percentage value. Returns true
|
* A method to get a percentage base for a percentage value. Returns true
|
||||||
|
|
|
@ -6452,7 +6452,7 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
|
||||||
break;
|
break;
|
||||||
case eCSSUnit_URL: {
|
case eCSSUnit_URL: {
|
||||||
display->mShapeOutside = StyleShapeOutside();
|
display->mShapeOutside = StyleShapeOutside();
|
||||||
display->mShapeOutside.SetURL(shapeOutsideValue);
|
display->mShapeOutside.SetURL(shapeOutsideValue->GetURLStructValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eCSSUnit_Array: {
|
case eCSSUnit_Array: {
|
||||||
|
@ -9865,7 +9865,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
|
||||||
break;
|
break;
|
||||||
case eCSSUnit_URL: {
|
case eCSSUnit_URL: {
|
||||||
svgReset->mClipPath = StyleClipPath();
|
svgReset->mClipPath = StyleClipPath();
|
||||||
svgReset->mClipPath.SetURL(clipPathValue);
|
svgReset->mClipPath.SetURL(clipPathValue->GetURLStructValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eCSSUnit_Array: {
|
case eCSSUnit_Array: {
|
||||||
|
|
|
@ -2542,7 +2542,7 @@ struct StyleShapeSource
|
||||||
: StyleShapeSource()
|
: StyleShapeSource()
|
||||||
{
|
{
|
||||||
if (aSource.mType == StyleShapeSourceType::URL) {
|
if (aSource.mType == StyleShapeSourceType::URL) {
|
||||||
CopyURL(aSource);
|
SetURL(aSource.mURL);
|
||||||
} else if (aSource.mType == StyleShapeSourceType::Shape) {
|
} else if (aSource.mType == StyleShapeSourceType::Shape) {
|
||||||
SetBasicShape(aSource.mBasicShape, aSource.mReferenceBox);
|
SetBasicShape(aSource.mBasicShape, aSource.mReferenceBox);
|
||||||
} else if (aSource.mType == StyleShapeSourceType::Box) {
|
} else if (aSource.mType == StyleShapeSourceType::Box) {
|
||||||
|
@ -2562,7 +2562,7 @@ struct StyleShapeSource
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aOther.mType == StyleShapeSourceType::URL) {
|
if (aOther.mType == StyleShapeSourceType::URL) {
|
||||||
CopyURL(aOther);
|
SetURL(aOther.mURL);
|
||||||
} else if (aOther.mType == StyleShapeSourceType::Shape) {
|
} else if (aOther.mType == StyleShapeSourceType::Shape) {
|
||||||
SetBasicShape(aOther.mBasicShape, aOther.mReferenceBox);
|
SetBasicShape(aOther.mBasicShape, aOther.mReferenceBox);
|
||||||
} else if (aOther.mType == StyleShapeSourceType::Box) {
|
} else if (aOther.mType == StyleShapeSourceType::Box) {
|
||||||
|
@ -2582,7 +2582,7 @@ struct StyleShapeSource
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mType == StyleShapeSourceType::URL) {
|
if (mType == StyleShapeSourceType::URL) {
|
||||||
return mURL == aOther.mURL;
|
return mURL->Equals(*aOther.mURL);
|
||||||
} else if (mType == StyleShapeSourceType::Shape) {
|
} else if (mType == StyleShapeSourceType::Shape) {
|
||||||
return *mBasicShape == *aOther.mBasicShape &&
|
return *mBasicShape == *aOther.mBasicShape &&
|
||||||
mReferenceBox == aOther.mReferenceBox;
|
mReferenceBox == aOther.mReferenceBox;
|
||||||
|
@ -2603,22 +2603,18 @@ struct StyleShapeSource
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
FragmentOrURL* GetURL() const
|
css::URLValue* GetURL() const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mType == StyleShapeSourceType::URL, "Wrong shape source type!");
|
MOZ_ASSERT(mType == StyleShapeSourceType::URL, "Wrong shape source type!");
|
||||||
return mURL;
|
return mURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetURL(const nsCSSValue* aValue)
|
bool SetURL(css::URLValue* aValue)
|
||||||
{
|
{
|
||||||
if (!aValue->GetURLValue()) {
|
MOZ_ASSERT(aValue);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReleaseRef();
|
ReleaseRef();
|
||||||
|
mURL = aValue;
|
||||||
mURL = new FragmentOrURL();
|
mURL->AddRef();
|
||||||
mURL->SetValue(aValue);
|
|
||||||
mType = StyleShapeSourceType::URL;
|
mType = StyleShapeSourceType::URL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2663,26 +2659,18 @@ private:
|
||||||
mBasicShape->Release();
|
mBasicShape->Release();
|
||||||
} else if (mType == StyleShapeSourceType::URL) {
|
} else if (mType == StyleShapeSourceType::URL) {
|
||||||
NS_ASSERTION(mURL, "expected pointer");
|
NS_ASSERTION(mURL, "expected pointer");
|
||||||
delete mURL;
|
mURL->Release();
|
||||||
}
|
}
|
||||||
// Both mBasicShape and mURL are pointers in a union. Nulling one of them
|
// Both mBasicShape and mURL are pointers in a union. Nulling one of them
|
||||||
// nulls both of them.
|
// nulls both of them.
|
||||||
mURL = nullptr;
|
mURL = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyURL(const StyleShapeSource& aOther)
|
|
||||||
{
|
|
||||||
ReleaseRef();
|
|
||||||
|
|
||||||
mURL = new FragmentOrURL(*aOther.mURL);
|
|
||||||
mType = StyleShapeSourceType::URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* operator new(size_t) = delete;
|
void* operator new(size_t) = delete;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
StyleBasicShape* mBasicShape;
|
StyleBasicShape* mBasicShape;
|
||||||
FragmentOrURL* mURL;
|
css::URLValue* mURL;
|
||||||
};
|
};
|
||||||
StyleShapeSourceType mType = StyleShapeSourceType::None;
|
StyleShapeSourceType mType = StyleShapeSourceType::None;
|
||||||
ReferenceBox mReferenceBox = ReferenceBox::NoBox;
|
ReferenceBox mReferenceBox = ReferenceBox::NoBox;
|
||||||
|
|
|
@ -942,6 +942,60 @@ ResolveFragmentOrURL(nsIFrame* aFrame, const FragmentOrURL* aFragmentOrURL)
|
||||||
return aFragmentOrURL->Resolve(baseURI);
|
return aFragmentOrURL->Resolve(baseURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static already_AddRefed<nsIURI>
|
||||||
|
ResolveURLUsingLocalRef(nsIFrame* aFrame, const css::URLValue* aURL)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aFrame);
|
||||||
|
|
||||||
|
if (!aURL) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-local-reference URL.
|
||||||
|
if (!aURL->IsLocalRef()) {
|
||||||
|
nsCOMPtr<nsIURI> result = aURL->GetURI();
|
||||||
|
return result.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For a local-reference URL, resolve that fragment against the current
|
||||||
|
// document that relative URLs are resolved against.
|
||||||
|
nsIContent* content = aFrame->GetContent();
|
||||||
|
nsCOMPtr<nsIURI> baseURI = content->OwnerDoc()->GetDocumentURI();
|
||||||
|
|
||||||
|
if (content->IsInAnonymousSubtree()) {
|
||||||
|
nsIContent* bindingParent = content->GetBindingParent();
|
||||||
|
nsCOMPtr<nsIURI> originalURI;
|
||||||
|
|
||||||
|
// content is in a shadow tree. If this URL was specified in the subtree
|
||||||
|
// referenced by the <use>(or -moz-binding) element, and that subtree came
|
||||||
|
// from a separate resource document, then we want the fragment-only URL
|
||||||
|
// to resolve to an element from the resource document. Otherwise, the
|
||||||
|
// URL was specified somewhere in the document with the <use> element, and
|
||||||
|
// we want the fragment-only URL to resolve to an element in that document.
|
||||||
|
if (bindingParent) {
|
||||||
|
if (content->IsAnonymousContentInSVGUseSubtree()) {
|
||||||
|
SVGUseElement* useElement = static_cast<SVGUseElement*>(bindingParent);
|
||||||
|
originalURI = useElement->GetSourceDocURI();
|
||||||
|
} else {
|
||||||
|
nsXBLBinding* binding = bindingParent->GetXBLBinding();
|
||||||
|
if (binding) {
|
||||||
|
originalURI = binding->GetSourceDocURI();
|
||||||
|
} else {
|
||||||
|
MOZ_ASSERT(content->IsInNativeAnonymousSubtree(),
|
||||||
|
"an non-native anonymous tree which is not from "
|
||||||
|
"an XBL binding?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originalURI && aURL->EqualsExceptRef(originalURI)) {
|
||||||
|
baseURI = originalURI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aURL->ResolveLocalRef(baseURI);
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIURI>
|
already_AddRefed<nsIURI>
|
||||||
nsSVGEffects::GetMarkerURI(nsIFrame* aFrame,
|
nsSVGEffects::GetMarkerURI(nsIFrame* aFrame,
|
||||||
FragmentOrURL nsStyleSVG::* aMarker)
|
FragmentOrURL nsStyleSVG::* aMarker)
|
||||||
|
@ -955,8 +1009,8 @@ nsSVGEffects::GetClipPathURI(nsIFrame* aFrame)
|
||||||
const nsStyleSVGReset* svgResetStyle = aFrame->StyleSVGReset();
|
const nsStyleSVGReset* svgResetStyle = aFrame->StyleSVGReset();
|
||||||
MOZ_ASSERT(svgResetStyle->mClipPath.GetType() == StyleShapeSourceType::URL);
|
MOZ_ASSERT(svgResetStyle->mClipPath.GetType() == StyleShapeSourceType::URL);
|
||||||
|
|
||||||
FragmentOrURL* url = svgResetStyle->mClipPath.GetURL();
|
css::URLValue* url = svgResetStyle->mClipPath.GetURL();
|
||||||
return ResolveFragmentOrURL(aFrame, url);
|
return ResolveURLUsingLocalRef(aFrame, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIURI>
|
already_AddRefed<nsIURI>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче