зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1914777 - Use cbindgen for StyleBorderImageRepeatKeyword. r=firefox-style-system-reviewers,layout-reviewers,emilio
Generated enum StyleBorderImageRepeatKeyword replaces enum StyleBorderImageRepeat. Differential Revision: https://phabricator.services.mozilla.com/D220073
This commit is contained in:
Родитель
47d05dbbf0
Коммит
11860bb190
|
@ -46,15 +46,15 @@ BorderStyle ToBorderStyle(StyleBorderStyle aStyle) {
|
|||
return wr::BorderStyle::None;
|
||||
}
|
||||
|
||||
wr::RepeatMode ToRepeatMode(StyleBorderImageRepeat aRepeat) {
|
||||
wr::RepeatMode ToRepeatMode(StyleBorderImageRepeatKeyword aRepeat) {
|
||||
switch (aRepeat) {
|
||||
case StyleBorderImageRepeat::Stretch:
|
||||
case StyleBorderImageRepeatKeyword::Stretch:
|
||||
return wr::RepeatMode::Stretch;
|
||||
case StyleBorderImageRepeat::Repeat:
|
||||
case StyleBorderImageRepeatKeyword::Repeat:
|
||||
return wr::RepeatMode::Repeat;
|
||||
case StyleBorderImageRepeat::Round:
|
||||
case StyleBorderImageRepeatKeyword::Round:
|
||||
return wr::RepeatMode::Round;
|
||||
case StyleBorderImageRepeat::Space:
|
||||
case StyleBorderImageRepeatKeyword::Space:
|
||||
return wr::RepeatMode::Space;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
enum class StyleBorderStyle : uint8_t;
|
||||
enum class StyleBorderImageRepeat : uint8_t;
|
||||
enum class StyleBorderImageRepeatKeyword : uint8_t;
|
||||
enum class StyleImageRendering : uint8_t;
|
||||
|
||||
namespace ipc {
|
||||
|
@ -566,7 +566,7 @@ static inline wr::LayoutSideOffsets ToLayoutSideOffsets(float top, float right,
|
|||
return offset;
|
||||
}
|
||||
|
||||
wr::RepeatMode ToRepeatMode(StyleBorderImageRepeat);
|
||||
wr::RepeatMode ToRepeatMode(StyleBorderImageRepeatKeyword);
|
||||
|
||||
template <class S, class T>
|
||||
static inline wr::WrTransformProperty ToWrTransformProperty(
|
||||
|
|
|
@ -716,8 +716,10 @@ ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorderWithStyleBorder(
|
|||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (aStyleBorder.mBorderImageRepeatH == StyleBorderImageRepeat::Space ||
|
||||
aStyleBorder.mBorderImageRepeatV == StyleBorderImageRepeat::Space) {
|
||||
if (aStyleBorder.mBorderImageRepeatH ==
|
||||
StyleBorderImageRepeatKeyword::Space ||
|
||||
aStyleBorder.mBorderImageRepeatV ==
|
||||
StyleBorderImageRepeatKeyword::Space) {
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -3480,7 +3480,7 @@ ImgDrawResult nsCSSBorderImageRenderer::DrawBorderImage(
|
|||
|
||||
for (int i = LEFT; i <= RIGHT; i++) {
|
||||
for (int j = TOP; j <= BOTTOM; j++) {
|
||||
StyleBorderImageRepeat fillStyleH, fillStyleV;
|
||||
StyleBorderImageRepeatKeyword fillStyleH, fillStyleV;
|
||||
nsSize unitSize;
|
||||
|
||||
if (i == MIDDLE && j == MIDDLE) {
|
||||
|
@ -3534,7 +3534,7 @@ ImgDrawResult nsCSSBorderImageRenderer::DrawBorderImage(
|
|||
unitSize.width = sliceWidth[i] * factor;
|
||||
unitSize.height = borderHeight[j];
|
||||
fillStyleH = mRepeatModeHorizontal;
|
||||
fillStyleV = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleV = StyleBorderImageRepeatKeyword::Stretch;
|
||||
|
||||
} else if (j == MIDDLE) { // left, right
|
||||
gfxFloat factor;
|
||||
|
@ -3546,15 +3546,15 @@ ImgDrawResult nsCSSBorderImageRenderer::DrawBorderImage(
|
|||
|
||||
unitSize.width = borderWidth[i];
|
||||
unitSize.height = sliceHeight[j] * factor;
|
||||
fillStyleH = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleH = StyleBorderImageRepeatKeyword::Stretch;
|
||||
fillStyleV = mRepeatModeVertical;
|
||||
|
||||
} else {
|
||||
// Corners are always stretched to fit the corner.
|
||||
unitSize.width = borderWidth[i];
|
||||
unitSize.height = borderHeight[j];
|
||||
fillStyleH = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleV = StyleBorderImageRepeat::Stretch;
|
||||
fillStyleH = StyleBorderImageRepeatKeyword::Stretch;
|
||||
fillStyleV = StyleBorderImageRepeatKeyword::Stretch;
|
||||
}
|
||||
|
||||
nsRect destArea(borderX[i], borderY[j], borderWidth[i], borderHeight[j]);
|
||||
|
|
|
@ -32,7 +32,7 @@ class nsDisplayButtonForeground;
|
|||
class nsDisplayOutline;
|
||||
|
||||
enum class StyleBorderStyle : uint8_t;
|
||||
enum class StyleBorderImageRepeat : uint8_t;
|
||||
enum class StyleBorderImageRepeatKeyword : uint8_t;
|
||||
|
||||
namespace gfx {
|
||||
class GradientStops;
|
||||
|
@ -297,8 +297,8 @@ class nsCSSBorderImageRenderer final {
|
|||
nsMargin mImageOutset;
|
||||
nsRect mArea;
|
||||
nsRect mClip;
|
||||
mozilla::StyleBorderImageRepeat mRepeatModeHorizontal;
|
||||
mozilla::StyleBorderImageRepeat mRepeatModeVertical;
|
||||
mozilla::StyleBorderImageRepeatKeyword mRepeatModeHorizontal;
|
||||
mozilla::StyleBorderImageRepeatKeyword mRepeatModeVertical;
|
||||
bool mFill;
|
||||
|
||||
friend class mozilla::nsDisplayBorder;
|
||||
|
|
|
@ -782,31 +782,31 @@ ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItemsForLayer(
|
|||
* tile used to fill the dest rect.
|
||||
* aFill The destination rect to be filled
|
||||
* aHFill and aVFill are the repeat patterns for the component -
|
||||
* StyleBorderImageRepeat - i.e., how a tiling unit is used to fill aFill
|
||||
* StyleBorderImageRepeatKeyword - 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, StyleBorderImageRepeat aHFill,
|
||||
StyleBorderImageRepeat aVFill,
|
||||
static nsRect ComputeTile(nsRect& aFill, StyleBorderImageRepeatKeyword aHFill,
|
||||
StyleBorderImageRepeatKeyword aVFill,
|
||||
const nsSize& aUnitSize, nsSize& aRepeatSize) {
|
||||
nsRect tile;
|
||||
switch (aHFill) {
|
||||
case StyleBorderImageRepeat::Stretch:
|
||||
case StyleBorderImageRepeatKeyword::Stretch:
|
||||
tile.x = aFill.x;
|
||||
tile.width = aFill.width;
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Repeat:
|
||||
case StyleBorderImageRepeatKeyword::Repeat:
|
||||
tile.x = aFill.x + aFill.width / 2 - aUnitSize.width / 2;
|
||||
tile.width = aUnitSize.width;
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Round:
|
||||
case StyleBorderImageRepeatKeyword::Round:
|
||||
tile.x = aFill.x;
|
||||
tile.width =
|
||||
nsCSSRendering::ComputeRoundedSize(aUnitSize.width, aFill.width);
|
||||
aRepeatSize.width = tile.width;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Space: {
|
||||
case StyleBorderImageRepeatKeyword::Space: {
|
||||
nscoord space;
|
||||
aRepeatSize.width = nsCSSRendering::ComputeBorderSpacedRepeatSize(
|
||||
aUnitSize.width, aFill.width, space);
|
||||
|
@ -820,23 +820,23 @@ static nsRect ComputeTile(nsRect& aFill, StyleBorderImageRepeat aHFill,
|
|||
}
|
||||
|
||||
switch (aVFill) {
|
||||
case StyleBorderImageRepeat::Stretch:
|
||||
case StyleBorderImageRepeatKeyword::Stretch:
|
||||
tile.y = aFill.y;
|
||||
tile.height = aFill.height;
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Repeat:
|
||||
case StyleBorderImageRepeatKeyword::Repeat:
|
||||
tile.y = aFill.y + aFill.height / 2 - aUnitSize.height / 2;
|
||||
tile.height = aUnitSize.height;
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Round:
|
||||
case StyleBorderImageRepeatKeyword::Round:
|
||||
tile.y = aFill.y;
|
||||
tile.height =
|
||||
nsCSSRendering::ComputeRoundedSize(aUnitSize.height, aFill.height);
|
||||
aRepeatSize.height = tile.height;
|
||||
break;
|
||||
case StyleBorderImageRepeat::Space: {
|
||||
case StyleBorderImageRepeatKeyword::Space: {
|
||||
nscoord space;
|
||||
aRepeatSize.height = nsCSSRendering::ComputeBorderSpacedRepeatSize(
|
||||
aUnitSize.height, aFill.height, space);
|
||||
|
@ -857,20 +857,21 @@ static nsRect ComputeTile(nsRect& aFill, StyleBorderImageRepeat aHFill,
|
|||
* the dest rect to be scaled from the source tile. See comment on ComputeTile
|
||||
* for argument descriptions.
|
||||
*/
|
||||
static bool RequiresScaling(const nsRect& aFill, StyleBorderImageRepeat aHFill,
|
||||
StyleBorderImageRepeat aVFill,
|
||||
static bool RequiresScaling(const nsRect& aFill,
|
||||
StyleBorderImageRepeatKeyword aHFill,
|
||||
StyleBorderImageRepeatKeyword aVFill,
|
||||
const nsSize& aUnitSize) {
|
||||
// If we have no tiling in either direction, we can skip the intermediate
|
||||
// scaling step.
|
||||
return (aHFill != StyleBorderImageRepeat::Stretch ||
|
||||
aVFill != StyleBorderImageRepeat::Stretch) &&
|
||||
return (aHFill != StyleBorderImageRepeatKeyword::Stretch ||
|
||||
aVFill != StyleBorderImageRepeatKeyword::Stretch) &&
|
||||
(aUnitSize.width != aFill.width || aUnitSize.height != aFill.height);
|
||||
}
|
||||
|
||||
ImgDrawResult nsImageRenderer::DrawBorderImageComponent(
|
||||
nsPresContext* aPresContext, gfxContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect, const nsRect& aFill, const CSSIntRect& aSrc,
|
||||
StyleBorderImageRepeat aHFill, StyleBorderImageRepeat aVFill,
|
||||
StyleBorderImageRepeatKeyword aHFill, StyleBorderImageRepeatKeyword aVFill,
|
||||
const nsSize& aUnitSize, uint8_t aIndex,
|
||||
const Maybe<nsSize>& aSVGViewportSize, const bool aHasIntrinsicRatio) {
|
||||
if (!IsReady()) {
|
||||
|
|
|
@ -227,8 +227,9 @@ class nsImageRenderer {
|
|||
ImgDrawResult DrawBorderImageComponent(
|
||||
nsPresContext* aPresContext, gfxContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect, const nsRect& aFill,
|
||||
const mozilla::CSSIntRect& aSrc, mozilla::StyleBorderImageRepeat aHFill,
|
||||
mozilla::StyleBorderImageRepeat aVFill, const nsSize& aUnitSize,
|
||||
const mozilla::CSSIntRect& aSrc,
|
||||
mozilla::StyleBorderImageRepeatKeyword aHFill,
|
||||
mozilla::StyleBorderImageRepeatKeyword aVFill, const nsSize& aUnitSize,
|
||||
uint8_t aIndex, const mozilla::Maybe<nsSize>& aSVGViewportSize,
|
||||
const bool aHasIntrinsicRatio);
|
||||
|
||||
|
|
|
@ -117,7 +117,6 @@ rusty-enums = [
|
|||
"mozilla::StyleMathStyle",
|
||||
"nsStyleImageLayers_Size_DimensionType",
|
||||
"mozilla::StyleBorderCollapse",
|
||||
"mozilla::StyleBorderImageRepeat",
|
||||
"mozilla::StyleBoxPack",
|
||||
"mozilla::StyleWindowShadow",
|
||||
"mozilla::StyleDominantBaseline",
|
||||
|
@ -460,6 +459,7 @@ cbindgen-types = [
|
|||
{ gecko = "StyleGenericPositionOrAuto", servo = "crate::values::generics::position::PositionOrAuto" },
|
||||
{ gecko = "StyleBackgroundSize", servo = "crate::values::computed::BackgroundSize" },
|
||||
{ gecko = "StyleGenericBackgroundSize", servo = "crate::values::generics::background::BackgroundSize" },
|
||||
{ gecko = "StyleBorderImageRepeatKeyword", servo = "crate::values::specified::border::BorderImageRepeatKeyword" },
|
||||
{ gecko = "StyleBorderImageSlice", servo = "crate::values::computed::BorderImageSlice" },
|
||||
{ gecko = "StyleBorderSpacing", servo = "crate::values::computed::BorderSpacing" },
|
||||
{ gecko = "StyleGenericLengthOrNumber", servo = "crate::values::generics::length::LengthOrNumber" },
|
||||
|
|
|
@ -206,9 +206,6 @@ enum class StyleMaskMode : uint8_t { Alpha = 0, Luminance, MatchSource };
|
|||
// See nsStyleTable
|
||||
enum class StyleBorderCollapse : uint8_t { Collapse, Separate };
|
||||
|
||||
// border-image-repeat
|
||||
enum class StyleBorderImageRepeat : uint8_t { Stretch, Repeat, Round, Space };
|
||||
|
||||
// See nsStyleVisibility
|
||||
enum class StyleDirection : uint8_t { Ltr, Rtl };
|
||||
|
||||
|
|
|
@ -397,8 +397,8 @@ nsStyleBorder::nsStyleBorder()
|
|||
mBorderImageSlice(
|
||||
{StyleRectWithAllSides(StyleNumberOrPercentage::Percentage({1.})),
|
||||
false}),
|
||||
mBorderImageRepeatH(StyleBorderImageRepeat::Stretch),
|
||||
mBorderImageRepeatV(StyleBorderImageRepeat::Stretch),
|
||||
mBorderImageRepeatH(StyleBorderImageRepeatKeyword::Stretch),
|
||||
mBorderImageRepeatV(StyleBorderImageRepeatKeyword::Stretch),
|
||||
mFloatEdge(StyleFloatEdge::ContentBox),
|
||||
mBoxDecorationBreak(StyleBoxDecorationBreak::Slice),
|
||||
mBorderTopColor(StyleColor::CurrentColor()),
|
||||
|
|
|
@ -501,8 +501,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder {
|
|||
mozilla::StyleBorderImageWidth mBorderImageWidth;
|
||||
mozilla::StyleNonNegativeLengthOrNumberRect mBorderImageOutset;
|
||||
mozilla::StyleBorderImageSlice mBorderImageSlice; // factor, percent
|
||||
mozilla::StyleBorderImageRepeat mBorderImageRepeatH;
|
||||
mozilla::StyleBorderImageRepeat mBorderImageRepeatV;
|
||||
mozilla::StyleBorderImageRepeatKeyword mBorderImageRepeatH;
|
||||
mozilla::StyleBorderImageRepeatKeyword mBorderImageRepeatV;
|
||||
mozilla::StyleFloatEdge mFloatEdge;
|
||||
mozilla::StyleBoxDecorationBreak mBoxDecorationBreak;
|
||||
|
||||
|
|
|
@ -659,20 +659,9 @@ fn static_assert() {
|
|||
${impl_simple("border_%s_radius" % corner, "mBorderRadius.%s" % corner)}
|
||||
% endfor
|
||||
|
||||
<%
|
||||
border_image_repeat_keywords = ["Stretch", "Repeat", "Round", "Space"]
|
||||
%>
|
||||
|
||||
pub fn set_border_image_repeat(&mut self, v: longhands::border_image_repeat::computed_value::T) {
|
||||
use crate::values::specified::border::BorderImageRepeatKeyword;
|
||||
use crate::gecko_bindings::structs::StyleBorderImageRepeat;
|
||||
|
||||
% for i, side in enumerate(["H", "V"]):
|
||||
self.mBorderImageRepeat${side} = match v.${i} {
|
||||
% for keyword in border_image_repeat_keywords:
|
||||
BorderImageRepeatKeyword::${keyword} => StyleBorderImageRepeat::${keyword},
|
||||
% endfor
|
||||
};
|
||||
self.mBorderImageRepeat${side} = v.${i};
|
||||
% endfor
|
||||
}
|
||||
|
||||
|
@ -686,15 +675,8 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn clone_border_image_repeat(&self) -> longhands::border_image_repeat::computed_value::T {
|
||||
use crate::values::specified::border::BorderImageRepeatKeyword;
|
||||
use crate::gecko_bindings::structs::StyleBorderImageRepeat;
|
||||
|
||||
% for side in ["H", "V"]:
|
||||
let servo_${side.lower()} = match self.mBorderImageRepeat${side} {
|
||||
% for keyword in border_image_repeat_keywords:
|
||||
StyleBorderImageRepeat::${keyword} => BorderImageRepeatKeyword::${keyword},
|
||||
% endfor
|
||||
};
|
||||
let servo_${side.lower()} = self.mBorderImageRepeat${side};
|
||||
% endfor
|
||||
longhands::border_image_repeat::computed_value::T(servo_h, servo_v)
|
||||
}
|
||||
|
|
|
@ -305,6 +305,7 @@ impl Parse for BorderSpacing {
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum BorderImageRepeatKeyword {
|
||||
Stretch,
|
||||
Repeat,
|
||||
|
|
|
@ -189,6 +189,7 @@ include = [
|
|||
"BackgroundSize",
|
||||
"BaselineSource",
|
||||
"BorderImageSlice",
|
||||
"BorderImageRepeatKeyword",
|
||||
"BorderSpacing",
|
||||
"BorderRadius",
|
||||
"ColorScheme",
|
||||
|
|
Загрузка…
Ссылка в новой задаче