Web Inspector: Canvas: support recording TypedOMCSSImageValue
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 20:32:39 +0000 (20:32 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 20:32:39 +0000 (20:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192609

Reviewed by Timothy Hatcher.

* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::indexForData):
(WebCore::InspectorCanvas::buildAction):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorCanvas.cpp
Source/WebCore/inspector/InspectorCanvas.h

index b70d5cd..7f967c9 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-23  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: support recording TypedOMCSSImageValue
+        https://bugs.webkit.org/show_bug.cgi?id=192609
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/InspectorCanvas.h:
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::indexForData):
+        (WebCore::InspectorCanvas::buildAction):
+
 2019-04-23  Andres Gonzalez  <andresg_22@apple.com>
 
         Accessibility text search and selection API enhancements.
index 96f7a24..f4e0fce 100644 (file)
@@ -57,6 +57,9 @@
 #include "RecordingSwizzleTypes.h"
 #include "SVGPathUtilities.h"
 #include "StringAdaptors.h"
+#if ENABLE(CSS_TYPED_OM)
+#include "TypedOMCSSImageValue.h"
+#endif
 #if ENABLE(WEBGL)
 #include "WebGLRenderingContext.h"
 #endif
@@ -454,6 +457,22 @@ int InspectorCanvas::indexForData(DuplicateDataVariant data)
                 array->addItem(indexForData(scriptCallStack->at(i)));
             item = WTFMove(array);
         },
+#if ENABLE(CSS_TYPED_OM)
+        [&] (const RefPtr<TypedOMCSSImageValue>& cssImageValue) {
+            String dataURL = "data:,"_s;
+
+            if (auto* cachedImage = cssImageValue->image()) {
+                auto* image = cachedImage->image();
+                if (image && image != &Image::nullImage()) {
+                    auto imageBuffer = ImageBuffer::create(image->size(), RenderingMode::Unaccelerated);
+                    imageBuffer->context().drawImage(*image, FloatPoint(0, 0));
+                    dataURL = imageBuffer->toDataURL("image/png");
+                }
+            }
+
+            index = indexForData(dataURL);
+        },
+#endif
         [&] (const ScriptCallFrame& scriptCallFrame) {
             auto array = JSON::ArrayOf<double>::create();
             array->addItem(indexForData(scriptCallFrame.functionName()));
@@ -664,8 +683,7 @@ Ref<JSON::ArrayOf<JSON::Value>> InspectorCanvas::buildAction(const String& name,
             [&] (const RefPtr<HTMLVideoElement>& value) { addParameter(indexForData(value), RecordingSwizzleTypes::Image); },
 #endif
 #if ENABLE(CSS_TYPED_OM)
-            // FIXME implement: <https://bugs.webkit.org/show_bug.cgi?id=192609>.
-            [&] (const RefPtr<TypedOMCSSImageValue>&) { },
+            [&] (const RefPtr<TypedOMCSSImageValue>& value) { addParameter(indexForData(value), RecordingSwizzleTypes::Image); },
 #endif
             [&] (const RefPtr<ImageBitmap>& value) { addParameter(indexForData(value), RecordingSwizzleTypes::ImageBitmap); },
             [&] (const RefPtr<ImageData>& value) { addParameter(indexForData(value), RecordingSwizzleTypes::ImageData); },
index 26c8671..45a43d4 100644 (file)
@@ -43,6 +43,9 @@ class HTMLImageElement;
 class HTMLVideoElement;
 class ImageBitmap;
 class ImageData;
+#if ENABLE(CSS_TYPED_OM)
+class TypedOMCSSImageValue;
+#endif
 
 typedef String ErrorString;
 
@@ -94,6 +97,9 @@ private:
         RefPtr<ImageData>,
         RefPtr<ImageBitmap>,
         RefPtr<Inspector::ScriptCallStack>,
+#if ENABLE(CSS_TYPED_OM)
+        RefPtr<TypedOMCSSImageValue>,
+#endif
         Inspector::ScriptCallFrame,
         String
     >;