Skip to content

Commit

Permalink
[CSS Quotes] Some CSS properties cause quotes to be reset
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=277154
rdar://132585704

Reviewed by Simon Fraser.

Some RenderStyle setters trigger copy-on-write, so the copy constructors need to be accurate.

In this case, quotes were not being copied over.

To avoid future similar issues, add ASSERTs to the copy constructors for classes that RenderStyle directly refers too.

* LayoutTests/fast/css/quotes-with-text-shadow-expected.html: Added.
* LayoutTests/fast/css/quotes-with-text-shadow.html: Added.
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setQuotes): Use arePointingToEqualData as it's easier to read and equivalent.
* Source/WebCore/rendering/style/SVGRenderStyle.cpp:
(WebCore::SVGRenderStyle::SVGRenderStyle):
* Source/WebCore/rendering/style/StyleInheritedData.cpp:
(WebCore::StyleInheritedData::StyleInheritedData):
* Source/WebCore/rendering/style/StyleNonInheritedData.cpp:
(WebCore::StyleNonInheritedData::StyleNonInheritedData):
* Source/WebCore/rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):

Canonical link: https://commits.webkit.org/281444@main
  • Loading branch information
nt1m committed Jul 27, 2024
1 parent 5cbdaff commit 1dd5907
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions LayoutTests/fast/css/quotes-with-text-shadow-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span>start<span style="text-shadow: 2px 2px red">startend</span>end</span>
5 changes: 5 additions & 0 deletions LayoutTests/fast/css/quotes-with-text-shadow.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<style>
q {
quotes: "start" "end";
}
</style><q><q style="text-shadow: 2px 2px red"></q></q>
6 changes: 3 additions & 3 deletions Source/WebCore/rendering/style/RenderStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2169,12 +2169,12 @@ void RenderStyle::setCursorList(RefPtr<CursorList>&& list)
m_rareInheritedData.access().cursorData = WTFMove(list);
}

void RenderStyle::setQuotes(RefPtr<QuotesData>&& q)
void RenderStyle::setQuotes(RefPtr<QuotesData>&& quotes)
{
if (m_rareInheritedData->quotes == q || (m_rareInheritedData->quotes && q && *m_rareInheritedData->quotes == *q))
if (arePointingToEqualData(m_rareInheritedData->quotes.get(), quotes.get()))
return;

m_rareInheritedData.access().quotes = WTFMove(q);
m_rareInheritedData.access().quotes = WTFMove(quotes);
}

void RenderStyle::setWillChange(RefPtr<WillChangeData>&& willChangeData)
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/style/SVGRenderStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ inline SVGRenderStyle::SVGRenderStyle(const SVGRenderStyle& other)
, m_miscData(other.m_miscData)
, m_layoutData(other.m_layoutData)
{
ASSERT(other == *this, "SVGRenderStyle should be properly copied.");
}

Ref<SVGRenderStyle> SVGRenderStyle::copy() const
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/style/StyleInheritedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ inline StyleInheritedData::StyleInheritedData(const StyleInheritedData& o)
, color(o.color)
, visitedLinkColor(o.visitedLinkColor)
{
ASSERT(o == *this, "StyleInheritedData should be properly copied.");
}

Ref<StyleInheritedData> StyleInheritedData::copy() const
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/style/StyleNonInheritedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ StyleNonInheritedData::StyleNonInheritedData(const StyleNonInheritedData& other)
, miscData(other.miscData)
, rareData(other.rareData)
{
ASSERT(other == *this, "StyleNonInheritedData should be properly copied.");
}

Ref<StyleNonInheritedData> StyleNonInheritedData::create()
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ StyleRareInheritedData::StyleRareInheritedData()
#if ENABLE(DARK_MODE_CSS)
, colorScheme(RenderStyle::initialColorScheme())
#endif
, quotes(RenderStyle::initialQuotes())
, appleColorFilter(StyleFilterData::create())
, lineGrid(RenderStyle::initialLineGrid())
, tabSize(RenderStyle::initialTabSize())
Expand Down Expand Up @@ -244,6 +245,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
, colorScheme(o.colorScheme)
#endif
, textEmphasisCustomMark(o.textEmphasisCustomMark)
, quotes(o.quotes)
, appleColorFilter(o.appleColorFilter)
, lineGrid(o.lineGrid)
, tabSize(o.tabSize)
Expand All @@ -256,6 +258,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
, listStyleType(o.listStyleType)
, scrollbarColor(o.scrollbarColor)
{
ASSERT(o == *this, "StyleRareInheritedData should be properly copied.");
}

Ref<StyleRareInheritedData> StyleRareInheritedData::copy() const
Expand Down

0 comments on commit 1dd5907

Please sign in to comment.