<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179390] trunk/Source/WebInspectorUI</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179390">179390</a></dd>
<dt>Author</dt> <dd>saambarati1@gmail.com</dd>
<dt>Date</dt> <dd>2015-01-29 20:02:25 -0800 (Thu, 29 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Make BasicBlockAnnotator lessen the saturation of syntax highlighting instead of graying out unexecuted code
https://bugs.webkit.org/show_bug.cgi?id=141011

Reviewed by Timothy Hatcher.

This patch removes a lot of the complicated logic associated around 
determining which code can be grayed out by the BasicBlockAnnotator. 
Instead, the BasicBlockAnnotator now applies a CSS class to all the
code that has not executed which lessens the saturation of the 
syntax coloring for the code. This creates both a nicer user
interface and a nicer user experience because it makes reading
source code with the BasicBlockAnnotator enabled more pleasant.

* UserInterface/Controllers/BasicBlockAnnotator.js:
(WebInspector.BasicBlockAnnotator.prototype._annotateBasicBlockExecutionRanges.):
(WebInspector.BasicBlockAnnotator.prototype._annotateBasicBlockExecutionRanges):
(WebInspector.BasicBlockAnnotator.prototype.set _highlightTextForBasicBlock):
(WebInspector.BasicBlockAnnotator.prototype._isTextRangeOnlyWhitespace): Deleted.
(WebInspector.BasicBlockAnnotator.prototype._isTextRangeOnlyClosingBrace): Deleted.
(_canGrayOutEntireLine): Deleted.
(_grayOutLine): Deleted.
(_clearRangeForBasicBlockMarker.get marker): Deleted.
(_clearRangeForBasicBlockMarker): Deleted.
* UserInterface/Views/SourceCodeTextEditor.css:
(.hover-menu.color &gt; img):
(.basic-block-has-not-executed): Deleted.
(.basic-block-has-not-executed-prepend::before): Deleted.
* UserInterface/Views/SyntaxHighlightingDefaultTheme.css:
(.cm-s-default .basic-block-has-not-executed):
(.cm-s-default .basic-block-has-not-executed.cm-comment):
(.cm-s-default .basic-block-has-not-executed.cm-m-css:matches(.cm-atom, .cm-meta, .cm-variable-3, .cm-property)):
(.cm-s-default .basic-block-has-not-executed:matches(.cm-number, .cm-atom.cm-hex-color)):
(.cm-s-default .basic-block-has-not-executed.cm-string):
(.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-meta):
(.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-attribute):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersBasicBlockAnnotatorjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorcss">trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsSyntaxHighlightingDefaultThemecss">trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (179389 => 179390)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-01-30 02:00:47 UTC (rev 179389)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-01-30 04:02:25 UTC (rev 179390)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2015-01-29  Saam Barati  &lt;saambarati1@gmail.com&gt;
+
+        Web Inspector: Make BasicBlockAnnotator lessen the saturation of syntax highlighting instead of graying out unexecuted code
+        https://bugs.webkit.org/show_bug.cgi?id=141011
+
+        Reviewed by Timothy Hatcher.
+
+        This patch removes a lot of the complicated logic associated around 
+        determining which code can be grayed out by the BasicBlockAnnotator. 
+        Instead, the BasicBlockAnnotator now applies a CSS class to all the
+        code that has not executed which lessens the saturation of the 
+        syntax coloring for the code. This creates both a nicer user
+        interface and a nicer user experience because it makes reading
+        source code with the BasicBlockAnnotator enabled more pleasant.
+
+        * UserInterface/Controllers/BasicBlockAnnotator.js:
+        (WebInspector.BasicBlockAnnotator.prototype._annotateBasicBlockExecutionRanges.):
+        (WebInspector.BasicBlockAnnotator.prototype._annotateBasicBlockExecutionRanges):
+        (WebInspector.BasicBlockAnnotator.prototype.set _highlightTextForBasicBlock):
+        (WebInspector.BasicBlockAnnotator.prototype._isTextRangeOnlyWhitespace): Deleted.
+        (WebInspector.BasicBlockAnnotator.prototype._isTextRangeOnlyClosingBrace): Deleted.
+        (_canGrayOutEntireLine): Deleted.
+        (_grayOutLine): Deleted.
+        (_clearRangeForBasicBlockMarker.get marker): Deleted.
+        (_clearRangeForBasicBlockMarker): Deleted.
+        * UserInterface/Views/SourceCodeTextEditor.css:
+        (.hover-menu.color &gt; img):
+        (.basic-block-has-not-executed): Deleted.
+        (.basic-block-has-not-executed-prepend::before): Deleted.
+        * UserInterface/Views/SyntaxHighlightingDefaultTheme.css:
+        (.cm-s-default .basic-block-has-not-executed):
+        (.cm-s-default .basic-block-has-not-executed.cm-comment):
+        (.cm-s-default .basic-block-has-not-executed.cm-m-css:matches(.cm-atom, .cm-meta, .cm-variable-3, .cm-property)):
+        (.cm-s-default .basic-block-has-not-executed:matches(.cm-number, .cm-atom.cm-hex-color)):
+        (.cm-s-default .basic-block-has-not-executed.cm-string):
+        (.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-meta):
+        (.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-attribute):
+
</ins><span class="cx"> 2015-01-29  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: ES6: Improved Console Format for Set and Map Objects (like Arrays)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersBasicBlockAnnotatorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js (179389 => 179390)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js        2015-01-30 02:00:47 UTC (rev 179389)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js        2015-01-30 04:02:25 UTC (rev 179390)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WebInspector.BasicBlockAnnotator.HasNotExecutedClassName = &quot;basic-block-has-not-executed&quot;;
</span><del>-WebInspector.BasicBlockAnnotator.HasNotExecutedPrependClassName = &quot;basic-block-has-not-executed-prepend&quot;;
</del><span class="cx"> 
</span><span class="cx"> WebInspector.BasicBlockAnnotator.prototype = {
</span><span class="cx">     constructor: WebInspector.BasicBlockAnnotator,
</span><span class="lines">@@ -72,7 +71,7 @@
</span><span class="cx"> 
</span><span class="cx">             var {startOffset, endOffset} = this.sourceCodeTextEditor.visibleRangeOffsets();
</span><span class="cx">             basicBlocks = basicBlocks.filter(function(block) {
</span><del>-                return block.startOffset &gt;= startOffset &amp;&amp; block.startOffset &lt;= endOffset;
</del><ins>+                return (block.startOffset &gt;= startOffset &amp;&amp; block.startOffset &lt;= endOffset) || (block.startOffset &lt;= startOffset &amp;&amp; block.endOffset &gt;= endOffset);
</ins><span class="cx">             });
</span><span class="cx"> 
</span><span class="cx">             for (var block of basicBlocks) {
</span><span class="lines">@@ -82,14 +81,13 @@
</span><span class="cx">                 if (hasKey &amp;&amp; hasExecuted)
</span><span class="cx">                     this._clearRangeForBasicBlockMarker(key);
</span><span class="cx">                 else if (!hasKey &amp;&amp; !hasExecuted) {
</span><del>-                    var basicBlockMarker = this._highlightTextForBasicBlock(block);
-                    if (basicBlockMarker)
-                        this._basicBlockMarkers.set(key, basicBlockMarker);
-                }
</del><ins>+                    var marker = this._highlightTextForBasicBlock(block);
+                    this._basicBlockMarkers.set(key, marker);
+                } 
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             var totalTime = Date.now() - startTime;
</span><del>-            var timeoutTime = Math.min(Math.max(6500, totalTime), 15 * totalTime);
</del><ins>+            var timeoutTime = Math.min(Math.max(6500, totalTime), 30 * totalTime);
</ins><span class="cx">             this._timeoutIdentifier = setTimeout(this.insertAnnotations.bind(this), timeoutTime);
</span><span class="cx">         }.bind(this));
</span><span class="cx">     },
</span><span class="lines">@@ -101,92 +99,25 @@
</span><span class="cx"> 
</span><span class="cx">         var startPosition = this.sourceCodeTextEditor.originalOffsetToCurrentPosition(basicBlock.startOffset);
</span><span class="cx">         var endPosition = this.sourceCodeTextEditor.originalOffsetToCurrentPosition(basicBlock.endOffset);
</span><del>-
-        if (this._isTextRangeOnlyWhitespace(startPosition, endPosition) || this._isTextRangeOnlyClosingBrace(startPosition, endPosition))
</del><ins>+        if (this._isTextRangeOnlyClosingBrace(startPosition, endPosition))
</ins><span class="cx">             return null;
</span><span class="cx"> 
</span><del>-        // Gray out the text range.
</del><span class="cx">         var marker = this.sourceCodeTextEditor.addStyleToTextRange(startPosition, endPosition, WebInspector.BasicBlockAnnotator.HasNotExecutedClassName);
</span><del>-
-        // When adding a style to the code range in CodeMirror, such as a background color, it will only apply the style
-        // to the area where text is, not to the style of an entire line. But, from a user interface perspective, it looks
-        // cleaner to have entire lines highlighted. The following logic grays out entire lines when the line's range is
-        // not across basic block boundaries.
-        var lineStyles = [];
-        if (endPosition.line &gt; startPosition.line) {
-            var startLineEndPosition = {line: startPosition.line, ch: this.sourceCodeTextEditor.line(startPosition.line).length};
-            if (this._canGrayOutEntireLine(startPosition.line, startPosition, startLineEndPosition)) {
-                this._grayOutLine(startPosition.line);
-                lineStyles.push({line: startPosition.line, className: WebInspector.BasicBlockAnnotator.HasNotExecutedClassName});
-            }
-
-            var endLineStartPosition = {line: endPosition.line, ch: 0};
-             
-            if (this._canGrayOutEntireLine(endPosition.line, endLineStartPosition, endPosition)) {
-                this._grayOutLine(endPosition.line);
-                lineStyles.push({line: endPosition.line, className: WebInspector.BasicBlockAnnotator.HasNotExecutedClassName});
-            } else {
-                this.sourceCodeTextEditor.addStyleClassToLine(endPosition.line, WebInspector.BasicBlockAnnotator.HasNotExecutedPrependClassName);
-                lineStyles.push({line: endPosition.line, className: WebInspector.BasicBlockAnnotator.HasNotExecutedPrependClassName});
-            }
-        } else {
-            console.assert(endPosition.line === startPosition.line);
-            if (this._canGrayOutEntireLine(startPosition.line, startPosition, endPosition)) {
-                this._grayOutLine(startPosition.line);
-                lineStyles.push({line: startPosition.line, className: WebInspector.BasicBlockAnnotator.HasNotExecutedClassName});
-            } else if (startPosition.ch === 0) {
-                this.sourceCodeTextEditor.addStyleClassToLine(endPosition.line, WebInspector.BasicBlockAnnotator.HasNotExecutedPrependClassName);
-                lineStyles.push({line: startPosition.line, className: WebInspector.BasicBlockAnnotator.HasNotExecutedPrependClassName});
-            }
-        }
-
-        if (endPosition.line - startPosition.line &gt;= 2) {
-            // There is at least one entire line to be grayed out between the start and end position of the basic block:
-            // n  : ...
-            // n+1: ... (This entire line can safely be grayed out).
-            // n+2: ...
-            for (var lineNumber = startPosition.line + 1; lineNumber &lt; endPosition.line; lineNumber++) {
-                this._grayOutLine(lineNumber);
-                lineStyles.push({line: lineNumber, className: WebInspector.BasicBlockAnnotator.HasNotExecutedClassName});
-            }
-        }
-
-        return {marker: marker, lineStyles: lineStyles};
</del><ins>+        return marker;
</ins><span class="cx">     },
</span><span class="cx"> 
</span><del>-    _isTextRangeOnlyWhitespace: function(startPosition, endPosition)
-    {
-        var isOnlyWhitespace = /^\s+$/;
-        return isOnlyWhitespace.test(this.sourceCodeTextEditor.getTextInRange(startPosition, endPosition));
-    },
-
</del><span class="cx">     _isTextRangeOnlyClosingBrace: function(startPosition, endPosition)
</span><span class="cx">     {
</span><span class="cx">         var isOnlyClosingBrace = /^\s*\}$/;
</span><span class="cx">         return isOnlyClosingBrace.test(this.sourceCodeTextEditor.getTextInRange(startPosition, endPosition));
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    _canGrayOutEntireLine: function(lineNumber, startPosition, endPosition)
-    {
-        console.assert(startPosition.line === endPosition.line);
-        var lineText = this.sourceCodeTextEditor.line(lineNumber);
-        var blockText = this.sourceCodeTextEditor.getTextInRange(startPosition, endPosition);
-        return lineText.trim() === blockText.trim();
-    },
-
-    _grayOutLine: function(lineNumber)
-    {
-        var className = WebInspector.BasicBlockAnnotator.HasNotExecutedClassName;
-        this.sourceCodeTextEditor.addStyleClassToLine(lineNumber, className);
-    },
-
</del><span class="cx">     _clearRangeForBasicBlockMarker: function(key)
</span><span class="cx">     {
</span><span class="cx">         console.assert(this._basicBlockMarkers.has(key));
</span><del>-        var {marker, lineStyles} = this._basicBlockMarkers.get(key);
-        marker.clear();
-        for (var {line, className} of lineStyles)
-            this.sourceCodeTextEditor.removeStyleClassFromLine(line, className);
</del><ins>+        var marker = this._basicBlockMarkers.get(key);
+        if (marker)
+            marker.clear();
</ins><span class="cx">         this._basicBlockMarkers.delete(key);
</span><span class="cx">     }
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.css (179389 => 179390)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.css        2015-01-30 02:00:47 UTC (rev 179389)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.css        2015-01-30 04:02:25 UTC (rev 179390)
</span><span class="lines">@@ -76,16 +76,3 @@
</span><span class="cx"> 
</span><span class="cx">     -webkit-transform: translateY(1px);
</span><span class="cx"> }
</span><del>-
-.basic-block-has-not-executed {
-    background-color: rgb(240, 240, 240);
-}
-
-.basic-block-has-not-executed-prepend::before {
-    background-color: rgb(240, 240, 240);
-    position: absolute;
-    content: &quot;&quot;; 
-    height: 13px;
-    left: 0px;
-    width: 7px;
-}
</del></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsSyntaxHighlightingDefaultThemecss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css (179389 => 179390)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css        2015-01-30 02:00:47 UTC (rev 179389)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css        2015-01-30 04:02:25 UTC (rev 179390)
</span><span class="lines">@@ -90,3 +90,32 @@
</span><span class="cx">     background-color: rgba(235, 215, 38, 0.2);
</span><span class="cx">     border-bottom: 1px solid rgb(237, 202, 71);
</span><span class="cx"> }
</span><ins>+
+.cm-s-default .basic-block-has-not-executed {
+    color: rgb(153, 153, 153);
+}
+
+.cm-s-default .basic-block-has-not-executed.cm-comment {
+    color: hsl(143, 191, 143);
+}
+
+.cm-s-default .basic-block-has-not-executed:matches(.cm-tag, .cm-bracket, .cm-atom, .cm-keyword, .cm-m-javascript.cm-builtin),
+.cm-s-default .basic-block-has-not-executed.cm-m-css:matches(.cm-atom, .cm-meta, .cm-variable-3, .cm-property) {
+    color: rgb(196, 164, 191);
+}
+
+.cm-s-default .basic-block-has-not-executed:matches(.cm-number, .cm-atom.cm-hex-color) {
+    color: rgb(180, 172, 229);
+}
+
+.cm-s-default .basic-block-has-not-executed.cm-string {
+    color: rgb(204, 154, 153);
+}
+
+.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-meta {
+    color: rgb(210, 210, 210);
+}
+
+.cm-s-default .basic-block-has-not-executed.cm-m-xml.cm-attribute {
+    color: rgb(201, 192, 166);
+}
</ins></span></pre>
</div>
</div>

</body>
</html>