Diff
Added: trunk/LayoutTests/fast/css/internal-th-center-ua-only-expected.txt (0 => 295625)
--- trunk/LayoutTests/fast/css/internal-th-center-ua-only-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/internal-th-center-ua-only-expected.txt 2022-06-17 02:47:14 UTC (rev 295625)
@@ -0,0 +1,4 @@
+
+PASS "text-align" property does not support value "-internal-th-center".
+PASS "text-align" property cannot be set to "-internal-th-center" by the author stylesheet.
+
Added: trunk/LayoutTests/fast/css/internal-th-center-ua-only.html (0 => 295625)
--- trunk/LayoutTests/fast/css/internal-th-center-ua-only.html (rev 0)
+++ trunk/LayoutTests/fast/css/internal-th-center-ua-only.html 2022-06-17 02:47:14 UTC (rev 295625)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+
+<style>
+th {
+ text-align: right;
+ text-align: -internal-th-center;
+}
+</style>
+<table>
+ <tr>
+ <th id="header"></th>
+ </tr>
+</table>
+
+<script>
+ test(function() {
+ assert_false(CSS.supports('text-align', '-internal-th-center'));
+ }, '"text-align" property does not support value "-internal-th-center".');
+
+ test(function() {
+ assert_equals(getComputedStyle(header).textAlign, 'right');
+ }, '"text-align" property cannot be set to "-internal-th-center" by the author stylesheet.');
+</script>
Modified: trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align-expected.html (295624 => 295625)
--- trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align-expected.html 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align-expected.html 2022-06-17 02:47:14 UTC (rev 295625)
@@ -4,7 +4,7 @@
<title>This tests that th is text-align centered when parent has initial value.</title>
<style>
table {
- width: 500px; border: 1px solid green;
+ width: 500px; border: 1px solid green;
}
</style>
<table><tbody>
@@ -12,11 +12,13 @@
<tr><th style="text-align: left">th initial</th></tr>
<tr><th style="text-align: left">th start</th></tr>
<tr><th style="text-align: center">th center</th></tr>
+ <tr><th style="text-align: left">th initial</th></tr>
<tr><th style="text-align: right">th end</th></tr>
<tr><th style="text-align: center">tr initial</th></tr>
<tr><th style="text-align: center">tr start</th></tr>
<tr><th style="text-align: center">tr center</th></tr>
<tr><th style="text-align: right">tr end</th></tr>
+ <tr><th style="text-align: right">tr end</th></tr>
<tr><th style="text-align: left">tr initial, th initial</th></tr>
<tr><th style="text-align: left">tr initial, th start</th></tr>
<tr><th style="text-align: left">tr start, th start</th></tr>
Modified: trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align.html (295624 => 295625)
--- trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align.html 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/LayoutTests/fast/table/center-th-when-parent-has-initial-text-align.html 2022-06-17 02:47:14 UTC (rev 295625)
@@ -4,7 +4,7 @@
<title>This tests that th is text-align centered when parent has initial value.</title>
<style>
table {
- width: 500px; border: 1px solid green;
+ width: 500px; border: 1px solid green;
}
</style>
<table><tbody>
@@ -12,11 +12,13 @@
<tr><th style="text-align: initial">th initial</th></tr>
<tr><th style="text-align: start">th start</th></tr>
<tr><th style="text-align: center">th center</th></tr>
+ <tr><th style="text-align: inherit">th initial</th></tr>
<tr><th style="text-align: end">th end</th></tr>
<tr style="text-align: initial"><th>tr initial</th></tr>
<tr style="text-align: start"><th>tr start</th></tr>
<tr style="text-align: center"><th>tr center</th></tr>
<tr style="text-align: end"><th>tr end</th></tr>
+ <tr style="text-align: end"><th style="text-align: inherit">tr end</th></tr>
<tr style="text-align: initial"><th style="text-align: initial">tr initial, th initial</th></tr>
<tr style="text-align: initial"><th style="text-align: start">tr initial, th start</th></tr>
<tr style="text-align: start"><th style="text-align: start">tr start, th start</th></tr>
Modified: trunk/Source/WebCore/css/CSSProperties.json (295624 => 295625)
--- trunk/Source/WebCore/css/CSSProperties.json 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/css/CSSProperties.json 2022-06-17 02:47:14 UTC (rev 295625)
@@ -4587,8 +4587,7 @@
}
],
"codegen-properties": {
- "converter": "TextAlign",
- "custom": "Initial|Value"
+ "converter": "TextAlign"
},
"specification": {
"category": "css-22",
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (295624 => 295625)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2022-06-17 02:47:14 UTC (rev 295625)
@@ -345,6 +345,7 @@
-webkit-center
match-parent
-webkit-match-parent
+-internal-th-center
//start
//end
//
Modified: trunk/Source/WebCore/css/html.css (295624 => 295625)
--- trunk/Source/WebCore/css/html.css 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/css/html.css 2022-06-17 02:47:14 UTC (rev 295625)
@@ -269,6 +269,7 @@
th {
font-weight: bold;
+ text-align: -internal-th-center;
}
caption {
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (295624 => 295625)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2022-06-17 02:47:14 UTC (rev 295625)
@@ -715,7 +715,7 @@
case CSSPropertyTableLayout: // auto | fixed
return valueID == CSSValueAuto || valueID == CSSValueFixed;
case CSSPropertyTextAlign:
- return (valueID >= CSSValueWebkitAuto && valueID <= CSSValueWebkitMatchParent) || valueID == CSSValueStart || valueID == CSSValueEnd;
+ return (valueID >= CSSValueWebkitAuto && valueID <= CSSValueInternalThCenter) || valueID == CSSValueStart || valueID == CSSValueEnd;
case CSSPropertyTextAlignLast:
// auto | start | end | left | right | center | justify | match-parent
return (valueID >= CSSValueLeft && valueID <= CSSValueJustify) || valueID == CSSValueStart || valueID == CSSValueEnd || valueID == CSSValueAuto || valueID == CSSValueMatchParent;
Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (295624 => 295625)
--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp 2022-06-17 02:47:14 UTC (rev 295625)
@@ -40,6 +40,8 @@
return isUASheetBehavior(mode);
case CSSValueWebkitFocusRingColor:
return isUASheetBehavior(mode) || isQuirksModeBehavior(mode);
+ case CSSValueInternalThCenter:
+ return isUASheetBehavior(mode);
default:
return true;
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (295624 => 295625)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2022-06-17 02:47:14 UTC (rev 295625)
@@ -197,7 +197,6 @@
m_nonInheritedFlags.hasExplicitlySetBorderTopRightRadius = false;
m_nonInheritedFlags.hasExplicitlySetDirection = false;
m_nonInheritedFlags.hasExplicitlySetWritingMode = false;
- m_nonInheritedFlags.hasExplicitlySetTextAlign = false;
m_nonInheritedFlags.usesViewportUnits = false;
m_nonInheritedFlags.usesContainerUnits = false;
m_nonInheritedFlags.hasExplicitlyInheritedProperties = false;
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (295624 => 295625)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2022-06-17 02:47:14 UTC (rev 295625)
@@ -1570,9 +1570,6 @@
bool hasExplicitlySetWritingMode() const { return m_nonInheritedFlags.hasExplicitlySetWritingMode; }
void setHasExplicitlySetWritingMode(bool v) { m_nonInheritedFlags.hasExplicitlySetWritingMode = v; }
- bool hasExplicitlySetTextAlign() const { return m_nonInheritedFlags.hasExplicitlySetTextAlign; }
- void setHasExplicitlySetTextAlign(bool v) { m_nonInheritedFlags.hasExplicitlySetTextAlign = v; }
-
// A unique style is one that has matches something that makes it impossible to share.
bool unique() const { return m_nonInheritedFlags.isUnique; }
void setUnique() { m_nonInheritedFlags.isUnique = true; }
@@ -1990,7 +1987,6 @@
unsigned hasExplicitlySetBorderTopRightRadius : 1;
unsigned hasExplicitlySetDirection : 1;
unsigned hasExplicitlySetWritingMode : 1;
- unsigned hasExplicitlySetTextAlign : 1;
#if ENABLE(DARK_MODE_CSS)
unsigned hasExplicitlySetColorScheme : 1;
#endif
@@ -2132,7 +2128,6 @@
&& hasExplicitlySetBorderTopRightRadius == other.hasExplicitlySetBorderTopRightRadius
&& hasExplicitlySetDirection == other.hasExplicitlySetDirection
&& hasExplicitlySetWritingMode == other.hasExplicitlySetWritingMode
- && hasExplicitlySetTextAlign == other.hasExplicitlySetTextAlign
#if ENABLE(DARK_MODE_CSS)
&& hasExplicitlySetColorScheme == other.hasExplicitlySetColorScheme
#endif
Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (295624 => 295625)
--- trunk/Source/WebCore/style/StyleAdjuster.cpp 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp 2022-06-17 02:47:14 UTC (rev 295625)
@@ -315,13 +315,6 @@
style.setFloating(Float::None);
}
- // User agents are expected to have a rule in their user agent stylesheet that matches th elements that have a parent
- // node whose computed value for the 'text-align' property is its initial value, whose declaration block consists of
- // just a single declaration that sets the 'text-align' property to the value 'center'.
- // https://html.spec.whatwg.org/multipage/rendering.html#rendering
- if (m_element->hasTagName(thTag) && !style.hasExplicitlySetTextAlign() && m_parentStyle.textAlign() == RenderStyle::initialTextAlign())
- style.setTextAlign(TextAlignMode::Center);
-
if (m_element->hasTagName(legendTag))
style.setEffectiveDisplay(DisplayType::Block);
}
Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (295624 => 295625)
--- trunk/Source/WebCore/style/StyleBuilderConverter.h 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h 2022-06-17 02:47:14 UTC (rev 295625)
@@ -610,23 +610,37 @@
inline TextAlignMode BuilderConverter::convertTextAlign(BuilderState& builderState, const CSSValue& value)
{
- auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+ const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
ASSERT(primitiveValue.isValueID());
- if (primitiveValue.valueID() != CSSValueWebkitMatchParent && primitiveValue.valueID() != CSSValueMatchParent)
- return primitiveValue;
+ const auto& parentStyle = builderState.parentStyle();
- auto* element = builderState.element();
- if (element && element == builderState.document().documentElement())
- return TextAlignMode::Start;
+ // User agents are expected to have a rule in their user agent stylesheet that matches th elements that have a parent
+ // node whose computed value for the 'text-align' property is its initial value, whose declaration block consists of
+ // just a single declaration that sets the 'text-align' property to the value 'center'.
+ // https://html.spec.whatwg.org/multipage/rendering.html#rendering
+ if (primitiveValue.valueID() == CSSValueInternalThCenter) {
+ if (parentStyle.textAlign() == RenderStyle::initialTextAlign())
+ return TextAlignMode::Center;
+ return parentStyle.textAlign();
+ }
- auto& parentStyle = builderState.parentStyle();
- if (parentStyle.textAlign() == TextAlignMode::Start)
- return parentStyle.isLeftToRightDirection() ? TextAlignMode::Left : TextAlignMode::Right;
- if (parentStyle.textAlign() == TextAlignMode::End)
- return parentStyle.isLeftToRightDirection() ? TextAlignMode::Right : TextAlignMode::Left;
- return parentStyle.textAlign();
+ if (primitiveValue.valueID() == CSSValueWebkitMatchParent || primitiveValue.valueID() == CSSValueMatchParent) {
+ const auto* element = builderState.element();
+
+ if (element && element == builderState.document().documentElement())
+ return TextAlignMode::Start;
+ if (parentStyle.textAlign() == TextAlignMode::Start)
+ return parentStyle.isLeftToRightDirection() ? TextAlignMode::Left : TextAlignMode::Right;
+ if (parentStyle.textAlign() == TextAlignMode::End)
+ return parentStyle.isLeftToRightDirection() ? TextAlignMode::Right : TextAlignMode::Left;
+
+ return parentStyle.textAlign();
+ }
+
+ return primitiveValue;
}
+
inline TextAlignLast BuilderConverter::convertTextAlignLast(BuilderState& builderState, const CSSValue& value)
{
auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (295624 => 295625)
--- trunk/Source/WebCore/style/StyleBuilderCustom.h 2022-06-17 02:20:29 UTC (rev 295624)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h 2022-06-17 02:47:14 UTC (rev 295625)
@@ -136,10 +136,6 @@
static void applyInheritVerticalAlign(BuilderState&);
static void applyValueVerticalAlign(BuilderState&, CSSValue&);
- // Custom handling of initial + value only.
- static void applyInitialTextAlign(BuilderState&);
- static void applyValueTextAlign(BuilderState&, CSSValue&);
-
// Custom handling of value setting only.
static void applyValueBaselineShift(BuilderState&, CSSValue&);
static void applyValueDirection(BuilderState&, CSSValue&);
@@ -192,18 +188,6 @@
builderState.style().setHasExplicitlySetDirection(true);
}
-inline void BuilderCustom::applyInitialTextAlign(BuilderState& builderState)
-{
- builderState.style().setTextAlign(RenderStyle::initialTextAlign());
- builderState.style().setHasExplicitlySetTextAlign(true);
-}
-
-inline void BuilderCustom::applyValueTextAlign(BuilderState& builderState, CSSValue& value)
-{
- builderState.style().setTextAlign(BuilderConverter::convertTextAlign(builderState, value));
- builderState.style().setHasExplicitlySetTextAlign(true);
-}
-
inline void BuilderCustom::resetEffectiveZoom(BuilderState& builderState)
{
// Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.