Title: [288016] trunk/Source/WebCore
Revision
288016
Author
[email protected]
Date
2022-01-14 07:21:32 -0800 (Fri, 14 Jan 2022)

Log Message

Stop forcing the creation of PseudoElement in KeyframeEffect
https://bugs.webkit.org/show_bug.cgi?id=235225

Reviewed by Antti Koivisto.

At the time we started supporting targeting pseudo-elements using the Web Animations API,
we resorted to some hack-ish code to enforce the creation of a PseudoElement should the
target of the animation be a ::before or ::after pseudo-element.

This isn't necessary, and was due to some incorrect code in
RenderTreeUpdater::GeneratedContent::updatePseudoElement() which this patch corrects.
Indeed, if there are animations targeting the pseudo-element in question, we should not
be removing the pseudo-element and exiting this method.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::didChangeTargetStyleable):
(WebCore::elementOrPseudoElementForStyleable): Deleted.
* rendering/updating/RenderTreeUpdaterGeneratedContent.cpp:
(WebCore::RenderTreeUpdater::GeneratedContent::updatePseudoElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288015 => 288016)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 13:40:15 UTC (rev 288015)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 15:21:32 UTC (rev 288016)
@@ -1,3 +1,25 @@
+2022-01-14  Antoine Quint  <[email protected]>
+
+        Stop forcing the creation of PseudoElement in KeyframeEffect
+        https://bugs.webkit.org/show_bug.cgi?id=235225
+
+        Reviewed by Antti Koivisto.
+
+        At the time we started supporting targeting pseudo-elements using the Web Animations API,
+        we resorted to some hack-ish code to enforce the creation of a PseudoElement should the
+        target of the animation be a ::before or ::after pseudo-element.
+
+        This isn't necessary, and was due to some incorrect code in
+        RenderTreeUpdater::GeneratedContent::updatePseudoElement() which this patch corrects.
+        Indeed, if there are animations targeting the pseudo-element in question, we should not
+        be removing the pseudo-element and exiting this method.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::didChangeTargetStyleable):
+        (WebCore::elementOrPseudoElementForStyleable): Deleted.
+        * rendering/updating/RenderTreeUpdaterGeneratedContent.cpp:
+        (WebCore::RenderTreeUpdater::GeneratedContent::updatePseudoElement):
+
 2022-01-14  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Incorrect root inline box position when non-empty atomic inline level child box has height: 0px

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (288015 => 288016)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-01-14 13:40:15 UTC (rev 288015)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-01-14 15:21:32 UTC (rev 288016)
@@ -69,21 +69,6 @@
 namespace WebCore {
 using namespace JSC;
 
-static Element* elementOrPseudoElementForStyleable(const std::optional<const Styleable>& styleable)
-{
-    if (!styleable)
-        return nullptr;
-
-    switch (styleable->pseudoId) {
-    case PseudoId::Before:
-        return styleable->element.beforePseudoElement();
-    case PseudoId::After:
-        return styleable->element.afterPseudoElement();
-    default:
-        return &styleable->element;
-    }
-}
-
 static inline void invalidateElement(const std::optional<const Styleable>& styleable)
 {
     if (styleable)
@@ -1354,15 +1339,6 @@
 {
     auto newTargetStyleable = targetStyleable();
 
-    // We must ensure a PseudoElement exists for this m_target / m_pseudoId pair if both are specified.
-    // FIXME: Ideally this wouldn't be necessary.
-    auto* newTargetElementOrPseudoElement = elementOrPseudoElementForStyleable(newTargetStyleable);
-    if (!newTargetElementOrPseudoElement && m_target.get() && m_pseudoId != PseudoId::None) {
-        // FIXME: We only support targeting ::before and ::after pseudo-elements at the moment.
-        if (m_pseudoId == PseudoId::Before || m_pseudoId == PseudoId::After)
-            newTargetElementOrPseudoElement = &m_target->ensurePseudoElement(m_pseudoId);
-    }
-
     if (auto* effectAnimation = animation())
         effectAnimation->effectTargetDidChange(previousTargetStyleable, newTargetStyleable);
 

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeUpdaterGeneratedContent.cpp (288015 => 288016)


--- trunk/Source/WebCore/rendering/updating/RenderTreeUpdaterGeneratedContent.cpp	2022-01-14 13:40:15 UTC (rev 288015)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeUpdaterGeneratedContent.cpp	2022-01-14 15:21:32 UTC (rev 288016)
@@ -121,7 +121,7 @@
         return nullptr;
     }();
 
-    if (!needsPseudoElement(update) && (!pseudoElement || !elementIsTargetedByKeyframeEffectRequiringPseudoElement(pseudoElement, pseudoId))) {
+    if (!needsPseudoElement(update) && !elementIsTargetedByKeyframeEffectRequiringPseudoElement(&current, pseudoId)) {
         if (pseudoElement) {
             if (pseudoId == PseudoId::Before)
                 removeBeforePseudoElement(current, m_updater.m_builder);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to