RESOLVED FIXED 151236
Web Inspector: Popover's arrow is misplaced
https://bugs.webkit.org/show_bug.cgi?id=151236
Summary Web Inspector: Popover's arrow is misplaced
Nikita Vasilyev
Reported 2015-11-12 17:00:50 PST
Created attachment 265454 [details] [Image] Bug Steps: 1. Set a breakpoint 2. Close the left sidebar 3. Right click on the breakpoint, select "Edit Breakpoint..."
Attachments
[Image] Bug (196.40 KB, image/png)
2015-11-12 17:00 PST, Nikita Vasilyev
no flags
[Patch] Proposed Fix (2.57 KB, patch)
2016-08-02 18:01 PDT, Matt Baker
no flags
[Image] Adjusted arrow placement (260.33 KB, image/png)
2016-08-02 18:52 PDT, Matt Baker
no flags
[Patch] For Landing (7.41 KB, patch)
2016-08-04 13:06 PDT, Matt Baker
no flags
Radar WebKit Bug Importer
Comment 1 2015-11-12 17:01:39 PST
Matt Baker
Comment 2 2015-11-12 21:38:44 PST
I wonder if this is related to https://bugs.webkit.org/show_bug.cgi?id=150551.
Matt Baker
Comment 3 2016-08-02 18:01:13 PDT
Created attachment 285172 [details] [Patch] Proposed Fix
Matt Baker
Comment 4 2016-08-02 18:02:10 PDT
(In reply to comment #2) > I wonder if this is related to > https://bugs.webkit.org/show_bug.cgi?id=150551. Not related.
Matt Baker
Comment 5 2016-08-02 18:52:51 PDT
Created attachment 285183 [details] [Image] Adjusted arrow placement
Blaze Burg
Comment 6 2016-08-04 11:12:17 PDT
Comment on attachment 285172 [details] [Patch] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=285172&action=review r=me but please address nits. Thanks Matt! > Source/WebInspectorUI/UserInterface/Views/Popover.js:498 > var arrowHalfLength = WebInspector.Popover.AnchorSize.width / 2; Nit: let's improve variable names: r-> cornerRadius arrowHalfLength -> arrowWidth (and multiply by 0.5) > Source/WebInspectorUI/UserInterface/Views/Popover.js:499 > var anchorPoint = this._anchorPoint; Nit: 'let' it be > Source/WebInspectorUI/UserInterface/Views/Popover.js:502 > + let anchorPointBounds = bounds.pad(-(r + arrowHalfLength)); It took me a little bit to understand this. So basically, we make a smaller bounds where we could correctly draw the arrow attached to any point of the bound. The earlier point we could attach the arrow is cornerRadius + 0.5 * arrowWidth away from any corner. Then we clamp the anchor point's x, y. Maybe we could come up with better names, like adjustedAnchorBounds or something. Or maybe it's just a messy bit of code. I think using Number.constrain would make it clearer: anchorPoint.x = Number.constrain(anchorPoint.x, anchorPointBounds.minX(), anchorPointBounds.maxX()) ...
Matt Baker
Comment 7 2016-08-04 12:35:40 PDT
Comment on attachment 285172 [details] [Patch] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=285172&action=review >> Source/WebInspectorUI/UserInterface/Views/Popover.js:502 >> + let anchorPointBounds = bounds.pad(-(r + arrowHalfLength)); > > It took me a little bit to understand this. So basically, we make a smaller bounds where we could correctly draw the arrow attached to any point of the bound. The earlier point we could attach the arrow is cornerRadius + 0.5 * arrowWidth away from any corner. Then we clamp the anchor point's x, y. > > Maybe we could come up with better names, like adjustedAnchorBounds or something. Or maybe it's just a messy bit of code. > I think using Number.constrain would make it clearer: > > anchorPoint.x = Number.constrain(anchorPoint.x, anchorPointBounds.minX(), anchorPointBounds.maxX()) > ... I like this better. Have a bounds rectangle is also misleading, since the arrow is really just bound on one axis, not both.
Matt Baker
Comment 8 2016-08-04 12:51:25 PDT
Comment on attachment 285172 [details] [Patch] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=285172&action=review >> Source/WebInspectorUI/UserInterface/Views/Popover.js:498 >> var arrowHalfLength = WebInspector.Popover.AnchorSize.width / 2; > > Nit: let's improve variable names: > > r-> cornerRadius > arrowHalfLength -> arrowWidth (and multiply by 0.5) I don't think arrowWidth is an improvement.
Matt Baker
Comment 9 2016-08-04 13:06:29 PDT
Created attachment 285350 [details] [Patch] For Landing
WebKit Commit Bot
Comment 10 2016-08-04 13:53:18 PDT
Comment on attachment 285350 [details] [Patch] For Landing Clearing flags on attachment: 285350 Committed r204136: <http://trac.webkit.org/changeset/204136>
WebKit Commit Bot
Comment 11 2016-08-04 13:53:23 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.