Title: [253158] trunk/Source/WebCore
Revision
253158
Author
[email protected]
Date
2019-12-05 11:26:32 -0800 (Thu, 05 Dec 2019)

Log Message

Add CSS parser support for the highlight pseudoelement
https://bugs.webkit.org/show_bug.cgi?id=204902

Reviewed by Antti Koivisto.

Add basic CSS parsing support for ::highlight(), per
https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/highlight/explainer.md

* css/CSSSelector.cpp:
(WebCore::CSSSelector::pseudoId):
(WebCore::CSSSelector::parsePseudoElementType):
* css/CSSSelector.h:
* css/SelectorPseudoElementTypeMap.in:
* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumePseudo):
* rendering/style/RenderStyleConstants.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253157 => 253158)


--- trunk/Source/WebCore/ChangeLog	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/ChangeLog	2019-12-05 19:26:32 UTC (rev 253158)
@@ -426,6 +426,25 @@
         (WebCore::hasHadRecentUserInteraction):
         (WebCore::ResourceLoadStatistics::toString const):
 
+2019-12-05  Simon Fraser  <[email protected]>
+
+        Add CSS parser support for the highlight pseudoelement
+        https://bugs.webkit.org/show_bug.cgi?id=204902
+
+        Reviewed by Antti Koivisto.
+
+        Add basic CSS parsing support for ::highlight(), per
+        https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/highlight/explainer.md
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId):
+        (WebCore::CSSSelector::parsePseudoElementType):
+        * css/CSSSelector.h:
+        * css/SelectorPseudoElementTypeMap.in:
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::CSSSelectorParser::consumePseudo):
+        * rendering/style/RenderStyleConstants.h:
+
 2019-12-04  Louie Livon-Bemel  <[email protected]>
 
         Add exclusion rule for text manipulation SPI to exclude based on element class

Modified: trunk/Source/WebCore/css/CSSSelector.cpp (253157 => 253158)


--- trunk/Source/WebCore/css/CSSSelector.cpp	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/css/CSSSelector.cpp	2019-12-05 19:26:32 UTC (rev 253158)
@@ -275,6 +275,8 @@
         return PseudoId::FirstLetter;
     case PseudoElementSelection:
         return PseudoId::Selection;
+    case PseudoElementHighlight:
+        return PseudoId::Highlight;
     case PseudoElementMarker:
         return PseudoId::Marker;
     case PseudoElementBefore:
@@ -314,11 +316,16 @@
 {
     if (name.isNull())
         return PseudoElementUnknown;
+
     auto type = parsePseudoElementString(name);
     if (type == PseudoElementUnknown) {
         if (name.startsWith("-webkit-"))
             type = PseudoElementWebKitCustom;
     }
+
+    if (type == PseudoElementHighlight && !RuntimeEnabledFeatures::sharedFeatures().highlightAPIEnabled())
+        return PseudoElementUnknown;
+
     if (type == PseudoElementPart && !RuntimeEnabledFeatures::sharedFeatures().cssShadowPartsEnabled())
         return PseudoElementUnknown;
 

Modified: trunk/Source/WebCore/css/CSSSelector.h (253157 => 253158)


--- trunk/Source/WebCore/css/CSSSelector.h	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/css/CSSSelector.h	2019-12-05 19:26:32 UTC (rev 253158)
@@ -181,6 +181,7 @@
 #endif
             PseudoElementFirstLetter,
             PseudoElementFirstLine,
+            PseudoElementHighlight,
             PseudoElementMarker,
             PseudoElementPart,
             PseudoElementResizer,

Modified: trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in (253157 => 253158)


--- trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/css/SelectorPseudoElementTypeMap.in	2019-12-05 19:26:32 UTC (rev 253158)
@@ -5,6 +5,7 @@
 #endif
 first-letter
 first-line
+highlight
 marker
 part
 placeholder, PseudoElementWebKitCustom

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (253157 => 253158)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2019-12-05 19:26:32 UTC (rev 253158)
@@ -611,7 +611,6 @@
         default:
             break;
         }
-
     }
     
     if (selector->match() == CSSSelector::PseudoElement) {
@@ -627,6 +626,17 @@
             return selector;
         }
 #endif
+        case CSSSelector::PseudoElementHighlight: {
+            DisallowPseudoElementsScope scope(this);
+
+            auto& ident = block.consumeIncludingWhitespace();
+            if (ident.type() != IdentToken)
+                return nullptr;
+
+            auto argumentList = makeUnique<Vector<AtomString>>();
+            argumentList->append(ident.value().toAtomString());
+            return selector;
+        }
         case CSSSelector::PseudoElementPart: {
             auto argumentList = makeUnique<Vector<AtomString>>();
             do {

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (253157 => 253158)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2019-12-05 19:26:29 UTC (rev 253157)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2019-12-05 19:26:32 UTC (rev 253158)
@@ -82,7 +82,7 @@
 };
 
 // Static pseudo styles. Dynamic ones are produced on the fly.
-enum class PseudoId : uint8_t {
+enum class PseudoId : uint16_t {
     // The order must be None, public IDs, and then internal IDs.
     None,
 
@@ -89,6 +89,7 @@
     // Public:
     FirstLine,
     FirstLetter,
+    Highlight,
     Marker,
     Before,
     After,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to