Title: [252076] trunk
Revision
252076
Author
[email protected]
Date
2019-11-05 13:41:48 -0800 (Tue, 05 Nov 2019)

Log Message

[css-lists] Implement list-style-type: <string>
https://bugs.webkit.org/show_bug.cgi?id=167729

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Some tests pass now.

* web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt:
* web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt:

Source/WebCore:

This patch extends the syntax of the list-style-type property to accept
arbitrary string values in order to customize the marker contents.

When a string is specified for list-style-type, the patch sets it to a
special ListStyleType::String, and the string value is stored in an
extra field.

Tests: imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001a.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001b.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-002.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-003.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-004.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005a.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005b.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-006.html
       imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-007.html
       imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed.html
       imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid.html

Some tests fail because mixed-bidi is not supported in markers
(https://bugs.webkit.org/show_bug.cgi?id=202849).

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSProperties.json:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isPartialKeywordPropertyID):
* css/parser/CSSParserFastPaths.h:
* css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseSingleValue):
* rendering/RenderListMarker.cpp:
(WebCore::effectiveListMarkerType):
(WebCore::listMarkerSuffix):
(WebCore::listMarkerText):
(WebCore::RenderListMarker::styleDidChange):
(WebCore::RenderListMarker::paint):
(WebCore::RenderListMarker::updateContent):
(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::updateMargins):
(WebCore::RenderListMarker::suffix const):
(WebCore::RenderListMarker::getRelativeMarkerRect):
* rendering/style/CounterContent.h:
(WebCore::CounterContent::CounterContent):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::listStyleStringValue const):
(WebCore::RenderStyle::setListStyleStringValue):
(WebCore::RenderStyle::initialListStyleStringValue):
* rendering/style/RenderStyleConstants.cpp:
(WebCore::operator<<):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
* rendering/style/StyleRareInheritedData.h:
* style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyInheritListStyleType):
(WebCore::Style::BuilderCustom::applyInitialListStyleType):
(WebCore::Style::BuilderCustom::applyValueListStyleType):

LayoutTests:

Most tests pass now, but some still fail because mixed-bidi is not
supported in markers (https://bugs.webkit.org/show_bug.cgi?id=202849).

iOS and Mac have some extra failures due to subpixel differences for the
marker position.

* TestExpectations:
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (252075 => 252076)


--- trunk/LayoutTests/ChangeLog	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/ChangeLog	2019-11-05 21:41:48 UTC (rev 252076)
@@ -1,3 +1,20 @@
+2019-11-05  Oriol Brufau  <[email protected]>
+
+        [css-lists] Implement list-style-type: <string>
+        https://bugs.webkit.org/show_bug.cgi?id=167729
+
+        Reviewed by Antti Koivisto.
+
+        Most tests pass now, but some still fail because mixed-bidi is not
+        supported in markers (https://bugs.webkit.org/show_bug.cgi?id=202849).
+
+        iOS and Mac have some extra failures due to subpixel differences for the
+        marker position.
+
+        * TestExpectations:
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2019-11-05  Simon Fraser  <[email protected]>
 
         Content can disappear with a combination of <video> with controls and clipping

Modified: trunk/LayoutTests/TestExpectations (252075 => 252076)


--- trunk/LayoutTests/TestExpectations	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/TestExpectations	2019-11-05 21:41:48 UTC (rev 252076)
@@ -3585,14 +3585,9 @@
 imported/w3c/web-platform-tests/css/css-lists/counter-increment-inside-display-contents.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-lists/counter-reset-inside-display-contents.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001a.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001b.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-002.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-003.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005a.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005b.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-006.html [ ImageOnlyFailure ]
-webkit.org/b/167729 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-007.html [ ImageOnlyFailure ]
+webkit.org/b/202849 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005a.html [ ImageOnlyFailure ]
+webkit.org/b/202849 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005b.html [ ImageOnlyFailure ]
+webkit.org/b/202849 imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-006.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-lists/list-with-image-display-changed-001.html [ ImageOnlyFailure ]
 
 [ Debug ] fast/css/first-letter-and-float-crash.html [ Skip ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (252075 => 252076)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-11-05 21:41:48 UTC (rev 252076)
@@ -1,3 +1,15 @@
+2019-11-05  Oriol Brufau  <[email protected]>
+
+        [css-lists] Implement list-style-type: <string>
+        https://bugs.webkit.org/show_bug.cgi?id=167729
+
+        Reviewed by Antti Koivisto.
+
+        Some tests pass now.
+
+        * web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt:
+        * web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt:
+
 2019-11-05  Said Abou-Hallawa  <[email protected]>
 
         Disabled SVG shapes should not be hit

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt (252075 => 252076)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt	2019-11-05 21:41:48 UTC (rev 252076)
@@ -14,8 +14,8 @@
 PASS Property list-style-type value 'georgian' computes to 'georgian' 
 PASS Property list-style-type value 'lower-alpha' computes to 'lower-alpha' 
 PASS Property list-style-type value 'upper-alpha' computes to 'upper-alpha' 
-FAIL Property list-style-type value '"marker string"' computes to '"marker string"' assert_true: '"marker string"' is a supported value for list-style-type. expected true got false
-FAIL Property list-style-type value '"Note: "' computes to '"Note: "' assert_true: '"Note: "' is a supported value for list-style-type. expected true got false
+PASS Property list-style-type value '"marker string"' computes to '"marker string"' 
+PASS Property list-style-type value '"Note: "' computes to '"Note: "' 
 FAIL Property list-style-type value 'counter-Style-Name' computes to 'counter-Style-Name' assert_true: 'counter-Style-Name' is a supported value for list-style-type. expected true got false
 FAIL Property list-style-type value 'CounterStyleName' computes to 'CounterStyleName' assert_true: 'CounterStyleName' is a supported value for list-style-type. expected true got false
 FAIL Property list-style-type value 'symbols(cyclic "string")' computes to 'symbols(cyclic "string")' assert_true: 'symbols(cyclic "string")' is a supported value for list-style-type. expected true got false

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt (252075 => 252076)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt	2019-11-05 21:41:48 UTC (rev 252076)
@@ -14,8 +14,8 @@
 PASS e.style['list-style-type'] = "georgian" should set the property value 
 PASS e.style['list-style-type'] = "lower-alpha" should set the property value 
 PASS e.style['list-style-type'] = "upper-alpha" should set the property value 
-FAIL e.style['list-style-type'] = "\"marker string\"" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['list-style-type'] = "\"Note: \"" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['list-style-type'] = "\"marker string\"" should set the property value 
+PASS e.style['list-style-type'] = "\"Note: \"" should set the property value 
 FAIL e.style['list-style-type'] = "counter-Style-Name" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['list-style-type'] = "CounterStyleName" should set the property value assert_not_equals: property should be set got disallowed value ""
 FAIL e.style['list-style-type'] = "symbols(cyclic \"string\")" should set the property value assert_not_equals: property should be set got disallowed value ""

Modified: trunk/LayoutTests/platform/ios/TestExpectations (252075 => 252076)


--- trunk/LayoutTests/platform/ios/TestExpectations	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2019-11-05 21:41:48 UTC (rev 252076)
@@ -3468,3 +3468,6 @@
 webkit.org/b/203356 [ Debug ] imported/w3c/web-platform-tests/css/css-transitions/properties-value-003.html [ Pass Failure ]
 webkit.org/b/203416 imported/w3c/web-platform-tests/css/css-transitions/before-load-001.html [ Pass Failure ]
 webkit.org/b/203416 imported/w3c/web-platform-tests/css/css-transitions/properties-value-auto-001.html [ Pass Failure ]
+
+# This test fails in iOS due to subpixel differences for the marker position
+imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-002.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (252075 => 252076)


--- trunk/LayoutTests/platform/mac/TestExpectations	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2019-11-05 21:41:48 UTC (rev 252076)
@@ -2027,3 +2027,7 @@
 
 # rdar://54275897 ([ macOS ] Add support for batched key requests)
 platform/mac/media/encrypted-media/fps-multiple-pssh.html [ Skip ]
+
+# These tests fail in Mac due to subpixel differences for the marker position
+imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-002.html [ ImageOnlyFailure ]
+imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-004.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (252075 => 252076)


--- trunk/Source/WebCore/ChangeLog	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/ChangeLog	2019-11-05 21:41:48 UTC (rev 252076)
@@ -1,3 +1,71 @@
+2019-11-05  Oriol Brufau  <[email protected]>
+
+        [css-lists] Implement list-style-type: <string>
+        https://bugs.webkit.org/show_bug.cgi?id=167729
+
+        Reviewed by Antti Koivisto.
+
+        This patch extends the syntax of the list-style-type property to accept
+        arbitrary string values in order to customize the marker contents.
+
+        When a string is specified for list-style-type, the patch sets it to a
+        special ListStyleType::String, and the string value is stored in an
+        extra field.
+
+        Tests: imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001a.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-001b.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-002.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-003.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-004.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005a.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-005b.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-006.html
+               imported/w3c/web-platform-tests/css/css-lists/list-style-type-string-007.html
+               imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed.html
+               imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid.html
+
+        Some tests fail because mixed-bidi is not supported in markers
+        (https://bugs.webkit.org/show_bug.cgi?id=202849).
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSProperties.json:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isPartialKeywordPropertyID):
+        * css/parser/CSSParserFastPaths.h:
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::CSSPropertyParser::parseSingleValue):
+        * rendering/RenderListMarker.cpp:
+        (WebCore::effectiveListMarkerType):
+        (WebCore::listMarkerSuffix):
+        (WebCore::listMarkerText):
+        (WebCore::RenderListMarker::styleDidChange):
+        (WebCore::RenderListMarker::paint):
+        (WebCore::RenderListMarker::updateContent):
+        (WebCore::RenderListMarker::computePreferredLogicalWidths):
+        (WebCore::RenderListMarker::updateMargins):
+        (WebCore::RenderListMarker::suffix const):
+        (WebCore::RenderListMarker::getRelativeMarkerRect):
+        * rendering/style/CounterContent.h:
+        (WebCore::CounterContent::CounterContent):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::listStyleStringValue const):
+        (WebCore::RenderStyle::setListStyleStringValue):
+        (WebCore::RenderStyle::initialListStyleStringValue):
+        * rendering/style/RenderStyleConstants.cpp:
+        (WebCore::operator<<):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        (WebCore::StyleRareInheritedData::operator== const):
+        * rendering/style/StyleRareInheritedData.h:
+        * style/StyleBuilderCustom.h:
+        (WebCore::Style::BuilderCustom::applyInheritListStyleType):
+        (WebCore::Style::BuilderCustom::applyInitialListStyleType):
+        (WebCore::Style::BuilderCustom::applyValueListStyleType):
+
 2019-11-05  Simon Fraser  <[email protected]>
 
         Content can disappear with a combination of <video> with controls and clipping

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (252075 => 252076)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -2933,6 +2933,8 @@
         case CSSPropertyListStylePosition:
             return cssValuePool.createValue(style.listStylePosition());
         case CSSPropertyListStyleType:
+            if (style.listStyleType() == ListStyleType::String)
+                return cssValuePool.createValue(style.listStyleStringValue(), CSSPrimitiveValue::CSS_STRING);
             return cssValuePool.createValue(style.listStyleType());
         case CSSPropertyWebkitLocale:
             if (style.locale().isNull())

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (252075 => 252076)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -1931,6 +1931,10 @@
     case ListStyleType::Square:
         m_value.valueID = CSSValueSquare;
         break;
+    case ListStyleType::String:
+        ASSERT_NOT_REACHED();
+        m_value.valueID = CSSValueInvalid;
+        break;
     case ListStyleType::Telugu:
         m_value.valueID = CSSValueTelugu;
         break;

Modified: trunk/Source/WebCore/css/CSSProperties.json (252075 => 252076)


--- trunk/Source/WebCore/css/CSSProperties.json	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/CSSProperties.json	2019-11-05 21:41:48 UTC (rev 252076)
@@ -2817,6 +2817,9 @@
                 "katakana-iroha",
                 "none"
             ],
+            "codegen-properties": {
+                "custom": "All"
+            },
             "specification": {
                 "category": "css-lists",
                 "url": "https://www.w3.org/TR/css-lists-3/#propdef-list-style-type"

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (252075 => 252076)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -983,6 +983,16 @@
     }
 }
 
+bool CSSParserFastPaths::isPartialKeywordPropertyID(CSSPropertyID propertyId)
+{
+    switch (propertyId) {
+    case CSSPropertyListStyleType:
+        return true;
+    default:
+        return false;
+    }
+}
+
 static bool isUniversalKeyword(const String& string)
 {
     // These keywords can be used for all properties.

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.h (252075 => 252076)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -48,6 +48,11 @@
 
     // Properties handled here shouldn't be explicitly handled in CSSPropertyParser
     static bool isKeywordPropertyID(CSSPropertyID);
+
+    // Returns whether a property may be handled by the fast path but has other
+    // non-keyword values which should be handled by the CSSPropertyParser.
+    static bool isPartialKeywordPropertyID(CSSPropertyID);
+
     static bool isValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, const CSSParserContext&);
 
     static RefPtr<CSSValue> parseColor(const String&, CSSParserMode);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (252075 => 252076)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -3792,10 +3792,12 @@
 RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand)
 {
     if (CSSParserFastPaths::isKeywordPropertyID(property)) {
-        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context))
+        if (CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context))
+            return consumeIdent(m_range);
+
+        // Some properties need to fallback onto the regular parser.
+        if (!CSSParserFastPaths::isPartialKeywordPropertyID(property))
             return nullptr;
-
-        return consumeIdent(m_range);
     }
     switch (property) {
     case CSSPropertyWillChange:
@@ -4248,6 +4250,9 @@
     case CSSPropertyColorScheme:
         return consumeColorScheme(m_range);
 #endif
+    case CSSPropertyListStyleType:
+        // NOTE: All the keyword values for the list-style-type property are handled by the CSSParserFastPaths.
+        return consumeString(m_range);
     default:
         return nullptr;
     }

Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (252075 => 252076)


--- trunk/Source/WebCore/rendering/RenderListMarker.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -496,6 +496,9 @@
     case ListStyleType::UpperLatin:
     case ListStyleType::UpperNorwegian:
         return (value < 1) ? ListStyleType::Decimal : type;
+    case ListStyleType::String:
+        ASSERT_NOT_REACHED();
+        break;
     }
 
     ASSERT_NOT_REACHED();
@@ -595,6 +598,9 @@
     case ListStyleType::UpperRoman:
     case ListStyleType::Urdu:
         return '.';
+    case ListStyleType::String:
+        ASSERT_NOT_REACHED();
+        break;
     }
 
     ASSERT_NOT_REACHED();
@@ -1048,6 +1054,9 @@
         return toGeorgian(value);
     case ListStyleType::Hebrew:
         return toHebrew(value);
+    case ListStyleType::String:
+        ASSERT_NOT_REACHED();
+        break;
     }
 
     ASSERT_NOT_REACHED();
@@ -1078,9 +1087,8 @@
 void RenderListMarker::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
     RenderBox::styleDidChange(diff, oldStyle);
-
     if (oldStyle) {
-        if (style().listStylePosition() != oldStyle->listStylePosition() || style().listStyleType() != oldStyle->listStyleType())
+        if (style().listStylePosition() != oldStyle->listStylePosition() || style().listStyleType() != oldStyle->listStyleType() || (style().listStyleType() == ListStyleType::String && style().listStyleStringValue() != oldStyle->listStyleStringValue()))
             setNeedsLayoutAndPrefWidthsRecalc();
         if (oldStyle->isDisplayInlineType() && !style().isDisplayInlineType()) {
             delete m_inlineBoxWrapper;
@@ -1258,6 +1266,7 @@
     case ListStyleType::Urdu:
     case ListStyleType::Asterisks:
     case ListStyleType::Footnotes:
+    case ListStyleType::String:
         break;
     }
     if (m_text.isEmpty())
@@ -1280,7 +1289,7 @@
     FloatPoint textOrigin = FloatPoint(markerRect.x(), markerRect.y() + style().fontMetrics().ascent());
     textOrigin = roundPointToDevicePixels(LayoutPoint(textOrigin), document().deviceScaleFactor(), style().isLeftToRightDirection());
 
-    if (type == ListStyleType::Asterisks || type == ListStyleType::Footnotes)
+    if (type == ListStyleType::Asterisks || type == ListStyleType::Footnotes || type == ListStyleType::String)
         context.drawText(font, textRun, textOrigin);
     else {
         const UChar suffix = listMarkerSuffix(type, m_listItem->value());
@@ -1395,6 +1404,9 @@
     switch (type) {
     case ListStyleType::None:
         break;
+    case ListStyleType::String:
+        m_text = style().listStyleStringValue();
+        break;
     case ListStyleType::Circle:
     case ListStyleType::Disc:
     case ListStyleType::Square:
@@ -1503,9 +1515,12 @@
     case ListStyleType::None:
         break;
     case ListStyleType::Asterisks:
-    case ListStyleType::Footnotes: {
-        TextRun run = RenderBlock::constructTextRun(m_text, style());
-        logicalWidth = font.width(run); // no suffix for these types
+    case ListStyleType::Footnotes:
+    case ListStyleType::String: {
+        if (!m_text.isEmpty()) {
+            TextRun run = RenderBlock::constructTextRun(m_text, style());
+            logicalWidth = font.width(run); // no suffix for these types
+        }
         break;
     }
     case ListStyleType::Circle:
@@ -1628,45 +1643,30 @@
             default:
                 break;
         }
+    } else if (isImage()) {
+        marginStart = -minPreferredLogicalWidth() - cMarkerPadding;
+        marginEnd = cMarkerPadding;
     } else {
-        if (style().isLeftToRightDirection()) {
-            if (isImage())
-                marginStart = -minPreferredLogicalWidth() - cMarkerPadding;
-            else {
-                int offset = fontMetrics.ascent() * 2 / 3;
-                switch (style().listStyleType()) {
-                case ListStyleType::Disc:
-                case ListStyleType::Circle:
-                case ListStyleType::Square:
-                    marginStart = -offset - cMarkerPadding - 1;
-                    break;
-                case ListStyleType::None:
-                    break;
-                default:
-                    marginStart = m_text.isEmpty() ? 0_lu : -minPreferredLogicalWidth() - offset / 2;
-                }
+        int offset = fontMetrics.ascent() * 2 / 3;
+        switch (style().listStyleType()) {
+        case ListStyleType::Disc:
+        case ListStyleType::Circle:
+        case ListStyleType::Square:
+            marginStart = -offset - cMarkerPadding - 1;
+            marginEnd = offset + cMarkerPadding + 1 - minPreferredLogicalWidth();
+            break;
+        case ListStyleType::None:
+            break;
+        case ListStyleType::String:
+            if (!m_text.isEmpty())
+                marginStart = -minPreferredLogicalWidth();
+            break;
+        default:
+            if (!m_text.isEmpty()) {
+                marginStart = -minPreferredLogicalWidth() - offset / 2;
+                marginEnd = offset / 2;
             }
-            marginEnd = -marginStart - minPreferredLogicalWidth();
-        } else {
-            if (isImage())
-                marginEnd = cMarkerPadding;
-            else {
-                int offset = fontMetrics.ascent() * 2 / 3;
-                switch (style().listStyleType()) {
-                case ListStyleType::Disc:
-                case ListStyleType::Circle:
-                case ListStyleType::Square:
-                    marginEnd = offset + cMarkerPadding + 1 - minPreferredLogicalWidth();
-                    break;
-                case ListStyleType::None:
-                    break;
-                default:
-                    marginEnd = m_text.isEmpty() ? 0 : offset / 2;
-                }
-            }
-            marginStart = -marginEnd - minPreferredLogicalWidth();
         }
-        
     }
 
     mutableStyle().setMarginStart(Length(marginStart, Fixed));
@@ -1690,6 +1690,9 @@
 String RenderListMarker::suffix() const
 {
     ListStyleType type = style().listStyleType();
+    if (type == ListStyleType::String)
+        return ""_str;
+
     const UChar suffix = listMarkerSuffix(type, m_listItem->value());
 
     if (suffix == ' ')
@@ -1722,7 +1725,10 @@
     ListStyleType type = style().listStyleType();
     switch (type) {
     case ListStyleType::Asterisks:
-    case ListStyleType::Footnotes: {
+    case ListStyleType::Footnotes:
+    case ListStyleType::String: {
+        if (m_text.isEmpty())
+            return FloatRect();
         const FontCascade& font = style().fontCascade();
         TextRun run = RenderBlock::constructTextRun(m_text, style());
         relativeRect = FloatRect(0, 0, font.width(run), font.fontMetrics().height());

Modified: trunk/Source/WebCore/rendering/style/CounterContent.h (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/CounterContent.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/CounterContent.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -37,6 +37,7 @@
         , m_listStyle(style)
         , m_separator(separator)
     {
+        ASSERT(style != ListStyleType::String);
     }
 
     const AtomString& identifier() const { return m_identifier; }

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -446,6 +446,7 @@
     EmptyCell emptyCells() const { return static_cast<EmptyCell>(m_inheritedFlags.emptyCells); }
     CaptionSide captionSide() const { return static_cast<CaptionSide>(m_inheritedFlags.captionSide); }
 
+    const AtomString& listStyleStringValue() const { return m_rareInheritedData->listStyleStringValue; }
     ListStyleType listStyleType() const { return static_cast<ListStyleType>(m_inheritedFlags.listStyleType); }
     StyleImage* listStyleImage() const;
     ListStylePosition listStylePosition() const { return static_cast<ListStylePosition>(m_inheritedFlags.listStylePosition); }
@@ -994,6 +995,7 @@
     void setAspectRatioDenominator(float v) { SET_VAR(m_rareNonInheritedData, aspectRatioDenominator, v); }
     void setAspectRatioNumerator(float v) { SET_VAR(m_rareNonInheritedData, aspectRatioNumerator, v); }
 
+    void setListStyleStringValue(const AtomString& s) { SET_VAR(m_rareInheritedData, listStyleStringValue, s); }
     void setListStyleType(ListStyleType v) { m_inheritedFlags.listStyleType = static_cast<unsigned>(v); }
     void setListStyleImage(RefPtr<StyleImage>&&);
     void setListStylePosition(ListStylePosition v) { m_inheritedFlags.listStylePosition = static_cast<unsigned>(v); }
@@ -1470,6 +1472,7 @@
     static LengthPoint initialObjectPosition() { return LengthPoint(Length(50.0f, Percent), Length(50.0f, Percent)); }
     static EmptyCell initialEmptyCells() { return EmptyCell::Show; }
     static ListStylePosition initialListStylePosition() { return ListStylePosition::Outside; }
+    static const AtomString& initialListStyleStringValue() { return nullAtom(); }
     static ListStyleType initialListStyleType() { return ListStyleType::Disc; }
     static TextTransform initialTextTransform() { return TextTransform::None; }
     static Visibility initialVisibility() { return Visibility::Visible; }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -758,6 +758,7 @@
     case ListStyleType::HiraganaIroha: ts << "hiragana-iroha"; break;
     case ListStyleType::KatakanaIroha: ts << "katakana-iroha"; break;
     case ListStyleType::None: ts << "none"; break;
+    case ListStyleType::String: ts << "string"; break;
     }
     return ts;
 }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -631,7 +631,8 @@
     Katakana,
     HiraganaIroha,
     KatakanaIroha,
-    None
+    None,
+    String
 };
 
 enum class QuoteType : uint8_t {

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp	2019-11-05 21:41:48 UTC (rev 252076)
@@ -42,7 +42,7 @@
     float firstFloat;
     Color colors[9];
     void* ownPtrs[1];
-    AtomString atomStrings[5];
+    AtomString atomStrings[6];
     void* refPtrs[3];
     Length lengths[2];
     float secondFloat;
@@ -75,6 +75,7 @@
 
 StyleRareInheritedData::StyleRareInheritedData()
     : listStyleImage(RenderStyle::initialListStyleImage())
+    , listStyleStringValue(RenderStyle::initialListStyleStringValue())
     , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
     , indent(RenderStyle::initialTextIndent())
     , effectiveZoom(RenderStyle::initialZoom())
@@ -163,6 +164,7 @@
 inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
     : RefCounted<StyleRareInheritedData>()
     , listStyleImage(o.listStyleImage)
+    , listStyleStringValue(o.listStyleStringValue)
     , textStrokeColor(o.textStrokeColor)
     , textStrokeWidth(o.textStrokeWidth)
     , textFillColor(o.textFillColor)
@@ -364,7 +366,8 @@
         && visitedLinkStrokeColor == o.visitedLinkStrokeColor
         && miterLimit == o.miterLimit
         && customProperties == o.customProperties
-        && arePointingToEqualData(listStyleImage, o.listStyleImage);
+        && arePointingToEqualData(listStyleImage, o.listStyleImage)
+        && listStyleStringValue == o.listStyleStringValue;
 }
 
 bool StyleRareInheritedData::hasColorFilters() const

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (252075 => 252076)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -68,6 +68,7 @@
     bool hasColorFilters() const;
 
     RefPtr<StyleImage> listStyleImage;
+    AtomString listStyleStringValue;
 
     Color textStrokeColor;
     float textStrokeWidth;

Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (252075 => 252076)


--- trunk/Source/WebCore/style/StyleBuilderCustom.h	2019-11-05 21:36:43 UTC (rev 252075)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h	2019-11-05 21:41:48 UTC (rev 252076)
@@ -89,6 +89,7 @@
 #if ENABLE(TEXT_AUTOSIZING)
     DECLARE_PROPERTY_CUSTOM_HANDLERS(LineHeight);
 #endif
+    DECLARE_PROPERTY_CUSTOM_HANDLERS(ListStyleType);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(OutlineStyle);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Size);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Stroke);
@@ -679,6 +680,30 @@
 
 #endif
 
+inline void BuilderCustom::applyInheritListStyleType(BuilderState& builderState)
+{
+    builderState.style().setListStyleType(builderState.parentStyle().listStyleType());
+    builderState.style().setListStyleStringValue(builderState.parentStyle().listStyleStringValue());
+}
+
+inline void BuilderCustom::applyInitialListStyleType(BuilderState& builderState)
+{
+    builderState.style().setListStyleType(RenderStyle::initialListStyleType());
+    builderState.style().setListStyleStringValue(RenderStyle::initialListStyleStringValue());
+}
+
+inline void BuilderCustom::applyValueListStyleType(BuilderState& builderState, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.isValueID()) {
+        builderState.style().setListStyleType(primitiveValue);
+        builderState.style().setListStyleStringValue(RenderStyle::initialListStyleStringValue());
+        return;
+    }
+    builderState.style().setListStyleType(ListStyleType::String);
+    builderState.style().setListStyleStringValue(primitiveValue.stringValue());
+}
+
 inline void BuilderCustom::applyInheritOutlineStyle(BuilderState& builderState)
 {
     builderState.style().setOutlineStyleIsAuto(builderState.parentStyle().outlineStyleIsAuto());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to