Diff
Modified: trunk/Source/WebCore/ChangeLog (251059 => 251060)
--- trunk/Source/WebCore/ChangeLog 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/ChangeLog 2019-10-13 17:08:33 UTC (rev 251060)
@@ -1,5 +1,34 @@
2019-10-13 Simon Fraser <simon.fra...@apple.com>
+ Convert ENinePieceImageRule into an enum class and rename
+ https://bugs.webkit.org/show_bug.cgi?id=202889
+
+ Reviewed by Alex Christensen.
+
+ Enum classify ENinePieceImageRule.
+
+ The bitfield in NinePieceImage isn't saving anything so don't use one there.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::valueForRepeatRule):
+ * css/CSSToStyleMap.cpp:
+ (WebCore::CSSToStyleMap::mapNinePieceImageRepeat):
+ * css/StyleBuilderCustom.h:
+ (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue):
+ * rendering/style/NinePieceImage.cpp:
+ (WebCore::NinePieceImage::NinePieceImage):
+ (WebCore::NinePieceImage::computeMiddleTileScale):
+ (WebCore::NinePieceImage::computeTileScales):
+ (WebCore::NinePieceImage::Data::Data):
+ (WebCore::NinePieceImage::Data::create):
+ * rendering/style/NinePieceImage.h:
+ (WebCore::NinePieceImage::horizontalRule const):
+ (WebCore::NinePieceImage::setHorizontalRule):
+ (WebCore::NinePieceImage::verticalRule const):
+ (WebCore::NinePieceImage::setVerticalRule):
+
+2019-10-13 Simon Fraser <simon.fra...@apple.com>
+
Clarify the naming of the radius-related functions on BorderData
https://bugs.webkit.org/show_bug.cgi?id=202888
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (251059 => 251060)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-10-13 17:08:33 UTC (rev 251060)
@@ -470,17 +470,17 @@
const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
-static CSSValueID valueForRepeatRule(int rule)
+static CSSValueID valueForRepeatRule(NinePieceImageRule rule)
{
switch (rule) {
- case RepeatImageRule:
- return CSSValueRepeat;
- case RoundImageRule:
- return CSSValueRound;
- case SpaceImageRule:
- return CSSValueSpace;
- default:
- return CSSValueStretch;
+ case NinePieceImageRule::Repeat:
+ return CSSValueRepeat;
+ case NinePieceImageRule::Round:
+ return CSSValueRound;
+ case NinePieceImageRule::Space:
+ return CSSValueSpace;
+ default:
+ return CSSValueStretch;
}
}
Modified: trunk/Source/WebCore/css/CSSToStyleMap.cpp (251059 => 251060)
--- trunk/Source/WebCore/css/CSSToStyleMap.cpp 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/css/CSSToStyleMap.cpp 2019-10-13 17:08:33 UTC (rev 251060)
@@ -645,36 +645,36 @@
CSSValueID firstIdentifier = pair->first()->valueID();
CSSValueID secondIdentifier = pair->second()->valueID();
- ENinePieceImageRule horizontalRule;
+ NinePieceImageRule horizontalRule;
switch (firstIdentifier) {
case CSSValueStretch:
- horizontalRule = StretchImageRule;
+ horizontalRule = NinePieceImageRule::Stretch;
break;
case CSSValueRound:
- horizontalRule = RoundImageRule;
+ horizontalRule = NinePieceImageRule::Round;
break;
case CSSValueSpace:
- horizontalRule = SpaceImageRule;
+ horizontalRule = NinePieceImageRule::Space;
break;
default: // CSSValueRepeat
- horizontalRule = RepeatImageRule;
+ horizontalRule = NinePieceImageRule::Repeat;
break;
}
image.setHorizontalRule(horizontalRule);
- ENinePieceImageRule verticalRule;
+ NinePieceImageRule verticalRule;
switch (secondIdentifier) {
case CSSValueStretch:
- verticalRule = StretchImageRule;
+ verticalRule = NinePieceImageRule::Stretch;
break;
case CSSValueRound:
- verticalRule = RoundImageRule;
+ verticalRule = NinePieceImageRule::Round;
break;
case CSSValueSpace:
- verticalRule = SpaceImageRule;
+ verticalRule = NinePieceImageRule::Space;
break;
default: // CSSValueRepeat
- verticalRule = RepeatImageRule;
+ verticalRule = NinePieceImageRule::Repeat;
break;
}
image.setVerticalRule(verticalRule);
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (251059 => 251060)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2019-10-13 17:08:33 UTC (rev 251060)
@@ -521,8 +521,8 @@
image.setOutset(LengthBox(0));
break;
case Repeat:
- image.setHorizontalRule(StretchImageRule);
- image.setVerticalRule(StretchImageRule);
+ image.setHorizontalRule(NinePieceImageRule::Stretch);
+ image.setVerticalRule(NinePieceImageRule::Stretch);
break;
case Slice:
// Masks have a different initial value for slices. Preserve the value of 0 for backwards compatibility.
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.cpp (251059 => 251060)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2019-10-13 17:08:33 UTC (rev 251060)
@@ -45,7 +45,7 @@
{
}
-NinePieceImage::NinePieceImage(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
+NinePieceImage::NinePieceImage(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule)
: m_data(Data::create(WTFMove(image), imageSlices, fill, borderSlices, outset, horizontalRule, verticalRule))
{
}
@@ -150,7 +150,7 @@
return FloatSize(scale, scale);
}
-FloatSize NinePieceImage::computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+FloatSize NinePieceImage::computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, NinePieceImageRule hRule, NinePieceImageRule vRule)
{
FloatSize scale(1, 1);
if (isEmptyPieceRect(MiddlePiece, destinationRects, sourceRects))
@@ -158,7 +158,7 @@
// Unlike the side pieces, the middle piece can have "stretch" specified in one axis but not the other.
// In fact the side pieces don't even use the scale factor unless they have a rule other than "stretch".
- if (hRule == StretchImageRule)
+ if (hRule == NinePieceImageRule::Stretch)
scale.setWidth(destinationRects[MiddlePiece].width() / sourceRects[MiddlePiece].width());
else if (!isEmptyPieceRect(TopPiece, destinationRects, sourceRects))
scale.setWidth(scales[TopPiece].width());
@@ -165,7 +165,7 @@
else if (!isEmptyPieceRect(BottomPiece, destinationRects, sourceRects))
scale.setWidth(scales[BottomPiece].width());
- if (vRule == StretchImageRule)
+ if (vRule == NinePieceImageRule::Stretch)
scale.setHeight(destinationRects[MiddlePiece].height() / sourceRects[MiddlePiece].height());
else if (!isEmptyPieceRect(LeftPiece, destinationRects, sourceRects))
scale.setHeight(scales[LeftPiece].height());
@@ -175,7 +175,7 @@
return scale;
}
-Vector<FloatSize> NinePieceImage::computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule)
+Vector<FloatSize> NinePieceImage::computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, NinePieceImageRule hRule, NinePieceImageRule vRule)
{
Vector<FloatSize> scales(MaxPiece, FloatSize(1, 1));
@@ -223,14 +223,9 @@
}
}
-inline NinePieceImage::Data::Data()
- : fill(false)
- , horizontalRule(StretchImageRule)
- , verticalRule(StretchImageRule)
-{
-}
+inline NinePieceImage::Data::Data() = default;
-inline NinePieceImage::Data::Data(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
+inline NinePieceImage::Data::Data(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule)
: fill(fill)
, horizontalRule(horizontalRule)
, verticalRule(verticalRule)
@@ -258,7 +253,7 @@
return adoptRef(*new Data);
}
-inline Ref<NinePieceImage::Data> NinePieceImage::Data::create(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
+inline Ref<NinePieceImage::Data> NinePieceImage::Data::create(RefPtr<StyleImage>&& image, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule)
{
return adoptRef(*new Data(WTFMove(image), imageSlices, fill, borderSlices, outset, horizontalRule, verticalRule));
}
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (251059 => 251060)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.h 2019-10-13 16:23:25 UTC (rev 251059)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h 2019-10-13 17:08:33 UTC (rev 251060)
@@ -34,8 +34,14 @@
class LayoutRect;
class RenderStyle;
-enum ENinePieceImageRule { StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule };
+enum class NinePieceImageRule : uint8_t {
+ Stretch,
+ Round,
+ Space,
+ Repeat,
+};
+// Used for array indexing, so not an enum class.
enum ImagePiece {
MinPiece = 0,
TopLeftPiece = MinPiece,
@@ -101,7 +107,7 @@
class NinePieceImage {
public:
NinePieceImage();
- NinePieceImage(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ NinePieceImage(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule);
bool operator==(const NinePieceImage& other) const { return m_data == other.m_data; }
bool operator!=(const NinePieceImage& other) const { return m_data != other.m_data; }
@@ -122,11 +128,11 @@
const LengthBox& outset() const { return m_data->outset; }
void setOutset(LengthBox outset) { m_data.access().outset = WTFMove(outset); }
- ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceImageRule>(m_data->horizontalRule); }
- void setHorizontalRule(ENinePieceImageRule rule) { m_data.access().horizontalRule = rule; }
+ NinePieceImageRule horizontalRule() const { return m_data->horizontalRule; }
+ void setHorizontalRule(NinePieceImageRule rule) { m_data.access().horizontalRule = rule; }
- ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImageRule>(m_data->verticalRule); }
- void setVerticalRule(ENinePieceImageRule rule) { m_data.access().verticalRule = rule; }
+ NinePieceImageRule verticalRule() const { return m_data->verticalRule; }
+ void setVerticalRule(NinePieceImageRule rule) { m_data.access().verticalRule = rule; }
void copyImageSlicesFrom(const NinePieceImage& other)
{
@@ -176,8 +182,8 @@
static void scaleSlicesIfNeeded(const LayoutSize&, LayoutBoxExtent& slices, float deviceScaleFactor);
static FloatSize computeSideTileScale(ImagePiece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects);
- static FloatSize computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
- static Vector<FloatSize> computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, ENinePieceImageRule hRule, ENinePieceImageRule vRule);
+ static FloatSize computeMiddleTileScale(const Vector<FloatSize>& scales, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, NinePieceImageRule hRule, NinePieceImageRule vRule);
+ static Vector<FloatSize> computeTileScales(const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects, NinePieceImageRule hRule, NinePieceImageRule vRule);
void paint(GraphicsContext&, RenderElement*, const RenderStyle&, const LayoutRect& destination, const LayoutSize& source, float deviceScaleFactor, CompositeOperator) const;
@@ -184,15 +190,15 @@
private:
struct Data : RefCounted<Data> {
static Ref<Data> create();
- static Ref<Data> create(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ static Ref<Data> create(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule);
Ref<Data> copy() const;
bool operator==(const Data&) const;
bool operator!=(const Data& other) const { return !(*this == other); }
- bool fill : 1;
- unsigned horizontalRule : 2; // ENinePieceImageRule
- unsigned verticalRule : 2; // ENinePieceImageRule
+ bool fill { false };
+ NinePieceImageRule horizontalRule { NinePieceImageRule::Stretch };
+ NinePieceImageRule verticalRule { NinePieceImageRule::Stretch };
RefPtr<StyleImage> image;
LengthBox imageSlices { { 100, Percent }, { 100, Percent }, { 100, Percent }, { 100, Percent } };
LengthBox borderSlices { { 1, Relative }, { 1, Relative }, { 1, Relative }, { 1, Relative } };
@@ -200,7 +206,7 @@
private:
Data();
- Data(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
+ Data(RefPtr<StyleImage>&&, LengthBox imageSlices, bool fill, LengthBox borderSlices, LengthBox outset, NinePieceImageRule horizontalRule, NinePieceImageRule verticalRule);
Data(const Data&);
};