Changeset 160202 in webkit
- Timestamp:
- Dec 5, 2013 4:57:43 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r160200 r160202 1 2013-12-05 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: expose node and frame snapshot capabilities. 4 https://bugs.webkit.org/show_bug.cgi?id=124326 5 6 Reviewed by Joseph Pecoraro. 7 8 This adds snapshotRect() and snapshotNode() to the Page domain. 9 Both methods create snapshots using FrameSnapshotting APIs 10 and send images to the inspector frontend as a data URL. 11 12 Remove the unimplemented Page.captureScreenshot API. 13 14 * inspector/InspectorPageAgent.cpp: 15 (WebCore::InspectorPageAgent::snapshotNode): Added. 16 (WebCore::InspectorPageAgent::snapshotRect): Added. 17 * inspector/InspectorPageAgent.h: 18 * inspector/protocol/Page.json: Added new protocol APIs. 19 1 20 2013-12-04 Bear Travis <betravis@adobe.com> 2 21 -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r160012 r160202 52 52 #include "Frame.h" 53 53 #include "FrameLoader.h" 54 #include "FrameSnapshotting.h" 54 55 #include "FrameView.h" 55 56 #include "GeolocationController.h" … … 58 59 #include "HTMLNames.h" 59 60 #include "IdentifiersFactory.h" 61 #include "ImageBuffer.h" 60 62 #include "InjectedScriptManager.h" 61 63 #include "InspectorAgent.h" 62 64 #include "InspectorClient.h" 65 #include "InspectorDOMAgent.h" 63 66 #include "InspectorFrontend.h" 64 67 #include "InspectorInstrumentation.h" … … 1252 1255 } 1253 1256 1254 void InspectorPageAgent::captureScreenshot(ErrorString* errorString, String* data) 1255 { 1256 if (!m_client->captureScreenshot(data)) 1257 *errorString = "Could not capture screenshot"; 1257 void InspectorPageAgent::snapshotNode(ErrorString* errorString, int nodeId, String* outDataURL) 1258 { 1259 Frame* frame = mainFrame(); 1260 ASSERT(frame); 1261 1262 InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent(); 1263 ASSERT(domAgent); 1264 Node* node = domAgent->assertNode(errorString, nodeId); 1265 if (!node) 1266 return; 1267 1268 std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode(*frame, *node); 1269 if (!snapshot) { 1270 *errorString = ASCIILiteral("Could not capture snapshot"); 1271 return; 1272 } 1273 1274 *outDataURL = snapshot->toDataURL(ASCIILiteral("image/png")); 1275 } 1276 1277 void InspectorPageAgent::snapshotRect(ErrorString* errorString, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL) 1278 { 1279 Frame* frame = mainFrame(); 1280 ASSERT(frame); 1281 1282 SnapshotOptions options = SnapshotOptionsNone; 1283 if (coordinateSystem == "Viewport") 1284 options |= SnapshotOptionsInViewCoordinates; 1285 1286 IntRect rectangle(x, y, width, height); 1287 std::unique_ptr<ImageBuffer> snapshot = snapshotFrameRect(*frame, rectangle, options); 1288 1289 if (!snapshot) { 1290 *errorString = ASCIILiteral("Could not capture snapshot"); 1291 return; 1292 } 1293 1294 *outDataURL = snapshot->toDataURL(ASCIILiteral("image/png")); 1258 1295 } 1259 1296 -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r160012 r160202 130 130 virtual void getCompositingBordersVisible(ErrorString*, bool* out_param); 131 131 virtual void setCompositingBordersVisible(ErrorString*, bool); 132 virtual void captureScreenshot(ErrorString*, String* data); 132 virtual void snapshotNode(ErrorString*, int nodeId, String* outDataURL); 133 virtual void snapshotRect(ErrorString*, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL); 133 134 virtual void handleJavaScriptDialog(ErrorString*, bool accept, const String* promptText); 134 135 virtual void archive(ErrorString*, String* data); -
trunk/Source/WebCore/inspector/protocol/Page.json
r159233 r160202 8 8 "enum": ["Document", "Stylesheet", "Image", "Font", "Script", "XHR", "WebSocket", "Other"], 9 9 "description": "Resource type as it was perceived by the rendering engine." 10 }, 11 { 12 "id": "CoordinateSystem", 13 "type": "string", 14 "enum": ["Viewport", "Page"], 15 "description": "Coordinate system used by supplied coordinates." 10 16 }, 11 17 { … … 345 351 }, 346 352 { 347 "name": "captureScreenshot", 348 "description": "Capture page screenshot.", 349 "returns": [ 350 { "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." } 353 "name": "snapshotNode", 354 "description": "Capture a snapshot of the specified node that does not include unrelated layers.", 355 "parameters": [ 356 { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Id of the node to snapshot." } 357 ], 358 "returns": [ 359 { "name": "dataURL", "type": "string", "description": "Base64-encoded image data (PNG)." } 360 ] 361 }, 362 { 363 "name": "snapshotRect", 364 "description": "Capture a snapshot of the page within the specified rectangle and coordinate system.", 365 "parameters": [ 366 { "name": "x", "type": "integer", "description": "X coordinate" }, 367 { "name": "y", "type": "integer", "description": "Y coordinate" }, 368 { "name": "width", "type": "integer", "description": "Rectangle width" }, 369 { "name": "height", "type": "integer", "description": "Rectangle height" }, 370 { "name": "coordinateSystem", "$ref": "CoordinateSystem", "description": "Indicates the coordinate system of the supplied rectangle." } 371 ], 372 "returns": [ 373 { "name": "dataURL", "type": "string", "description": "Base64-encoded image data (PNG)." } 351 374 ] 352 375 }, -
trunk/Source/WebInspectorUI/ChangeLog
r160198 r160202 1 2013-12-05 Brian J. Burg <burg@cs.washington.edu> 2 3 Web Inspector: expose node and frame snapshot capabilities. 4 https://bugs.webkit.org/show_bug.cgi?id=124326 5 6 Reviewed by Joseph Pecoraro. 7 8 Add method signatures for snapshotNode() and snapshotRect(). 9 Remove method signature for unimplemented Page.captureScreenshot. 10 11 * UserInterface/InspectorBackendCommands.js: 12 1 13 2013-12-05 Alexandru Chiculita <achicu@adobe.com> 2 14 -
trunk/Source/WebInspectorUI/UserInterface/InspectorBackendCommands.js
r159475 r160202 1 1 // File is generated by Source/WebCore/inspector/CodeGeneratorInspector.py 2 2 3 // Copyright (c) 2013 Apple Inc. All Rights Reserved. 3 4 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 5 // Use of this source code is governed by a BSD-style license that can be … … 290 291 InspectorBackend.registerPageDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "Page"); 291 292 InspectorBackend.registerEnum("Page.ResourceType", {Document: "Document", Stylesheet: "Stylesheet", Image: "Image", Font: "Font", Script: "Script", XHR: "XHR", WebSocket: "WebSocket", Other: "Other"}); 293 InspectorBackend.registerEnum("Page.CoordinateSystem", {Viewport: "Viewport", Page: "Page"}); 292 294 InspectorBackend.registerEvent("Page.domContentEventFired", ["timestamp"]); 293 295 InspectorBackend.registerEvent("Page.loadEventFired", ["timestamp"]); … … 335 337 InspectorBackend.registerCommand("Page.getCompositingBordersVisible", [], ["result"]); 336 338 InspectorBackend.registerCommand("Page.setCompositingBordersVisible", [{"name": "visible", "type": "boolean", "optional": false}], []); 337 InspectorBackend.registerCommand("Page.captureScreenshot", [], ["data"]); 339 InspectorBackend.registerCommand("Page.snapshotNode", [{"name": "nodeId", "type": "number", "optional": false}], ["dataURL"]); 340 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"]); 338 341 InspectorBackend.registerCommand("Page.handleJavaScriptDialog", [{"name": "accept", "type": "boolean", "optional": false}, {"name": "promptText", "type": "string", "optional": true}], []); 339 342 InspectorBackend.registerCommand("Page.archive", [], ["data"]); -
trunk/Source/WebInspectorUI/UserInterface/Legacy/7.0/InspectorBackendCommands.js
r156357 r160202 1 1 // File is generated by Source/WebCore/inspector/CodeGeneratorInspector.py 2 2 3 // Copyright (c) 2013 Apple Inc. All Rights Reserved. 3 4 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 5 // Use of this source code is governed by a BSD-style license that can be … … 67 68 InspectorBackend.registerCommand("Page.getCompositingBordersVisible", [], ["result"]); 68 69 InspectorBackend.registerCommand("Page.setCompositingBordersVisible", [{"name": "visible", "type": "boolean", "optional": false}], []); 69 InspectorBackend.registerCommand("Page.captureScreenshot", [], ["data"]);70 70 InspectorBackend.registerCommand("Page.handleJavaScriptDialog", [{"name": "accept", "type": "boolean", "optional": false}, {"name": "promptText", "type": "string", "optional": true}], []); 71 71 -
trunk/Source/WebInspectorUI/Versions/Inspector-iOS-7.0.json
r156357 r160202 409 409 "parameters": [ 410 410 { "name": "visible", "type": "boolean", "description": "True for showing compositing borders." } 411 ]412 },413 {414 "name": "captureScreenshot",415 "description": "Capture page screenshot.",416 "returns": [417 { "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." }418 411 ] 419 412 },
Note: See TracChangeset
for help on using the changeset viewer.