Skip to content
Permalink
Browse files
Minor RenderStyle boxShadow cleanup
https://bugs.webkit.org/show_bug.cgi?id=218952

Reviewed by Sam Weinig.

Rename getBoxShadowExtent() to boxShadowExtent() and have it return a LayoutBoxExtent.

Make shadow-related functions static that can be, and private that can be.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::applyVisualEffectOverflow const):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::repaintAfterLayoutIfNeeded):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::shadowExtent):
(WebCore::RenderStyle::shadowInsetExtent):
(WebCore::RenderStyle::getShadowHorizontalExtent):
(WebCore::RenderStyle::getShadowVerticalExtent):
(WebCore::RenderStyle::getShadowExtent const): Deleted.
(WebCore::RenderStyle::getShadowInsetExtent const): Deleted.
(WebCore::RenderStyle::getShadowHorizontalExtent const): Deleted.
(WebCore::RenderStyle::getShadowVerticalExtent const): Deleted.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::boxShadowExtent const):
(WebCore::RenderStyle::boxShadowInsetExtent const):
(WebCore::RenderStyle::getBoxShadowExtent const): Deleted.
(WebCore::RenderStyle::getBoxShadowInsetExtent const): Deleted.


Canonical link: https://commits.webkit.org/231600@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269835 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Nov 16, 2020
1 parent 01b4e17 commit 4c1ab8f3dd42801d64568d47289a7e608982f614
Showing 5 changed files with 56 additions and 27 deletions.
@@ -1,3 +1,33 @@
2020-11-15 Simon Fraser <simon.fraser@apple.com>

Minor RenderStyle boxShadow cleanup
https://bugs.webkit.org/show_bug.cgi?id=218952

Reviewed by Sam Weinig.

Rename getBoxShadowExtent() to boxShadowExtent() and have it return a LayoutBoxExtent.

Make shadow-related functions static that can be, and private that can be.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::applyVisualEffectOverflow const):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::repaintAfterLayoutIfNeeded):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::shadowExtent):
(WebCore::RenderStyle::shadowInsetExtent):
(WebCore::RenderStyle::getShadowHorizontalExtent):
(WebCore::RenderStyle::getShadowVerticalExtent):
(WebCore::RenderStyle::getShadowExtent const): Deleted.
(WebCore::RenderStyle::getShadowInsetExtent const): Deleted.
(WebCore::RenderStyle::getShadowHorizontalExtent const): Deleted.
(WebCore::RenderStyle::getShadowVerticalExtent const): Deleted.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::boxShadowExtent const):
(WebCore::RenderStyle::boxShadowInsetExtent const):
(WebCore::RenderStyle::getBoxShadowExtent const): Deleted.
(WebCore::RenderStyle::getBoxShadowInsetExtent const): Deleted.

2020-11-15 Andres Gonzalez <andresg_22@apple.com>

Fix for infinite recursion crash in isolated tree mode.
@@ -4613,22 +4613,18 @@ LayoutRect RenderBox::applyVisualEffectOverflow(const LayoutRect& borderBox) con

// Compute box-shadow overflow first.
if (style().boxShadow()) {
LayoutUnit shadowLeft;
LayoutUnit shadowRight;
LayoutUnit shadowTop;
LayoutUnit shadowBottom;
style().getBoxShadowExtent(shadowTop, shadowRight, shadowBottom, shadowLeft);
auto shadowExtent = style().boxShadowExtent();

// In flipped blocks writing modes such as vertical-rl, the physical right shadow value is actually at the lower x-coordinate.
overflowMinX = borderBox.x() + ((!isFlipped || isHorizontal) ? shadowLeft : -shadowRight);
overflowMaxX = borderBox.maxX() + ((!isFlipped || isHorizontal) ? shadowRight : -shadowLeft);
overflowMinY = borderBox.y() + ((!isFlipped || !isHorizontal) ? shadowTop : -shadowBottom);
overflowMaxY = borderBox.maxY() + ((!isFlipped || !isHorizontal) ? shadowBottom : -shadowTop);
overflowMinX = borderBox.x() + ((!isFlipped || isHorizontal) ? shadowExtent.left() : -shadowExtent.right());
overflowMaxX = borderBox.maxX() + ((!isFlipped || isHorizontal) ? shadowExtent.right() : -shadowExtent.left());
overflowMinY = borderBox.y() + ((!isFlipped || !isHorizontal) ? shadowExtent.top() : -shadowExtent.bottom());
overflowMaxY = borderBox.maxY() + ((!isFlipped || !isHorizontal) ? shadowExtent.bottom() : -shadowExtent.top());
}

// Now compute border-image-outset overflow.
if (style().hasBorderImageOutsets()) {
LayoutBoxExtent borderOutsets = style().borderImageOutsets();
auto borderOutsets = style().borderImageOutsets();

// In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right
// border is at the lower x coordinate value.
@@ -1234,7 +1234,7 @@ bool RenderElement::repaintAfterLayoutIfNeeded(const RenderLayerModelObject* rep
// two rectangles (but typically only one).
const RenderStyle& outlineStyle = outlineStyleForRepaint();
LayoutUnit outlineWidth { outlineStyle.outlineSize() };
LayoutBoxExtent insetShadowExtent = style().getBoxShadowInsetExtent();
auto insetShadowExtent = style().boxShadowInsetExtent();
LayoutUnit width = absoluteValue(newOutlineBox.width() - oldOutlineBox.width());
if (width) {
LayoutUnit shadowLeft;
@@ -1919,12 +1919,12 @@ void RenderStyle::setFontItalic(Optional<FontSelectionValue> value)
fontCascade().update(currentFontSelector);
}

void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
LayoutBoxExtent RenderStyle::shadowExtent(const ShadowData* shadow)
{
top = 0;
right = 0;
bottom = 0;
left = 0;
LayoutUnit top;
LayoutUnit right;
LayoutUnit bottom;
LayoutUnit left;

for ( ; shadow; shadow = shadow->next()) {
if (shadow->style() == ShadowStyle::Inset)
@@ -1936,9 +1936,11 @@ void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit& top, Lay
bottom = std::max<LayoutUnit>(bottom, shadow->y() + extentAndSpread);
left = std::min<LayoutUnit>(left, shadow->x() - extentAndSpread);
}

return { top, right, bottom, left };
}

LayoutBoxExtent RenderStyle::getShadowInsetExtent(const ShadowData* shadow) const
LayoutBoxExtent RenderStyle::shadowInsetExtent(const ShadowData* shadow)
{
LayoutUnit top;
LayoutUnit right;
@@ -1956,10 +1958,10 @@ LayoutBoxExtent RenderStyle::getShadowInsetExtent(const ShadowData* shadow) cons
left = std::max<LayoutUnit>(left, shadow->x() + extentAndSpread);
}

return LayoutBoxExtent(WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left));
return { top, right, bottom, left };
}

void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit &left, LayoutUnit &right) const
void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit &left, LayoutUnit &right)
{
left = 0;
right = 0;
@@ -1974,7 +1976,7 @@ void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit
}
}

void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &bottom) const
void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &bottom)
{
top = 0;
bottom = 0;
@@ -563,8 +563,8 @@ class RenderStyle {
const GridPosition& gridItemRowEnd() const { return m_rareNonInheritedData->gridItem->gridRowEnd; }

const ShadowData* boxShadow() const { return m_rareNonInheritedData->boxShadow.get(); }
void getBoxShadowExtent(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); }
LayoutBoxExtent getBoxShadowInsetExtent() const { return getShadowInsetExtent(boxShadow()); }
LayoutBoxExtent boxShadowExtent() const { return shadowExtent(boxShadow()); }
LayoutBoxExtent boxShadowInsetExtent() const { return shadowInsetExtent(boxShadow()); }
void getBoxShadowHorizontalExtent(LayoutUnit& left, LayoutUnit& right) const { getShadowHorizontalExtent(boxShadow(), left, right); }
void getBoxShadowVerticalExtent(LayoutUnit& top, LayoutUnit& bottom) const { getShadowVerticalExtent(boxShadow(), top, bottom); }
void getBoxShadowInlineDirectionExtent(LayoutUnit& logicalLeft, LayoutUnit& logicalRight) const { getShadowInlineDirectionExtent(boxShadow(), logicalLeft, logicalRight); }
@@ -1777,9 +1777,7 @@ class RenderStyle {
void setVisitedLinkCaretColor(const Color& v) { SET_VAR(m_rareInheritedData, visitedLinkCaretColor, v); }

void inheritUnicodeBidiFrom(const RenderStyle* parent) { m_nonInheritedFlags.unicodeBidi = parent->m_nonInheritedFlags.unicodeBidi; }
void getShadowExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const;
void getShadowHorizontalExtent(const ShadowData*, LayoutUnit& left, LayoutUnit& right) const;
void getShadowVerticalExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& bottom) const;

void getShadowInlineDirectionExtent(const ShadowData*, LayoutUnit& logicalLeft, LayoutUnit& logicalRight) const;
void getShadowBlockDirectionExtent(const ShadowData*, LayoutUnit& logicalTop, LayoutUnit& logicalBottom) const;

@@ -1912,14 +1910,17 @@ class RenderStyle {

void setContent(std::unique_ptr<ContentData>, bool add);

LayoutBoxExtent getShadowInsetExtent(const ShadowData*) const;

static bool isDisplayReplacedType(DisplayType);
static bool isDisplayInlineType(DisplayType);
static bool isDisplayFlexibleBox(DisplayType);
static bool isDisplayGridBox(DisplayType);
static bool isDisplayFlexibleOrGridBox(DisplayType);

static LayoutBoxExtent shadowExtent(const ShadowData*);
static LayoutBoxExtent shadowInsetExtent(const ShadowData*);
static void getShadowHorizontalExtent(const ShadowData*, LayoutUnit& left, LayoutUnit& right);
static void getShadowVerticalExtent(const ShadowData*, LayoutUnit& top, LayoutUnit& bottom);

Color colorResolvingCurrentColor(CSSPropertyID colorProperty, bool visitedLink) const;

bool changeAffectsVisualOverflow(const RenderStyle&) const;

0 comments on commit 4c1ab8f

Please sign in to comment.