Bug 50227 - Web Inspector: Enable switching between revisions of stylesheets
Summary: Web Inspector: Enable switching between revisions of stylesheets
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: 50241
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-30 05:22 PST by Alexander Pavlov (apavlov)
Modified: 2010-11-30 07:59 PST (History)
10 users (show)

See Also:


Attachments
[PATCH] Suggested solution (7.78 KB, patch)
2010-11-30 06:00 PST, Alexander Pavlov (apavlov)
yurys: review-
Details | Formatted Diff | Diff
[PATCH] Comment addressed (6.06 KB, patch)
2010-11-30 06:30 PST, Alexander Pavlov (apavlov)
yurys: review-
Details | Formatted Diff | Diff
[PATCH] Reverted userCallback invocation (6.33 KB, patch)
2010-11-30 06:48 PST, Alexander Pavlov (apavlov)
no flags Details | Formatted Diff | Diff
[PATCH] Removed unused method and user callback (6.04 KB, patch)
2010-11-30 07:07 PST, Alexander Pavlov (apavlov)
pfeldman: review-
Details | Formatted Diff | Diff
[PATCH] My version of the patch. (15.11 KB, patch)
2010-11-30 07:52 PST, Pavel Feldman
no flags 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) 2010-11-30 05:22:29 PST
We currently track revisions of stylesheets edited by the user. We should also be able to apply any revision as the "current" one, to revert the stylesheet state to some point in the past.
Comment 1 Alexander Pavlov (apavlov) 2010-11-30 06:00:27 PST
Created attachment 75131 [details]
[PATCH] Suggested solution
Comment 2 Yury Semikhatsky 2010-11-30 06:18:20 PST
Comment on attachment 75131 [details]
[PATCH] Suggested solution

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

> WebCore/inspector/front-end/CSSStyleModel.js:168
> +        function callback(styleSheetId, href, content)

Just use styleSheetId from the outer scope without passing it as additional explicit parameter, this way you would avoid callback.bind call below.

> WebCore/inspector/front-end/CSSStyleModel.js:221
> +    return payload ? new WebInspector.CSSStyleDeclaration(payload) : null;

The contract should be that the caller checks for null payload because otherwise we have two null checks instead of one, first one in the parse method and the second one at the call site where we check for null parsed value.

> WebCore/inspector/front-end/CSSStyleModel.js:369
> +    return payload ? new WebInspector.CSSRule(payload) : null;

ditto

> WebCore/inspector/front-end/CSSStyleModel.js:410
> +    if (!payload)

ditto

> WebCore/inspector/front-end/CSSStyleModel.js:530
> +    return payload ? new WebInspector.CSSStyleSheet(payload) : null;

ditto
Comment 3 Alexander Pavlov (apavlov) 2010-11-30 06:30:22 PST
Created attachment 75135 [details]
[PATCH] Comment addressed
Comment 4 Yury Semikhatsky 2010-11-30 06:32:11 PST
Comment on attachment 75135 [details]
[PATCH] Comment addressed

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

> WebCore/inspector/front-end/CSSStyleModel.js:-538
> -        function callback(styleSheetPayload)

Please revert this.
Comment 5 Alexander Pavlov (apavlov) 2010-11-30 06:38:50 PST
(In reply to comment #4)
> (From update of attachment 75135 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=75135&action=review
> 
> > WebCore/inspector/front-end/CSSStyleModel.js:-538
> > -        function callback(styleSheetPayload)
> 
> Please revert this.

The code in question was wrong. setStyleSheetText2() does not return a stylesheet payload. Instead, it returns the stylesheet "href" and the new textual contents. Yet, I'm adding back the missing userCallback invocation.
Comment 6 Alexander Pavlov (apavlov) 2010-11-30 06:40:44 PST
(In reply to comment #5)
> (In reply to comment #4)
> > (From update of attachment 75135 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=75135&action=review
> > 
> > > WebCore/inspector/front-end/CSSStyleModel.js:-538
> > > -        function callback(styleSheetPayload)
> > 
> > Please revert this.
> 
> The code in question was wrong. setStyleSheetText2() does not return a stylesheet payload. Instead, it returns the stylesheet "href" and the new textual contents. Yet, I'm adding back the missing userCallback invocation.

Sorry for the confusion. setStyleSheetText2() does not return anything. It's getStyleSheetText2() that returns the href and stylesheet contents.
Comment 7 Alexander Pavlov (apavlov) 2010-11-30 06:48:29 PST
Created attachment 75140 [details]
[PATCH] Reverted userCallback invocation
Comment 8 Yury Semikhatsky 2010-11-30 06:52:54 PST
Comment on attachment 75140 [details]
[PATCH] Reverted userCallback invocation

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

> WebCore/inspector/front-end/CSSStyleModel.js:173
> +            if (userCallback)

Let's get rid of the unused callbacks. We can add them later once we need them.

> WebCore/inspector/front-end/CSSStyleModel.js:549
>      setText: function(newText, userCallback)

This method is not used, consider removing it completely.
Comment 9 Alexander Pavlov (apavlov) 2010-11-30 07:07:07 PST
Created attachment 75144 [details]
[PATCH] Removed unused method and user callback
Comment 10 Alexander Pavlov (apavlov) 2010-11-30 07:29:34 PST
Committing to http://svn.webkit.org/repository/webkit/trunk ...
        M       WebCore/ChangeLog
        M       WebCore/English.lproj/localizedStrings.js
        M       WebCore/inspector/InspectorStyleSheet.cpp
        M       WebCore/inspector/front-end/CSSStyleModel.js
        M       WebCore/inspector/front-end/ResourcesPanel.js
Committed r72914
Comment 11 Pavel Feldman 2010-11-30 07:50:57 PST
Comment on attachment 75144 [details]
[PATCH] Removed unused method and user callback

I have a much better change that is using universal rollback callback and works both for styles and javascript. It does not introduce dependency from resource panel to style sheet model + does not introduce weird .styleSheetId property. Anyways, I did not land it since setStyleSeetText was not working. Is it fixed now?
Comment 12 Pavel Feldman 2010-11-30 07:52:33 PST
Created attachment 75147 [details]
[PATCH] My version of the patch.
Comment 13 Alexander Pavlov (apavlov) 2010-11-30 07:56:56 PST
Comment on attachment 75147 [details]
[PATCH] My version of the patch.

You need to add:
m_pageStyleSheet->styleSheetChanged();
after
m_pageStyleSheet->parseString(text, m_pageStyleSheet->useStrictParsing());
in
InspectorStyleSheet::reparseStyleSheet(const String& text).