зеркало из https://github.com/mozilla/gecko-dev.git
Bug 652991 - Part 5. Using FragmentOrURL to represent SVG clippath. r=heycam
MozReview-Commit-ID: BErpWUQ5iQ1 --HG-- extra : rebase_source : 16ed0cd6bb1fd3bc7ac91b33078c9938306a69b6 extra : source : fd15e7962cffec5b2c1f101a36e32dcdce17146c
This commit is contained in:
Родитель
0de453b35d
Коммит
25577ba9c8
|
@ -3955,10 +3955,13 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
|
|||
|
||||
if (type == StyleClipPathType::URL) {
|
||||
nsIDocument* doc = aStyleContext->PresContext()->Document();
|
||||
nsString pathString;
|
||||
clipPath.GetURL()->GetSourceString(pathString);
|
||||
RefPtr<nsStringBuffer> uriAsStringBuffer =
|
||||
GetURIAsUtf16StringBuffer(clipPath.GetURL());
|
||||
nsCSSValue::BufferFromString(pathString);
|
||||
|
||||
RefPtr<mozilla::css::URLValue> url =
|
||||
new mozilla::css::URLValue(clipPath.GetURL(),
|
||||
new mozilla::css::URLValue(clipPath.GetURL()->GetSourceURL(),
|
||||
uriAsStringBuffer,
|
||||
doc->GetDocumentURI(),
|
||||
doc->NodePrincipal());
|
||||
|
|
|
@ -6032,8 +6032,10 @@ nsComputedDOMStyle::DoGetClipPath()
|
|||
return CreatePrimitiveValueForClipPath(nullptr,
|
||||
svg->mClipPath.GetSizingBox());
|
||||
case StyleClipPathType::URL: {
|
||||
// Bug 1288812 - we should only serialize fragment for local-ref URL.
|
||||
nsCOMPtr<nsIURI> pathURI = svg->mClipPath.GetURL()->GetSourceURL();
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
val->SetURI(svg->mClipPath.GetURL());
|
||||
val->SetURI(pathURI);
|
||||
return val.forget();
|
||||
}
|
||||
case StyleClipPathType::None_: {
|
||||
|
|
|
@ -9891,10 +9891,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
|
|||
break;
|
||||
case eCSSUnit_URL: {
|
||||
svgReset->mClipPath = nsStyleClipPath();
|
||||
nsIURI* url = clipPathValue->GetURLValue();
|
||||
if (url) {
|
||||
svgReset->mClipPath.SetURL(url);
|
||||
}
|
||||
svgReset->mClipPath.SetURL(clipPathValue);
|
||||
break;
|
||||
}
|
||||
case eCSSUnit_Array: {
|
||||
|
|
|
@ -1122,7 +1122,7 @@ nsStyleClipPath::nsStyleClipPath(const nsStyleClipPath& aSource)
|
|||
, mSizingBox(StyleClipShapeSizing::NoBox)
|
||||
{
|
||||
if (aSource.mType == StyleClipPathType::URL) {
|
||||
SetURL(aSource.mURL);
|
||||
CopyURL(aSource);
|
||||
} else if (aSource.mType == StyleClipPathType::Shape) {
|
||||
SetBasicShape(aSource.mBasicShape, aSource.mSizingBox);
|
||||
} else if (aSource.mType == StyleClipPathType::Box) {
|
||||
|
@ -1143,7 +1143,7 @@ nsStyleClipPath::operator=(const nsStyleClipPath& aOther)
|
|||
}
|
||||
|
||||
if (aOther.mType == StyleClipPathType::URL) {
|
||||
SetURL(aOther.mURL);
|
||||
CopyURL(aOther);
|
||||
} else if (aOther.mType == StyleClipPathType::Shape) {
|
||||
SetBasicShape(aOther.mBasicShape, aOther.mSizingBox);
|
||||
} else if (aOther.mType == StyleClipPathType::Box) {
|
||||
|
@ -1183,7 +1183,7 @@ nsStyleClipPath::ReleaseRef()
|
|||
mBasicShape->Release();
|
||||
} else if (mType == StyleClipPathType::URL) {
|
||||
NS_ASSERTION(mURL, "expected pointer");
|
||||
mURL->Release();
|
||||
delete mURL;
|
||||
}
|
||||
// mBasicShap, mURL, etc. are all pointers in a union of pointers. Nulling
|
||||
// one of them nulls all of them:
|
||||
|
@ -1191,15 +1191,29 @@ nsStyleClipPath::ReleaseRef()
|
|||
}
|
||||
|
||||
void
|
||||
nsStyleClipPath::SetURL(nsIURI* aURL)
|
||||
nsStyleClipPath::CopyURL(const nsStyleClipPath& aOther)
|
||||
{
|
||||
NS_ASSERTION(aURL, "expected pointer");
|
||||
ReleaseRef();
|
||||
mURL = aURL;
|
||||
mURL->AddRef();
|
||||
|
||||
mURL = new FragmentOrURL(*aOther.mURL);
|
||||
mType = StyleClipPathType::URL;
|
||||
}
|
||||
|
||||
bool
|
||||
nsStyleClipPath::SetURL(const nsCSSValue* aValue)
|
||||
{
|
||||
if (!aValue->GetURLValue()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ReleaseRef();
|
||||
|
||||
mURL = new FragmentOrURL();
|
||||
mURL->SetValue(aValue);
|
||||
mType = StyleClipPathType::URL;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape,
|
||||
StyleClipShapeSizing aSizingBox)
|
||||
|
|
|
@ -3551,11 +3551,11 @@ struct nsStyleClipPath
|
|||
return mType;
|
||||
}
|
||||
|
||||
nsIURI* GetURL() const {
|
||||
FragmentOrURL* GetURL() const {
|
||||
NS_ASSERTION(mType == mozilla::StyleClipPathType::URL, "wrong clip-path type");
|
||||
return mURL;
|
||||
}
|
||||
void SetURL(nsIURI* aURL);
|
||||
bool SetURL(const nsCSSValue* aValue);
|
||||
|
||||
nsStyleBasicShape* GetBasicShape() const {
|
||||
NS_ASSERTION(mType == mozilla::StyleClipPathType::Shape, "wrong clip-path type");
|
||||
|
@ -3571,11 +3571,13 @@ struct nsStyleClipPath
|
|||
|
||||
private:
|
||||
void ReleaseRef();
|
||||
void CopyURL(const nsStyleClipPath& aOther);
|
||||
|
||||
void* operator new(size_t) = delete;
|
||||
|
||||
union {
|
||||
nsStyleBasicShape* mBasicShape;
|
||||
nsIURI* mURL;
|
||||
FragmentOrURL* mURL;
|
||||
};
|
||||
mozilla::StyleClipPathType mType;
|
||||
mozilla::StyleClipShapeSizing mSizingBox;
|
||||
|
|
|
@ -573,8 +573,9 @@ nsSVGEffects::GetEffectProperties(nsIFrame *aFrame)
|
|||
result.mFilter = GetOrCreateFilterProperty(aFrame);
|
||||
|
||||
if (style->mClipPath.GetType() == StyleClipPathType::URL) {
|
||||
nsCOMPtr<nsIURI> pathURI = nsSVGEffects::GetClipPathURI(aFrame);
|
||||
result.mClipPath =
|
||||
GetPaintingProperty(style->mClipPath.GetURL(), aFrame, ClipPathProperty());
|
||||
GetPaintingProperty(pathURI, aFrame, ClipPathProperty());
|
||||
} else {
|
||||
result.mClipPath = nullptr;
|
||||
}
|
||||
|
@ -910,3 +911,13 @@ nsSVGEffects::GetMarkerURI(nsIFrame* aFrame,
|
|||
{
|
||||
return ResolveFragmentOrURL(aFrame, &(aFrame->StyleSVG()->*aMarker));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
nsSVGEffects::GetClipPathURI(nsIFrame *aFrame)
|
||||
{
|
||||
const nsStyleSVGReset* svgResetStyle = aFrame->StyleSVGReset();
|
||||
MOZ_ASSERT(svgResetStyle->mClipPath.GetType() == NS_STYLE_CLIP_PATH_URL);
|
||||
|
||||
FragmentOrURL* url = svgResetStyle->mClipPath.GetURL();
|
||||
return ResolveFragmentOrURL(aFrame, url);
|
||||
}
|
||||
|
|
|
@ -598,6 +598,12 @@ public:
|
|||
*/
|
||||
static already_AddRefed<nsIURI>
|
||||
GetMarkerURI(nsIFrame* aFrame, FragmentOrURL nsStyleSVG::* aMarker);
|
||||
|
||||
/**
|
||||
* A helper function to resolve clip-path URL.
|
||||
*/
|
||||
static already_AddRefed<nsIURI>
|
||||
GetClipPathURI(nsIFrame* aFrame);
|
||||
};
|
||||
|
||||
#endif /*NSSVGEFFECTS_H_*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче