Diff
Modified: trunk/LayoutTests/ChangeLog (248196 => 248197)
--- trunk/LayoutTests/ChangeLog 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/LayoutTests/ChangeLog 2019-08-03 08:52:53 UTC (rev 248197)
@@ -1,3 +1,15 @@
+2019-08-03 Devin Rousso <[email protected]>
+
+ Web Inspector: CSS Formatter: comments with an escape character aren't formatted
+ https://bugs.webkit.org/show_bug.cgi?id=200168
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/formatting/formatting-css.html:
+ * inspector/formatting/formatting-css-expected.txt:
+ * inspector/formatting/resources/css-tests/comment.css: Added.
+ * inspector/formatting/resources/css-tests/comment-expected.css: Added.
+
2019-08-02 Andres Gonzalez <[email protected]>
[ Mac ] Layout Test accessibility/mac/press-not-work-for-disabled-menu-list.html is a flaky failure
Modified: trunk/LayoutTests/inspector/formatting/formatting-css-expected.txt (248196 => 248197)
--- trunk/LayoutTests/inspector/formatting/formatting-css-expected.txt 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/LayoutTests/inspector/formatting/formatting-css-expected.txt 2019-08-03 08:52:53 UTC (rev 248197)
@@ -5,6 +5,9 @@
-- Running test case: CSSFormatter.basic.css
PASS
+-- Running test case: CSSFormatter.comment.css
+PASS
+
-- Running test case: CSSFormatter.gradient.css
PASS
Modified: trunk/LayoutTests/inspector/formatting/formatting-css.html (248196 => 248197)
--- trunk/LayoutTests/inspector/formatting/formatting-css.html 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/LayoutTests/inspector/formatting/formatting-css.html 2019-08-03 08:52:53 UTC (rev 248197)
@@ -10,6 +10,7 @@
addFormattingTests(suite, "text/css", [
"resources/css-tests/basic.css",
+ "resources/css-tests/comment.css",
"resources/css-tests/gradient.css",
"resources/css-tests/keyframes.css",
"resources/css-tests/media-query.css",
Added: trunk/LayoutTests/inspector/formatting/resources/css-tests/comment-expected.css (0 => 248197)
--- trunk/LayoutTests/inspector/formatting/resources/css-tests/comment-expected.css (rev 0)
+++ trunk/LayoutTests/inspector/formatting/resources/css-tests/comment-expected.css 2019-08-03 08:52:53 UTC (rev 248197)
@@ -0,0 +1,80 @@
+/* test \*/
+x {
+ a: b;
+ c: d
+}
+/* reset */
+
+/* test \*/
+x {
+ a: b;
+ c: d
+}
+/* reset */
+
+x /* test \*/ {
+ a: b;
+ c: d
+}
+/* reset */
+
+x {
+ /* test \*/
+ a: b;
+ c: d
+}
+/* reset */
+
+x {
+ a /* test \*/: b;
+ c: d
+}
+/* reset */
+
+x {
+ a: /* test \*/ b;
+ c: d
+}
+/* reset */
+
+x {
+ a: b /* test \*/;
+ c: d
+}
+/* reset */
+
+x {
+ a: b;
+ /* test \*/
+ c: d
+}
+/* reset */
+
+x {
+ a: b;
+ c /* test \*/: d
+}
+/* reset */
+
+x {
+ a: b;
+ c: /* test \*/ d
+}
+/* reset */
+
+x {
+ a: b;
+ c: d /* test \*/
+}
+/* reset */
+
+x {
+ a: b;
+ c: d
+}
+/* test \*/
+/* reset */
+
+/* 1 \*/
+/* 2 \*/
+/* 3 \*/
Added: trunk/LayoutTests/inspector/formatting/resources/css-tests/comment.css (0 => 248197)
--- trunk/LayoutTests/inspector/formatting/resources/css-tests/comment.css (rev 0)
+++ trunk/LayoutTests/inspector/formatting/resources/css-tests/comment.css 2019-08-03 08:52:53 UTC (rev 248197)
@@ -0,0 +1,40 @@
+/* test \*/
+x{a:b;c:d}
+/* reset */
+
+/* test \*/x{a:b;c:d}
+/* reset */
+
+x/* test \*/{a:b;c:d}
+/* reset */
+
+x{/* test \*/a:b;c:d}
+/* reset */
+
+x{a/* test \*/:b;c:d}
+/* reset */
+
+x{a:/* test \*/b;c:d}
+/* reset */
+
+x{a:b/* test \*/;c:d}
+/* reset */
+
+x{a:b;/* test \*/c:d}
+/* reset */
+
+x{a:b;c/* test \*/:d}
+/* reset */
+
+x{a:b;c:/* test \*/d}
+/* reset */
+
+x{a:b;c:d/* test \*/}
+/* reset */
+
+x{a:b;c:d}/* test \*/
+/* reset */
+
+/* 1 \*/
+/* 2 \*/
+/* 3 \*/
Modified: trunk/Source/WebInspectorUI/ChangeLog (248196 => 248197)
--- trunk/Source/WebInspectorUI/ChangeLog 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/Source/WebInspectorUI/ChangeLog 2019-08-03 08:52:53 UTC (rev 248197)
@@ -1,5 +1,23 @@
2019-08-03 Devin Rousso <[email protected]>
+ Web Inspector: CSS Formatter: comments with an escape character aren't formatted
+ https://bugs.webkit.org/show_bug.cgi?id=200168
+
+ Reviewed by Joseph Pecoraro.
+
+ Don't allow escaping of the "*" in CSS comments (e.g. `\*/`).
+
+ Add additional pretty printing rules for comments so that there's always some space between
+ them and the surrounding text. This ensures that they don't interfere with readability.
+
+ * UserInterface/Workers/Formatter/CSSFormatter.js:
+ (CSSFormatter.prototype._format):
+
+ * UserInterface/Workers/Formatter/FormatterContentBuilder.js:
+ (FormatterContentBuilder.prototype.get indented): Added.
+
+2019-08-03 Devin Rousso <[email protected]>
+
Web Inspector: Console: execution context picker doesn't update when switching to the inferred context from auto
https://bugs.webkit.org/show_bug.cgi?id=200279
Modified: trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/CSSFormatter.js (248196 => 248197)
--- trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/CSSFormatter.js 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/CSSFormatter.js 2019-08-03 08:52:53 UTC (rev 248197)
@@ -76,6 +76,8 @@
const removeSpaceBefore = new Set([`,`, `(`, `)`, `}`, `:`, `;`]);
const removeSpaceAfter = new Set([`(`, `{`, `}`, `,`, `!`, `;`]);
+ const whitespaceOnlyRegExp = /^\s*$/;
+
const inAtRuleRegExp = /^\s*@[a-zA-Z][-a-zA-Z]+/;
const inAtRuleBeforeParenthesisRegExp = /^\s*@[a-zA-Z][-a-zA-Z]+$/;
const inAtRuleAfterParenthesisRegExp = /^\s*@[a-zA-Z][-a-zA-Z]+[^("':]*\([^"':]*:/;
@@ -92,6 +94,8 @@
let testCurrentLine = (regExp) => regExp.test(this._builder.currentLine);
+ let inComment = false;
+
let inSelector = () => {
let nextOpenBrace = this._sourceText.indexOf(`{`, i);
if (nextOpenBrace !== -1) {
@@ -225,36 +229,84 @@
let specialSequenceEnd = null;
if (quoteTypes.has(c))
specialSequenceEnd = c;
- else if (c === `/` && this._sourceText[i + 1] === `*`)
+ else if (c === `/` && this._sourceText[i + 1] === `*`) {
+ inComment = true;
specialSequenceEnd = `*/`;
- else if (c === `u` && this._sourceText[i + 1] === `r` && this._sourceText[i + 2] === `l` && this._sourceText[i + 3] === `(`)
+ } else if (c === `u` && this._sourceText[i + 1] === `r` && this._sourceText[i + 2] === `l` && this._sourceText[i + 3] === `(`)
specialSequenceEnd = `)`;
if (specialSequenceEnd) {
+ let startIndex = i;
let endIndex = i;
do {
endIndex = this._sourceText.indexOf(specialSequenceEnd, endIndex + specialSequenceEnd.length);
- } while (endIndex !== -1 && this._sourceText[endIndex - 1] === `\\`);
+ } while (endIndex !== -1 && !inComment && this._sourceText[endIndex - 1] === `\\`);
if (endIndex === -1)
endIndex = this._sourceText.length;
+ endIndex += specialSequenceEnd.length;
- this._builder.appendToken(this._sourceText.substring(i, endIndex + specialSequenceEnd.length), i);
- i = endIndex + specialSequenceEnd.length - 1; // Account for the iteration of the for loop.
+ let specialSequenceText = this._sourceText.substring(startIndex, endIndex);
+ let lastSourceNewlineWasMultiple = this._sourceText[startIndex - 1] === `\n` && this._sourceText[startIndex - 2] === `\n`;
+ let lastAppendNewlineWasMultiple = this._builder.lastNewlineAppendWasMultiple;
+
+ let commentOnOwnLine = false;
+ if (inComment) {
+ commentOnOwnLine = testCurrentLine(whitespaceOnlyRegExp);
+
+ if (!commentOnOwnLine || lastAppendNewlineWasMultiple) {
+ while (this._builder.lastTokenWasNewline)
+ this._builder.removeLastNewline();
+ }
+
+ if (commentOnOwnLine) {
+ if (startIndex > 0 && !this._builder.indented)
+ this._builder.appendNewline();
+ } else if (this._builder.currentLine.length && !this._builder.lastTokenWasWhitespace)
+ this._builder.appendSpace();
+
+ if (this._builder.lastTokenWasNewline && lastSourceNewlineWasMultiple)
+ this._builder.appendNewline(true);
+ }
+
+ this._builder.appendToken(specialSequenceText, startIndex);
+
+ i = endIndex;
c = this._sourceText[i];
+
+ if (inComment) {
+ if (commentOnOwnLine) {
+ if (lastAppendNewlineWasMultiple && !lastSourceNewlineWasMultiple)
+ this._builder.appendMultipleNewlines(2);
+ else
+ this._builder.appendNewline();
+ } else if (!/\s/.test(c)) {
+ if (!testCurrentLine(inAtRuleRegExp) && !inSelector() && !inProperty())
+ this._builder.appendNewline();
+ else
+ this._builder.appendSpace();
+ }
+ }
+
+ --i; // Account for the iteration of the for loop.
+ c = this._sourceText[i];
+
formatAfter();
continue;
}
if (/\s/.test(c)) {
- if (c === `\n` && !this._builder.lastTokenWasNewline) {
- while (this._builder.lastTokenWasWhitespace)
- this._builder.removeLastWhitespace();
- if (!removeSpaceAfter.has(this._builder.lastToken))
- this._builder.appendNewline();
- else
- this._builder.appendSpace();
+ if (c === `\n`) {
+ this._builder.addOriginalLineEnding(i);
+ if (!this._builder.lastTokenWasNewline) {
+ while (this._builder.lastTokenWasWhitespace)
+ this._builder.removeLastWhitespace();
+ if (!removeSpaceAfter.has(this._builder.lastToken))
+ this._builder.appendNewline();
+ else
+ this._builder.appendSpace();
+ }
} else if (!this._builder.lastTokenWasWhitespace && !removeSpaceAfter.has(this._builder.lastToken))
this._builder.appendSpace();
continue;
Modified: trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterContentBuilder.js (248196 => 248197)
--- trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterContentBuilder.js 2019-08-03 07:37:00 UTC (rev 248196)
+++ trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterContentBuilder.js 2019-08-03 08:52:53 UTC (rev 248197)
@@ -87,6 +87,11 @@
return this._currentLine;
}
+ get indented()
+ {
+ return this._indent > 0;
+ }
+
setOriginalContent(originalContent)
{
console.assert(!this._originalContent);