<!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>[160552] 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/160552">160552</a></dd>
<dt>Author</dt> <dd>graouts@apple.com</dd>
<dt>Date</dt> <dd>2013-12-13 11:32:49 -0800 (Fri, 13 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: provide an abstraction for CodeMirror's TextMarker
https://bugs.webkit.org/show_bug.cgi?id=125695

Reviewed by Timothy Hatcher.

Introduce a new WebInspector.TextMarker class which is used by code with CodeMirror knowledge
to return information related to text markers to objects that should have no direct knowledge
of CodeMirror. Start using this class in TextEditor and SourceCodeTextEditor to remove the
last remaining pieces of CodeMirror knowledge added to SourceCodeTextEditor to fix
https://webkit.org/b/124364.

* UserInterface/CodeMirrorAdditions.js:
Stop using __markedColor to identify a color marker and instead use the type on the matching
WebInspector.TextMarker. Additionally, create a WebInspector.TextMarker with type
WebInspector.TextMarker.Type.Color in createColorMarkers().

* UserInterface/CodeMirrorColorEditingController.js:
(WebInspector.CodeMirrorColorEditingController):
Use a WebInspector.TextRange to track the edited range and obtain it directly from the
WebInspector.TextMaker used to instantiate the object. We also use the new &quot;text&quot; public
property to create the color.

(WebInspector.CodeMirrorColorEditingController.prototype.set color):
Simply assing the serialized color to the new &quot;text&quot; public property.

(WebInspector.CodeMirrorColorEditingController.prototype.get text):
(WebInspector.CodeMirrorColorEditingController.prototype.set text):
New public property to set get and set the text for the edited range, automatically updating
the range upon setting to a new text.

(WebInspector.CodeMirrorColorEditingController.prototype.presentHoverMenu):
Obtain the bounds directly from the WebInspector.TextMarker object.

* UserInterface/CodeMirrorTokenTrackingController.js:
(WebInspector.CodeMirrorTokenTrackingController.prototype._updateHoveredTokenInfo):
Since we're now tracking the hoveredMarker as a WebInspector.TextMarker, get the CodeMirror
TextMarker from that object to check if it's contained within the text markers at the
hovered position.

* UserInterface/Main.html:
Add the new TextMarker class source.

* UserInterface/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._hasColorMarkers):
Use the WebInspector.TextMarker type to identify a given text marker is marking a color.

(WebInspector.SourceCodeTextEditor.prototype.tokenTrackingControllerNewHighlightCandidate):
Use the renamed markersAtPosition() method from TextEditor.

(WebInspector.SourceCodeTextEditor.prototype._tokenTrackingControllerHighlightedMarkedExpression):
Use the WebInspector.TextMarker type to identify a given text marker is marking a color.

(WebInspector.SourceCodeTextEditor.prototype.colorEditingControllerDidFinishEditing):
Since the CodeMirrorColorEditingController is now using a WebInspector.TextRange for its range,
update to use a WebInspector.TextRange API to get the range's start line.

* UserInterface/TextEditor.js:
(WebInspector.TextEditor.prototype.get markers):
Return WebInspector.TextMarker objects instead of CodeMirror TextRange objects.

(WebInspector.TextEditor.prototype.markersAtPosition):
Rename method to a better name instead of using the CodeMirror-influenced name. Also, return
WebInspector.TextMarker objects instead of CodeMirror TextRange objects.

* UserInterface/TextMarker.js: Added.
(WebInspector.TextMarker):
Create a WebInspector.TextMarker with a CodeMirror TextMarker and an optional type.

(WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker):
Static method to either obtain the existing WebInspector.TextMarker for a given CodeMirror
TextMarker, or create a new WebInspector.TextMarker.

(WebInspector.TextMarker.prototype.get codeMirrorTextMarker):
Public property to access the CodeMirror TextMarker objects for classes that have direct
knowledge of CodeMirror.

(WebInspector.TextMarker.prototype.get type):
Public property to access the type used to create this text marker.

(WebInspector.TextMarker.prototype.get range):
(WebInspector.TextMarker.prototype.get bounds):
Public properties allowing easy access to generally useful information related to marked text.

(WebInspector.TextMarker.prototype.clear):
Wrapper for the CodeMirror TextMarker clear() method.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceCodeMirrorAdditionsjs">trunk/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceCodeMirrorColorEditingControllerjs">trunk/Source/WebInspectorUI/UserInterface/CodeMirrorColorEditingController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceCodeMirrorTokenTrackingControllerjs">trunk/Source/WebInspectorUI/UserInterface/CodeMirrorTokenTrackingController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceSourceCodeTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/SourceCodeTextEditor.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/TextEditor.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTextMarkerjs">trunk/Source/WebInspectorUI/UserInterface/TextMarker.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/ChangeLog        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -1,3 +1,91 @@
</span><ins>+2013-12-13  Antoine Quint  &lt;graouts@apple.com&gt;
+
+        Web Inspector: provide an abstraction for CodeMirror's TextMarker
+        https://bugs.webkit.org/show_bug.cgi?id=125695
+
+        Reviewed by Timothy Hatcher.
+
+        Introduce a new WebInspector.TextMarker class which is used by code with CodeMirror knowledge
+        to return information related to text markers to objects that should have no direct knowledge
+        of CodeMirror. Start using this class in TextEditor and SourceCodeTextEditor to remove the
+        last remaining pieces of CodeMirror knowledge added to SourceCodeTextEditor to fix
+        https://webkit.org/b/124364.
+
+        * UserInterface/CodeMirrorAdditions.js:
+        Stop using __markedColor to identify a color marker and instead use the type on the matching
+        WebInspector.TextMarker. Additionally, create a WebInspector.TextMarker with type
+        WebInspector.TextMarker.Type.Color in createColorMarkers().
+        
+        * UserInterface/CodeMirrorColorEditingController.js:
+        (WebInspector.CodeMirrorColorEditingController):
+        Use a WebInspector.TextRange to track the edited range and obtain it directly from the
+        WebInspector.TextMaker used to instantiate the object. We also use the new &quot;text&quot; public
+        property to create the color.
+
+        (WebInspector.CodeMirrorColorEditingController.prototype.set color):
+        Simply assing the serialized color to the new &quot;text&quot; public property.
+
+        (WebInspector.CodeMirrorColorEditingController.prototype.get text):
+        (WebInspector.CodeMirrorColorEditingController.prototype.set text):
+        New public property to set get and set the text for the edited range, automatically updating
+        the range upon setting to a new text.
+
+        (WebInspector.CodeMirrorColorEditingController.prototype.presentHoverMenu):
+        Obtain the bounds directly from the WebInspector.TextMarker object.
+
+        * UserInterface/CodeMirrorTokenTrackingController.js:
+        (WebInspector.CodeMirrorTokenTrackingController.prototype._updateHoveredTokenInfo):
+        Since we're now tracking the hoveredMarker as a WebInspector.TextMarker, get the CodeMirror
+        TextMarker from that object to check if it's contained within the text markers at the
+        hovered position.
+
+        * UserInterface/Main.html:
+        Add the new TextMarker class source.
+
+        * UserInterface/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype._hasColorMarkers):
+        Use the WebInspector.TextMarker type to identify a given text marker is marking a color.
+
+        (WebInspector.SourceCodeTextEditor.prototype.tokenTrackingControllerNewHighlightCandidate):
+        Use the renamed markersAtPosition() method from TextEditor.
+
+        (WebInspector.SourceCodeTextEditor.prototype._tokenTrackingControllerHighlightedMarkedExpression):
+        Use the WebInspector.TextMarker type to identify a given text marker is marking a color.
+
+        (WebInspector.SourceCodeTextEditor.prototype.colorEditingControllerDidFinishEditing):
+        Since the CodeMirrorColorEditingController is now using a WebInspector.TextRange for its range,
+        update to use a WebInspector.TextRange API to get the range's start line.
+
+        * UserInterface/TextEditor.js:
+        (WebInspector.TextEditor.prototype.get markers):
+        Return WebInspector.TextMarker objects instead of CodeMirror TextRange objects.
+
+        (WebInspector.TextEditor.prototype.markersAtPosition):
+        Rename method to a better name instead of using the CodeMirror-influenced name. Also, return
+        WebInspector.TextMarker objects instead of CodeMirror TextRange objects.
+
+        * UserInterface/TextMarker.js: Added.
+        (WebInspector.TextMarker):
+        Create a WebInspector.TextMarker with a CodeMirror TextMarker and an optional type.
+
+        (WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker):
+        Static method to either obtain the existing WebInspector.TextMarker for a given CodeMirror
+        TextMarker, or create a new WebInspector.TextMarker.
+
+        (WebInspector.TextMarker.prototype.get codeMirrorTextMarker):
+        Public property to access the CodeMirror TextMarker objects for classes that have direct
+        knowledge of CodeMirror.
+
+        (WebInspector.TextMarker.prototype.get type):
+        Public property to access the type used to create this text marker.
+
+        (WebInspector.TextMarker.prototype.get range):
+        (WebInspector.TextMarker.prototype.get bounds):
+        Public properties allowing easy access to generally useful information related to marked text.
+
+        (WebInspector.TextMarker.prototype.clear):
+        Wrapper for the CodeMirror TextMarker clear() method.
+
</ins><span class="cx"> 2013-12-13  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Switch WebKit solution to Visual Studio 2013
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceCodeMirrorAdditionsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/CodeMirrorAdditions.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -450,10 +450,10 @@
</span><span class="cx">                 var foundColorMarker = false;
</span><span class="cx">                 var markers = this.findMarksAt(to);
</span><span class="cx">                 for (var j = 0; j &lt; markers.length; ++j) {
</span><del>-                    if (!markers[j].__markedColor)
-                        continue;
-                    foundColorMarker = true;
-                    break;
</del><ins>+                    if (WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker(markers[j]).type === WebInspector.TextMarker.Type.Color) {
+                        foundColorMarker = true;
+                        break;
+                    }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (foundColorMarker) {
</span><span class="lines">@@ -469,7 +469,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 var marker = this.markText(from, to);
</span><del>-                marker.__markedColor = true;
</del><ins>+                marker = new WebInspector.TextMarker(marker, WebInspector.TextMarker.Type.Color);
</ins><span class="cx"> 
</span><span class="cx">                 createdMarkers.push(marker);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceCodeMirrorColorEditingControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/CodeMirrorColorEditingController.js (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/CodeMirrorColorEditingController.js        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/CodeMirrorColorEditingController.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -31,10 +31,9 @@
</span><span class="cx">     this._marker = marker;
</span><span class="cx">     this._delegate = null;
</span><span class="cx"> 
</span><del>-    this._range = marker.find();
</del><ins>+    this._range = marker.range;
+    this._color = WebInspector.Color.fromString(this.text);
</ins><span class="cx"> 
</span><del>-    this._color = WebInspector.Color.fromString(codeMirror.getRange(this._range.from, this._range.to));
-
</del><span class="cx">     this._keyboardShortcutEsc = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -61,10 +60,7 @@
</span><span class="cx">     
</span><span class="cx">     set color(color)
</span><span class="cx">     {
</span><del>-        var colorText = color.toString();
-        this._codeMirror.replaceRange(colorText, this._range.from, this._range.to);
-        this._range.to.ch = this._range.from.ch + colorText.length;
-
</del><ins>+        this.text = color.toString();
</ins><span class="cx">         this._color = color;
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="lines">@@ -77,15 +73,31 @@
</span><span class="cx">     {
</span><span class="cx">         this._delegate = delegate;
</span><span class="cx">     },
</span><ins>+
+    get text()
+    {
+        var from = {line: this._range.startLine, ch: this._range.startColumn};
+        var to = {line: this._range.endLine, ch: this._range.endColumn};
+        return this._codeMirror.getRange(from, to);
+    },
</ins><span class="cx">     
</span><ins>+    set text(text)
+    {
+        var from = {line: this._range.startLine, ch: this._range.startColumn};
+        var to = {line: this._range.endLine, ch: this._range.endColumn};
+        this._codeMirror.replaceRange(text, from, to);
+
+        var lines = text.split(&quot;\n&quot;);
+        var endLine = this._range.startLine + lines.length - 1;
+        var endColumn = lines.length &gt; 1 ? lines.lastValue.length : this._range.startColumn + text.length;
+        this._range = new WebInspector.TextRange(this._range.startLine, this._range.startColumn, endLine, endColumn);
+    },
+    
</ins><span class="cx">     presentHoverMenu: function()
</span><span class="cx">     {
</span><span class="cx">         this._hoverMenu = new WebInspector.HoverMenu(this);
</span><span class="cx">         this._hoverMenu.element.classList.add(&quot;color&quot;);
</span><del>-        this._bounds = this._codeMirror.boundsForRange({
-            start: this._range.from,
-            end: this._range.to
-        });
</del><ins>+        this._bounds = this._marker.bounds;
</ins><span class="cx">         this._hoverMenu.present(this._bounds);
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceCodeMirrorTokenTrackingControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/CodeMirrorTokenTrackingController.js (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/CodeMirrorTokenTrackingController.js        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/CodeMirrorTokenTrackingController.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -305,8 +305,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (!token || !token.type || !token.string) {
</span><span class="cx">             if (this._hoveredMarker &amp;&amp; this._delegate &amp;&amp; typeof this._delegate.tokenTrackingControllerMouseOutOfHoveredMarker === &quot;function&quot;) {
</span><del>-                var markers = this._codeMirror.findMarksAt(position);
-                if (!markers.contains(this._hoveredMarker))
</del><ins>+                if (!this._codeMirror.findMarksAt(position).contains(this._hoveredMarker.codeMirrorTextMarker))
</ins><span class="cx">                     this._delegate.tokenTrackingControllerMouseOutOfHoveredMarker(this, this._hoveredMarker);
</span><span class="cx">             }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -286,6 +286,7 @@
</span><span class="cx">     &lt;script src=&quot;ResourceSearchMatchObject.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;SearchResultTreeElement.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;TextRange.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;TextMarker.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;ConsoleMessage.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;ConsoleMessageImpl.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;ConsoleGroup.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceSourceCodeTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/SourceCodeTextEditor.js (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/SourceCodeTextEditor.js        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/SourceCodeTextEditor.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -1016,7 +1016,7 @@
</span><span class="cx">     _hasColorMarkers: function()
</span><span class="cx">     {
</span><span class="cx">         for (var marker of this.markers) {
</span><del>-            if (marker.__markedColor)
</del><ins>+            if (marker.type === WebInspector.TextMarker.Type.Color)
</ins><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">         return false;
</span><span class="lines">@@ -1070,7 +1070,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (this.tokenTrackingController.mode === WebInspector.CodeMirrorTokenTrackingController.Mode.MarkedTokens) {
</span><del>-            var markers = this.findMarkersAtPosition(candidate.hoveredTokenRange.start);
</del><ins>+            var markers = this.markersAtPosition(candidate.hoveredTokenRange.start);
</ins><span class="cx">             if (markers.length &gt; 0)
</span><span class="cx">                 this._tokenTrackingControllerHighlightedMarkedExpression(candidate, markers);
</span><span class="cx">             else
</span><span class="lines">@@ -1298,7 +1298,7 @@
</span><span class="cx">     {
</span><span class="cx">         var colorMarker;
</span><span class="cx">         for (var marker of markers) {
</span><del>-            if (marker.__markedColor) {
</del><ins>+            if (marker.type === WebInspector.TextMarker.Type.Color) {
</ins><span class="cx">                 colorMarker = marker;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="lines">@@ -1356,7 +1356,7 @@
</span><span class="cx">     
</span><span class="cx">     colorEditingControllerDidFinishEditing: function(colorEditingController)
</span><span class="cx">     {
</span><del>-        this._updateColorMarkers(colorEditingController.range.from.line);
</del><ins>+        this._updateColorMarkers(colorEditingController.range.startLine);
</ins><span class="cx"> 
</span><span class="cx">         this._ignoreContentDidChange--;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/TextEditor.js (160551 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/TextEditor.js        2013-12-13 19:27:21 UTC (rev 160551)
+++ trunk/Source/WebInspectorUI/UserInterface/TextEditor.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -603,13 +603,16 @@
</span><span class="cx"> 
</span><span class="cx">     get markers()
</span><span class="cx">     {
</span><del>-        // FIXME: we should not return CodeMirror TextMarker objects but rather wrappers.
-        return this._codeMirror.getAllMarks();
</del><ins>+        return this._codeMirror.getAllMarks().map(function(codeMirrorTextMarker) {
+            return WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker(codeMirrorTextMarker);
+        });
</ins><span class="cx">     },
</span><span class="cx"> 
</span><del>-    findMarkersAtPosition: function(position)
</del><ins>+    markersAtPosition: function(position)
</ins><span class="cx">     {
</span><del>-        return this._codeMirror.findMarksAt(position);
</del><ins>+        return this._codeMirror.findMarksAt(position).map(function(codeMirrorTextMarker) {
+            return WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker(codeMirrorTextMarker);
+        });
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     createColorMarkers: function(lineNumber)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTextMarkerjs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/TextMarker.js (0 => 160552)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/TextMarker.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/TextMarker.js        2013-12-13 19:32:49 UTC (rev 160552)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.TextMarker = function(codeMirrorTextMarker, type)
+{
+    WebInspector.Object.call(this);
+
+    this._codeMirrorTextMarker = codeMirrorTextMarker;
+    codeMirrorTextMarker.__webInspectorTextMarker = this;
+
+    this._type = type || WebInspector.TextMarker.Type.Plain;
+}
+
+WebInspector.TextMarker.Type = {
+    Color: &quot;text-marker-type-color&quot;,
+    Plain: &quot;text-marker-type-plain&quot;
+};
+
+WebInspector.TextMarker.textMarkerForCodeMirrorTextMarker = function(codeMirrorTextMarker)
+{
+    return codeMirrorTextMarker.__webInspectorTextMarker || new WebInspector.TextMarker(codeMirrorTextMarker);
+};
+
+WebInspector.TextMarker.prototype = {
+    constructor: WebInspector.TextMarker,
+    __proto__: WebInspector.Object.prototype,
+    
+    // Public
+
+    get codeMirrorTextMarker()
+    {
+        return this._codeMirrorTextMarker;
+    },
+
+    get type()
+    {
+        return this._type;
+    },
+
+    get range()
+    {
+        var range = this._codeMirrorTextMarker.find();
+        if (!range)
+            return null;
+        return new WebInspector.TextRange(range.from.line, range.from.ch, range.to.line, range.to.ch);
+    },
+
+    get bounds()
+    {
+        var range = this._codeMirrorTextMarker.find();
+        if (!range)
+            return WebInspector.Rect.ZERO_RECT;
+        return this._codeMirrorTextMarker.doc.cm.boundsForRange({
+            start: range.from,
+            end: range.to
+        });
+    },
+    
+    clear: function()
+    {
+        this._codeMirrorTextMarker.clear();
+    }
+};
</ins></span></pre>
</div>
</div>

</body>
</html>