Bug 59326 - Web Inspector: Use CachedResource to retrieve charset-decoded stylesheet text
Summary: Web Inspector: Use CachedResource to retrieve charset-decoded stylesheet text
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: Alexander Pavlov (apavlov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-25 09:38 PDT by Alexander Pavlov (apavlov)
Modified: 2011-04-28 02:24 PDT (History)
11 users (show)

See Also:


Attachments
[PATCH] Suggested fix (3.02 KB, patch)
2011-04-25 10:40 PDT, Alexander Pavlov (apavlov)
pfeldman: review-
Details | Formatted Diff | Diff
[PATCH] Improved solution (8.49 KB, patch)
2011-04-26 09:35 PDT, Alexander Pavlov (apavlov)
pfeldman: review-
Details | Formatted Diff | Diff
[PATCH] Comments addressed (8.34 KB, patch)
2011-04-26 10:08 PDT, Alexander Pavlov (apavlov)
pfeldman: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pavlov (apavlov) 2011-04-25 09:38:33 PDT
Instead of manual text decoding, use CachedCSSStyleSheet::sheetText() which does what we need.
Comment 1 Alexander Pavlov (apavlov) 2011-04-25 10:40:21 PDT
Created attachment 90929 [details]
[PATCH] Suggested fix
Comment 2 Pavel Feldman 2011-04-25 11:05:34 PDT
Comment on attachment 90929 [details]
[PATCH] Suggested fix

Btw, how does this new code relate to the decoding logic in the InspectorPageAgent::resourceContent itself? It seems that it should produce valid result without your change.
Comment 3 Alexander Pavlov (apavlov) 2011-04-26 09:35:28 PDT
Created attachment 91118 [details]
[PATCH] Improved solution
Comment 4 WebKit Review Bot 2011-04-26 09:37:24 PDT
Attachment 91118 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/inspector/InspectorPageAgent.cpp:180:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Alexander Pavlov (apavlov) 2011-04-26 09:40:11 PDT
(In reply to comment #2)
> (From update of attachment 90929 [details])
> Btw, how does this new code relate to the decoding logic in the InspectorPageAgent::resourceContent itself? It seems that it should produce valid result without your change.

The other way round: it does not produce valid results even with my previous change (and \uFEFF did get into the frontend JavaScript but were not displayed). This is now fixed.
Comment 6 WebKit Review Bot 2011-04-26 09:41:14 PDT
Attachment 91118 [details] did not build on mac:
Build output: http://queues.webkit.org/results/8507670
Comment 7 Pavel Feldman 2011-04-26 09:43:13 PDT
Comment on attachment 91118 [details]
[PATCH] Improved solution

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

> Source/WebCore/inspector/InspectorPageAgent.cpp:67
> +bool decodeSharedBuffer(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, String* result)

Please make this static.

> Source/WebCore/inspector/InspectorPageAgent.cpp:79
> +bool prepareCachedResourceBuffer(CachedResource* cachedResource, bool* hasZeroSize)

Ditto.

> Source/WebCore/inspector/InspectorPageAgent.cpp:105
> +bool cachedResourceDecoded(CachedResource* cachedResource, String* result)

ditto. decodeCachedResource ?

> Source/WebCore/inspector/InspectorPageAgent.cpp:131
> +PassRefPtr<SharedBuffer> mainResourceSharedBuffer(Frame* frame, const KURL& url, String* textEncodingName)

ditto

> Source/WebCore/inspector/InspectorPageAgent.cpp:135
> +    if (equalIgnoringFragmentIdentifier(url, loader->url())) {

You should only enter mainResourceSharedBuffer for main resource urls.
Comment 8 Alexander Pavlov (apavlov) 2011-04-26 10:08:35 PDT
Created attachment 91123 [details]
[PATCH] Comments addressed
Comment 9 Alexander Pavlov (apavlov) 2011-04-28 02:24:01 PDT
Committed r85172: <http://trac.webkit.org/changeset/85172>