Title: [226517] trunk/Source/WebInspectorUI
- Revision
- 226517
- Author
- [email protected]
- Date
- 2018-01-08 09:42:17 -0800 (Mon, 08 Jan 2018)
Log Message
Web Inspector: Find next / previous within a resource content view does not have bouncy highlight when editor scrolls
https://bugs.webkit.org/show_bug.cgi?id=181279
<rdar://problem/36291097>
Patch by Joseph Pecoraro <[email protected]> on 2018-01-08
Reviewed by Brian Burg.
* UserInterface/Views/TextEditor.js:
(WI.TextEditor.prototype._revealSearchResult):
Reposition the bouncy highlight on scroll based on the CodeMirror
line/ch position of the search result.
(WI.TextEditor.prototype._removeBouncyHighlightElementIfNeeded):
Track the bouncy highlight scroll handler in a member variable so that
we always remember to remove it and don't leak scroll handlers.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (226516 => 226517)
--- trunk/Source/WebInspectorUI/ChangeLog 2018-01-08 17:40:21 UTC (rev 226516)
+++ trunk/Source/WebInspectorUI/ChangeLog 2018-01-08 17:42:17 UTC (rev 226517)
@@ -1,3 +1,20 @@
+2018-01-08 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Find next / previous within a resource content view does not have bouncy highlight when editor scrolls
+ https://bugs.webkit.org/show_bug.cgi?id=181279
+ <rdar://problem/36291097>
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Views/TextEditor.js:
+ (WI.TextEditor.prototype._revealSearchResult):
+ Reposition the bouncy highlight on scroll based on the CodeMirror
+ line/ch position of the search result.
+
+ (WI.TextEditor.prototype._removeBouncyHighlightElementIfNeeded):
+ Track the bouncy highlight scroll handler in a member variable so that
+ we always remember to remove it and don't leak scroll handlers.
+
2018-01-07 David Kilzer <[email protected]>
Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (226516 => 226517)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2018-01-08 17:40:21 UTC (rev 226516)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2018-01-08 17:42:17 UTC (rev 226517)
@@ -1055,7 +1055,7 @@
_revealSearchResult(result, changeFocus, directionInCaseOfRevalidation)
{
- var position = result.find();
+ let position = result.find();
// Check for a valid position, it might have been removed from editing by the user.
// If the position is invalide, revalidate all positions reveal as needed.
@@ -1078,50 +1078,55 @@
if (changeFocus)
this._codeMirror.focus();
+ // Collect info for the bouncy highlight.
+ let highlightEditorPosition = this._codeMirror.getCursor("start");
+ let textContent = this._codeMirror.getSelection();
+
// Remove the bouncy highlight if it is still around. The animation will not
// start unless we remove it and add it back to the document.
- if (this._bouncyHighlightElement)
- this._bouncyHighlightElement.remove();
+ this._removeBouncyHighlightElementIfNeeded();
// Create the bouncy highlight.
this._bouncyHighlightElement = document.createElement("div");
this._bouncyHighlightElement.className = WI.TextEditor.BouncyHighlightStyleClassName;
+ this._bouncyHighlightElement.textContent = textContent;
- // Collect info for the bouncy highlight.
- var textContent = this._codeMirror.getSelection();
- var coordinates = this._codeMirror.cursorCoords(true, "page");
+ function positionBouncyHighlight() {
+ // Adjust the coordinates to be based in the text editor's space.
+ let coordinates = this._codeMirror.cursorCoords(highlightEditorPosition, "page");
+ let textEditorRect = this.element.getBoundingClientRect();
+ coordinates.top -= textEditorRect.top;
+ coordinates.left -= textEditorRect.left;
- // Adjust the coordinates to be based in the text editor's space.
- let textEditorRect = this.element.getBoundingClientRect();
- coordinates.top -= textEditorRect.top;
- coordinates.left -= textEditorRect.left;
+ // Position the bouncy highlight.
+ this._bouncyHighlightElement.style.top = coordinates.top + "px";
+ this._bouncyHighlightElement.style.left = coordinates.left + "px";
+ }
- // Position and show the bouncy highlight.
- this._bouncyHighlightElement.textContent = textContent;
- this._bouncyHighlightElement.style.top = coordinates.top + "px";
- this._bouncyHighlightElement.style.left = coordinates.left + "px";
+ // Position and show the highlight.
+ positionBouncyHighlight.call(this);
this.element.appendChild(this._bouncyHighlightElement);
- let scrollHandler = () => {
- if (this._bouncyHighlightElement)
- this._bouncyHighlightElement.remove();
- };
+ // Reposition the highlight if the editor scrolls.
+ this._bouncyHighlightScrollHandler = () => { positionBouncyHighlight.call(this); };
+ this.addScrollHandler(this._bouncyHighlightScrollHandler);
- this.addScrollHandler(scrollHandler);
+ // Listen for the end of the animation so we can remove the element.
+ this._bouncyHighlightElement.addEventListener("animationend", () => {
+ this._removeBouncyHighlightElementIfNeeded();
+ });
+ }
- function animationEnded()
- {
- if (!this._bouncyHighlightElement)
- return;
+ _removeBouncyHighlightElementIfNeeded()
+ {
+ if (!this._bouncyHighlightElement)
+ return;
- this._bouncyHighlightElement.remove();
- delete this._bouncyHighlightElement;
+ this.removeScrollHandler(this._bouncyHighlightScrollHandler);
+ this._bouncyHighlightScrollHandler = null;
- this.removeScrollHandler(scrollHandler);
- }
-
- // Listen for the end of the animation so we can remove the element.
- this._bouncyHighlightElement.addEventListener("animationend", animationEnded.bind(this));
+ this._bouncyHighlightElement.remove();
+ this._bouncyHighlightElement = null;
}
_binarySearchInsertionIndexInSearchResults(object, comparator)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes