<!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>[285711] 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/285711">285711</a></dd>
<dt>Author</dt> <dd>rcaliman@apple.com</dd>
<dt>Date</dt> <dd>2021-11-12 02:54:05 -0800 (Fri, 12 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Extract reusable logic from ResourceQueryController, ResourceQueryResult and ResourceQueryMatch
https://bugs.webkit.org/show_bug.cgi?id=231604
<rdar://problem/84160281>

Reviewed by Devin Rousso.

Extract reusable logic from `ResourceQueryController` into a generic `QueryController`
to enable subclassing for other specialized use cases.

* UserInterface/Controllers/QueryController.js: Added.
(WI.QueryController.prototype.executeQuery):
(WI.QueryController.prototype.findQueryMatches.pushMatch):
(WI.QueryController.prototype.findQueryMatches.matchNextSpecialCharacter):
(WI.QueryController.prototype.findQueryMatches.backtrack):
(WI.QueryController.prototype.findQueryMatches):
(WI.QueryController):

Keep only the reusable matching logic in `QueryController`.
Subclasses like `ResourceQueryController` are responsible for agregating
the data to be queried, customization for special characters and sorting results.

* UserInterface/Controllers/ResourceQueryController.js:
(WI.ResourceQueryController.prototype.executeQuery):
(WI.ResourceQueryController.prototype._findQueryMatches.pushMatch): Deleted.
(WI.ResourceQueryController.prototype._findQueryMatches.matchNextSpecialCharacter): Deleted.
(WI.ResourceQueryController.prototype._findQueryMatches.backtrack): Deleted.
(WI.ResourceQueryController.prototype._findQueryMatches): Deleted.

* UserInterface/Main.html:

* UserInterface/Models/QueryMatch.js: Renamed from Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js.

`ResourceQueryMatch` doesn't contain any resource-specific logic. It can be generalized to `QueryMatch`.

* UserInterface/Models/QueryResult.js: Copied from Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js.
(WI.QueryResult):
(WI.QueryResult.prototype.get value):
(WI.QueryResult.prototype.get rank):
(WI.QueryResult.prototype.get matchingTextRanges):
(WI.QueryResult.prototype._calculateRank.getMultiplier):
(WI.QueryResult.prototype._calculateRank):
(WI.QueryResult.prototype._createMatchingTextRanges):

A generic `QueryResult` can be extracted from `ResourceQueryResult` containing
the reusable logic for ranking results and identifing matching text ranges.

* UserInterface/Models/ResourceQueryResult.js:
(WI.ResourceQueryResult):
(WI.ResourceQueryResult.prototype.get resource):
(WI.ResourceQueryResult.prototype.__test_createMatchesMask):
(WI.ResourceQueryResult.prototype.get rank): Deleted.
(WI.ResourceQueryResult.prototype.get matchingTextRanges): Deleted.
(WI.ResourceQueryResult.prototype._calculateRank.getMultiplier): Deleted.
(WI.ResourceQueryResult.prototype._calculateRank): Deleted.
(WI.ResourceQueryResult.prototype._createMatchingTextRanges): Deleted.

`ResourceQueryResult` extends `QueryResult` with resource-specifc members:
- the `cookie` property which holds the optional line and column info used when jumping to matched files
- the `resource` property which maps to the generic `QueryResult.value`; this is used in tests and when sorting in `ResourceQueryController`

* UserInterface/Test.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersResourceQueryControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/ResourceQueryController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryResultjs">trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTesthtml">trunk/Source/WebInspectorUI/UserInterface/Test.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersQueryControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/QueryController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsQueryMatchjs">trunk/Source/WebInspectorUI/UserInterface/Models/QueryMatch.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsQueryResultjs">trunk/Source/WebInspectorUI/UserInterface/Models/QueryResult.js</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryMatchjs">trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/ChangeLog       2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2021-11-12  Razvan Caliman  <rcaliman@apple.com>
+
+        Web Inspector: Extract reusable logic from ResourceQueryController, ResourceQueryResult and ResourceQueryMatch
+        https://bugs.webkit.org/show_bug.cgi?id=231604
+        <rdar://problem/84160281>
+
+        Reviewed by Devin Rousso.
+
+        Extract reusable logic from `ResourceQueryController` into a generic `QueryController`
+        to enable subclassing for other specialized use cases.
+
+        * UserInterface/Controllers/QueryController.js: Added.
+        (WI.QueryController.prototype.executeQuery):
+        (WI.QueryController.prototype.findQueryMatches.pushMatch):
+        (WI.QueryController.prototype.findQueryMatches.matchNextSpecialCharacter):
+        (WI.QueryController.prototype.findQueryMatches.backtrack):
+        (WI.QueryController.prototype.findQueryMatches):
+        (WI.QueryController):
+
+        Keep only the reusable matching logic in `QueryController`.
+        Subclasses like `ResourceQueryController` are responsible for agregating
+        the data to be queried, customization for special characters and sorting results.
+
+        * UserInterface/Controllers/ResourceQueryController.js:
+        (WI.ResourceQueryController.prototype.executeQuery):
+        (WI.ResourceQueryController.prototype._findQueryMatches.pushMatch): Deleted.
+        (WI.ResourceQueryController.prototype._findQueryMatches.matchNextSpecialCharacter): Deleted.
+        (WI.ResourceQueryController.prototype._findQueryMatches.backtrack): Deleted.
+        (WI.ResourceQueryController.prototype._findQueryMatches): Deleted.
+
+        * UserInterface/Main.html:
+
+        * UserInterface/Models/QueryMatch.js: Renamed from Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js.
+
+        `ResourceQueryMatch` doesn't contain any resource-specific logic. It can be generalized to `QueryMatch`.
+
+        * UserInterface/Models/QueryResult.js: Copied from Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js.
+        (WI.QueryResult):
+        (WI.QueryResult.prototype.get value):
+        (WI.QueryResult.prototype.get rank):
+        (WI.QueryResult.prototype.get matchingTextRanges):
+        (WI.QueryResult.prototype._calculateRank.getMultiplier):
+        (WI.QueryResult.prototype._calculateRank):
+        (WI.QueryResult.prototype._createMatchingTextRanges):
+
+        A generic `QueryResult` can be extracted from `ResourceQueryResult` containing
+        the reusable logic for ranking results and identifing matching text ranges.
+
+        * UserInterface/Models/ResourceQueryResult.js:
+        (WI.ResourceQueryResult):
+        (WI.ResourceQueryResult.prototype.get resource):
+        (WI.ResourceQueryResult.prototype.__test_createMatchesMask):
+        (WI.ResourceQueryResult.prototype.get rank): Deleted.
+        (WI.ResourceQueryResult.prototype.get matchingTextRanges): Deleted.
+        (WI.ResourceQueryResult.prototype._calculateRank.getMultiplier): Deleted.
+        (WI.ResourceQueryResult.prototype._calculateRank): Deleted.
+        (WI.ResourceQueryResult.prototype._createMatchingTextRanges): Deleted.
+
+        `ResourceQueryResult` extends `QueryResult` with resource-specifc members:
+        - the `cookie` property which holds the optional line and column info used when jumping to matched files
+        - the `resource` property which maps to the generic `QueryResult.value`; this is used in tests and when sorting in `ResourceQueryController`
+
+        * UserInterface/Test.html:
+
</ins><span class="cx"> 2021-11-10  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove non-standard -webkit-border-fit CSS property
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersQueryControllerjs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/Controllers/QueryController.js (0 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/QueryController.js                         (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/QueryController.js    2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -0,0 +1,111 @@
</span><ins>+/*
+ * Copyright (C) 2021 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.
+ */
+
+WI.QueryController = class QueryController
+{
+    // Public
+
+    executeQuery(query)
+    {
+        throw WI.NotImplementedError.subclassMustOverride();
+    }
+
+    findQueryMatches(query, searchString, specialCharacterIndices)
+    {
+        if (query.length > searchString.length)
+            return [];
+
+        let matches = [];
+        let queryIndex = 0;
+        let searchIndex = 0;
+        let specialIndex = 0;
+        let deadBranches = (new Array(query.length)).fill(Infinity);
+        let type = WI.QueryMatch.Type.Special;
+
+        function pushMatch(index) {
+            matches.push(new WI.QueryMatch(type, index, queryIndex));
+            searchIndex = index + 1;
+            queryIndex++;
+        }
+
+        function matchNextSpecialCharacter() {
+            if (specialIndex >= specialCharacterIndices.length)
+                return false;
+
+            let originalSpecialIndex = specialIndex;
+            while (specialIndex < specialCharacterIndices.length) {
+                // Normal character matching can move past special characters,
+                // so advance the special character index if it's before the
+                // current search string position.
+                let index = specialCharacterIndices[specialIndex++];
+                if (index < searchIndex)
+                    continue;
+
+                if (query[queryIndex] === searchString[index]) {
+                    pushMatch(index);
+                    return true;
+                }
+            }
+
+            specialIndex = originalSpecialIndex;
+            return false;
+        }
+
+        function backtrack() {
+            while (matches.length) {
+                queryIndex--;
+
+                let lastMatch = matches.pop();
+                if (lastMatch.type !== WI.QueryMatch.Type.Special)
+                    continue;
+
+                deadBranches[lastMatch.queryIndex] = lastMatch.index;
+                searchIndex = matches.lastValue ? matches.lastValue.index + 1 : 0;
+                return true;
+            }
+
+            return false;
+        }
+
+        while (queryIndex < query.length && searchIndex <= searchString.length) {
+            if (type === WI.QueryMatch.Type.Special && !matchNextSpecialCharacter())
+                type = WI.QueryMatch.Type.Normal;
+
+            if (type === WI.QueryMatch.Type.Normal) {
+                let index = searchString.indexOf(query[queryIndex], searchIndex);
+                if (index >= 0 && index < deadBranches[queryIndex]) {
+                    pushMatch(index);
+                    type = WI.QueryMatch.Type.Special;
+                } else if (!backtrack())
+                    return [];
+            }
+        }
+
+        if (queryIndex < query.length)
+            return [];
+
+        return matches;
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersResourceQueryControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/ResourceQueryController.js (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/ResourceQueryController.js 2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/ResourceQueryController.js    2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-WI.ResourceQueryController = class ResourceQueryController extends WI.Object
</del><ins>+WI.ResourceQueryController = class ResourceQueryController extends WI.QueryController
</ins><span class="cx"> {
</span><span class="cx">     constructor()
</span><span class="cx">     {
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">                 cachedData.specialCharacterIndices = this._findSpecialCharacterIndices(displayName);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            let matches = this._findQueryMatches(query, cachedData.searchString, cachedData.specialCharacterIndices);
</del><ins>+            let matches = this.findQueryMatches(query, cachedData.searchString, cachedData.specialCharacterIndices);
</ins><span class="cx">             if (matches.length)
</span><span class="cx">                 results.push(new WI.ResourceQueryResult(resource, matches, cookie));
</span><span class="cx">         }
</span><span class="lines">@@ -89,86 +89,6 @@
</span><span class="cx"> 
</span><span class="cx">     // Private
</span><span class="cx"> 
</span><del>-    _findQueryMatches(query, searchString, specialCharacterIndices)
-    {
-        if (query.length > searchString.length)
-            return [];
-
-        let matches = [];
-        let queryIndex = 0;
-        let searchIndex = 0;
-        let specialIndex = 0;
-        let deadBranches = new Array(query.length).fill(Infinity);
-        let type = WI.ResourceQueryMatch.Type.Special;
-
-        function pushMatch(index)
-        {
-            matches.push(new WI.ResourceQueryMatch(type, index, queryIndex));
-            searchIndex = index + 1;
-            queryIndex++;
-        }
-
-        function matchNextSpecialCharacter()
-        {
-            if (specialIndex >= specialCharacterIndices.length)
-                return false;
-
-            let originalSpecialIndex = specialIndex;
-            while (specialIndex < specialCharacterIndices.length) {
-                // Normal character matching can move past special characters,
-                // so advance the special character index if it's before the
-                // current search string position.
-                let index = specialCharacterIndices[specialIndex++];
-                if (index < searchIndex)
-                    continue;
-
-                if (query[queryIndex] === searchString[index]) {
-                    pushMatch(index);
-                    return true;
-                }
-            }
-
-            specialIndex = originalSpecialIndex;
-            return false;
-        }
-
-        function backtrack()
-        {
-            while (matches.length) {
-                queryIndex--;
-
-                let lastMatch = matches.pop();
-                if (lastMatch.type !== WI.ResourceQueryMatch.Type.Special)
-                    continue;
-
-                deadBranches[lastMatch.queryIndex] = lastMatch.index;
-                searchIndex = matches.lastValue ? matches.lastValue.index + 1 : 0;
-                return true;
-            }
-
-            return false;
-        }
-
-        while (queryIndex < query.length && searchIndex <= searchString.length) {
-            if (type === WI.ResourceQueryMatch.Type.Special && !matchNextSpecialCharacter())
-                type = WI.ResourceQueryMatch.Type.Normal;
-
-            if (type === WI.ResourceQueryMatch.Type.Normal) {
-                let index = searchString.indexOf(query[queryIndex], searchIndex);
-                if (index >= 0 && index < deadBranches[queryIndex]) {
-                    pushMatch(index);
-                    type = WI.ResourceQueryMatch.Type.Special;
-                } else if (!backtrack())
-                    return [];
-            }
-        }
-
-        if (queryIndex < query.length)
-            return [];
-
-        return matches;
-    }
-
</del><span class="cx">     _findSpecialCharacterIndices(string)
</span><span class="cx">     {
</span><span class="cx">         if (!string.length)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html      2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -468,6 +468,8 @@
</span><span class="cx">     <script src="Models/PropertyDescriptor.js"></script>
</span><span class="cx">     <script src="Models/PropertyPath.js"></script>
</span><span class="cx">     <script src="Models/PropertyPreview.js"></script>
</span><ins>+    <script src="Models/QueryMatch.js"></script>
+    <script src="Models/QueryResult.js"></script>
</ins><span class="cx">     <script src="Models/Recording.js"></script>
</span><span class="cx">     <script src="Models/RecordingAction.js"></script>
</span><span class="cx">     <script src="Models/RecordingFrame.js"></script>
</span><span class="lines">@@ -476,7 +478,6 @@
</span><span class="cx">     <script src="Models/Redirect.js"></script>
</span><span class="cx">     <script src="Models/RenderingFrameTimelineRecord.js"></script>
</span><span class="cx">     <script src="Models/ResourceCollection.js"></script>
</span><del>-    <script src="Models/ResourceQueryMatch.js"></script>
</del><span class="cx">     <script src="Models/ResourceQueryResult.js"></script>
</span><span class="cx">     <script src="Models/ResourceTimelineRecord.js"></script>
</span><span class="cx">     <script src="Models/ResourceTimingData.js"></script>
</span><span class="lines">@@ -887,6 +888,7 @@
</span><span class="cx"> 
</span><span class="cx">     <script src="Controllers/Annotator.js"></script>
</span><span class="cx">     <script src="Controllers/CodeMirrorEditingController.js"></script>
</span><ins>+    <script src="Controllers/QueryController.js"></script>
</ins><span class="cx"> 
</span><span class="cx">     <script src="Controllers/AnimationManager.js"></script>
</span><span class="cx">     <script src="Controllers/AuditManager.js"></script>
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsQueryMatchjsfromrev285710trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryMatchjs"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebInspectorUI/UserInterface/Models/QueryMatch.js (from rev 285710, trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js) (0 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/QueryMatch.js                           (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/QueryMatch.js      2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2021 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.
+ */
+
+WI.QueryMatch = class QueryMatch
+{
+    constructor(type, index, queryIndex)
+    {
+        console.assert(Object.values(WI.QueryMatch.Type).includes(type), type);
+        console.assert(index >= 0, index);
+        console.assert(queryIndex >= 0, queryIndex);
+        this._type = type;
+        this._index = index;
+        this._queryIndex = queryIndex;
+    }
+
+    // Public
+
+    get type() { return this._type; }
+    get index() { return this._index; }
+    get queryIndex() { return this._queryIndex; }
+};
+
+WI.QueryMatch.Type = {
+    Normal: Symbol("normal"),
+    Special: Symbol("special"),
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsQueryResultjsfromrev285710trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryResultjs"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebInspectorUI/UserInterface/Models/QueryResult.js (from rev 285710, trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js) (0 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/QueryResult.js                          (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/QueryResult.js     2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -0,0 +1,126 @@
</span><ins>+/*
+ * Copyright (C) 2021 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.
+ */
+
+WI.QueryResult = class QueryResult
+{
+    constructor(value, matches)
+    {
+        console.assert(matches.length, "Query matches list can't be empty.");
+
+        this._value = value;
+        this._matches = matches;
+    }
+
+    // Public
+
+    get value() { return this._value; }
+
+    get rank()
+    {
+        if (this._rank === undefined)
+            this._calculateRank();
+
+        return this._rank;
+    }
+
+    get matchingTextRanges()
+    {
+        this._matchingTextRanges ??= this._createMatchingTextRanges();
+
+        return this._matchingTextRanges;
+    }
+
+    // Private
+
+    _calculateRank()
+    {
+        const normalWeight = 10;
+        const consecutiveWeight = 5;
+        const specialMultiplier = 5;
+
+        function getMultiplier(match) {
+            if (match.type === WI.QueryMatch.Type.Special)
+                return specialMultiplier;
+
+            return 1;
+        }
+
+        this._rank = 0;
+
+        let previousMatch = null;
+        let consecutiveMatchStart = null;
+        for (let match of this._matches) {
+            this._rank += normalWeight * getMultiplier(match);
+
+            let consecutive = previousMatch && previousMatch.index === match.index - 1;
+            if (consecutive) {
+                if (!consecutiveMatchStart)
+                    consecutiveMatchStart = previousMatch;
+
+                // If the first match in this consecutive series was a special character, give a
+                // bonus (more likely to match a specific word in the text).  Otherwise, multiply
+                // by the current length of the consecutive sequence (gives priority to fewer
+                // longer sequences instead of more short sequences).
+                this._rank += consecutiveWeight * getMultiplier(consecutiveMatchStart) * (match.index - consecutiveMatchStart.index);
+            } else if (consecutiveMatchStart)
+                consecutiveMatchStart = null;
+
+            previousMatch = match;
+
+            // The match index is deducted from the total rank, so matches that occur closer to
+            // the beginning of the string are ranked higher.  Increase the amount subtracted if
+            // the match is special, so as to favor matches towards the beginning of the string.
+            if (!consecutive)
+                this._rank -= match.index * getMultiplier(match);
+        }
+    }
+
+    _createMatchingTextRanges()
+    {
+        if (!this._matches.length)
+            return [];
+
+        let ranges = [];
+        let startIndex = this._matches[0].index;
+        let endIndex = startIndex;
+        for (let i = 1; i < this._matches.length; ++i) {
+            let match = this._matches[i];
+
+            // Increment endIndex for consecutive match.
+            if (match.index === endIndex + 1) {
+                endIndex++;
+                continue;
+            }
+
+            // Begin a new range when a gap between this match and the previous match is found.
+            ranges.push(new WI.TextRange(0, startIndex, 0, endIndex + 1));
+            startIndex = match.index;
+            endIndex = startIndex;
+        }
+
+        ranges.push(new WI.TextRange(0, startIndex, 0, endIndex + 1));
+        return ranges;
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryMatchjs"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js   2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryMatch.js      2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -1,45 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 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.
- */
-
-WI.ResourceQueryMatch = class ResourceQueryMatch
-{
-    constructor(type, index, queryIndex)
-    {
-        this._type = type;
-        this._index = index;
-        this._queryIndex = queryIndex;
-    }
-
-    // Public
-
-    get type() { return this._type; }
-    get index() { return this._index; }
-    get queryIndex() { return this._queryIndex; }
-};
-
-WI.ResourceQueryMatch.Type = {
-    Normal: Symbol("normal"),
-    Special: Symbol("special")
-};
</del></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsResourceQueryResultjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js  2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ResourceQueryResult.js     2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -23,115 +23,26 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-WI.ResourceQueryResult = class ResourceQueryResult
</del><ins>+WI.ResourceQueryResult = class ResourceQueryResult extends WI.QueryResult
</ins><span class="cx"> {
</span><span class="cx">     constructor(resource, matches, cookie)
</span><span class="cx">     {
</span><del>-        console.assert(matches.length, "Query matches list can't be empty.");
</del><ins>+        console.assert(resource instanceof WI.Resource, resource);
+        super(resource, matches);
</ins><span class="cx"> 
</span><del>-        this._resource = resource;
-        this._matches = matches;
</del><span class="cx">         this._cookie = cookie || null;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Public
</span><span class="cx"> 
</span><del>-    get resource() { return this._resource; }
</del><ins>+    get resource() { return this.value; }
</ins><span class="cx">     get cookie() { return this._cookie; }
</span><span class="cx"> 
</span><del>-    get rank()
-    {
-        if (this._rank === undefined)
-            this._calculateRank();
-
-        return this._rank;
-    }
-
-    get matchingTextRanges()
-    {
-        if (!this._matchingTextRanges)
-            this._matchingTextRanges = this._createMatchingTextRanges();
-
-        return this._matchingTextRanges;
-    }
-
-    // Private
-
-    _calculateRank()
-    {
-        const normalWeight = 10;
-        const consecutiveWeight = 5;
-        const specialMultiplier = 5;
-
-        function getMultiplier(match) {
-            if (match.type === WI.ResourceQueryMatch.Type.Special)
-                return specialMultiplier;
-
-            return 1;
-        }
-
-        this._rank = 0;
-
-        let previousMatch = null;
-        let consecutiveMatchStart = null;
-        for (let match of this._matches) {
-            this._rank += normalWeight * getMultiplier(match);
-
-            let consecutive = previousMatch && previousMatch.index === match.index - 1;
-            if (consecutive) {
-                if (!consecutiveMatchStart)
-                    consecutiveMatchStart = previousMatch;
-
-                // If the first match in this consecutive series was a special character, give a
-                // bonus (more likely to match a specific word in the text).  Otherwise, multiply
-                // by the current length of the consecutive sequence (gives priority to fewer
-                // longer sequences instead of more short sequences).
-                this._rank += consecutiveWeight * getMultiplier(consecutiveMatchStart) * (match.index - consecutiveMatchStart.index);
-            } else if (consecutiveMatchStart)
-                consecutiveMatchStart = null;
-
-            previousMatch = match;
-
-            // The match index is deducted from the total rank, so matches that occur closer to
-            // the beginning of the string are ranked higher.  Increase the amount subtracted if
-            // the match is special, so as to favor matches towards the beginning of the string.
-            if (!consecutive)
-                this._rank -= match.index * getMultiplier(match);
-        }
-    }
-
-    _createMatchingTextRanges()
-    {
-        if (!this._matches.length)
-            return [];
-
-        let ranges = [];
-        let startIndex = this._matches[0].index;
-        let endIndex = startIndex;
-        for (let i = 1; i < this._matches.length; ++i) {
-            let match = this._matches[i];
-
-            // Increment endIndex for consecutive match.
-            if (match.index === endIndex + 1) {
-                endIndex++;
-                continue;
-            }
-
-            // Begin a new range when a gap between this match and the previous match is found.
-            ranges.push(new WI.TextRange(0, startIndex, 0, endIndex + 1));
-            startIndex = match.index;
-            endIndex = startIndex;
-        }
-
-        ranges.push(new WI.TextRange(0, startIndex, 0, endIndex + 1));
-        return ranges;
-    }
-
</del><span class="cx">     // Testing
</span><span class="cx"> 
</span><span class="cx">     __test_createMatchesMask()
</span><span class="cx">     {
</span><del>-        let filename = this._resource.displayName;
</del><ins>+        let filename = this.resource.displayName;
</ins><span class="cx">         let lastIndex = -1;
</span><span class="cx">         let result = "";
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTesthtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (285710 => 285711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test.html      2021-11-12 10:50:47 UTC (rev 285710)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2021-11-12 10:54:05 UTC (rev 285711)
</span><span class="lines">@@ -196,6 +196,8 @@
</span><span class="cx">     <script src="Models/ProfileNodeCall.js"></script>
</span><span class="cx">     <script src="Models/PropertyDescriptor.js"></script>
</span><span class="cx">     <script src="Models/PropertyPreview.js"></script>
</span><ins>+    <script src="Models/QueryMatch.js"></script>
+    <script src="Models/QueryResult.js"></script>
</ins><span class="cx">     <script src="Models/Recording.js"></script>
</span><span class="cx">     <script src="Models/RecordingAction.js"></script>
</span><span class="cx">     <script src="Models/RecordingFrame.js"></script>
</span><span class="lines">@@ -204,7 +206,6 @@
</span><span class="cx">     <script src="Models/Redirect.js"></script>
</span><span class="cx">     <script src="Models/RenderingFrameTimelineRecord.js"></script>
</span><span class="cx">     <script src="Models/ResourceCollection.js"></script>
</span><del>-    <script src="Models/ResourceQueryMatch.js"></script>
</del><span class="cx">     <script src="Models/ResourceQueryResult.js"></script>
</span><span class="cx">     <script src="Models/ResourceTimelineRecord.js"></script>
</span><span class="cx">     <script src="Models/ResourceTimingData.js"></script>
</span><span class="lines">@@ -244,6 +245,8 @@
</span><span class="cx">     <script src="Proxies/HeapSnapshotProxy.js"></script>
</span><span class="cx">     <script src="Proxies/HeapSnapshotWorkerProxy.js"></script>
</span><span class="cx"> 
</span><ins>+    <script src="Controllers/QueryController.js"></script>
+
</ins><span class="cx">     <script src="Controllers/AnimationManager.js"></script>
</span><span class="cx">     <script src="Controllers/AuditManager.js"></script>
</span><span class="cx">     <script src="Controllers/ApplicationCacheManager.js"></script>
</span></span></pre>
</div>
</div>

</body>
</html>