Title: [294485] trunk
- Revision
- 294485
- Author
- [email protected]
- Date
- 2022-05-19 08:46:15 -0700 (Thu, 19 May 2022)
Log Message
REGRESSION (r294291): Nullptr crash with :first-letter
https://bugs.webkit.org/show_bug.cgi?id=240631
<rdar://93495868>
Reviewed by Alan Bujtas.
Test: fast/css/first-letter-multicol-crash.html
* Source/WebCore/rendering/RenderObject.h:
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
With multicol there can be multiple levels of anonymous ancestors. Search for the
nearest non-anonymous ancestor to find the first-letter style.
(WebCore::styleForFirstLetter):
* LayoutTests/fast/css-generated-content/first-letter-in-nested-before-table-expected.html:
Update expected results. The new results match Chrome behavior.
* LayoutTests/fast/css/first-letter-multicol-crash-expected.txt: Added.
* LayoutTests/fast/css/first-letter-multicol-crash.html: Added.
Canonical link: https://commits.webkit.org/250744@main
Modified Paths
Added Paths
Diff
Added: trunk/LayoutTests/fast/css/first-letter-multicol-crash-expected.txt (0 => 294485)
--- trunk/LayoutTests/fast/css/first-letter-multicol-crash-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/first-letter-multicol-crash-expected.txt 2022-05-19 15:46:15 UTC (rev 294485)
@@ -0,0 +1 @@
+This test passes if it doesn't crash.
Added: trunk/LayoutTests/fast/css/first-letter-multicol-crash.html (0 => 294485)
--- trunk/LayoutTests/fast/css/first-letter-multicol-crash.html (rev 0)
+++ trunk/LayoutTests/fast/css/first-letter-multicol-crash.html 2022-05-19 15:46:15 UTC (rev 294485)
@@ -0,0 +1,19 @@
+<style>
+ body {
+ column-count: 2;
+ }
+ ::first-letter {
+ width: 0;
+ }
+</style>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ _onload_ = () => {
+ document.execCommand('SelectAll');
+ document.designMode = 'on';
+ document.execCommand('Indent');
+ };
+</script>
+This test passes if it doesn't crash.
Modified: trunk/LayoutTests/fast/css-generated-content/first-letter-in-nested-before-table-expected.html (294484 => 294485)
--- trunk/LayoutTests/fast/css-generated-content/first-letter-in-nested-before-table-expected.html 2022-05-19 15:40:42 UTC (rev 294484)
+++ trunk/LayoutTests/fast/css-generated-content/first-letter-in-nested-before-table-expected.html 2022-05-19 15:46:15 UTC (rev 294485)
@@ -1,21 +1,7 @@
<!DOCTYPE html>
<html>
-<body style="font-family: ahem; font-size: 50px; -webkit-font-smoothing: none;">
-<style>
-.test1:before {
- display: table;
- content: "AB";
-}
-.test2:after {
- display: table;
- content: "EF";
-}
-</style>
-<div class="test1">C</div>
-<div class="test2"><span style="color:green">D</span></div>
-<div class="test2"></div>
-<script>
-document.body.offsetTop;
-document.body.style.color = "blue";
-</script>
+<body style="color:blue; font-family: ahem; font-size: 50px; -webkit-font-smoothing: none;">
+<div><div style="display:table"><span style="color:green">A</span>B</div>C</div>
+<div><span style="color:green">D</span><div style="display:table">EF</div></div>
+<div><div style="display:table"><span style="color:green">E</span>F</div></div>
</html>
Modified: trunk/Source/WebCore/rendering/RenderObject.h (294484 => 294485)
--- trunk/Source/WebCore/rendering/RenderObject.h 2022-05-19 15:40:42 UTC (rev 294484)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2022-05-19 15:46:15 UTC (rev 294485)
@@ -136,6 +136,8 @@
RenderObject* firstLeafChild() const;
RenderObject* lastLeafChild() const;
+ RenderElement* firstNonAnonymousAncestor() const;
+
#if ENABLE(TEXT_AUTOSIZING)
// Minimal distance between the block with fixed height and overflowing content and the text block to apply text autosizing.
// The greater this constant is the more potential places we have where autosizing is turned off.
@@ -779,8 +781,6 @@
void addPDFURLRect(PaintInfo&, const LayoutPoint&);
Node& nodeForNonAnonymous() const { ASSERT(!isAnonymous()); return m_node; }
- RenderElement* firstNonAnonymousAncestor() const;
-
void adjustRectForOutlineAndShadow(LayoutRect&) const;
virtual void willBeDestroyed();
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp (294484 => 294485)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp 2022-05-19 15:40:42 UTC (rev 294484)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp 2022-05-19 15:46:15 UTC (rev 294485)
@@ -41,7 +41,7 @@
static std::optional<RenderStyle> styleForFirstLetter(const RenderElement& firstLetterContainer)
{
- auto& styleContainer = firstLetterContainer.isAnonymous() && firstLetterContainer.parent() ? *firstLetterContainer.parent() : firstLetterContainer;
+ auto& styleContainer = firstLetterContainer.isAnonymous() ? *firstLetterContainer.firstNonAnonymousAncestor() : firstLetterContainer;
auto style = styleContainer.style().getCachedPseudoStyle(PseudoId::FirstLetter);
if (!style)
return { };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes