Bug 1288626 Part 5 - Rename StyleClipPathType to StyleShapeSourceType. r=heycam
StyleClipPathType will be generalized to StyleShapeSourceType to match this
change.
MozReview-Commit-ID: Igaad2EoSSt
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3949,38 +3949,38 @@ StyleAnimationValue::ExtractComputedValu
break;
}
#endif
case eCSSProperty_clip_path: {
const nsStyleSVGReset* svgReset =
static_cast<const nsStyleSVGReset*>(styleStruct);
const StyleClipPath& clipPath = svgReset->mClipPath;
- const StyleClipPathType type = clipPath.GetType();
-
- if (type == StyleClipPathType::URL) {
+ const StyleShapeSourceType type = clipPath.GetType();
+
+ if (type == StyleShapeSourceType::URL) {
nsIDocument* doc = aStyleContext->PresContext()->Document();
RefPtr<mozilla::css::URLValue> url =
FragmentOrURLToURLValue(clipPath.GetURL(), doc);
auto result = MakeUnique<nsCSSValue>();
result->SetURLValue(url);
aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL);
- } else if (type == StyleClipPathType::Box) {
+ } else if (type == StyleShapeSourceType::Box) {
aComputedValue.SetIntValue(clipPath.GetSizingBox(),
eUnit_Enumerated);
- } else if (type == StyleClipPathType::Shape) {
+ } else if (type == StyleShapeSourceType::Shape) {
RefPtr<nsCSSValue::Array> result = nsCSSValue::Array::Create(2);
if (!StyleClipBasicShapeToCSSArray(clipPath, result)) {
return false;
}
aComputedValue.SetCSSValueArrayValue(result, eUnit_Shape);
} else {
- MOZ_ASSERT(type == StyleClipPathType::None_, "unknown type");
+ MOZ_ASSERT(type == StyleShapeSourceType::None_, "unknown type");
aComputedValue.SetNoneValue();
}
break;
}
case eCSSProperty_filter: {
const nsStyleEffects* effects =
static_cast<const nsStyleEffects*>(styleStruct);
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -6021,28 +6021,28 @@ nsComputedDOMStyle::CreatePrimitiveValue
return valueList.forget();
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetClipPath()
{
const nsStyleSVGReset* svg = StyleSVGReset();
switch (svg->mClipPath.GetType()) {
- case StyleClipPathType::Shape:
+ case StyleShapeSourceType::Shape:
return CreatePrimitiveValueForClipPath(svg->mClipPath.GetBasicShape(),
svg->mClipPath.GetSizingBox());
- case StyleClipPathType::Box:
+ case StyleShapeSourceType::Box:
return CreatePrimitiveValueForClipPath(nullptr,
svg->mClipPath.GetSizingBox());
- case StyleClipPathType::URL: {
+ case StyleShapeSourceType::URL: {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToFragmentOrURL(svg->mClipPath.GetURL(), val);
return val.forget();
}
- case StyleClipPathType::None_: {
+ case StyleShapeSourceType::None_: {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetIdent(eCSSKeyword_none);
return val.forget();
}
default:
NS_NOTREACHED("unexpected type");
}
return nullptr;
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -68,25 +68,16 @@ enum class StyleBoxSizing : uint8_t {
Border
};
// box-shadow
enum class StyleBoxShadowType : uint8_t {
Inset,
};
-// clip-path type
-// X11 has a #define for None causing conflicts, so we use None_ here
-enum class StyleClipPathType : uint8_t {
- None_,
- URL,
- Shape,
- Box,
-};
-
// clip-path sizing
enum class StyleClipShapeSizing : uint8_t {
NoBox,
Content,
Padding,
Border,
Margin,
Fill,
@@ -95,16 +86,25 @@ enum class StyleClipShapeSizing : uint8_
};
// float-edge
enum class StyleFloatEdge : uint8_t {
ContentBox,
MarginBox,
};
+// Shape source type
+// X11 has a #define for None causing conflicts, so we use None_ here
+enum class StyleShapeSourceType : uint8_t {
+ None_,
+ URL,
+ Shape,
+ Box,
+};
+
// user-focus
// X11 has a #define for None causing conflicts, so we use None_ here
enum class StyleUserFocus : uint8_t {
None_,
Ignore,
Normal,
SelectAll,
SelectBefore,
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1105,137 +1105,137 @@ StyleBasicShape::GetShapeTypeName() cons
return eCSSKeyword_UNKNOWN;
}
// --------------------
// StyleClipPath
//
StyleClipPath::StyleClipPath()
: mURL(nullptr)
- , mType(StyleClipPathType::None_)
+ , mType(StyleShapeSourceType::None_)
, mSizingBox(StyleClipShapeSizing::NoBox)
{
}
StyleClipPath::StyleClipPath(const StyleClipPath& aSource)
: mURL(nullptr)
- , mType(StyleClipPathType::None_)
+ , mType(StyleShapeSourceType::None_)
, mSizingBox(StyleClipShapeSizing::NoBox)
{
- if (aSource.mType == StyleClipPathType::URL) {
+ if (aSource.mType == StyleShapeSourceType::URL) {
CopyURL(aSource);
- } else if (aSource.mType == StyleClipPathType::Shape) {
+ } else if (aSource.mType == StyleShapeSourceType::Shape) {
SetBasicShape(aSource.mBasicShape, aSource.mSizingBox);
- } else if (aSource.mType == StyleClipPathType::Box) {
+ } else if (aSource.mType == StyleShapeSourceType::Box) {
SetSizingBox(aSource.mSizingBox);
}
}
StyleClipPath::~StyleClipPath()
{
ReleaseRef();
}
StyleClipPath&
StyleClipPath::operator=(const StyleClipPath& aOther)
{
if (this == &aOther) {
return *this;
}
- if (aOther.mType == StyleClipPathType::URL) {
+ if (aOther.mType == StyleShapeSourceType::URL) {
CopyURL(aOther);
- } else if (aOther.mType == StyleClipPathType::Shape) {
+ } else if (aOther.mType == StyleShapeSourceType::Shape) {
SetBasicShape(aOther.mBasicShape, aOther.mSizingBox);
- } else if (aOther.mType == StyleClipPathType::Box) {
+ } else if (aOther.mType == StyleShapeSourceType::Box) {
SetSizingBox(aOther.mSizingBox);
} else {
ReleaseRef();
mSizingBox = StyleClipShapeSizing::NoBox;
- mType = StyleClipPathType::None_;
+ mType = StyleShapeSourceType::None_;
}
return *this;
}
bool
StyleClipPath::operator==(const StyleClipPath& aOther) const
{
if (mType != aOther.mType) {
return false;
}
- if (mType == StyleClipPathType::URL) {
+ if (mType == StyleShapeSourceType::URL) {
return EqualURIs(mURL, aOther.mURL);
- } else if (mType == StyleClipPathType::Shape) {
+ } else if (mType == StyleShapeSourceType::Shape) {
return *mBasicShape == *aOther.mBasicShape &&
mSizingBox == aOther.mSizingBox;
- } else if (mType == StyleClipPathType::Box) {
+ } else if (mType == StyleShapeSourceType::Box) {
return mSizingBox == aOther.mSizingBox;
}
return true;
}
void
StyleClipPath::ReleaseRef()
{
- if (mType == StyleClipPathType::Shape) {
+ if (mType == StyleShapeSourceType::Shape) {
NS_ASSERTION(mBasicShape, "expected pointer");
mBasicShape->Release();
- } else if (mType == StyleClipPathType::URL) {
+ } else if (mType == StyleShapeSourceType::URL) {
NS_ASSERTION(mURL, "expected pointer");
delete mURL;
}
// mBasicShap, mURL, etc. are all pointers in a union of pointers. Nulling
// one of them nulls all of them:
mURL = nullptr;
}
void
StyleClipPath::CopyURL(const StyleClipPath& aOther)
{
ReleaseRef();
mURL = new FragmentOrURL(*aOther.mURL);
- mType = StyleClipPathType::URL;
+ mType = StyleShapeSourceType::URL;
}
bool
StyleClipPath::SetURL(const nsCSSValue* aValue)
{
if (!aValue->GetURLValue()) {
return false;
}
ReleaseRef();
mURL = new FragmentOrURL();
mURL->SetValue(aValue);
- mType = StyleClipPathType::URL;
+ mType = StyleShapeSourceType::URL;
return true;
}
void
StyleClipPath::SetBasicShape(StyleBasicShape* aBasicShape,
StyleClipShapeSizing aSizingBox)
{
NS_ASSERTION(aBasicShape, "expected pointer");
ReleaseRef();
mBasicShape = aBasicShape;
mBasicShape->AddRef();
mSizingBox = aSizingBox;
- mType = StyleClipPathType::Shape;
+ mType = StyleShapeSourceType::Shape;
}
void
StyleClipPath::SetSizingBox(StyleClipShapeSizing aSizingBox)
{
ReleaseRef();
mSizingBox = aSizingBox;
- mType = StyleClipPathType::Box;
+ mType = StyleShapeSourceType::Box;
}
// --------------------
// nsStyleFilter
//
nsStyleFilter::nsStyleFilter()
: mType(NS_STYLE_FILTER_NONE)
, mDropShadow(nullptr)
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3539,28 +3539,28 @@ struct StyleClipPath
StyleClipPath& operator=(const StyleClipPath& aOther);
bool operator==(const StyleClipPath& aOther) const;
bool operator!=(const StyleClipPath& aOther) const {
return !(*this == aOther);
}
- StyleClipPathType GetType() const {
+ StyleShapeSourceType GetType() const {
return mType;
}
FragmentOrURL* GetURL() const {
- NS_ASSERTION(mType == StyleClipPathType::URL, "wrong clip-path type");
+ MOZ_ASSERT(mType == StyleShapeSourceType::URL, "Wrong shape source type!");
return mURL;
}
bool SetURL(const nsCSSValue* aValue);
StyleBasicShape* GetBasicShape() const {
- NS_ASSERTION(mType == StyleClipPathType::Shape, "wrong clip-path type");
+ MOZ_ASSERT(mType == StyleShapeSourceType::Shape, "Wrong shape source type!");
return mBasicShape;
}
void SetBasicShape(StyleBasicShape* mBasicShape,
StyleClipShapeSizing aSizingBox =
StyleClipShapeSizing::NoBox);
StyleClipShapeSizing GetSizingBox() const { return mSizingBox; }
@@ -3571,17 +3571,17 @@ private:
void CopyURL(const StyleClipPath& aOther);
void* operator new(size_t) = delete;
union {
StyleBasicShape* mBasicShape;
FragmentOrURL* mURL;
};
- StyleClipPathType mType;
+ StyleShapeSourceType mType;
StyleClipShapeSizing mSizingBox;
};
} // namespace mozilla
struct nsStyleFilter
{
nsStyleFilter();
@@ -3664,17 +3664,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
// CalcDifference never returns the reflow hints that are sometimes
// handled for descendants as hints not handled for descendants.
return nsChangeHint_NeedReflow |
nsChangeHint_ReflowChangesSizeOrPosition |
nsChangeHint_ClearAncestorIntrinsics;
}
bool HasClipPath() const {
- return mClipPath.GetType() != mozilla::StyleClipPathType::None_;
+ return mClipPath.GetType() != mozilla::StyleShapeSourceType::None_;
}
bool HasNonScalingStroke() const {
return mVectorEffect == NS_STYLE_VECTOR_EFFECT_NON_SCALING_STROKE;
}
nsStyleImageLayers mMask;
mozilla::StyleClipPath mClipPath; // [reset]
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -18,42 +18,42 @@
using namespace mozilla;
using namespace mozilla::gfx;
/* static*/ void
nsCSSClipPathInstance::ApplyBasicShapeClip(gfxContext& aContext,
nsIFrame* aFrame)
{
auto& clipPathStyle = aFrame->StyleSVGReset()->mClipPath;
- StyleClipPathType type = clipPathStyle.GetType();
- MOZ_ASSERT(type != StyleClipPathType::None_, "unexpected none value");
+ StyleShapeSourceType type = clipPathStyle.GetType();
+ MOZ_ASSERT(type != StyleShapeSourceType::None_, "unexpected none value");
// In the future nsCSSClipPathInstance may handle <clipPath> references as
// well. For the time being return early.
- if (type == StyleClipPathType::URL) {
+ if (type == StyleShapeSourceType::URL) {
return;
}
nsCSSClipPathInstance instance(aFrame, clipPathStyle);
aContext.NewPath();
RefPtr<Path> path = instance.CreateClipPath(aContext.GetDrawTarget());
aContext.SetPath(path);
aContext.Clip();
}
/* static*/ bool
nsCSSClipPathInstance::HitTestBasicShapeClip(nsIFrame* aFrame,
const gfxPoint& aPoint)
{
auto& clipPathStyle = aFrame->StyleSVGReset()->mClipPath;
- StyleClipPathType type = clipPathStyle.GetType();
- MOZ_ASSERT(type != StyleClipPathType::None_, "unexpected none value");
+ StyleShapeSourceType type = clipPathStyle.GetType();
+ MOZ_ASSERT(type != StyleShapeSourceType::None_, "unexpected none value");
// In the future nsCSSClipPathInstance may handle <clipPath> references as
// well. For the time being return early.
- if (type == StyleClipPathType::URL) {
+ if (type == StyleShapeSourceType::URL) {
return false;
}
nsCSSClipPathInstance instance(aFrame, clipPathStyle);
RefPtr<DrawTarget> drawTarget =
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
RefPtr<Path> path = instance.CreateClipPath(drawTarget);
@@ -76,17 +76,17 @@ nsCSSClipPathInstance::CreateClipPath(Dr
break;
case StyleClipShapeSizing::Margin:
r = mTargetFrame->GetMarginRectRelativeToSelf();
break;
default: // Use the border box
r = mTargetFrame->GetRectRelativeToSelf();
}
- if (mClipPathStyle.GetType() != StyleClipPathType::Shape) {
+ if (mClipPathStyle.GetType() != StyleShapeSourceType::Shape) {
// TODO Clip to border-radius/reference box if no shape
// was specified.
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
return builder->Finish();
}
nscoord appUnitsPerDevPixel =
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -574,17 +574,17 @@ nsSVGEffects::GetEffectProperties(nsIFra
{
NS_ASSERTION(!aFrame->GetPrevContinuation(), "aFrame should be first continuation");
EffectProperties result;
const nsStyleSVGReset *style = aFrame->StyleSVGReset();
result.mFilter = GetOrCreateFilterProperty(aFrame);
- if (style->mClipPath.GetType() == StyleClipPathType::URL) {
+ if (style->mClipPath.GetType() == StyleShapeSourceType::URL) {
nsCOMPtr<nsIURI> pathURI = nsSVGEffects::GetClipPathURI(aFrame);
result.mClipPath =
GetPaintingProperty(pathURI, aFrame, ClipPathProperty());
} else {
result.mClipPath = nullptr;
}
MOZ_ASSERT(style->mMask.mImageCount > 0);
@@ -924,17 +924,17 @@ nsSVGEffects::GetMarkerURI(nsIFrame* aFr
{
return ResolveFragmentOrURL(aFrame, &(aFrame->StyleSVG()->*aMarker));
}
already_AddRefed<nsIURI>
nsSVGEffects::GetClipPathURI(nsIFrame* aFrame)
{
const nsStyleSVGReset* svgResetStyle = aFrame->StyleSVGReset();
- MOZ_ASSERT(svgResetStyle->mClipPath.GetType() == StyleClipPathType::URL);
+ MOZ_ASSERT(svgResetStyle->mClipPath.GetType() == StyleShapeSourceType::URL);
FragmentOrURL* url = svgResetStyle->mClipPath.GetURL();
return ResolveFragmentOrURL(aFrame, url);
}
already_AddRefed<nsIURI>
nsSVGEffects::GetFilterURI(nsIFrame* aFrame, uint32_t aIndex)
{