Changeset 249089 in webkit


Ignore:
Timestamp:
Aug 24, 2019 11:21:04 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: "Copy Rule" menu item does not propagate comments properly
https://bugs.webkit.org/show_bug.cgi?id=201095

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

  • UserInterface/Models/CSSProperty.js:

(WI.CSSProperty.prototype.commentOut):
(WI.CSSProperty.prototype.get formattedText):
Wrap the text in /* ${text} */ if the WI.CSSProperty isn't enabled (e.g. commented out).

LayoutTests:

  • inspector/css/generateCSSRuleString.html:
  • inspector/css/generateCSSRuleString-expected.txt:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249078 r249089  
     12019-08-24  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: "Copy Rule" menu item does not propagate comments properly
     4        https://bugs.webkit.org/show_bug.cgi?id=201095
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/css/generateCSSRuleString.html:
     9        * inspector/css/generateCSSRuleString-expected.txt:
     10
    1112019-08-23  Devin Rousso  <drousso@apple.com>
    212
  • trunk/LayoutTests/inspector/css/generateCSSRuleString-expected.txt

    r248202 r249089  
    55-- Running test case: CSS.generateCSSRuleString.InlineStyle
    66#test-node {
    7     a-b: 1;
    8     c-d: 2;
     7    a: 1;
     8    b: 2;
     9    c: 3;
     10}
     11
     12-- Running test case: CSS.generateCSSRuleString.InlineStyle.WithCommentedProperty
     13#test-node {
     14    a: 1;
     15    /* b: 2; */
     16    c: 3;
    917}
    1018
     
    1321    @media only screen and (min-height: 0px) {
    1422        body > div#test-node {
    15             a-b: 1;
    16             c-d: 2;
     23            a: 1;
     24            b: 2;
     25            c: 3;
    1726        }
    1827    }
     
    2029@media only screen and (min-width: 0px) {
    2130    body > #test-node {
    22         a-b: 1;
    23         c-d: 2;
     31        a: 1;
     32        b: 2;
     33        c: 3;
    2434    }
    2535}
    2636body > div {
    27     a-b: 1;
    28     c-d: 2;
     37    a: 1;
     38    b: 2;
     39    c: 3;
    2940}
    3041body > * {
    31     a-b: 1;
    32     c-d: 2;
     42    a: 1;
     43    b: 2;
     44    c: 3;
    3345}
    3446* {
    35     a-b: 1;
    36     c-d: 2;
     47    a: 1;
     48    b: 2;
     49    c: 3;
    3750}
    3851address, article, aside, div, footer, header, hgroup, layer, main, nav, section {
     
    4053}
    4154
     55-- Running test case: CSS.generateCSSRuleString.MatchedRules.WithCommentedProperties
     56@media only screen and (min-width: 0px) {
     57    @media only screen and (min-height: 0px) {
     58        body > div#test-node {
     59            a: 1;
     60            /* b: 2; */
     61            c: 3;
     62        }
     63    }
     64}
     65@media only screen and (min-width: 0px) {
     66    body > #test-node {
     67        a: 1;
     68        /* b: 2; */
     69        c: 3;
     70    }
     71}
     72body > div {
     73    a: 1;
     74    /* b: 2; */
     75    c: 3;
     76}
     77body > * {
     78    a: 1;
     79    /* b: 2; */
     80    c: 3;
     81}
     82* {
     83    a: 1;
     84    /* b: 2; */
     85    c: 3;
     86}
     87
  • trunk/LayoutTests/inspector/css/generateCSSRuleString.html

    r248202 r249089  
    33<head>
    44<style>
    5 *{a-b:1;c-d:2}
    6 body>*{a-b:1;c-d:2}
    7 @media all {body>div{a-b:1;c-d:2}}
    8 @media only screen and (min-width:0px) {body>#test-node{a-b:1;c-d:2}}
    9 @media only screen and (min-width:0px) {@media only screen and (min-height:0px) {body>div#test-node{a-b:1;c-d:2}}}
     5*{a:1;b:2;c:3}
     6body>*{a:1;b:2;c:3}
     7@media all {body>div{a:1;b:2;c:3}}
     8@media only screen and (min-width:0px) {body>#test-node{a:1;b:2;c:3}}
     9@media only screen and (min-width:0px) {@media only screen and (min-height:0px) {body>div#test-node{a:1;b:2;c:3}}}
    1010</style>
    1111<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     
    2525
    2626    suite.addTestCase({
     27        name: "CSS.generateCSSRuleString.InlineStyle.WithCommentedProperty",
     28        description: "Check the formatting of the generated inline style string if a property is commented out.",
     29        test() {
     30            nodeStyles.inlineStyle.properties[1].commentOut(true);
     31            InspectorTest.log(nodeStyles.inlineStyle.generateCSSRuleString());
     32        },
     33    });
     34
     35    suite.addTestCase({
    2736        name: "CSS.generateCSSRuleString.MatchedRules",
    2837        description: "Check the formatting of the generated string for all matched CSS rules.",
     
    3039            for (let rule of nodeStyles.matchedRules)
    3140                InspectorTest.log(rule.style.generateCSSRuleString());
     41        }
     42    });
     43
     44    suite.addTestCase({
     45        name: "CSS.generateCSSRuleString.MatchedRules.WithCommentedProperties",
     46        description: "Check the formatting of the generated string for all matched CSS rules if a property is commented out in each.",
     47        test() {
     48            for (let rule of nodeStyles.matchedRules) {
     49                if (!rule.style.editable)
     50                    continue;
     51
     52                rule.style.properties[1].commentOut(true);
     53                InspectorTest.log(rule.style.generateCSSRuleString());
     54            }
    3255        }
    3356    });
     
    5477<body onload="runTest()">
    5578    <p>Testing that generated CSS rule strings have proper formatting.</p>
    56     <div id="test-node" style="a-b:1;c-d:2"></div>
     79    <div id="test-node" style="a:1;b:2;c:3"></div>
    5780</body>
    5881</html>
  • trunk/Source/WebInspectorUI/ChangeLog

    r249078 r249089  
     12019-08-24  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: "Copy Rule" menu item does not propagate comments properly
     4        https://bugs.webkit.org/show_bug.cgi?id=201095
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Models/CSSProperty.js:
     9        (WI.CSSProperty.prototype.commentOut):
     10        (WI.CSSProperty.prototype.get formattedText):
     11        Wrap the `text` in `/* ${text} */` if the `WI.CSSProperty` isn't `enabled` (e.g. commented out).
     12
    1132019-08-23  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js

    r248391 r249089  
    150150    commentOut(disabled)
    151151    {
     152        console.assert(this.editable);
    152153        if (this._enabled === !disabled)
    153154            return;
     
    182183            return "";
    183184
    184         return `${this._name}: ${this._rawValue};`;
     185        let text = `${this._name}: ${this._rawValue};`;
     186        if (!this._enabled)
     187            text = "/* " + text + " */";
     188        return text;
    185189    }
    186190
Note: See TracChangeset for help on using the changeset viewer.