Title: [135541] trunk/Source/WebCore
- Revision
- 135541
- Author
- [email protected]
- Date
- 2012-11-22 14:30:02 -0800 (Thu, 22 Nov 2012)
Log Message
Web Inspector: evaluate on hover regressed with the editor change
https://bugs.webkit.org/show_bug.cgi?id=103063
Reviewed by Vsevolod Vlasov.
We are no longer mutating the editor's dom from outside.
* inspector/front-end/DOMExtension.js:
(Element.prototype.remove):
* inspector/front-end/DefaultTextEditor.js:
(WebInspector.DefaultTextEditor.prototype.highlightRangesWithStyleClass):
(WebInspector.DefaultTextEditor.prototype.highlightExpression):
(WebInspector.DefaultTextEditor.prototype.hideHighlightedExpression):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype._getPopoverAnchor):
(WebInspector._javascript_SourceFrame.prototype._onHidePopover):
(WebInspector._javascript_SourceFrame.prototype._highlightExpression):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135540 => 135541)
--- trunk/Source/WebCore/ChangeLog 2012-11-22 22:14:52 UTC (rev 135540)
+++ trunk/Source/WebCore/ChangeLog 2012-11-22 22:30:02 UTC (rev 135541)
@@ -1,3 +1,23 @@
+2012-11-22 Pavel Feldman <[email protected]>
+
+ Web Inspector: evaluate on hover regressed with the editor change
+ https://bugs.webkit.org/show_bug.cgi?id=103063
+
+ Reviewed by Vsevolod Vlasov.
+
+ We are no longer mutating the editor's dom from outside.
+
+ * inspector/front-end/DOMExtension.js:
+ (Element.prototype.remove):
+ * inspector/front-end/DefaultTextEditor.js:
+ (WebInspector.DefaultTextEditor.prototype.highlightRangesWithStyleClass):
+ (WebInspector.DefaultTextEditor.prototype.highlightExpression):
+ (WebInspector.DefaultTextEditor.prototype.hideHighlightedExpression):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype._getPopoverAnchor):
+ (WebInspector._javascript_SourceFrame.prototype._onHidePopover):
+ (WebInspector._javascript_SourceFrame.prototype._highlightExpression):
+
2012-09-26 Gustavo Noronha Silva <[email protected]>
[GTK] Split SVG from WebCore to work-around make limitation
Modified: trunk/Source/WebCore/inspector/front-end/DOMExtension.js (135540 => 135541)
--- trunk/Source/WebCore/inspector/front-end/DOMExtension.js 2012-11-22 22:14:52 UTC (rev 135540)
+++ trunk/Source/WebCore/inspector/front-end/DOMExtension.js 2012-11-22 22:30:02 UTC (rev 135541)
@@ -200,6 +200,13 @@
return this.scrollTop + this.clientHeight === this.scrollHeight;
}
+Element.prototype.remove = function()
+{
+ if (this.parentElement)
+ this.parentElement.removeChild(this);
+}
+
+
/**
* @constructor
* @param {number} width
Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (135540 => 135541)
--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2012-11-22 22:14:52 UTC (rev 135540)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2012-11-22 22:30:02 UTC (rev 135541)
@@ -591,6 +591,67 @@
this._freeCachedElements();
},
+ /**
+ * @param {Element} element
+ * @param {Array.<Object>} resultRanges
+ * @param {string} styleClass
+ * @param {Array.<Object>=} changes
+ */
+ highlightRangesWithStyleClass: function(element, resultRanges, styleClass, changes)
+ {
+ this._mainPanel.beginDomUpdates();
+ WebInspector.highlightRangesWithStyleClass(element, resultRanges, styleClass, changes);
+ this._mainPanel.endDomUpdates();
+ },
+
+ /**
+ * @param {Element} element
+ * @param {Object} skipClasses
+ * @param {Object} skipTokens
+ * @return {Element}
+ */
+ highlightExpression: function(element, skipClasses, skipTokens)
+ {
+ // Collect tokens belonging to evaluated _expression_.
+ var tokens = [ element ];
+ var token = element.previousSibling;
+ while (token && (skipClasses[token.className] || skipTokens[token.textContent.trim()])) {
+ tokens.push(token);
+ token = token.previousSibling;
+ }
+ tokens.reverse();
+
+ // Wrap them with highlight element.
+ this._mainPanel.beginDomUpdates();
+ var parentElement = element.parentElement;
+ var nextElement = element.nextSibling;
+ var container = document.createElement("span");
+ for (var i = 0; i < tokens.length; ++i)
+ container.appendChild(tokens[i]);
+ parentElement.insertBefore(container, nextElement);
+ this._mainPanel.endDomUpdates();
+ return container;
+ },
+
+ /**
+ * @param {Element} highlightElement
+ */
+ hideHighlightedExpression: function(highlightElement)
+ {
+ this._mainPanel.beginDomUpdates();
+ var parentElement = highlightElement.parentElement;
+ if (parentElement) {
+ var child = highlightElement.firstChild;
+ while (child) {
+ var nextSibling = child.nextSibling;
+ parentElement.insertBefore(child, highlightElement);
+ child = nextSibling;
+ }
+ parentElement.removeChild(highlightElement);
+ }
+ this._mainPanel.endDomUpdates();
+ },
+
__proto__: WebInspector.View.prototype
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (135540 => 135541)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-11-22 22:14:52 UTC (rev 135540)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-11-22 22:30:02 UTC (rev 135541)
@@ -289,7 +289,7 @@
// 2. 'highlight' them with artificial style to detect word boundaries
var changes = [];
- WebInspector.highlightRangesWithStyleClass(lineElement, ranges, "source-frame-token", changes);
+ this.textEditor.highlightRangesWithStyleClass(lineElement, ranges, "source-frame-token", changes);
var lineOffsetLeft = lineElement.totalOffsetLeft();
for (var child = lineElement.firstChild; child; child = child.nextSibling) {
if (child.nodeType !== Node.ELEMENT_NODE || !child.hasStyleClass("source-frame-token"))
@@ -338,38 +338,17 @@
return;
// FIXME: the text editor should maintain highlight on its own. The check below is a workaround for
// the case when highlight element is detached from DOM by the TextEditor when re-building the DOM.
- var parentElement = highlightElement.parentElement;
- if (parentElement) {
- var child = highlightElement.firstChild;
- while (child) {
- var nextSibling = child.nextSibling;
- parentElement.insertBefore(child, highlightElement);
- child = nextSibling;
- }
- parentElement.removeChild(highlightElement);
- }
+ this.textEditor.hideHighlightedExpression(highlightElement);
delete this._highlightElement;
},
+ /**
+ * @param {Element} element
+ * @return {Element}
+ */
_highlightExpression: function(element)
{
- // Collect tokens belonging to evaluated _expression_.
- var tokens = [ element ];
- var token = element.previousSibling;
- while (token && (token.className === "webkit-_javascript_-ident" || token.className === "source-frame-token" || token.className === "webkit-_javascript_-keyword" || token.textContent.trim() === ".")) {
- tokens.push(token);
- token = token.previousSibling;
- }
- tokens.reverse();
-
- // Wrap them with highlight element.
- var parentElement = element.parentElement;
- var nextElement = element.nextSibling;
- var container = document.createElement("span");
- for (var i = 0; i < tokens.length; ++i)
- container.appendChild(tokens[i]);
- parentElement.insertBefore(container, nextElement);
- return container;
+ return this.textEditor.highlightExpression(element, { "webkit-_javascript_-ident": true, "source-frame-token": true, "webkit-_javascript_-keyword": true }, { ".": true });
},
/**
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes