Bug 57466 - Web Inspector: provide front-end wrappers for DOMAgent.querySelector[All]() that take care of fetching the document
Summary: Web Inspector: provide front-end wrappers for DOMAgent.querySelector[All]() t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Andrey Kosyakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-30 09:26 PDT by Andrey Kosyakov
Modified: 2011-04-05 07:27 PDT (History)
9 users (show)

See Also:


Attachments
patch (11.67 KB, patch)
2011-03-30 09:31 PDT, Andrey Kosyakov
pfeldman: review+
Details | Formatted Diff | Diff
patch (17.22 KB, patch)
2011-03-31 06:42 PDT, Andrey Kosyakov
pfeldman: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kosyakov 2011-03-30 09:26:21 PDT
Requiring document to be set on front-end before calls to querySelector[All]() is counter-intuitive.
This is a better fix for bug 57349 (with some cosmetic drive-by fixes)
Comment 1 Andrey Kosyakov 2011-03-30 09:31:12 PDT
Created attachment 87549 [details]
patch
Comment 2 Pavel Feldman 2011-03-30 22:25:13 PDT
Comment on attachment 87549 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=87549&action=review

> Source/WebCore/inspector/front-end/AuditRules.js:675
> +                console.error("Failed to get image style");

When does this happen?

> Source/WebCore/inspector/front-end/AuditRules.js:731
> +                console.error("Failed to get styles");

ditto

> Source/WebCore/inspector/front-end/DOMAgent.js:363
> +            requestArguments.push(callbackWrapper);

do you want to do this only in the success branch of onDocumentAvailable?

> Source/WebCore/inspector/front-end/DOMAgent.js:495
> +            DOMAgent.querySelector(nodeId || this._document.id, selectors, documentWide, wrappedCallback);

So 0 is still valid? I thought we agreed on not allowing it here.
Comment 3 Andrey Kosyakov 2011-03-31 06:40:29 PDT
Comment on attachment 87549 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=87549&action=review

>> Source/WebCore/inspector/front-end/AuditRules.js:675
>> +                console.error("Failed to get image style");
> 
> When does this happen?

This used to happen because we were getting 0 ids from querySelectorAll(), because document wasn't pushed to front-end. I actually removed it now, this is only supposed to happen in case something seriously went wrong in other places, so let's crash instead.

>> Source/WebCore/inspector/front-end/AuditRules.js:731
>> +                console.error("Failed to get styles");
> 
> ditto

Now this is a bit different, this happens only in case we receive error from getStylesAsync() (from what I can see, this is only in case we supplied invalid node id -- yet, if there's a possibility of a function to return error, we shouldn't be swallowing it or crashing on it, hence I just added logging).

>> Source/WebCore/inspector/front-end/DOMAgent.js:363
>> +            requestArguments.push(callbackWrapper);
> 
> do you want to do this only in the success branch of onDocumentAvailable?

I tried it, but didn't quite like it -- we need to extract callback from the argument list anyway, and I think that having this push together with callback extraction logic makes things a bit more readable.

>> Source/WebCore/inspector/front-end/DOMAgent.js:495
>> +            DOMAgent.querySelector(nodeId || this._document.id, selectors, documentWide, wrappedCallback);
> 
> So 0 is still valid? I thought we agreed on not allowing it here.

Yup, now the document request logic moves to client (and I'm also dropping documentWide parameter altogether, as discussed).
Comment 4 Andrey Kosyakov 2011-03-31 06:42:50 PDT
Created attachment 87716 [details]
patch

- removed documentWide parameter to querySelector[All]()
- moved document request logic from DOMAgent.js to the client side
Comment 5 Andrey Kosyakov 2011-04-05 07:27:40 PDT
Manually committed as r82663: http://trac.webkit.org/changeset/82663