Bug 109340

Summary: Web Inspector: protocol should support setStyleText
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: Web Inspector (Deprecated)Assignee: Timothy Hatcher <timothy>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, commit-queue, graouts, joepeck, keishi, loislo, pfeldman, pmuellr, vsevik, web-inspector-bugs, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch none

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]
Patch
Comment 3 Benjamin Poulain 2013-04-18 13:51:33 PDT
Comment on attachment 198728 [details]
Patch

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]
Patch
Comment 5 Joseph Pecoraro 2013-04-18 22:17:05 PDT
Comment on attachment 198767 [details]
Patch

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

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.