Skip to content

Commit

Permalink
REGRESSION(269613@main): text-wrap: balance parses even when `text-…
Browse files Browse the repository at this point in the history
…wrap-style` is disabled

https://bugs.webkit.org/show_bug.cgi?id=263495
rdar://117295817

Reviewed by Alan Baradlay.

269613@main accidentally enabled `text-wrap: balance`. It was assuming the generated `text-wrap-style` parsing function
would check for the preference, but that is not the case.

Add a manual check for the preference to avoid exposing the `text-wrap-style` values in `text-wrap` when the longhand is disabled.

* LayoutTests/fast/css/text-wrap-style-disabled-expected.txt: Added.
* LayoutTests/fast/css/text-wrap-style-disabled.html: Added.
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeTextWrapShorthand):

Canonical link: https://commits.webkit.org/269624@main
  • Loading branch information
nt1m authored and alanbaradlay committed Oct 21, 2023
1 parent 2eed046 commit 6051265
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
28 changes: 28 additions & 0 deletions LayoutTests/fast/css/text-wrap-style-disabled-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
When text-wrap-style is disabled, the following should not parse:


PASS e.style['text-wrap-style'] = "auto" should not set the property value
PASS e.style['text-wrap-style'] = "balance" should not set the property value
PASS e.style['text-wrap-style'] = "stable" should not set the property value
PASS e.style['text-wrap-style'] = "pretty" should not set the property value
PASS e.style['text-wrap'] = "auto" should not set the property value
PASS e.style['text-wrap'] = "balance" should not set the property value
PASS e.style['text-wrap'] = "stable" should not set the property value
PASS e.style['text-wrap'] = "pretty" should not set the property value
PASS e.style['text-wrap'] = "wrap auto" should not set the property value
PASS e.style['text-wrap'] = "wrap balance" should not set the property value
PASS e.style['text-wrap'] = "wrap pretty" should not set the property value
PASS e.style['text-wrap'] = "wrap stable" should not set the property value
PASS e.style['text-wrap'] = "auto wrap" should not set the property value
PASS e.style['text-wrap'] = "balance wrap" should not set the property value
PASS e.style['text-wrap'] = "pretty wrap" should not set the property value
PASS e.style['text-wrap'] = "stable wrap" should not set the property value
PASS e.style['text-wrap'] = "nowrap auto" should not set the property value
PASS e.style['text-wrap'] = "nowrap balance" should not set the property value
PASS e.style['text-wrap'] = "nowrap pretty" should not set the property value
PASS e.style['text-wrap'] = "nowrap stable" should not set the property value
PASS e.style['text-wrap'] = "auto nowrap" should not set the property value
PASS e.style['text-wrap'] = "balance nowrap" should not set the property value
PASS e.style['text-wrap'] = "pretty nowrap" should not set the property value
PASS e.style['text-wrap'] = "stable nowrap" should not set the property value

43 changes: 43 additions & 0 deletions LayoutTests/fast/css/text-wrap-style-disabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- webkit-test-runner [ CSSTextWrapStyleEnabled=false ]-->
<!DOCTYPE html>
<html>
<head>
<title>Test text-wrap parsing when text-wrap-style is disabled</title>
<meta charset="utf-8">
</head>
<body>
<p>When text-wrap-style is disabled, the following should not parse:</p>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../imported/w3c/web-platform-tests/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_value("text-wrap-style", "auto");
test_invalid_value("text-wrap-style", "balance");
test_invalid_value("text-wrap-style", "stable");
test_invalid_value("text-wrap-style", "pretty");

test_invalid_value("text-wrap", "auto");
test_invalid_value("text-wrap", "balance");
test_invalid_value("text-wrap", "stable");
test_invalid_value("text-wrap", "pretty");

test_invalid_value("text-wrap", "wrap auto");
test_invalid_value("text-wrap", "wrap balance");
test_invalid_value("text-wrap", "wrap pretty");
test_invalid_value("text-wrap", "wrap stable");
test_invalid_value("text-wrap", "auto wrap");
test_invalid_value("text-wrap", "balance wrap");
test_invalid_value("text-wrap", "pretty wrap");
test_invalid_value("text-wrap", "stable wrap");

test_invalid_value("text-wrap", "nowrap auto");
test_invalid_value("text-wrap", "nowrap balance");
test_invalid_value("text-wrap", "nowrap pretty");
test_invalid_value("text-wrap", "nowrap stable");
test_invalid_value("text-wrap", "auto nowrap");
test_invalid_value("text-wrap", "balance nowrap");
test_invalid_value("text-wrap", "pretty nowrap");
test_invalid_value("text-wrap", "stable nowrap");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion Source/WebCore/css/parser/CSSPropertyParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ bool CSSPropertyParser::consumeTextWrapShorthand(bool important)
for (unsigned propertiesParsed = 0; propertiesParsed < 2 && !m_range.atEnd(); ++propertiesParsed) {
if (!mode && (mode = CSSPropertyParsing::consumeTextWrapMode(m_range)))
continue;
if (!style && (style = CSSPropertyParsing::consumeTextWrapStyle(m_range)))
if (!style && m_context.propertySettings.cssTextWrapStyleEnabled && (style = CSSPropertyParsing::consumeTextWrapStyle(m_range)))
continue;
// If we didn't find at least one match, this is an invalid shorthand and we have to ignore it.
return false;
Expand Down

0 comments on commit 6051265

Please sign in to comment.