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

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, 8 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 a7b85c688df575a4d536cc3b673609781ea72373..d38eceb4c64667ee07aa47cea9c0dbd2065aa3a7 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,58 @@ WebInspector.ObjectPropertyTreeElement = function(property)
TreeElement.call(this);
this.toggleOnClick = true;
this.selectable = false;
+ this._highlightChanges = [];
}
WebInspector.ObjectPropertyTreeElement.prototype = {
+ /**
+ * @param {!RegExp} regex
+ * @param {string=} additionalCssClassName
+ * @return {boolean}
+ */
+ applyHighlight: function(regex, additionalCssClassName) {
lushnikov 2016/04/22 19:43:00 setSearchRegex: .. to be consistent with ConsoleV
allada 2016/04/25 23:48:49 Done.
+ var nameRanges = [];
+ var valueRanges = [];
+ if (additionalCssClassName)
+ var cssClasses = [additionalCssClassName, WebInspector.highlightedSearchResultClassName];
+ else
+ var cssClasses = [WebInspector.highlightedSearchResultClassName];
+
+ this.revertHighlightChanges();
+
+ var nameContent = this.nameElement.textContent;
+ regex.lastIndex = 0;
+ var match = regex.exec(nameContent);
+ while (match) {
lushnikov 2016/04/22 19:43:00 this could be extracted
allada 2016/04/25 23:48:49 Done.
+ nameRanges.push(new WebInspector.SourceRange(match.index, match[0].length));
+ match = regex.exec(nameContent);
+ }
+ var className = WebInspector.highlightedSearchResultClassName;
+ if (nameRanges.length)
+ WebInspector.highlightRangesWithStyleClass(this.nameElement, nameRanges, cssClasses.join(" "), this._highlightChanges);
+
+ var valueType = this.property.value.type;
+ if (valueType !== "object" && valueType !== "array") {
+ var valueContent = this.valueElement.textContent;
+ regex.lastIndex = 0;
+ match = regex.exec(valueContent);
+ while (match) {
+ valueRanges.push(new WebInspector.SourceRange(match.index, match[0].length));
+ match = regex.exec(valueContent);
+ }
+ if (valueRanges.length)
+ WebInspector.highlightRangesWithStyleClass(this.valueElement, valueRanges, cssClasses.join(" "), this._highlightChanges);
+ }
+
+ return !!this._highlightChanges.length;
+ },
+
+ 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