Bug 151236 - Web Inspector: Popover's arrow is misplaced
Summary: Web Inspector: Popover's arrow is misplaced
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-11-12 17:00 PST by Nikita Vasilyev
Modified: 2016-08-04 13:53 PDT (History)
9 users (show)

See Also:


Attachments
[Image] Bug (196.40 KB, image/png)
2015-11-12 17:00 PST, Nikita Vasilyev
no flags Details
[Patch] Proposed Fix (2.57 KB, patch)
2016-08-02 18:01 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
[Image] Adjusted arrow placement (260.33 KB, image/png)
2016-08-02 18:52 PDT, Matt Baker
no flags Details
[Patch] For Landing (7.41 KB, patch)
2016-08-04 13:06 PDT, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 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..."
Comment 1 Radar WebKit Bug Importer 2015-11-12 17:01:39 PST
<rdar://problem/23527296>
Comment 2 Matt Baker 2015-11-12 21:38:44 PST
I wonder if this is related to https://bugs.webkit.org/show_bug.cgi?id=150551.
Comment 3 Matt Baker 2016-08-02 18:01:13 PDT
Created attachment 285172 [details]
[Patch] Proposed Fix
Comment 4 Matt Baker 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.
Comment 5 Matt Baker 2016-08-02 18:52:51 PDT
Created attachment 285183 [details]
[Image] Adjusted arrow placement
Comment 6 BJ Burg 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())
...
Comment 7 Matt Baker 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.
Comment 8 Matt Baker 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.
Comment 9 Matt Baker 2016-08-04 13:06:29 PDT
Created attachment 285350 [details]
[Patch] For Landing
Comment 10 WebKit Commit Bot 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>
Comment 11 WebKit Commit Bot 2016-08-04 13:53:23 PDT
All reviewed patches have been landed.  Closing bug.