Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js

Issue 1899893003: [Devtools] JSONView implements Searchable interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js b/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
index 6ce99dc00c1f1c94d3aad73d8a81079a16be65ce..0185ab8db2cc3962b61e354d929110dfcef5bbf7 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js
@@ -213,9 +213,55 @@ WebInspector.ObjectPropertyTreeElement = function(property)
TreeElement.call(this);
this.toggleOnClick = true;
this.selectable = false;
+ /** @type {!Array.<!Object>} */
+ this._highlightChanges = [];
}
WebInspector.ObjectPropertyTreeElement.prototype = {
+ /**
+ * @param {!RegExp} regex
+ * @param {string=} additionalCssClassName
+ * @return {boolean}
+ */
+ setSearchRegex: function(regex, additionalCssClassName) {
+ var cssClasses = WebInspector.highlightedSearchResultClassName;
+ if (additionalCssClassName)
+ cssClasses += " " + additionalCssClassName;
+ this.revertHighlightChanges();
+
+ this._applySearch(regex, this.nameElement, cssClasses);
+ var valueType = this.property.value.type;
+ if (valueType !== "object" && valueType !== "array")
+ this._applySearch(regex, this.valueElement, cssClasses);
+
+ return !!this._highlightChanges.length;
+ },
+
+ /**
+ * @param {!RegExp} regex
+ * @param {!Element} element
+ * @param {string} cssClassName
+ */
+ _applySearch: function(regex, element, cssClassName)
+ {
+ var ranges = [];
+ var content = element.textContent;
+ regex.lastIndex = 0;
+ var match = regex.exec(content);
+ while (match) {
+ ranges.push(new WebInspector.SourceRange(match.index, match[0].length));
+ match = regex.exec(content);
+ }
+ if (ranges.length)
+ WebInspector.highlightRangesWithStyleClass(element, ranges, cssClassName, this._highlightChanges);
+ },
+
+ revertHighlightChanges: function()
+ {
+ WebInspector.revertDomChanges(this._highlightChanges);
+ this._highlightChanges = [];
+ },
+
onpopulate: function()
{
var propertyValue = /** @type {!WebInspector.RemoteObject} */ (this.property.value);

Powered by Google App Engine
This is Rietveld 408576698