Bug 1287755 - Replace NS_STYLE_CLIP_SHAPE_SIZING_* with an enum class; r=heycam

MozReview-Commit-ID: KutLb8H9JOk

--HG--
extra : rebase_source : ae38fcb7ebc8c6d5a8c77c773c8706580e41040c
This commit is contained in:
Manish Goregaokar 2016-07-20 11:12:42 +05:30
Родитель 5f7ab9c8f9
Коммит 8add405354
9 изменённых файлов: 45 добавлений и 37 удалений

Просмотреть файл

@ -3573,7 +3573,8 @@ StyleClipBasicShapeToCSSArray(const nsStyleClipPath& aClipPath,
MOZ_ASSERT_UNREACHABLE("Unknown shape type");
return false;
}
aResult->Item(1).SetIntValue(aClipPath.GetSizingBox(), eCSSUnit_Enumerated);
aResult->Item(1).SetIntValue(uint8_t(aClipPath.GetSizingBox()),
eCSSUnit_Enumerated);
return true;
}
@ -3963,7 +3964,8 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
result->SetURLValue(url);
aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL);
} else if (type == NS_STYLE_CLIP_PATH_BOX) {
aComputedValue.SetIntValue(clipPath.GetSizingBox(), eUnit_Enumerated);
aComputedValue.SetIntValue(uint8_t(clipPath.GetSizingBox()),
eUnit_Enumerated);
} else if (type == NS_STYLE_CLIP_PATH_SHAPE) {
RefPtr<nsCSSValue::Array> result = nsCSSValue::Array::Create(2);
if (!StyleClipBasicShapeToCSSArray(clipPath, result)) {

Просмотреть файл

@ -2300,13 +2300,13 @@ const KTableEntry nsCSSProps::kFillRuleKTable[] = {
};
const KTableEntry nsCSSProps::kClipShapeSizingKTable[] = {
{ eCSSKeyword_content_box, NS_STYLE_CLIP_SHAPE_SIZING_CONTENT },
{ eCSSKeyword_padding_box, NS_STYLE_CLIP_SHAPE_SIZING_PADDING },
{ eCSSKeyword_border_box, NS_STYLE_CLIP_SHAPE_SIZING_BORDER },
{ eCSSKeyword_margin_box, NS_STYLE_CLIP_SHAPE_SIZING_MARGIN },
{ eCSSKeyword_fill_box, NS_STYLE_CLIP_SHAPE_SIZING_FILL },
{ eCSSKeyword_stroke_box, NS_STYLE_CLIP_SHAPE_SIZING_STROKE },
{ eCSSKeyword_view_box, NS_STYLE_CLIP_SHAPE_SIZING_VIEW },
{ eCSSKeyword_content_box, uint8_t(StyleClipShapeSizing::Content) },
{ eCSSKeyword_padding_box, uint8_t(StyleClipShapeSizing::Padding) },
{ eCSSKeyword_border_box, uint8_t(StyleClipShapeSizing::Border) },
{ eCSSKeyword_margin_box, uint8_t(StyleClipShapeSizing::Margin) },
{ eCSSKeyword_fill_box, uint8_t(StyleClipShapeSizing::Fill) },
{ eCSSKeyword_stroke_box, uint8_t(StyleClipShapeSizing::Stroke) },
{ eCSSKeyword_view_box, uint8_t(StyleClipShapeSizing::View) },
{ eCSSKeyword_UNKNOWN, -1 }
};

Просмотреть файл

@ -5975,7 +5975,8 @@ nsComputedDOMStyle::CreatePrimitiveValueForBasicShape(
already_AddRefed<CSSValue>
nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox)
const nsStyleBasicShape* aStyleBasicShape,
mozilla::StyleClipShapeSizing aSizingBox)
{
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
if (aStyleBasicShape) {
@ -5983,13 +5984,13 @@ nsComputedDOMStyle::CreatePrimitiveValueForClipPath(
CreatePrimitiveValueForBasicShape(aStyleBasicShape));
}
if (aSizingBox == NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
if (aSizingBox == StyleClipShapeSizing::NoBox) {
return valueList.forget();
}
nsAutoString boxString;
AppendASCIItoUTF16(
nsCSSProps::ValueToKeyword(aSizingBox,
nsCSSProps::ValueToKeyword(uint8_t(aSizingBox),
nsCSSProps::kClipShapeSizingKTable),
boxString);
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;

Просмотреть файл

@ -643,7 +643,8 @@ private:
const nsStyleFilter& aStyleFilter);
already_AddRefed<CSSValue> CreatePrimitiveValueForClipPath(
const nsStyleBasicShape* aStyleBasicShape, uint8_t aSizingBox);
const nsStyleBasicShape* aStyleBasicShape,
mozilla::StyleClipShapeSizing aSizingBox);
// Helper function for computing basic shape styles.
already_AddRefed<CSSValue> CreatePrimitiveValueForBasicShape(

Просмотреть файл

@ -9701,17 +9701,17 @@ nsRuleNode::SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
MOZ_ASSERT(array->Count() == 1 || array->Count() == 2,
"Expect one or both of a shape function and geometry-box");
uint8_t sizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX;
StyleClipShapeSizing sizingBox = StyleClipShapeSizing::NoBox;
RefPtr<nsStyleBasicShape> basicShape;
for (size_t i = 0; i < array->Count(); ++i) {
if (array->Item(i).GetUnit() == eCSSUnit_Enumerated) {
int32_t type = array->Item(i).GetIntValue();
if (type > NS_STYLE_CLIP_SHAPE_SIZING_VIEW ||
type < NS_STYLE_CLIP_SHAPE_SIZING_NOBOX) {
if (type > uint8_t(StyleClipShapeSizing::View) ||
type < uint8_t(StyleClipShapeSizing::NoBox)) {
NS_NOTREACHED("unexpected reference box");
return;
}
sizingBox = (uint8_t)type;
sizingBox = static_cast<StyleClipShapeSizing>(type);
} else if (array->Item(i).GetUnit() == eCSSUnit_Function) {
basicShape = GetStyleBasicShapeFromCSSValue(array->Item(i), aStyleContext,
aPresContext, aConditions);

Просмотреть файл

@ -61,14 +61,16 @@ enum class StyleBoxSizing : uint8_t {
};
// clip-path sizing
#define NS_STYLE_CLIP_SHAPE_SIZING_NOBOX 0
#define NS_STYLE_CLIP_SHAPE_SIZING_CONTENT 1
#define NS_STYLE_CLIP_SHAPE_SIZING_PADDING 2
#define NS_STYLE_CLIP_SHAPE_SIZING_BORDER 3
#define NS_STYLE_CLIP_SHAPE_SIZING_MARGIN 4
#define NS_STYLE_CLIP_SHAPE_SIZING_FILL 5
#define NS_STYLE_CLIP_SHAPE_SIZING_STROKE 6
#define NS_STYLE_CLIP_SHAPE_SIZING_VIEW 7
enum class StyleClipShapeSizing : uint8_t {
NoBox,
Content,
Padding,
Border,
Margin,
Fill,
Stroke,
View,
};
// Basic Shapes
#define NS_STYLE_BASIC_SHAPE_POLYGON 0

Просмотреть файл

@ -1007,14 +1007,14 @@ nsStyleBasicShape::GetShapeTypeName() const
nsStyleClipPath::nsStyleClipPath()
: mType(NS_STYLE_CLIP_PATH_NONE)
, mURL(nullptr)
, mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX)
, mSizingBox(mozilla::StyleClipShapeSizing::NoBox)
{
}
nsStyleClipPath::nsStyleClipPath(const nsStyleClipPath& aSource)
: mType(NS_STYLE_CLIP_PATH_NONE)
, mURL(nullptr)
, mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX)
, mSizingBox(mozilla::StyleClipShapeSizing::NoBox)
{
if (aSource.mType == NS_STYLE_CLIP_PATH_URL) {
SetURL(aSource.mURL);
@ -1045,7 +1045,7 @@ nsStyleClipPath::operator=(const nsStyleClipPath& aOther)
SetSizingBox(aOther.mSizingBox);
} else {
ReleaseRef();
mSizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX;
mSizingBox = mozilla::StyleClipShapeSizing::NoBox;
mType = NS_STYLE_CLIP_PATH_NONE;
}
return *this;
@ -1096,7 +1096,8 @@ nsStyleClipPath::SetURL(nsIURI* aURL)
}
void
nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, uint8_t aSizingBox)
nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape,
mozilla::StyleClipShapeSizing aSizingBox)
{
NS_ASSERTION(aBasicShape, "expected pointer");
ReleaseRef();
@ -1107,7 +1108,7 @@ nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, uint8_t aSizingBo
}
void
nsStyleClipPath::SetSizingBox(uint8_t aSizingBox)
nsStyleClipPath::SetSizingBox(mozilla::StyleClipShapeSizing aSizingBox)
{
ReleaseRef();
mSizingBox = aSizingBox;

Просмотреть файл

@ -3522,10 +3522,11 @@ struct nsStyleClipPath
}
void SetBasicShape(nsStyleBasicShape* mBasicShape,
uint8_t aSizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX);
mozilla::StyleClipShapeSizing aSizingBox =
mozilla::StyleClipShapeSizing::NoBox);
uint8_t GetSizingBox() const { return mSizingBox; }
void SetSizingBox(uint8_t aSizingBox);
mozilla::StyleClipShapeSizing GetSizingBox() const { return mSizingBox; }
void SetSizingBox(mozilla::StyleClipShapeSizing aSizingBox);
private:
void ReleaseRef();
@ -3536,7 +3537,7 @@ private:
nsStyleBasicShape* mBasicShape;
nsIURI* mURL;
};
uint8_t mSizingBox; // see NS_STYLE_CLIP_SHAPE_SIZING_* constants in nsStyleConsts.h
mozilla::StyleClipShapeSizing mSizingBox;
};
struct nsStyleFilter

Просмотреть файл

@ -68,13 +68,13 @@ nsCSSClipPathInstance::CreateClipPath(DrawTarget* aDrawTarget)
nsRect r;
// XXXkrit SVG needs to use different boxes.
switch (mClipPathStyle.GetSizingBox()) {
case NS_STYLE_CLIP_SHAPE_SIZING_CONTENT:
case StyleClipShapeSizing::Content:
r = mTargetFrame->GetContentRectRelativeToSelf();
break;
case NS_STYLE_CLIP_SHAPE_SIZING_PADDING:
case StyleClipShapeSizing::Padding:
r = mTargetFrame->GetPaddingRectRelativeToSelf();
break;
case NS_STYLE_CLIP_SHAPE_SIZING_MARGIN:
case StyleClipShapeSizing::Margin:
r = mTargetFrame->GetMarginRectRelativeToSelf();
break;
default: // Use the border box