Skip to content

Commit

Permalink
[Outline] Introduce BorderData::Radii
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246044

Reviewed by Antti Koivisto.

This is in preparation for supporting outline with border-radius.
(This structure is going to be used to pass around radii information in BorderPainter)

* Source/WebCore/rendering/style/BorderData.h:
(WebCore::BorderData::hasBorderRadius const):
(WebCore::BorderData::operator== const):
(WebCore::BorderData::topLeftRadius const):
(WebCore::BorderData::topRightRadius const):
(WebCore::BorderData::bottomLeftRadius const):
(WebCore::BorderData::bottomRightRadius const):
(WebCore::BorderData::BorderData): Deleted.
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::resetBorderTopLeftRadius):
(WebCore::RenderStyle::resetBorderTopRightRadius):
(WebCore::RenderStyle::resetBorderBottomLeftRadius):
(WebCore::RenderStyle::resetBorderBottomRightRadius):
(WebCore::RenderStyle::setBorderTopLeftRadius):
(WebCore::RenderStyle::setBorderTopRightRadius):
(WebCore::RenderStyle::setBorderBottomLeftRadius):
(WebCore::RenderStyle::setBorderBottomRightRadius):

Canonical link: https://commits.webkit.org/255172@main
  • Loading branch information
alanbaradlay committed Oct 5, 2022
1 parent b483b29 commit 3870776
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
36 changes: 16 additions & 20 deletions Source/WebCore/rendering/style/BorderData.h
Expand Up @@ -35,13 +35,12 @@ class OutlineValue;
class BorderData {
friend class RenderStyle;
public:
BorderData()
: m_topLeftRadius { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } }
, m_topRightRadius { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } }
, m_bottomLeftRadius { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } }
, m_bottomRightRadius { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } }
{
}
struct Radii {
LengthSize topLeft { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize topRight { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize bottomLeft { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize bottomRight { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
};

bool hasBorder() const
{
Expand All @@ -60,10 +59,10 @@ friend class RenderStyle;

bool hasBorderRadius() const
{
return !m_topLeftRadius.width.isZero()
|| !m_topRightRadius.width.isZero()
|| !m_bottomLeftRadius.width.isZero()
|| !m_bottomRightRadius.width.isZero();
return !m_radii.topLeft.width.isZero()
|| !m_radii.topRight.width.isZero()
|| !m_radii.bottomLeft.width.isZero()
|| !m_radii.bottomRight.width.isZero();
}

float borderLeftWidth() const
Expand Down Expand Up @@ -112,7 +111,7 @@ friend class RenderStyle;
bool operator==(const BorderData& o) const
{
return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom && m_image == o.m_image
&& m_topLeftRadius == o.m_topLeftRadius && m_topRightRadius == o.m_topRightRadius && m_bottomLeftRadius == o.m_bottomLeftRadius && m_bottomRightRadius == o.m_bottomRightRadius;
&& m_radii.topLeft == o.m_radii.topLeft && m_radii.topRight == o.m_radii.topRight && m_radii.bottomLeft == o.m_radii.bottomLeft && m_radii.bottomRight == o.m_radii.bottomRight;
}

bool operator!=(const BorderData& o) const
Expand All @@ -127,10 +126,10 @@ friend class RenderStyle;

const NinePieceImage& image() const { return m_image; }

const LengthSize& topLeftRadius() const { return m_topLeftRadius; }
const LengthSize& topRightRadius() const { return m_topRightRadius; }
const LengthSize& bottomLeftRadius() const { return m_bottomLeftRadius; }
const LengthSize& bottomRightRadius() const { return m_bottomRightRadius; }
const LengthSize& topLeftRadius() const { return m_radii.topLeft; }
const LengthSize& topRightRadius() const { return m_radii.topRight; }
const LengthSize& bottomLeftRadius() const { return m_radii.bottomLeft; }
const LengthSize& bottomRightRadius() const { return m_radii.bottomRight; }

void dump(TextStream&, DumpStyleValues = DumpStyleValues::All) const;

Expand All @@ -142,10 +141,7 @@ friend class RenderStyle;

NinePieceImage m_image;

LengthSize m_topLeftRadius;
LengthSize m_topRightRadius;
LengthSize m_bottomLeftRadius;
LengthSize m_bottomRightRadius;
Radii m_radii;
};

WTF::TextStream& operator<<(WTF::TextStream&, const BorderValue&);
Expand Down
16 changes: 8 additions & 8 deletions Source/WebCore/rendering/style/RenderStyle.h
Expand Up @@ -930,10 +930,10 @@ class RenderStyle {
void resetBorderLeft() { SET_VAR(m_surroundData, border.m_left, BorderValue()); }
void resetBorderImage() { SET_VAR(m_surroundData, border.m_image, NinePieceImage()); }
void resetBorderRadius() { resetBorderTopLeftRadius(); resetBorderTopRightRadius(); resetBorderBottomLeftRadius(); resetBorderBottomRightRadius(); }
void resetBorderTopLeftRadius() { SET_VAR(m_surroundData, border.m_topLeftRadius, initialBorderRadius()); }
void resetBorderTopRightRadius() { SET_VAR(m_surroundData, border.m_topRightRadius, initialBorderRadius()); }
void resetBorderBottomLeftRadius() { SET_VAR(m_surroundData, border.m_bottomLeftRadius, initialBorderRadius()); }
void resetBorderBottomRightRadius() { SET_VAR(m_surroundData, border.m_bottomRightRadius, initialBorderRadius()); }
void resetBorderTopLeftRadius() { SET_VAR(m_surroundData, border.m_radii.topLeft, initialBorderRadius()); }
void resetBorderTopRightRadius() { SET_VAR(m_surroundData, border.m_radii.topRight, initialBorderRadius()); }
void resetBorderBottomLeftRadius() { SET_VAR(m_surroundData, border.m_radii.bottomLeft, initialBorderRadius()); }
void resetBorderBottomRightRadius() { SET_VAR(m_surroundData, border.m_radii.bottomRight, initialBorderRadius()); }

void setBackgroundColor(const StyleColor& v) { SET_VAR(m_backgroundData, color, v); }

Expand All @@ -957,10 +957,10 @@ class RenderStyle {
void setBorderImageHorizontalRule(NinePieceImageRule);
void setBorderImageVerticalRule(NinePieceImageRule);

void setBorderTopLeftRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_topLeftRadius, WTFMove(size)); }
void setBorderTopRightRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_topRightRadius, WTFMove(size)); }
void setBorderBottomLeftRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_bottomLeftRadius, WTFMove(size)); }
void setBorderBottomRightRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_bottomRightRadius, WTFMove(size)); }
void setBorderTopLeftRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_radii.topLeft, WTFMove(size)); }
void setBorderTopRightRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_radii.topRight, WTFMove(size)); }
void setBorderBottomLeftRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_radii.bottomLeft, WTFMove(size)); }
void setBorderBottomRightRadius(LengthSize&& size) { SET_VAR(m_surroundData, border.m_radii.bottomRight, WTFMove(size)); }

void setBorderRadius(LengthSize&&);
void setBorderRadius(const IntSize&);
Expand Down

0 comments on commit 3870776

Please sign in to comment.