Title: [127418] trunk
Revision
127418
Author
[email protected]
Date
2012-09-03 06:22:42 -0700 (Mon, 03 Sep 2012)

Log Message

Web Inspector: Unhide hidden characters
https://bugs.webkit.org/show_bug.cgi?id=93888

Reviewed by Pavel Feldman.

Source/WebCore:

Certain invisible characters will be rendered as HTML entity references in the DOM tree to make them visible to the user.

* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeElement.prototype._startEditingTextNode):

LayoutTests:

* inspector/elements/elements-panel-structure-expected.txt:
* inspector/elements/elements-panel-structure.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (127417 => 127418)


--- trunk/LayoutTests/ChangeLog	2012-09-03 13:20:02 UTC (rev 127417)
+++ trunk/LayoutTests/ChangeLog	2012-09-03 13:22:42 UTC (rev 127418)
@@ -1,3 +1,13 @@
+2012-09-03  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Unhide hidden characters
+        https://bugs.webkit.org/show_bug.cgi?id=93888
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/elements/elements-panel-structure-expected.txt:
+        * inspector/elements/elements-panel-structure.html:
+
 2012-09-03  Dominik Röttsches  <[email protected]>
 
         [EFL] Unreviewed gardening.

Modified: trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt (127417 => 127418)


--- trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt	2012-09-03 13:20:02 UTC (rev 127417)
+++ trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt	2012-09-03 13:22:42 UTC (rev 127418)
@@ -1,6 +1,6 @@
 Tests that elements panel shows DOM tree structure.
 
-"Quoted Text"
+"Quoted Text". Special characters: ><"'    ​‌‍‎‏
       <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 - <html>
     - <head>
@@ -14,7 +14,7 @@
           <p>Tests that elements panel shows DOM tree structure.</p>
         - <div id="level1">
             - <div id="level2">
-                  ""Quoted Text"        "
+                  ""Quoted Text". Special&nbsp;characters: ><"'&nbsp;&ensp;&emsp;&thinsp;&#8203;&zwnj;&zwj;&lrm;&rlm;"
                   <div id="level3"></div>
               </div>
           </div>

Modified: trunk/LayoutTests/inspector/elements/elements-panel-structure.html (127417 => 127418)


--- trunk/LayoutTests/inspector/elements/elements-panel-structure.html	2012-09-03 13:20:02 UTC (rev 127417)
+++ trunk/LayoutTests/inspector/elements/elements-panel-structure.html	2012-09-03 13:22:42 UTC (rev 127418)
@@ -25,8 +25,7 @@
 </p>
 
 <div id="level1">
-    <div id="level2">"Quoted Text"
-        <div id="level3"></div>
+    <div id="level2">"Quoted Text". Special&nbsp;characters: &gt;&lt;&quot;&apos;&nbsp;&ensp;&emsp;&thinsp;&#8203;&zwnj;&zwj;&lrm;&rlm;<div id="level3"></div>
     </div>
 </div>
 

Modified: trunk/Source/WebCore/ChangeLog (127417 => 127418)


--- trunk/Source/WebCore/ChangeLog	2012-09-03 13:20:02 UTC (rev 127417)
+++ trunk/Source/WebCore/ChangeLog	2012-09-03 13:22:42 UTC (rev 127418)
@@ -1,3 +1,15 @@
+2012-09-03  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Unhide hidden characters
+        https://bugs.webkit.org/show_bug.cgi?id=93888
+
+        Reviewed by Pavel Feldman.
+
+        Certain invisible characters will be rendered as HTML entity references in the DOM tree to make them visible to the user.
+
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeElement.prototype._startEditingTextNode):
+
 2012-09-03  Pavel Feldman  <[email protected]>
 
         Web Inspector: rename _javascript_ContextManager to RuntimeModel for consistency.

Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (127417 => 127418)


--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2012-09-03 13:20:02 UTC (rev 127417)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2012-09-03 13:22:42 UTC (rev 127418)
@@ -71,6 +71,18 @@
     SelectedNodeChanged: "SelectedNodeChanged"
 }
 
+WebInspector.ElementsTreeOutline.MappedCharToEntity = {
+    "\u00a0": "nbsp",
+    "\u2002": "ensp",
+    "\u2003": "emsp",
+    "\u2009": "thinsp",
+    "\u200b": "#8203",
+    "\u200c": "zwnj",
+    "\u200d": "zwj",
+    "\u200e": "lrm",
+    "\u200f": "rlm"
+}
+
 WebInspector.ElementsTreeOutline.prototype = {
     _createNodeDecorators: function()
     {
@@ -1302,7 +1314,7 @@
 
         var container = textNode.enclosingNodeOrSelfWithClass("webkit-html-text-node");
         if (container)
-            container.innerText = container.innerText; // Strip the CSS or JS highlighting if present.
+            container.innerText = textNode._originalContent; // Strip the CSS or JS highlighting if present.
         var config = new WebInspector.EditingConfig(this._textNodeEditingCommitted.bind(this), this._editingCancelled.bind(this));
         this._editing = WebInspector.startEditing(textNode, config);
         window.getSelection().setBaseAndExtent(textNode, 0, textNode, 1);
@@ -1703,6 +1715,25 @@
         parentElement.appendChild(document.createTextNode("\u200B"));
     },
 
+    _convertWhitespaceToEntities: function(text)
+    {
+        var result = "";
+        var lastIndexAfterEntity = 0;
+        var charToEntity = WebInspector.ElementsTreeOutline.MappedCharToEntity;
+        for (var i = 0, size = text.length; i < size; ++i) {
+            var char = text.charAt(i);
+            if (charToEntity[char]) {
+                result += text.substring(lastIndexAfterEntity, i) + "&" + charToEntity[char] + ";";
+                lastIndexAfterEntity = i + 1;
+            }
+        }
+        if (result) {
+            result += text.substring(lastIndexAfterEntity);
+            return result;
+        }
+        return text;
+    },
+
     _nodeTitleInfo: function(linkify)
     {
         var node = this.representedObject;
@@ -1741,7 +1772,8 @@
                 // create a subtree for them
                 if (showInlineText) {
                     var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node");
-                    textNodeElement.textContent = textChild.nodeValue();
+                    textNodeElement.textContent = this._convertWhitespaceToEntities(textChild.nodeValue());
+                    textNodeElement._originalContent = textChild.nodeValue();
                     info.titleDOM.appendChild(document.createTextNode("\u200B"));
                     this._buildTagDOM(info.titleDOM, tagName, true, false);
                     info.hasChildren = false;
@@ -1764,7 +1796,8 @@
                 } else {
                     info.titleDOM.appendChild(document.createTextNode("\""));
                     var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node");
-                    textNodeElement.textContent = node.nodeValue();
+                    textNodeElement.textContent = this._convertWhitespaceToEntities(node.nodeValue());
+                    textNodeElement._originalContent = node.nodeValue();
                     info.titleDOM.appendChild(document.createTextNode("\""));
                 }
                 break;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to