Title: [236028] trunk/Source/WebInspectorUI
Revision
236028
Author
commit-qu...@webkit.org
Date
2018-09-14 17:39:59 -0700 (Fri, 14 Sep 2018)

Log Message

Web Inspector: Source View doesn't scroll to show line when breakpoint is hit inside of <script> in HTML resource
https://bugs.webkit.org/show_bug.cgi?id=189638
<rdar://problem/43359278>

Patch by Joseph Pecoraro <pecor...@apple.com> on 2018-09-14
Reviewed by Matt Baker.

Pausing in Document resources on page load have special considerations where we
may not receive their full content immediately, so we may synthesize inline script
content for the resource until we have full content. Unfortunately, when we get
full content and update the TextEditor we were losing the revealed position and
other editor information. This change specifically targets those cases, by
re-applying editor state when updating such a resource from partial to full content.

* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype._contentAvailable):
Signal to the editor that when updating the content it should carry
over editor state. Only do this if we had partial content before.

* UserInterface/Views/TextEditor.js:
(WI.TextEditor):
(WI.TextEditor.prototype.set repeatReveal):
Provide a way to signal we should restore state when update the content.

(WI.TextEditor.set string.update):
(WI.TextEditor.prototype.set string):
When repeatReveal was enabled, restore editor state such as the
revealed location and text selection.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (236027 => 236028)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-09-15 00:33:58 UTC (rev 236027)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-09-15 00:39:59 UTC (rev 236028)
@@ -1,3 +1,33 @@
+2018-09-14  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Source View doesn't scroll to show line when breakpoint is hit inside of <script> in HTML resource
+        https://bugs.webkit.org/show_bug.cgi?id=189638
+        <rdar://problem/43359278>
+
+        Reviewed by Matt Baker.
+
+        Pausing in Document resources on page load have special considerations where we
+        may not receive their full content immediately, so we may synthesize inline script
+        content for the resource until we have full content. Unfortunately, when we get
+        full content and update the TextEditor we were losing the revealed position and
+        other editor information. This change specifically targets those cases, by
+        re-applying editor state when updating such a resource from partial to full content.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WI.SourceCodeTextEditor.prototype._contentAvailable):
+        Signal to the editor that when updating the content it should carry
+        over editor state. Only do this if we had partial content before.
+
+        * UserInterface/Views/TextEditor.js:
+        (WI.TextEditor):
+        (WI.TextEditor.prototype.set repeatReveal):
+        Provide a way to signal we should restore state when update the content.
+
+        (WI.TextEditor.set string.update):
+        (WI.TextEditor.prototype.set string):
+        When repeatReveal was enabled, restore editor state such as the
+        revealed location and text selection.
+
 2018-09-14  Devin Rousso  <web...@devinrousso.com>
 
         Web Inspector: Record actions performed on ImageBitmapRenderingContext

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (236027 => 236028)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2018-09-15 00:33:58 UTC (rev 236027)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2018-09-15 00:39:59 UTC (rev 236028)
@@ -547,7 +547,13 @@
         this._fullContentPopulated = true;
         this._invalidLineNumbers = {};
 
+        // If we had partial content (such as inline script content) before we had full content, we
+        // will want to re-restore the revealed position now that we are populating with full content.
+        this.repeatReveal = !!this.string;
+
         this._populateWithContent(content);
+
+        this.repeatReveal = false;
     }
 
     _breakpointStatusDidChange(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (236027 => 236028)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2018-09-15 00:33:58 UTC (rev 236027)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2018-09-15 00:39:59 UTC (rev 236028)
@@ -94,6 +94,7 @@
         this._formattingPromise = null;
         this._formatterSourceMap = null;
         this._deferReveal = false;
+        this._repeatReveal = false;
 
         this._delegate = delegate || null;
     }
@@ -112,6 +113,8 @@
 
     set string(newString)
     {
+        let previousSelectedTextRange = this._repeatReveal ? this.selectedTextRange : null;
+
         function update()
         {
             // Clear any styles that may have been set on the empty line before content loaded.
@@ -147,8 +150,13 @@
             for (var lineNumber in this._breakpoints)
                 this._setBreakpointStylesOnLine(lineNumber);
 
-            // Try revealing the pending line now that we might have content with enough lines.
+            // Try revealing the pending line, or previous position, now that we might have new content.
             this._revealPendingPositionIfPossible();
+            if (previousSelectedTextRange) {
+                this.selectedTextRange = previousSelectedTextRange;
+                let position = this._codeMirrorPositionFromTextRange(previousSelectedTextRange);
+                this._scrollIntoViewCentered(position.start);
+            }
         }
 
         this._ignoreCodeMirrorContentDidChangeEvent++;
@@ -292,6 +300,11 @@
         this._deferReveal = defer;
     }
 
+    set repeatReveal(repeat)
+    {
+        this._repeatReveal = repeat;
+    }
+
     performSearch(query)
     {
         if (this._searchQuery === query)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to