Changeset 243304 in webkit
- Timestamp:
- Mar 21, 2019, 11:33:11 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
page/animation/AnimationBase.h (modified) (1 diff)
-
page/animation/ImplicitAnimation.cpp (modified) (5 diffs)
-
page/animation/ImplicitAnimation.h (modified) (1 diff)
-
page/ios/ContentChangeObserver.cpp (modified) (3 diffs)
-
page/ios/ContentChangeObserver.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243303 r243304 1 2019-03-21 Zalan Bujtas <zalan@apple.com> 2 3 [ContentChangeObserver] Add support for observing implicit transitions 4 https://bugs.webkit.org/show_bug.cgi?id=195914 5 <rdar://problem/49091959> 6 7 Reviewed by Simon Fraser. 8 9 This patch is in preparation for observing elements with property "left" implicit transitions. 10 11 This is not a continuous tracking, we are only interested in the start and the end state. 12 The idea here is to register hidden elements only and check if they become visible by 13 the end of the transition (and ignore if the transition gets "canceled"). 14 15 * page/animation/AnimationBase.h: 16 * page/animation/ImplicitAnimation.cpp: 17 (WebCore::ImplicitAnimation::ImplicitAnimation): 18 (WebCore::ImplicitAnimation::~ImplicitAnimation): 19 (WebCore::ImplicitAnimation::clear): 20 (WebCore::ImplicitAnimation::onAnimationEnd): 21 * page/animation/ImplicitAnimation.h: 22 * page/ios/ContentChangeObserver.cpp: 23 (WebCore::ContentChangeObserver::didAddTransition): 24 (WebCore::ContentChangeObserver::removeTransitionIfNeeded): 25 (WebCore::ContentChangeObserver::didFinishTransition): 26 (WebCore::ContentChangeObserver::didRemoveTransition): 27 (WebCore::ContentChangeObserver::didInstallDOMTimer): 28 * page/ios/ContentChangeObserver.h: 29 (WebCore::ContentChangeObserver::isObservingTransitions const): 30 (WebCore::ContentChangeObserver::isObservedPropertyForTransition const): 31 1 32 2019-03-21 Devin Rousso <drousso@apple.com> 2 33 -
trunk/Source/WebCore/page/animation/AnimationBase.h
r243112 r243304 62 62 const RenderStyle& currentStyle() const override; 63 63 RenderElement* renderer() const override; 64 v oid clear();64 virtual void clear(); 65 65 66 66 double duration() const; -
trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp
r243112 r243304 33 33 #include "CSSPropertyAnimation.h" 34 34 #include "CompositeAnimation.h" 35 #if PLATFORM(IOS_FAMILY) 36 #include "ContentChangeObserver.h" 37 #endif 35 38 #include "EventNames.h" 36 39 #include "GeometryUtilities.h" … … 47 50 , m_animatingProperty(animatingProperty) 48 51 { 52 #if PLATFORM(IOS_FAMILY) 53 element.document().contentChangeObserver().didAddTransition(element, transition); 54 #endif 49 55 ASSERT(animatingProperty != CSSPropertyInvalid); 50 56 } … … 52 58 ImplicitAnimation::~ImplicitAnimation() 53 59 { 60 #if PLATFORM(IOS_FAMILY) 61 if (auto* element = this->element()) 62 element->document().contentChangeObserver().didRemoveTransition(*element, m_animatingProperty); 63 #endif 54 64 // // Make sure to tell the renderer that we are ending. This will make sure any accelerated animations are removed. 55 65 if (!postActive()) … … 159 169 } 160 170 171 void ImplicitAnimation::clear() 172 { 173 #if PLATFORM(IOS_FAMILY) 174 if (auto* element = this->element()) 175 element->document().contentChangeObserver().didRemoveTransition(*element, m_animatingProperty); 176 #endif 177 AnimationBase::clear(); 178 } 179 161 180 void ImplicitAnimation::endAnimation(bool) 162 181 { … … 167 186 void ImplicitAnimation::onAnimationEnd(double elapsedTime) 168 187 { 188 #if PLATFORM(IOS_FAMILY) 189 if (auto* element = this->element()) 190 element->document().contentChangeObserver().didFinishTransition(*element, m_animatingProperty); 191 #endif 169 192 // If we have a keyframe animation on this property, this transition is being overridden. The keyframe 170 193 // animation keeps an unanimated style in case a transition starts while the keyframe animation is -
trunk/Source/WebCore/page/animation/ImplicitAnimation.h
r240012 r243304 80 80 const RenderStyle& unanimatedStyle() const override { return *m_fromStyle; } 81 81 82 void clear() override; 83 82 84 protected: 83 85 bool shouldSendEventForListener(Document::ListenerType) const; -
trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp
r243017 r243304 40 40 namespace WebCore { 41 41 42 static const Seconds maximumDelayForTimers { 300_ms }; 43 static const Seconds maximumDelayForTransitions { 300_ms }; 44 42 45 ContentChangeObserver::ContentChangeObserver(Document& document) 43 46 : m_document(document) … … 82 85 } 83 86 87 void ContentChangeObserver::didAddTransition(const Element& element, const Animation& transition) 88 { 89 if (!m_document.settings().contentChangeObserverEnabled()) 90 return; 91 if (hasVisibleChangeState()) 92 return; 93 if (!isObservingTransitions()) 94 return; 95 if (!transition.isDurationSet() || !transition.isPropertySet()) 96 return; 97 if (!isObservedPropertyForTransition(transition.property())) 98 return; 99 auto transitionEnd = Seconds { transition.duration() + std::max<double>(0, transition.isDelaySet() ? transition.delay() : 0) }; 100 if (transitionEnd > maximumDelayForTransitions) 101 return; 102 LOG_WITH_STREAM(ContentObservation, stream << "didAddTransition: transition created on " << &element << " (" << transitionEnd.milliseconds() << "ms)."); 103 104 m_elementsWithTransition.add(&element); 105 // FIXME: report state change. 106 } 107 108 void ContentChangeObserver::didFinishTransition(const Element& element, CSSPropertyID propertyID) 109 { 110 if (!isObservedPropertyForTransition(propertyID)) 111 return; 112 if (!m_elementsWithTransition.take(&element)) 113 return; 114 LOG_WITH_STREAM(ContentObservation, stream << "didFinishTransition: transition finished (" << &element << ")."); 115 // FIXME: report state change. 116 } 117 118 void ContentChangeObserver::didRemoveTransition(const Element& element, CSSPropertyID propertyID) 119 { 120 if (!isObservedPropertyForTransition(propertyID)) 121 return; 122 if (!m_elementsWithTransition.take(&element)) 123 return; 124 LOG_WITH_STREAM(ContentObservation, stream << "didRemoveTransition: transition got interrupted (" << &element << ")."); 125 // FIXME: report state change. 126 } 127 84 128 void ContentChangeObserver::didInstallDOMTimer(const DOMTimer& timer, Seconds timeout, bool singleShot) 85 129 { … … 88 132 if (m_document.activeDOMObjectsAreSuspended()) 89 133 return; 90 if (timeout > 300_ms || !singleShot)134 if (timeout > maximumDelayForTimers || !singleShot) 91 135 return; 92 136 if (!isObservingDOMTimerScheduling()) -
trunk/Source/WebCore/page/ios/ContentChangeObserver.h
r243290 r243304 31 31 #include "Timer.h" 32 32 #include "WKContentObservation.h" 33 #include <wtf/HashSet.h> 33 34 34 35 namespace WebCore { 35 36 37 class Animation; 36 38 class DOMTimer; 37 39 class Document; … … 47 49 void didInstallDOMTimer(const DOMTimer&, Seconds timeout, bool singleShot); 48 50 void didRemoveDOMTimer(const DOMTimer&); 51 52 void didAddTransition(const Element&, const Animation&); 53 void didFinishTransition(const Element&, CSSPropertyID); 54 void didRemoveTransition(const Element&, CSSPropertyID); 55 49 56 WEBCORE_EXPORT void willNotProceedWithClick(); 50 57 WEBCORE_EXPORT static void didRecognizeLongPress(Frame& mainFrame); … … 115 122 void setShouldObserveDOMTimerScheduling(bool observe) { m_isObservingDOMTimerScheduling = observe; } 116 123 bool isObservingDOMTimerScheduling() const { return m_isObservingDOMTimerScheduling; } 124 bool isObservingTransitions() const { return m_isObservingTransitions; } 125 bool isObservedPropertyForTransition(CSSPropertyID propertyId) const { return propertyId == CSSPropertyLeft; } 117 126 void domTimerExecuteDidStart(const DOMTimer&); 118 127 void domTimerExecuteDidFinish(const DOMTimer&); … … 168 177 Timer m_contentObservationTimer; 169 178 HashSet<const DOMTimer*> m_DOMTimerList; 179 // FIXME: Move over to WeakHashSet when it starts supporting const. 180 HashSet<const Element*> m_elementsWithTransition; 170 181 bool m_touchEventIsBeingDispatched { false }; 171 182 bool m_isWaitingForStyleRecalc { false }; … … 175 186 bool m_mouseMovedEventIsBeingDispatched { false }; 176 187 bool m_isBetweenTouchEndAndMouseMoved { false }; 188 bool m_isObservingTransitions { false }; 177 189 }; 178 190
Note:
See TracChangeset
for help on using the changeset viewer.