Diff
Modified: trunk/Source/WebCore/ChangeLog (160201 => 160202)
--- trunk/Source/WebCore/ChangeLog 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebCore/ChangeLog 2013-12-06 00:57:43 UTC (rev 160202)
@@ -1,3 +1,22 @@
+2013-12-05 Brian J. Burg <[email protected]>
+
+ Web Inspector: expose node and frame snapshot capabilities.
+ https://bugs.webkit.org/show_bug.cgi?id=124326
+
+ Reviewed by Joseph Pecoraro.
+
+ This adds snapshotRect() and snapshotNode() to the Page domain.
+ Both methods create snapshots using FrameSnapshotting APIs
+ and send images to the inspector frontend as a data URL.
+
+ Remove the unimplemented Page.captureScreenshot API.
+
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::snapshotNode): Added.
+ (WebCore::InspectorPageAgent::snapshotRect): Added.
+ * inspector/InspectorPageAgent.h:
+ * inspector/protocol/Page.json: Added new protocol APIs.
+
2013-12-04 Bear Travis <[email protected]>
[CSS Shapes] Enable CSS Shapes on Windows
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (160201 => 160202)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-12-06 00:57:43 UTC (rev 160202)
@@ -51,15 +51,18 @@
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "FrameSnapshotting.h"
#include "FrameView.h"
#include "GeolocationController.h"
#include "GeolocationError.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLNames.h"
#include "IdentifiersFactory.h"
+#include "ImageBuffer.h"
#include "InjectedScriptManager.h"
#include "InspectorAgent.h"
#include "InspectorClient.h"
+#include "InspectorDOMAgent.h"
#include "InspectorFrontend.h"
#include "InspectorInstrumentation.h"
#include "InspectorOverlay.h"
@@ -1251,12 +1254,46 @@
m_page->settings().setShowRepaintCounter(visible);
}
-void InspectorPageAgent::captureScreenshot(ErrorString* errorString, String* data)
+void InspectorPageAgent::snapshotNode(ErrorString* errorString, int nodeId, String* outDataURL)
{
- if (!m_client->captureScreenshot(data))
- *errorString = "Could not capture screenshot";
+ Frame* frame = mainFrame();
+ ASSERT(frame);
+
+ InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent();
+ ASSERT(domAgent);
+ Node* node = domAgent->assertNode(errorString, nodeId);
+ if (!node)
+ return;
+
+ std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode(*frame, *node);
+ if (!snapshot) {
+ *errorString = ASCIILiteral("Could not capture snapshot");
+ return;
+ }
+
+ *outDataURL = snapshot->toDataURL(ASCIILiteral("image/png"));
}
+void InspectorPageAgent::snapshotRect(ErrorString* errorString, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL)
+{
+ Frame* frame = mainFrame();
+ ASSERT(frame);
+
+ SnapshotOptions options = SnapshotOptionsNone;
+ if (coordinateSystem == "Viewport")
+ options |= SnapshotOptionsInViewCoordinates;
+
+ IntRect rectangle(x, y, width, height);
+ std::unique_ptr<ImageBuffer> snapshot = snapshotFrameRect(*frame, rectangle, options);
+
+ if (!snapshot) {
+ *errorString = ASCIILiteral("Could not capture snapshot");
+ return;
+ }
+
+ *outDataURL = snapshot->toDataURL(ASCIILiteral("image/png"));
+}
+
void InspectorPageAgent::handleJavaScriptDialog(ErrorString* errorString, bool accept, const String* promptText)
{
if (!m_client->handleJavaScriptDialog(accept, promptText))
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (160201 => 160202)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-12-06 00:57:43 UTC (rev 160202)
@@ -129,7 +129,8 @@
virtual void setEmulatedMedia(ErrorString*, const String&);
virtual void getCompositingBordersVisible(ErrorString*, bool* out_param);
virtual void setCompositingBordersVisible(ErrorString*, bool);
- virtual void captureScreenshot(ErrorString*, String* data);
+ virtual void snapshotNode(ErrorString*, int nodeId, String* outDataURL);
+ virtual void snapshotRect(ErrorString*, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL);
virtual void handleJavaScriptDialog(ErrorString*, bool accept, const String* promptText);
virtual void archive(ErrorString*, String* data);
Modified: trunk/Source/WebCore/inspector/protocol/Page.json (160201 => 160202)
--- trunk/Source/WebCore/inspector/protocol/Page.json 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebCore/inspector/protocol/Page.json 2013-12-06 00:57:43 UTC (rev 160202)
@@ -9,6 +9,12 @@
"description": "Resource type as it was perceived by the rendering engine."
},
{
+ "id": "CoordinateSystem",
+ "type": "string",
+ "enum": ["Viewport", "Page"],
+ "description": "Coordinate system used by supplied coordinates."
+ },
+ {
"id": "Frame",
"type": "object",
"description": "Information about the Frame on the page.",
@@ -344,13 +350,30 @@
]
},
{
- "name": "captureScreenshot",
- "description": "Capture page screenshot.",
+ "name": "snapshotNode",
+ "description": "Capture a snapshot of the specified node that does not include unrelated layers.",
+ "parameters": [
+ { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Id of the node to snapshot." }
+ ],
"returns": [
- { "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." }
+ { "name": "dataURL", "type": "string", "description": "Base64-encoded image data (PNG)." }
]
},
{
+ "name": "snapshotRect",
+ "description": "Capture a snapshot of the page within the specified rectangle and coordinate system.",
+ "parameters": [
+ { "name": "x", "type": "integer", "description": "X coordinate" },
+ { "name": "y", "type": "integer", "description": "Y coordinate" },
+ { "name": "width", "type": "integer", "description": "Rectangle width" },
+ { "name": "height", "type": "integer", "description": "Rectangle height" },
+ { "name": "coordinateSystem", "$ref": "CoordinateSystem", "description": "Indicates the coordinate system of the supplied rectangle." }
+ ],
+ "returns": [
+ { "name": "dataURL", "type": "string", "description": "Base64-encoded image data (PNG)." }
+ ]
+ },
+ {
"name": "handleJavaScriptDialog",
"description": "Accepts or dismisses a _javascript_ initiated dialog (alert, confirm, prompt, or onbeforeunload).",
"parameters": [
Modified: trunk/Source/WebInspectorUI/ChangeLog (160201 => 160202)
--- trunk/Source/WebInspectorUI/ChangeLog 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebInspectorUI/ChangeLog 2013-12-06 00:57:43 UTC (rev 160202)
@@ -1,3 +1,15 @@
+2013-12-05 Brian J. Burg <[email protected]>
+
+ Web Inspector: expose node and frame snapshot capabilities.
+ https://bugs.webkit.org/show_bug.cgi?id=124326
+
+ Reviewed by Joseph Pecoraro.
+
+ Add method signatures for snapshotNode() and snapshotRect().
+ Remove method signature for unimplemented Page.captureScreenshot.
+
+ * UserInterface/InspectorBackendCommands.js:
+
2013-12-05 Alexandru Chiculita <[email protected]>
Web Inspector: [CSS Regions] Show a list of containing regions when clicking a node that is part of a flow
Modified: trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js (160201 => 160202)
--- trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js 2013-12-06 00:57:43 UTC (rev 160202)
@@ -1,5 +1,6 @@
// File is generated by Source/WebCore/inspector/CodeGeneratorInspector.py
+// Copyright (c) 2013 Apple Inc. All Rights Reserved.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -289,6 +290,7 @@
// Page.
InspectorBackend.registerPageDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Page");
InspectorBackend.registerEnum("Page.ResourceType", {Document: "Document", Stylesheet: "Stylesheet", Image: "Image", Font: "Font", Script: "Script", XHR: "XHR", WebSocket: "WebSocket", Other: "Other"});
+InspectorBackend.registerEnum("Page.CoordinateSystem", {Viewport: "Viewport", Page: "Page"});
InspectorBackend.registerEvent("Page.domContentEventFired", ["timestamp"]);
InspectorBackend.registerEvent("Page.loadEventFired", ["timestamp"]);
InspectorBackend.registerEvent("Page.frameNavigated", ["frame"]);
@@ -334,7 +336,8 @@
InspectorBackend.registerCommand("Page.setEmulatedMedia", [{"name": "media", "type": "string", "optional": false}], []);
InspectorBackend.registerCommand("Page.getCompositingBordersVisible", [], ["result"]);
InspectorBackend.registerCommand("Page.setCompositingBordersVisible", [{"name": "visible", "type": "boolean", "optional": false}], []);
-InspectorBackend.registerCommand("Page.captureScreenshot", [], ["data"]);
+InspectorBackend.registerCommand("Page.snapshotNode", [{"name": "nodeId", "type": "number", "optional": false}], ["dataURL"]);
+InspectorBackend.registerCommand("Page.snapshotRect", [{"name": "x", "type": "number", "optional": false}, {"name": "y", "type": "number", "optional": false}, {"name": "width", "type": "number", "optional": false}, {"name": "height", "type": "number", "optional": false}, {"name": "coordinateSystem", "type": "string", "optional": false}], ["dataURL"]);
InspectorBackend.registerCommand("Page.handleJavaScriptDialog", [{"name": "accept", "type": "boolean", "optional": false}, {"name": "promptText", "type": "string", "optional": true}], []);
InspectorBackend.registerCommand("Page.archive", [], ["data"]);
Modified: trunk/Source/WebInspectorUI/UserInterface/Legacy/7.0/InspectorBackendCommands.js (160201 => 160202)
--- trunk/Source/WebInspectorUI/UserInterface/Legacy/7.0/InspectorBackendCommands.js 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebInspectorUI/UserInterface/Legacy/7.0/InspectorBackendCommands.js 2013-12-06 00:57:43 UTC (rev 160202)
@@ -1,5 +1,6 @@
// File is generated by Source/WebCore/inspector/CodeGeneratorInspector.py
+// Copyright (c) 2013 Apple Inc. All Rights Reserved.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -66,7 +67,6 @@
InspectorBackend.registerCommand("Page.setEmulatedMedia", [{"name": "media", "type": "string", "optional": false}], []);
InspectorBackend.registerCommand("Page.getCompositingBordersVisible", [], ["result"]);
InspectorBackend.registerCommand("Page.setCompositingBordersVisible", [{"name": "visible", "type": "boolean", "optional": false}], []);
-InspectorBackend.registerCommand("Page.captureScreenshot", [], ["data"]);
InspectorBackend.registerCommand("Page.handleJavaScriptDialog", [{"name": "accept", "type": "boolean", "optional": false}, {"name": "promptText", "type": "string", "optional": true}], []);
// Runtime.
Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json (160201 => 160202)
--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json 2013-12-06 00:25:44 UTC (rev 160201)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json 2013-12-06 00:57:43 UTC (rev 160202)
@@ -411,13 +411,6 @@
]
},
{
- "name": "captureScreenshot",
- "description": "Capture page screenshot.",
- "returns": [
- { "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." }
- ]
- },
- {
"name": "handleJavaScriptDialog",
"description": "Accepts or dismisses a _javascript_ initiated dialog (alert, confirm, prompt, or onbeforeunload).",
"parameters": [