зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325940 part 2 - Converted NS_STYLE_BORDER_IMAGE_REPEAT_* to an enum class. r=emilio
MozReview-Commit-ID: Kdzm5D8Dpv --HG-- extra : rebase_source : 7c6ed8d2e777c7fa07b0486147c48bd98cc477a5
This commit is contained in:
Родитель
a3cafec7b7
Коммит
e2d3edd426
|
@ -490,16 +490,16 @@ static inline wr::SideOffsets2D_f32 ToSideOffsets2D_f32(float top, float right,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static inline wr::RepeatMode ToRepeatMode(uint8_t repeatMode)
|
||||
static inline wr::RepeatMode ToRepeatMode(mozilla::StyleBorderImageRepeat repeatMode)
|
||||
{
|
||||
switch (repeatMode) {
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
|
||||
case mozilla::StyleBorderImageRepeat::Stretch:
|
||||
return wr::RepeatMode::Stretch;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
|
||||
case mozilla::StyleBorderImageRepeat::Repeat:
|
||||
return wr::RepeatMode::Repeat;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
|
||||
case mozilla::StyleBorderImageRepeat::Round:
|
||||
return wr::RepeatMode::Round;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
|
||||
case mozilla::StyleBorderImageRepeat::Space:
|
||||
return wr::RepeatMode::Space;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
|
|
|
@ -749,10 +749,10 @@ nsCSSRendering::CreateWebRenderCommandsForBorder(nsDisplayItem* aItem,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (styleBorder->mBorderImageRepeatH == NS_STYLE_BORDER_IMAGE_REPEAT_ROUND ||
|
||||
styleBorder->mBorderImageRepeatH == NS_STYLE_BORDER_IMAGE_REPEAT_SPACE ||
|
||||
styleBorder->mBorderImageRepeatV == NS_STYLE_BORDER_IMAGE_REPEAT_ROUND ||
|
||||
styleBorder->mBorderImageRepeatV == NS_STYLE_BORDER_IMAGE_REPEAT_SPACE) {
|
||||
if (styleBorder->mBorderImageRepeatH == StyleBorderImageRepeat::Round ||
|
||||
styleBorder->mBorderImageRepeatH == StyleBorderImageRepeat::Space ||
|
||||
styleBorder->mBorderImageRepeatV == StyleBorderImageRepeat::Round ||
|
||||
styleBorder->mBorderImageRepeatV == StyleBorderImageRepeat::Space) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3754,7 +3754,7 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext,
|
|||
|
||||
for (int i = LEFT; i <= RIGHT; i++) {
|
||||
for (int j = TOP; j <= BOTTOM; j++) {
|
||||
uint8_t fillStyleH, fillStyleV;
|
||||
StyleBorderImageRepeat fillStyleH, fillStyleV;
|
||||
nsSize unitSize;
|
||||
|
||||
if (i == MIDDLE && j == MIDDLE) {
|
||||
|
@ -3808,7 +3808,7 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext,
|
|||
unitSize.width = sliceWidth[i] * factor;
|
||||
unitSize.height = borderHeight[j];
|
||||
fillStyleH = mRepeatModeHorizontal;
|
||||
fillStyleV = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
|
||||
fillStyleV = StyleBorderImageRepeat::Stretch;
|
||||
|
||||
} else if (j == MIDDLE) { // left, right
|
||||
gfxFloat factor;
|
||||
|
@ -3819,15 +3819,15 @@ nsCSSBorderImageRenderer::DrawBorderImage(nsPresContext* aPresContext,
|
|||
|
||||
unitSize.width = borderWidth[i];
|
||||
unitSize.height = sliceHeight[j] * factor;
|
||||
fillStyleH = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
|
||||
fillStyleH = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleV = mRepeatModeVertical;
|
||||
|
||||
} else {
|
||||
// Corners are always stretched to fit the corner.
|
||||
unitSize.width = borderWidth[i];
|
||||
unitSize.height = borderHeight[j];
|
||||
fillStyleH = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
|
||||
fillStyleV = NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH;
|
||||
fillStyleH = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleV = StyleBorderImageRepeat::Stretch;
|
||||
}
|
||||
|
||||
nsRect destArea(borderX[i], borderY[j], borderWidth[i], borderHeight[j]);
|
||||
|
|
|
@ -336,8 +336,8 @@ private:
|
|||
nsMargin mImageOutset;
|
||||
nsRect mArea;
|
||||
nsRect mClip;
|
||||
uint8_t mRepeatModeHorizontal;
|
||||
uint8_t mRepeatModeVertical;
|
||||
mozilla::StyleBorderImageRepeat mRepeatModeHorizontal;
|
||||
mozilla::StyleBorderImageRepeat mRepeatModeVertical;
|
||||
uint8_t mFill;
|
||||
|
||||
friend class nsDisplayBorder;
|
||||
|
|
|
@ -745,35 +745,35 @@ nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext* aPresCo
|
|||
* tile used to fill the dest rect.
|
||||
* aFill The destination rect to be filled
|
||||
* aHFill and aVFill are the repeat patterns for the component -
|
||||
* NS_STYLE_BORDER_IMAGE_REPEAT_* - i.e., how a tiling unit is used to fill aFill
|
||||
* StyleBorderImageRepeat - i.e., how a tiling unit is used to fill aFill
|
||||
* aUnitSize The size of the source rect in dest coords.
|
||||
*/
|
||||
static nsRect
|
||||
ComputeTile(nsRect& aFill,
|
||||
uint8_t aHFill,
|
||||
uint8_t aVFill,
|
||||
StyleBorderImageRepeat aHFill,
|
||||
StyleBorderImageRepeat aVFill,
|
||||
const nsSize& aUnitSize,
|
||||
nsSize& aRepeatSize)
|
||||
{
|
||||
nsRect tile;
|
||||
switch (aHFill) {
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
|
||||
case StyleBorderImageRepeat::Stretch:
|
||||
tile.x = aFill.x;
|
||||
tile.width = aFill.width;
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
|
||||
case StyleBorderImageRepeat::Repeat:
|
||||
tile.x = aFill.x + aFill.width/2 - aUnitSize.width/2;
|
||||
tile.width = aUnitSize.width;
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
|
||||
case StyleBorderImageRepeat::Round:
|
||||
tile.x = aFill.x;
|
||||
tile.width = nsCSSRendering::ComputeRoundedSize(aUnitSize.width,
|
||||
aFill.width);
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
|
||||
case StyleBorderImageRepeat::Space:
|
||||
{
|
||||
nscoord space;
|
||||
aRepeatSize.width =
|
||||
|
@ -790,23 +790,23 @@ ComputeTile(nsRect& aFill,
|
|||
}
|
||||
|
||||
switch (aVFill) {
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
|
||||
case StyleBorderImageRepeat::Stretch:
|
||||
tile.y = aFill.y;
|
||||
tile.height = aFill.height;
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
|
||||
case StyleBorderImageRepeat::Repeat:
|
||||
tile.y = aFill.y + aFill.height/2 - aUnitSize.height/2;
|
||||
tile.height = aUnitSize.height;
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
|
||||
case StyleBorderImageRepeat::Round:
|
||||
tile.y = aFill.y;
|
||||
tile.height = nsCSSRendering::ComputeRoundedSize(aUnitSize.height,
|
||||
aFill.height);
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
|
||||
case StyleBorderImageRepeat::Space:
|
||||
{
|
||||
nscoord space;
|
||||
aRepeatSize.height =
|
||||
|
@ -832,14 +832,14 @@ ComputeTile(nsRect& aFill,
|
|||
*/
|
||||
static bool
|
||||
RequiresScaling(const nsRect& aFill,
|
||||
uint8_t aHFill,
|
||||
uint8_t aVFill,
|
||||
StyleBorderImageRepeat aHFill,
|
||||
StyleBorderImageRepeat aVFill,
|
||||
const nsSize& aUnitSize)
|
||||
{
|
||||
// If we have no tiling in either direction, we can skip the intermediate
|
||||
// scaling step.
|
||||
return (aHFill != NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH ||
|
||||
aVFill != NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH) &&
|
||||
return (aHFill != StyleBorderImageRepeat::Stretch ||
|
||||
aVFill != StyleBorderImageRepeat::Stretch) &&
|
||||
(aUnitSize.width != aFill.width ||
|
||||
aUnitSize.height != aFill.height);
|
||||
}
|
||||
|
@ -850,8 +850,8 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext,
|
|||
const nsRect& aDirtyRect,
|
||||
const nsRect& aFill,
|
||||
const CSSIntRect& aSrc,
|
||||
uint8_t aHFill,
|
||||
uint8_t aVFill,
|
||||
StyleBorderImageRepeat aHFill,
|
||||
StyleBorderImageRepeat aVFill,
|
||||
const nsSize& aUnitSize,
|
||||
uint8_t aIndex,
|
||||
const Maybe<nsSize>& aSVGViewportSize,
|
||||
|
|
|
@ -247,8 +247,8 @@ public:
|
|||
const nsRect& aDirtyRect,
|
||||
const nsRect& aFill,
|
||||
const mozilla::CSSIntRect& aSrc,
|
||||
uint8_t aHFill,
|
||||
uint8_t aVFill,
|
||||
mozilla::StyleBorderImageRepeat aHFill,
|
||||
mozilla::StyleBorderImageRepeat aVFill,
|
||||
const nsSize& aUnitSize,
|
||||
uint8_t aIndex,
|
||||
const mozilla::Maybe<nsSize>& aSVGViewportSize,
|
||||
|
|
|
@ -168,6 +168,7 @@ rusty-enums = [
|
|||
"StyleBasicShapeType",
|
||||
"nsStyleImageLayers_Size_DimensionType",
|
||||
"StyleStackSizing",
|
||||
"StyleBorderImageRepeat",
|
||||
"StyleBoxPack",
|
||||
"StyleBoxOrient",
|
||||
"StyleBoxAlign",
|
||||
|
|
|
@ -454,8 +454,7 @@ nsCSSCompressedDataBlock::HasDefaultBorderImageRepeat() const
|
|||
{
|
||||
const nsCSSValuePair &repeat =
|
||||
ValueFor(eCSSProperty_border_image_repeat)->GetPairValue();
|
||||
return repeat.BothValuesEqualTo(
|
||||
nsCSSValue(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH, eCSSUnit_Enumerated));
|
||||
return repeat.BothValuesEqualTo(nsCSSValue(StyleBorderImageRepeat::Stretch));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -13158,8 +13158,7 @@ CSSParserImpl::SetBorderImageInitialValues()
|
|||
// border-image-repeat: repeat
|
||||
nsCSSValue repeat;
|
||||
nsCSSValuePair repeatPair;
|
||||
repeatPair.SetBothValuesTo(nsCSSValue(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH,
|
||||
eCSSUnit_Enumerated));
|
||||
repeatPair.SetBothValuesTo(nsCSSValue(StyleBorderImageRepeat::Stretch));
|
||||
repeat.SetPairValue(&repeatPair);
|
||||
AppendValue(eCSSProperty_border_image_repeat, repeat);
|
||||
}
|
||||
|
|
|
@ -1004,10 +1004,10 @@ const KTableEntry nsCSSProps::kBorderCollapseKTable[] = {
|
|||
};
|
||||
|
||||
const KTableEntry nsCSSProps::kBorderImageRepeatKTable[] = {
|
||||
{ eCSSKeyword_stretch, NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH },
|
||||
{ eCSSKeyword_repeat, NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT },
|
||||
{ eCSSKeyword_round, NS_STYLE_BORDER_IMAGE_REPEAT_ROUND },
|
||||
{ eCSSKeyword_space, NS_STYLE_BORDER_IMAGE_REPEAT_SPACE },
|
||||
{ eCSSKeyword_stretch, StyleBorderImageRepeat::Stretch },
|
||||
{ eCSSKeyword_repeat, StyleBorderImageRepeat::Repeat },
|
||||
{ eCSSKeyword_round, StyleBorderImageRepeat::Round },
|
||||
{ eCSSKeyword_space, StyleBorderImageRepeat::Space },
|
||||
{ eCSSKeyword_UNKNOWN, -1 }
|
||||
};
|
||||
|
||||
|
|
|
@ -1425,6 +1425,7 @@ struct SetEnumValueHelper
|
|||
aField = static_cast<type_>(value); \
|
||||
}
|
||||
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleBorderImageRepeat, Stretch, Space)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleBoxAlign, Stretch, End)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleBoxDecorationBreak, Slice, Clone)
|
||||
DEFINE_ENUM_CLASS_SETTER(StyleBoxDirection, Normal, Reverse)
|
||||
|
@ -7602,14 +7603,14 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
conditions,
|
||||
SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
|
||||
parentBorder->mBorderImageRepeatH,
|
||||
NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
|
||||
StyleBorderImageRepeat::Stretch);
|
||||
|
||||
SetValue(borderImageRepeat.mYValue,
|
||||
border->mBorderImageRepeatV,
|
||||
conditions,
|
||||
SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
|
||||
parentBorder->mBorderImageRepeatV,
|
||||
NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
|
||||
StyleBorderImageRepeat::Stretch);
|
||||
|
||||
COMPUTE_END_RESET(Border, border)
|
||||
}
|
||||
|
|
|
@ -337,11 +337,13 @@ enum class StyleImageLayerRepeat : uint8_t {
|
|||
#define NS_STYLE_BORDER_STYLE_HIDDEN 9
|
||||
#define NS_STYLE_BORDER_STYLE_AUTO 10 // for outline-style only
|
||||
|
||||
// See nsStyleBorder mBorderImage
|
||||
#define NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH 0
|
||||
#define NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT 1
|
||||
#define NS_STYLE_BORDER_IMAGE_REPEAT_ROUND 2
|
||||
#define NS_STYLE_BORDER_IMAGE_REPEAT_SPACE 3
|
||||
// border-image-repeat
|
||||
enum class StyleBorderImageRepeat : uint8_t {
|
||||
Stretch,
|
||||
Repeat,
|
||||
Round,
|
||||
Space
|
||||
};
|
||||
|
||||
#define NS_STYLE_BORDER_IMAGE_SLICE_NOFILL 0
|
||||
#define NS_STYLE_BORDER_IMAGE_SLICE_FILL 1
|
||||
|
|
|
@ -337,8 +337,8 @@ nsStylePadding::CalcDifference(const nsStylePadding& aNewData) const
|
|||
|
||||
nsStyleBorder::nsStyleBorder(const nsPresContext* aContext)
|
||||
: mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL)
|
||||
, mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
|
||||
, mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH)
|
||||
, mBorderImageRepeatH(StyleBorderImageRepeat::Stretch)
|
||||
, mBorderImageRepeatV(StyleBorderImageRepeat::Stretch)
|
||||
, mFloatEdge(StyleFloatEdge::ContentBox)
|
||||
, mBoxDecorationBreak(StyleBoxDecorationBreak::Slice)
|
||||
, mComputedBorder(0, 0, 0, 0)
|
||||
|
|
|
@ -1253,8 +1253,8 @@ public:
|
|||
nsStyleSides mBorderImageOutset; // [reset] length, factor
|
||||
|
||||
uint8_t mBorderImageFill; // [reset]
|
||||
uint8_t mBorderImageRepeatH; // [reset] see nsStyleConsts.h
|
||||
uint8_t mBorderImageRepeatV; // [reset]
|
||||
mozilla::StyleBorderImageRepeat mBorderImageRepeatH; // [reset]
|
||||
mozilla::StyleBorderImageRepeat mBorderImageRepeatV; // [reset]
|
||||
mozilla::StyleFloatEdge mFloatEdge; // [reset]
|
||||
mozilla::StyleBoxDecorationBreak mBoxDecorationBreak; // [reset]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче