Log Message
Web Inspector: unindent line ending block upon { hit.
https://bugs.webkit.org/show_bug.cgi?id=90795Reviewed by Vsevolod Vlasov. Added block-start / block-end markup into the highlighter. * inspector/front-end/SourceCSSTokenizer.js: (WebInspector.SourceCSSTokenizer.prototype.nextToken): * inspector/front-end/SourceCSSTokenizer.re2js: * inspector/front-end/SourceJavaScriptTokenizer.js: (WebInspector.SourceJavaScriptTokenizer.prototype.nextToken): * inspector/front-end/SourceJavaScriptTokenizer.re2js: * inspector/front-end/TextEditor.js: (WebInspector.TextEditorMainPanel.prototype._applyDomUpdates): (WebInspector.TextEditorMainPanel.prototype._unindentAfterBlock):
Modified Paths
- trunk/LayoutTests/inspector/syntax-highlight-css-expected.txt
- trunk/LayoutTests/inspector/syntax-highlight-_javascript_-expected.txt
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
- trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js
- trunk/Source/WebCore/inspector/front-end/SourceFrame.js
- trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js
- trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js
- trunk/Source/WebCore/inspector/front-end/TextEditor.js
Diff
Modified: trunk/LayoutTests/inspector/syntax-highlight-css-expected.txt (122113 => 122114)
--- trunk/LayoutTests/inspector/syntax-highlight-css-expected.txt 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/LayoutTests/inspector/syntax-highlight-css-expected.txt 2012-07-09 17:30:38 UTC (rev 122114)
@@ -4,9 +4,9 @@
#content > a:hover: *,webkit-css-selector,*,webkit-css-selector,*,webkit-css-selector
@import url(style.css);: webkit-css-at-rule,*,webkit-css-keyword,*
@import url("style.css") projection, tv;: webkit-css-at-rule,*,webkit-css-keyword,*,webkit-css-string,*,webkit-css-keyword,*,webkit-css-keyword,*
-@import "/css/fireball_unicode.css"; html {}: webkit-css-at-rule,*,webkit-css-string,*,webkit-css-selector,*
-@media screen { body { color: red; } }: webkit-css-at-rule,*,webkit-css-keyword,*,webkit-css-selector,*,webkit-css-property,*,webkit-css-color,*
-@font-face { font-family: "MyHelvetica"; }: webkit-css-at-rule,*,webkit-css-property,*,webkit-css-string,*
-p { color: color; red: red; color: #000; color: #FFF; color: #123AbC; color: #faebfe; color:papayawhip; }: webkit-css-selector,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*
-p { margin: -10px !important; }: webkit-css-selector,*,webkit-css-property,*,webkit-css-number,*,webkit-css-important,*
+@import "/css/fireball_unicode.css"; html {}: webkit-css-at-rule,*,webkit-css-string,*,webkit-css-selector,*,webkit-block-start,webkit-block-end
+@media screen { body { color: red; } }: webkit-css-at-rule,*,webkit-css-keyword,*,webkit-block-start,*,webkit-css-selector,*,webkit-block-start,*,webkit-css-property,*,webkit-css-color,*,webkit-block-end,*,webkit-block-end
+@font-face { font-family: "MyHelvetica"; }: webkit-css-at-rule,*,webkit-block-start,*,webkit-css-property,*,webkit-css-string,*,webkit-block-end
+p { color: color; red: red; color: #000; color: #FFF; color: #123AbC; color: #faebfe; color:papayawhip; }: webkit-css-selector,*,webkit-block-start,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-css-property,*,webkit-css-color,*,webkit-block-end
+p { margin: -10px !important; }: webkit-css-selector,*,webkit-block-start,*,webkit-css-property,*,webkit-css-number,*,webkit-css-important,*,webkit-block-end
Modified: trunk/LayoutTests/inspector/syntax-highlight-_javascript_-expected.txt (122113 => 122114)
--- trunk/LayoutTests/inspector/syntax-highlight-_javascript_-expected.txt 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/LayoutTests/inspector/syntax-highlight-_javascript_-expected.txt 2012-07-09 17:30:38 UTC (rev 122114)
@@ -15,6 +15,6 @@
foo/**
/
*/foo: webkit-_javascript_-ident,webkit-_javascript_-comment,,webkit-_javascript_-comment,,webkit-_javascript_-comment,webkit-_javascript_-ident
-{0: true}: *,webkit-_javascript_-number,*,webkit-_javascript_-keyword,*
+{0: true}: webkit-block-start,webkit-_javascript_-number,*,webkit-_javascript_-keyword,webkit-block-end
var toString;: webkit-_javascript_-keyword,*,webkit-_javascript_-ident,*
Modified: trunk/Source/WebCore/ChangeLog (122113 => 122114)
--- trunk/Source/WebCore/ChangeLog 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/ChangeLog 2012-07-09 17:30:38 UTC (rev 122114)
@@ -1,3 +1,22 @@
+2012-07-09 Pavel Feldman <[email protected]>
+
+ Web Inspector: unindent line ending block upon { hit.
+ https://bugs.webkit.org/show_bug.cgi?id=90795
+
+ Reviewed by Vsevolod Vlasov.
+
+ Added block-start / block-end markup into the highlighter.
+
+ * inspector/front-end/SourceCSSTokenizer.js:
+ (WebInspector.SourceCSSTokenizer.prototype.nextToken):
+ * inspector/front-end/SourceCSSTokenizer.re2js:
+ * inspector/front-end/SourceJavaScriptTokenizer.js:
+ (WebInspector.SourceJavaScriptTokenizer.prototype.nextToken):
+ * inspector/front-end/SourceJavaScriptTokenizer.re2js:
+ * inspector/front-end/TextEditor.js:
+ (WebInspector.TextEditorMainPanel.prototype._applyDomUpdates):
+ (WebInspector.TextEditorMainPanel.prototype._unindentAfterBlock):
+
2012-07-09 Sheriff Bot <[email protected]>
Unreviewed, rolling out r122107.
Modified: trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Dec 19 17:28:29 2011 */
+/* Generated by re2c 0.13.5 on Mon Jul 9 19:31:30 2012 */
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
*
@@ -33,14 +33,15 @@
/*
re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
- | sed 's|^yy\([^:]*\)*\:|case \1:|' \
- | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
- | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
- | sed 's|[*]cursor|this._charAt(cursor)|' \
- | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
- | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
- | sed 's|unsigned\ int|var|' \
- | sed 's|var\ yych|case 1: case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|yych <= \(0x[0-9a-fA-F]*\)|yych \<\= String.fromCharCode(\1)|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
*/
/**
@@ -648,7 +649,7 @@
case 45:
++cursor;
{
- this.tokenType = null;
+ this.tokenType = "block-start";
if (this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE)
this._condition.parseCondition = this._parseConditions.INITIAL;
else
@@ -658,7 +659,7 @@
case 47:
++cursor;
{
- this.tokenType = null;
+ this.tokenType = "block-end";
this._condition.parseCondition = this._parseConditions.INITIAL;
return cursor;
}
Modified: trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -32,14 +32,15 @@
/*
re2c -isc Source/WebCore/inspector/front-end/SourceCSSTokenizer.re2js \
- | sed 's|^yy\([^:]*\)*\:|case \1:|' \
- | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
- | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
- | sed 's|[*]cursor|this._charAt(cursor)|' \
- | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
- | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
- | sed 's|unsigned\ int|var|' \
- | sed 's|var\ yych|case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|yych <= \(0x[0-9a-fA-F]*\)|yych \<\= String.fromCharCode(\1)|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: var yych|' > Source/WebCore/inspector/front-end/SourceCSSTokenizer.js
*/
/**
@@ -211,7 +212,7 @@
<INITIAL> OpenCurlyBracket
{
- this.tokenType = null;
+ this.tokenType = "block-start";
if (this._condition.parseCondition === this._parseConditions.AT_MEDIA_RULE)
this._condition.parseCondition = this._parseConditions.INITIAL;
else
@@ -221,7 +222,7 @@
<INITIAL> CloseCurlyBracket
{
- this.tokenType = null;
+ this.tokenType = "block-end";
this._condition.parseCondition = this._parseConditions.INITIAL;
return cursor;
}
Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -169,6 +169,7 @@
this._clearLineToScrollTo();
this._lineToHighlight = line;
this._innerHighlightLineIfNeeded();
+ this._textEditor.setSelection(WebInspector.TextRange.createFromLocation(line, 0));
},
_innerHighlightLineIfNeeded: function()
Modified: trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri May 13 20:01:13 2011 */
+/* Generated by re2c 0.13.5 on Mon Jul 9 18:23:02 2012 */
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
*
@@ -29,18 +29,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// Generate js file as follows:
-//
-// re2c -isc WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
-// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
-// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
-// | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
-// | sed 's|[*]cursor|this._charAt(cursor)|' \
-// | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
-// | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
-// | sed 's|yych <= \(0x[0-9a-fA-f]+\)|yych <= String.fromCharCode(\1)|' \
-// | sed 's|unsigned\ int|var|' \
-// | sed 's|var\ yych|case 1: case 1: var yych|'
+/*
+ * Generate js file as follows:
+re2c -isc Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|{ gotoCase = \([^; continue; };]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|yych <= \(0x[0-9a-fA-F]*\)|yych \<\= String.fromCharCode(\1)|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: case 1: var yych|'
+ */
/**
* @constructor
@@ -90,7 +91,7 @@
while (1) {
switch (gotoCase)
// Following comment is replaced with generated state machine.
-
+
{
case 1: var yych;
var yyaccept = 0;
@@ -243,7 +244,15 @@
if ((yych = this._charAt(cursor)) == '=') { gotoCase = 115; continue; };
case 18:
this.setLexCondition(this._lexConditions.NODIV);
- { this.tokenType = null; return cursor; }
+ {
+ var token = this._line.charAt(cursorOnEnter);
+ if (token === "{")
+ this.tokenType = "block-start";
+ else if (token === "}")
+ this.tokenType = "block-end";
+ else this.tokenType = null;
+ return cursor;
+ }
case 19:
yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor);
@@ -1174,7 +1183,15 @@
++cursor;
if ((yych = this._charAt(cursor)) == '=') { gotoCase = 260; continue; };
case 139:
- { this.tokenType = null; return cursor; }
+ {
+ var token = this._line.charAt(cursorOnEnter);
+ if (token === "{")
+ this.tokenType = "block-start";
+ else if (token === "}")
+ this.tokenType = "block-end";
+ else this.tokenType = null;
+ return cursor;
+ }
case 140:
yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor);
Modified: trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -28,18 +28,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// Generate js file as follows:
-//
-// re2c -isc Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
-// | sed 's|^yy\([^:]*\)*\:|case \1:|' \
-// | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
-// | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
-// | sed 's|[*]cursor|this._charAt(cursor)|' \
-// | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
-// | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
-// | sed 's|yych <= \(0x[0-9a-fA-f]*\)|yych <= String.fromCharCode(\1)|' \
-// | sed 's|unsigned\ int|var|' \
-// | sed 's|var\ yych|case 1: var yych|'
+/*
+ * Generate js file as follows:
+re2c -isc Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js \
+ | sed 's|^yy\([^:]*\)*\:|case \1:|' \
+ | sed 's|[*]cursor[+][+]|this._charAt(cursor++)|' \
+ | sed 's|[[*][+][+]cursor|this._charAt(++cursor)|' \
+ | sed 's|[*]cursor|this._charAt(cursor)|' \
+ | sed 's|yych = \*\([^;]*\)|yych = this._charAt\1|' \
+ | sed 's|goto case \([^;]*\)|{ gotoCase = \1; continue; }|' \
+ | sed 's|yych <= \(0x[0-9a-fA-F]*\)|yych \<\= String.fromCharCode(\1)|' \
+ | sed 's|unsigned\ int|var|' \
+ | sed 's|var\ yych|case 1: var yych|' > Source/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js
+ */
/**
* @constructor
@@ -177,7 +178,16 @@
return cursor;
}
<DIV,NODIV> RightParen => DIV { this.tokenType = null; return cursor; }
- <DIV,NODIV> Punctuation => NODIV { this.tokenType = null; return cursor; }
+ <DIV,NODIV> Punctuation => NODIV
+ {
+ var token = this._line.charAt(cursorOnEnter);
+ if (token === "{")
+ this.tokenType = "block-start";
+ else if (token === "}")
+ this.tokenType = "block-end";
+ else this.tokenType = null;
+ return cursor;
+ }
<DIV> Division => NODIV { this.tokenType = null; return cursor; }
<*> [^] { this.tokenType = null; return cursor; }
*/
Modified: trunk/Source/WebCore/inspector/front-end/TextEditor.js (122113 => 122114)
--- trunk/Source/WebCore/inspector/front-end/TextEditor.js 2012-07-09 17:24:55 UTC (rev 122113)
+++ trunk/Source/WebCore/inspector/front-end/TextEditor.js 2012-07-09 17:30:38 UTC (rev 122114)
@@ -2191,6 +2191,9 @@
return; // Noop
}
+ if (lines.length === 1 && lines[0] === "}" && oldRange.isEmpty() && selection.isEmpty() && !this._textModel.line(oldRange.endLine).trim())
+ this._unindentAfterBlock(oldRange, selection);
+
// This is a "foreign" call outside of this class. Should be before we delete the dirty lines flag.
this._enterTextChangeMode();
@@ -2206,6 +2209,38 @@
/**
* @param {WebInspector.TextRange} oldRange
+ * @param {WebInspector.TextRange} selection
+ */
+ _unindentAfterBlock: function(oldRange, selection)
+ {
+ var nestingLevel = 1;
+ for (var i = oldRange.endLine; i >= 0; --i) {
+ var attribute = this._textModel.getAttribute(i, "highlight");
+ if (!attribute)
+ continue;
+ var columnNumbers = Object.keys(attribute).reverse();
+ for (var j = 0; j < columnNumbers.length; ++j) {
+ var column = columnNumbers[j];
+ if (attribute[column].tokenType === "block-start") {
+ if (!(--nestingLevel)) {
+ var lineContent = this._textModel.line(i);
+ var blockOffset = lineContent.length - lineContent.trimLeft().length;
+ if (blockOffset < oldRange.startColumn) {
+ oldRange.startColumn = blockOffset;
+ selection.startColumn = blockOffset + 1;
+ selection.endColumn = blockOffset + 1;
+ }
+ return;
+ }
+ }
+ if (attribute[column].tokenType === "block-end")
+ ++nestingLevel;
+ }
+ }
+ },
+
+ /**
+ * @param {WebInspector.TextRange} oldRange
* @param {WebInspector.TextRange} newRange
*/
textChanged: function(oldRange, newRange)
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo/webkit-changes
