Bug 109340 - Web Inspector: protocol should support setStyleText
Summary: Web Inspector: protocol should support setStyleText
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Timothy Hatcher
Depends on:
Reported: 2013-02-08 20:24 PST by Timothy Hatcher
Modified: 2013-04-18 22:57 PDT (History)
11 users (show)

See Also:

Patch (22.03 KB, patch)
2013-04-18 06:28 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff
Patch (22.04 KB, patch)
2013-04-18 14:53 PDT, Timothy Hatcher
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2013-02-08 20:24:52 PST
You should be able to edit a whole CSSStyleDeclaration (like you can in the CSSOM with the cssText property).

Something like:

                "name": "setStyleText",
                "parameters": [
                    { "name": "styleId", "$ref": "CSSStyleId" },
                    { "name": "text", "type": "string" },
                "returns": [
                    { "name": "style", "$ref": "CSSStyle", "description": "The resulting style after the text modification." }
                "description": "Sets the new <code>text</code> for the respective style."

I understand you can get this crudely by using getStyleSheetText, replace the range gotten from the CSSStyle, then call setStyleSheetText. But that is fairly heavy handed, and would cause a world update for all rules in that stylesheet instead of a single rule.

Having this setStyleText call would allow features like free-form editing of inline styles or rules in the sidebar, instead of individual property editing.
Comment 1 Timothy Hatcher 2013-04-18 05:30:59 PDT
I have a patch for this. Working on the test now.
Comment 2 Timothy Hatcher 2013-04-18 06:28:22 PDT
Created attachment 198728 [details]
Comment 3 Benjamin Poulain 2013-04-18 13:51:33 PDT
Comment on attachment 198728 [details]

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

> Source/WebCore/inspector/InspectorCSSAgent.cpp:363
> +        : InspectorCSSAgent::StyleSheetAction("SetStyleText", styleSheet)

-> ASCIILiteral("SetStyleText") :)
Comment 4 Timothy Hatcher 2013-04-18 14:53:38 PDT
Created attachment 198767 [details]
Comment 5 Joseph Pecoraro 2013-04-18 22:17:05 PDT
Comment on attachment 198767 [details]

Nice! r=me
Comment 6 WebKit Commit Bot 2013-04-18 22:57:50 PDT
Comment on attachment 198767 [details]

Clearing flags on attachment: 198767

Committed r148723: <http://trac.webkit.org/changeset/148723>
Comment 7 WebKit Commit Bot 2013-04-18 22:57:53 PDT
All reviewed patches have been landed.  Closing bug.