Changeset 269623 in webkit


Ignore:
Timestamp:
Nov 10, 2020 3:35:51 AM (21 months ago)
Author:
graouts@webkit.org
Message:

[Web Animations] KeyframeEffect.pseudoElement does not return a valid string when targeting ::marker or ::first-letter
https://bugs.webkit.org/show_bug.cgi?id=218741
<rdar://problem/71229846>

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Mark two new PASS results showing that KeyframeEffect.pseudoElement shows the correct value
when targeting ::marker or ::first-letter.

  • web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt:

Source/WebCore:

We used to use PseudoElement::pseudoElementNameForEvents() to go from PseudoId to a String, but PseudoElement
only knows about ::before and ::after and not about valid pseudo-elements. We remove that method and create an
equivalent in WebAnimationUtilities that knows about all public pseudo-elements.

  • animation/DeclarativeAnimation.cpp:

(WebCore::DeclarativeAnimation::enqueueDOMEvent):

  • animation/KeyframeEffect.cpp:

(WebCore::KeyframeEffect::pseudoElement const):

  • animation/WebAnimationUtilities.cpp:

(WebCore::pseudoIdAsString):

  • animation/WebAnimationUtilities.h:
  • dom/PseudoElement.cpp:

(WebCore::PseudoElement::pseudoElementNameForEvents): Deleted.

  • dom/PseudoElement.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r269612 r269623  
     12020-11-10  Antoine Quint  <graouts@webkit.org>
     2
     3        [Web Animations] KeyframeEffect.pseudoElement does not return a valid string when targeting ::marker or ::first-letter
     4        https://bugs.webkit.org/show_bug.cgi?id=218741
     5        <rdar://problem/71229846>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Mark two new PASS results showing that KeyframeEffect.pseudoElement shows the correct value
     10        when targeting ::marker or ::first-letter.
     11
     12        * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt:
     13
    1142020-11-09  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt

    r267649 r269623  
    144144PASS animate() with pseudoElement an Animation object targeting the correct pseudo-element
    145145PASS animate() with pseudoElement without content creates an Animation object targeting the correct pseudo-element
    146 FAIL animate() with pseudoElement an Animation object targeting the correct pseudo-element for ::marker assert_equals: The returned Animation targets the correct selector expected "::marker" but got ""
    147 FAIL animate() with pseudoElement an Animation object targeting the correct pseudo-element for ::first-line assert_equals: The returned Animation targets the correct selector expected "::first-line" but got ""
     146PASS animate() with pseudoElement an Animation object targeting the correct pseudo-element for ::marker
     147PASS animate() with pseudoElement an Animation object targeting the correct pseudo-element for ::first-line
    148148PASS animate() with a non-null invalid pseudoElement '' throws a SyntaxError
    149149PASS animate() with a non-null invalid pseudoElement 'before' throws a SyntaxError
  • trunk/Source/WebCore/ChangeLog

    r269622 r269623  
     12020-11-10  Antoine Quint  <graouts@webkit.org>
     2
     3        [Web Animations] KeyframeEffect.pseudoElement does not return a valid string when targeting ::marker or ::first-letter
     4        https://bugs.webkit.org/show_bug.cgi?id=218741
     5        <rdar://problem/71229846>
     6
     7        Reviewed by Dean Jackson.
     8
     9        We used to use PseudoElement::pseudoElementNameForEvents() to go from PseudoId to a String, but PseudoElement
     10        only knows about ::before and ::after and not about valid pseudo-elements. We remove that method and create an
     11        equivalent in WebAnimationUtilities that knows about all public pseudo-elements.
     12
     13        * animation/DeclarativeAnimation.cpp:
     14        (WebCore::DeclarativeAnimation::enqueueDOMEvent):
     15        * animation/KeyframeEffect.cpp:
     16        (WebCore::KeyframeEffect::pseudoElement const):
     17        * animation/WebAnimationUtilities.cpp:
     18        (WebCore::pseudoIdAsString):
     19        * animation/WebAnimationUtilities.h:
     20        * dom/PseudoElement.cpp:
     21        (WebCore::PseudoElement::pseudoElementNameForEvents): Deleted.
     22        * dom/PseudoElement.h:
     23
    1242020-11-10  Martin Robinson  <mrobinson@igalia.com>
    225
  • trunk/Source/WebCore/animation/DeclarativeAnimation.cpp

    r267571 r269623  
    351351
    352352    auto time = secondsToWebAnimationsAPITime(elapsedTime) / 1000;
    353     const auto& pseudoId = PseudoElement::pseudoElementNameForEvents(m_owningPseudoId);
     353    auto pseudoId = pseudoIdAsString(m_owningPseudoId);
    354354    auto timelineTime = timeline() ? timeline()->currentTime() : WTF::nullopt;
    355355    auto event = createEvent(eventType, time, pseudoId, timelineTime);
  • trunk/Source/WebCore/animation/KeyframeEffect.cpp

    r268932 r269623  
    11781178    // When the effect target is a pseudo-element, this specifies the pseudo-element selector (e.g. ::before).
    11791179    if (targetsPseudoElement())
    1180         return PseudoElement::pseudoElementNameForEvents(m_pseudoId);
     1180        return pseudoIdAsString(m_pseudoId);
    11811181    return { };
    11821182}
  • trunk/Source/WebCore/animation/WebAnimationUtilities.cpp

    r267571 r269623  
    179179}
    180180
     181String pseudoIdAsString(PseudoId pseudoId)
     182{
     183    static NeverDestroyed<const String> after(MAKE_STATIC_STRING_IMPL("::after"));
     184    static NeverDestroyed<const String> before(MAKE_STATIC_STRING_IMPL("::before"));
     185    static NeverDestroyed<const String> firstLetter(MAKE_STATIC_STRING_IMPL("::first-letter"));
     186    static NeverDestroyed<const String> firstLine(MAKE_STATIC_STRING_IMPL("::first-line"));
     187    static NeverDestroyed<const String> highlight(MAKE_STATIC_STRING_IMPL("::highlight"));
     188    static NeverDestroyed<const String> marker(MAKE_STATIC_STRING_IMPL("::marker"));
     189    static NeverDestroyed<const String> selection(MAKE_STATIC_STRING_IMPL("::selection"));
     190    static NeverDestroyed<const String> scrollbar(MAKE_STATIC_STRING_IMPL("::scrollbar"));
     191    switch (pseudoId) {
     192    case PseudoId::After:
     193        return after;
     194    case PseudoId::Before:
     195        return before;
     196    case PseudoId::FirstLetter:
     197        return firstLetter;
     198    case PseudoId::FirstLine:
     199        return firstLine;
     200    case PseudoId::Highlight:
     201        return highlight;
     202    case PseudoId::Marker:
     203        return marker;
     204    case PseudoId::Selection:
     205        return selection;
     206    case PseudoId::Scrollbar:
     207        return scrollbar;
     208    default:
     209        return emptyString();
     210    }
     211}
     212
    181213} // namespace WebCore
  • trunk/Source/WebCore/animation/WebAnimationUtilities.h

    r261470 r269623  
    5252
    5353bool compareAnimationsByCompositeOrder(const WebAnimation&, const WebAnimation&);
     54String pseudoIdAsString(PseudoId);
    5455
    5556} // namespace WebCore
  • trunk/Source/WebCore/dom/PseudoElement.cpp

    r267571 r269623  
    4949}
    5050
    51 String PseudoElement::pseudoElementNameForEvents(PseudoId pseudoId)
    52 {
    53     static NeverDestroyed<const String> after(MAKE_STATIC_STRING_IMPL("::after"));
    54     static NeverDestroyed<const String> before(MAKE_STATIC_STRING_IMPL("::before"));
    55     switch (pseudoId) {
    56     case PseudoId::After:
    57         return after;
    58     case PseudoId::Before:
    59         return before;
    60     default:
    61         return emptyString();
    62     }
    63 }
    64 
    6551PseudoElement::PseudoElement(Element& host, PseudoId pseudoId)
    6652    : Element(pseudoElementTagName(), host.document(), CreatePseudoElement)
  • trunk/Source/WebCore/dom/PseudoElement.h

    r260139 r269623  
    4747    bool canContainRangeEndPoint() const override { return false; }
    4848
    49     static String pseudoElementNameForEvents(PseudoId);
    50 
    5149private:
    5250    PseudoElement(Element&, PseudoId);
Note: See TracChangeset for help on using the changeset viewer.