WebKit Bugzilla
Attachment 361521 Details for
Bug 182523
: Web Inspector: Styles: close unbalanced quotes and parenthesis when editing values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
patch.txt (text/plain), 7.99 KB, created by
Nikita Vasilyev
on 2019-02-08 11:53:55 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Nikita Vasilyev
Created:
2019-02-08 11:53:55 PST
Size:
7.99 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 395610b7ad6..581124ea256 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2019-02-08 Nikita Vasilyev <nvasilyev@apple.com> >+ >+ Web Inspector: Styles: close unbalanced quotes and parenthesis when editing values >+ https://bugs.webkit.org/show_bug.cgi?id=182523 >+ <rdar://problem/37260209> >+ >+ Reviewed by Devin Rousso. >+ >+ Test common cases of unmatched quotes, parenthesis, comments, and trailing backslashes. >+ >+ * inspector/unit-tests/css-completions-expected.txt: Added. >+ * inspector/unit-tests/css-completions.html: Added. >+ > 2019-02-01 Antoine Quint <graouts@apple.com> > > Dispatch pointercancel events when content is panned or zoomed on iOS >diff --git a/LayoutTests/inspector/unit-tests/css-completions-expected.txt b/LayoutTests/inspector/unit-tests/css-completions-expected.txt >new file mode 100644 >index 00000000000..bd776ff3d2b >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/css-completions-expected.txt >@@ -0,0 +1,41 @@ >+Testing CSS completion. >+ >+ >+== Running test suite: CSSCompletions >+-- Running test case: CSSCompletions.completeUnbalancedValue >+url(|) >+url()| >+rgb(1|) >+rgb(1,2,3)| >+calc(var(--foo|)) >+'|' >+''| >+'foo|' >+'foo'| >+"|" >+""| >+"bar|" >+"bar"| >+/*|*/ >+/**/| >+/* "foo */| >+/* 'foo */| >+/* (foo */| >+('foo"|') >+('foo")|') >+("bar"')|') >+("bar")| >+'(|' >+'(foo|' >+"(|" >+"(bar|" >+\|\ >+\\| >+\\\|\ >+"\"|" >+'\'|' >+(\)|) >+/*\*/|*/ >+radial-gradient(ellipse closest-corner at var(--v) var(--h), hsl(198, 100%, 20%) 0%, hsla(204, 100%, 20%, 0) 100%)| >+"Helvetica Neue", 'Source Code Pro', "Comic Sans", 'PT Mono'| >+ >diff --git a/LayoutTests/inspector/unit-tests/css-completions.html b/LayoutTests/inspector/unit-tests/css-completions.html >new file mode 100644 >index 00000000000..5313e59fbb5 >--- /dev/null >+++ b/LayoutTests/inspector/unit-tests/css-completions.html >@@ -0,0 +1,73 @@ >+<!doctype html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script> >+function test() >+{ >+ let suite = InspectorTest.createSyncSuite("CSSCompletions"); >+ >+ suite.addTestCase({ >+ name: "CSSCompletions.completeUnbalancedValue", >+ test() { >+ function log(cssValue) { >+ let suffix = WI.CSSCompletions.completeUnbalancedValue(cssValue); >+ InspectorTest.log(cssValue + "|" + suffix); >+ } >+ >+ log(`url(`); >+ log(`url()`); >+ log(`rgb(1`); >+ log(`rgb(1,2,3)`); >+ log(`calc(var(--foo`); >+ >+ log(`'`); >+ log(`''`); >+ log(`'foo`); >+ log(`'foo'`); >+ >+ log(`"`); >+ log(`""`); >+ log(`"bar`); >+ log(`"bar"`); >+ >+ log(`/*`); >+ log(`/**/`); >+ log(`/* "foo */`); >+ log(`/* 'foo */`); >+ log(`/* (foo */`); >+ >+ log(`('foo"`); >+ log(`('foo")`); >+ log(`("bar"')`); >+ log(`("bar")`); >+ >+ log(`'(`); >+ log(`'(foo`); >+ log(`"(`); >+ log(`"(bar`); >+ >+ log(`\\`); >+ log(`\\\\`); >+ log(`\\\\\\`); >+ >+ log(`"\\"`); >+ log(`'\\'`); >+ log(`(\\)`); >+ log(`/*\\*/`); >+ >+ log(`radial-gradient(ellipse closest-corner at var(--v) var(--h), hsl(198, 100%, 20%) 0%, hsla(204, 100%, 20%, 0) 100%)`); >+ log(`"Helvetica Neue", 'Source Code Pro', "Comic Sans", 'PT Mono'`); >+ >+ return true; >+ } >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Testing CSS completion.</p> >+</body> >+</html> >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 08a49fed285..84d80559160 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,18 @@ >+2019-02-08 Nikita Vasilyev <nvasilyev@apple.com> >+ >+ Web Inspector: Styles: close unbalanced quotes and parenthesis when editing values >+ https://bugs.webkit.org/show_bug.cgi?id=182523 >+ <rdar://problem/37260209> >+ >+ Reviewed by Devin Rousso. >+ >+ Close CSS comments, append missing closed quotes and right parenthesis. >+ >+ * UserInterface/Models/CSSCompletions.js: >+ (WI.CSSCompletions.completeUnbalancedValue): >+ * UserInterface/Models/CSSProperty.js: >+ (WI.CSSProperty.prototype.set rawValue): >+ > 2019-02-01 Joseph Pecoraro <pecoraro@apple.com> > > Web Inspector: Make WI.ColumnChart a WI.View subclass >diff --git a/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js b/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js >index 09d61048421..bb40d391b8c 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js >+++ b/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js >@@ -171,6 +171,91 @@ WI.CSSCompletions = class CSSCompletions > target.CSSAgent.getSupportedSystemFontFamilyNames(fontFamilyNamesCallback); > } > >+ static completeUnbalancedValue(value) >+ { >+ const State = { >+ Data: 0, >+ SingleQuoteString: 1, >+ DoubleQuoteString: 2, >+ Comment: 3 >+ }; >+ >+ let state = State.Data; >+ let unclosedParenthesisCount = 0; >+ let trailingBackslash = false; >+ let length = value.length; >+ >+ for (let i = 0; i < length; ++i) { >+ switch (value[i]) { >+ case "'": >+ if (state === State.Data) >+ state = State.SingleQuoteString; >+ else if (state === State.SingleQuoteString) >+ state = State.Data; >+ break; >+ >+ case "\"": >+ if (state === State.Data) >+ state = State.DoubleQuoteString; >+ else if (state === State.DoubleQuoteString) >+ state = State.Data; >+ break; >+ >+ case "(": >+ if (state === State.Data) >+ ++unclosedParenthesisCount; >+ break; >+ >+ case ")": >+ if (state === State.Data && unclosedParenthesisCount) >+ --unclosedParenthesisCount; >+ break; >+ >+ case "/": >+ if (state === State.Data) { >+ if (value[i + 1] === "*") >+ state = State.Comment; >+ } >+ break; >+ >+ case "\\": >+ if (i === length - 1) >+ trailingBackslash = true; >+ else >+ ++i; // Skip next character. >+ break; >+ >+ case "*": >+ if (state === State.Comment) { >+ if (value[i + 1] === "/") >+ state = State.Data; >+ } >+ break; >+ } >+ } >+ >+ let suffix = ""; >+ >+ if (trailingBackslash) >+ suffix += "\\"; >+ >+ switch (state) { >+ case State.SingleQuoteString: >+ suffix += "'"; >+ break; >+ case State.DoubleQuoteString: >+ suffix += "\""; >+ break; >+ case State.Comment: >+ suffix += "*/"; >+ break; >+ } >+ >+ suffix += ")".repeat(unclosedParenthesisCount); >+ >+ return suffix; >+ } >+ > // Public > > get values() >diff --git a/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js b/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >index 1be38e5d5fe..3fa167aff4d 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >+++ b/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js >@@ -230,6 +230,10 @@ WI.CSSProperty = class CSSProperty extends WI.Object > > this._markModified(); > >+ let suffix = WI.CSSCompletions.completeUnbalancedValue(value); >+ if (suffix) >+ value += suffix; >+ > this._rawValue = value; > this._value = undefined; > this._updateStyleText();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 182523
:
333149
|
361144
|
361146
|
361363
|
361367
| 361521