WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
105315
Web Inspector: introduce Page.captureScreenshot
https://bugs.webkit.org/show_bug.cgi?id=105315
Summary
Web Inspector: introduce Page.captureScreenshot
Pavel Feldman
Reported
2012-12-18 09:17:18 PST
It will be primarily used by the automation clients, but maybe we find a good place for it in the front-end as well.
Attachments
Patch
(10.61 KB, patch)
2012-12-18 09:23 PST
,
Pavel Feldman
no flags
Details
Formatted Diff
Diff
Patch
(14.27 KB, patch)
2012-12-19 06:06 PST
,
Pavel Feldman
yurys
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Pavel Feldman
Comment 1
2012-12-18 09:23:04 PST
Created
attachment 179958
[details]
Patch
WebKit Review Bot
Comment 2
2012-12-18 09:25:41 PST
Please wait for approval from
abarth@webkit.org
,
dglazkov@chromium.org
,
fishd@chromium.org
,
jamesr@chromium.org
or
tkent@chromium.org
before submitting, as this patch contains changes to the Chromium public API. See also
https://trac.webkit.org/wiki/ChromiumWebKitAPI
.
Brian Burg
Comment 3
2012-12-18 13:44:24 PST
Is there a platform-agnostic way to expose the screenshot image data to the inspector frontend? I'm not aware of any other Inspector functionality that creates image data with a backend Inspector*Agent and exposes it to the Inspector's DOM. Do you have a sense of the difficulty? It would be extremely useful for debugging animation frames, showing youtube-like scrubbing previews, etc.
Pavel Feldman
Comment 4
2012-12-18 22:41:56 PST
(In reply to
comment #3
)
> Is there a platform-agnostic way to expose the screenshot image data to the inspector frontend? I'm not aware of any other Inspector functionality that creates image data with a backend Inspector*Agent and exposes it to the Inspector's DOM. Do you have a sense of the difficulty? > > It would be extremely useful for debugging animation frames, showing youtube-like scrubbing previews, etc.
We do ship images from the backend into front-end using base64 encoded strings and display them using data: urls. If you have some good feature in mind that would leverage that for screenshots, please let us know or send a mock!
Pavel Feldman
Comment 5
2012-12-19 06:06:40 PST
Created
attachment 180147
[details]
Patch
Alexander Pavlov (apavlov)
Comment 6
2012-12-19 06:22:11 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:84 > +static const char screenshot[] = "screenshot";
Guess we should migrate to "static const char* const" whenever possible (to make use of the constant memory)
> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:814 > + case BrowserDataHintScreenshot:
The WebKit style for this is: case Foo: { BarOne; BarTwo; } (see e.g. CSSParser.cpp:1822)
Andrey Kosyakov
Comment 7
2012-12-19 07:06:29 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:814 >> + case BrowserDataHintScreenshot: > > The WebKit style for this is: > > case Foo: { > BarOne; > BarTwo; > } > > (see e.g. CSSParser.cpp:1822)
Why does this need braces at all?
Andrey Kosyakov
Comment 8
2012-12-19 07:13:04 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
> Source/WebCore/inspector/InspectorPageAgent.cpp:1204 > + *errorString = "Could not capture screenshot.";
please drop the punctuation from error messages.
Pavel Feldman
Comment 9
2012-12-19 07:45:33 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
>> Source/WebCore/inspector/InspectorPageAgent.cpp:1204 >> + *errorString = "Could not capture screenshot."; > > please drop the punctuation from error messages.
I'd need to do it in 10 more places throughout this file. I'd better do that separately.
>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:84 >> +static const char screenshot[] = "screenshot"; > > Guess we should migrate to "static const char* const" whenever possible (to make use of the constant memory)
Will do.
>>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:814 >>> + case BrowserDataHintScreenshot: >> >> The WebKit style for this is: >> >> case Foo: { >> BarOne; >> BarTwo; >> } >> >> (see e.g. CSSParser.cpp:1822) > > Why does this need braces at all?
Historical reasons: I used to have variable declaration there.
Yury Semikhatsky
Comment 10
2012-12-19 23:51:48 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
> Source/WebKit/chromium/public/WebDevToolsAgent.h:101 > + WEBKIT_EXPORT static WebString patchWithBrowserData(const WebString& message, BrowserDataHint, const WebString& hintData);
This means that the client of this API will always be responsible for formatting the hintData. Is it always going to be a string? What about raw cookies, wouldn't we need to serialize them in some protocol-defined format if so then we should expose a way to set the patch data and and let WebCore serialize it into a message.
>>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:84 >>> +static const char screenshot[] = "screenshot"; >> >> Guess we should migrate to "static const char* const" whenever possible (to make use of the constant memory) > > Will do.
This sounds weird, the array content is already immutable, why making the pointer itself immutable changes where its content is stored?
Yury Semikhatsky
Comment 11
2012-12-19 23:54:29 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:782 > + String messageString(message, messageLength);
This will always copy the message while we want shouldPatchWithBrowserData to be as fast as possible since we are going to call it for each message. You should either use C-functions to find the substring or create the String as String(ASCIILiteral(message)) if the message is always is a null-terminated string.
Pavel Feldman
Comment 12
2012-12-20 00:22:36 PST
Comment on
attachment 180147
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=180147&action=review
>> Source/WebKit/chromium/public/WebDevToolsAgent.h:101 >> + WEBKIT_EXPORT static WebString patchWithBrowserData(const WebString& message, BrowserDataHint, const WebString& hintData); > > This means that the client of this API will always be responsible for formatting the hintData. Is it always going to be a string? What about raw cookies, wouldn't we need to serialize them in some protocol-defined format if so then we should expose a way to set the patch data and and let WebCore serialize it into a message.
I was planning on adding as much parameters as possible here. Having said that, I think they need to be of primitive types so that we don't grow WebKit API too much. We will be able to serialize data such as cookies into the protocol string on the browser-side as soon as they become "public" in the protocol, i.e. standardized.
>>>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:84 >>>> +static const char screenshot[] = "screenshot"; >>> >>> Guess we should migrate to "static const char* const" whenever possible (to make use of the constant memory) >> >> Will do. > > This sounds weird, the array content is already immutable, why making the pointer itself immutable changes where its content is stored?
Leaving as []
>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:782 >> + String messageString(message, messageLength); > > This will always copy the message while we want shouldPatchWithBrowserData to be as fast as possible since we are going to call it for each message. You should either use C-functions to find the substring or create the String as String(ASCIILiteral(message)) if the message is always is a null-terminated string.
There is a guard above that makes it work only for the overridden messages that are always small ("message" is not always null-terminated).
>>>> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:814 >>>> + case BrowserDataHintScreenshot: >>> >>> The WebKit style for this is: >>> >>> case Foo: { >>> BarOne; >>> BarTwo; >>> } >>> >>> (see e.g. CSSParser.cpp:1822) >> >> Why does this need braces at all? > > Historical reasons: I used to have variable declaration there.
Fixed.
Pavel Feldman
Comment 13
2012-12-20 01:40:39 PST
Committed
r138236
: <
http://trac.webkit.org/changeset/138236
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug