Implement the imageready event to reliably test the async image decoding
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 May 2017 23:21:12 +0000 (23:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 May 2017 23:21:12 +0000 (23:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171016

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-05-03
Reviewed by Simon Fraser.

The event will be fired for each client of the image. Firing the event
will happen after finishing the decoding and repainting the client.

Existing tests will be modified in a separate patch to use this event.

* dom/Element.cpp:
(WebCore::Element::dispatchWebKitImageReadyEventForTesting):
* dom/Element.h:
* page/Settings.in:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::imageFrameAvailable):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216154 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/page/Settings.in
Source/WebCore/rendering/RenderElement.cpp

index 26940b6..df44785 100644 (file)
@@ -1,3 +1,22 @@
+2017-05-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Implement the imageready event to reliably test the async image decoding
+        https://bugs.webkit.org/show_bug.cgi?id=171016
+
+        Reviewed by Simon Fraser.
+
+        The event will be fired for each client of the image. Firing the event
+        will happen after finishing the decoding and repainting the client.
+
+        Existing tests will be modified in a separate patch to use this event.
+
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchWebKitImageReadyEventForTesting):
+        * dom/Element.h:
+        * page/Settings.in:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::imageFrameAvailable):
+
 2017-05-03  Tim Horton  <timothy_horton@apple.com>
 
         Maintain interaction information URL as a URL, not a string
index 81bc731..1fceda1 100644 (file)
@@ -2508,6 +2508,12 @@ void Element::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
     EventDispatcher::dispatchEvent(*this, FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, WTFMove(newFocusedElement)));
 }
 
+void Element::dispatchWebKitImageReadyEventForTesting()
+{
+    if (document().settings().webkitImageReadyEventEnabled())
+        dispatchEvent(Event::create("webkitImageFrameReady", true, true));
+}
+
 bool Element::dispatchMouseForceWillBegin()
 {
 #if ENABLE(MOUSE_FORCE_EVENTS)
index 13c975c..56fadb4 100644 (file)
@@ -491,6 +491,7 @@ public:
     void dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement);
     virtual void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection);
     virtual void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement);
+    void dispatchWebKitImageReadyEventForTesting();
 
     WEBCORE_EXPORT bool dispatchMouseForceWillBegin();
 
index 6b64f83..db9c51d 100644 (file)
@@ -285,6 +285,7 @@ forcedPrefersReducedMotionAccessibilityValue type=ForcedAccessibilityValue, init
 
 largeImageAsyncDecodingEnabled initial=true
 animatedImageAsyncDecodingEnabled initial=true
+webkitImageReadyEventEnabled initial=false
 
 shouldSuppressKeyboardInputDuringProvisionalNavigation initial=false
 
index 8303c88..2ef261f 100644 (file)
@@ -1508,6 +1508,9 @@ VisibleInViewportState RenderElement::imageFrameAvailable(CachedImage& image, Im
     if (shouldRepaint || animatingState == ImageAnimatingState::No)
         imageChanged(&image, changeRect);
 
+    if (element() && image.image()->isBitmapImage())
+        element()->dispatchWebKitImageReadyEventForTesting();
+
     return shouldRepaint ? VisibleInViewportState::Yes : VisibleInViewportState::No;
 }