Bug 171902 - REGRESSION (r?): Web Inspector: Shift-click on color square in Styles sidebar should not select text
Summary: REGRESSION (r?): Web Inspector: Shift-click on color square in Styles sidebar...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: EasyFix, GoodFirstBug
Depends on:
Blocks:
 
Reported: 2017-05-09 18:33 PDT by Nikita Vasilyev
Modified: 2017-05-18 15:33 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.37 KB, patch)
2017-05-17 17:29 PDT, Devin Rousso
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 2017-05-09 18:33:34 PDT
Steps:
1. Inspect any element.
2. Add "color: brown" rule.
3. Click twice on the color square before "brown" while holding Shift key.

Expected:
Text selection shouldn't change.
Comment 1 Devin Rousso 2017-05-17 17:29:44 PDT
Created attachment 310468 [details]
Patch
Comment 2 Matt Baker 2017-05-18 13:50:00 PDT
Comment on attachment 310468 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=310468&action=review

r=me, with some notes.

> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:-455
> -        if (this._mouseDownCursorPosition.line === cursor.line && this._mouseDownCursorPosition.ch === cursor.ch) {

Hmm, it would be nice if we could keep this check and return early if it fails. This would improve the readability of the function and avoid doing the work to determine `clickedBookmark` when not needed. To do this would require that `this._mouseDownCursorPosition = null` happen first, instead of at the end of the function. A local `mouseDownCursorPosition` would be needed since the rest of the function uses the value.

I'll leave it up to you. If you think the function is cleanest as-is, I'm fine with it.
Comment 3 Devin Rousso 2017-05-18 15:05:16 PDT
Comment on attachment 310468 [details]
Patch

(In reply to Matt Baker from comment #2)
> Comment on attachment 310468 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=310468&action=review
> 
> r=me, with some notes.
> 
> > Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:-455
> > -        if (this._mouseDownCursorPosition.line === cursor.line && this._mouseDownCursorPosition.ch === cursor.ch) {
> 
> Hmm, it would be nice if we could keep this check and return early if it
> fails. This would improve the readability of the function and avoid doing
> the work to determine `clickedBookmark` when not needed. To do this would
> require that `this._mouseDownCursorPosition = null` happen first, instead of
> at the end of the function. A local `mouseDownCursorPosition` would be
> needed since the rest of the function uses the value.
> 
> I'll leave it up to you. If you think the function is cleanest as-is, I'm
> fine with it.

I personally would prefer not to do that, as it seems a bit awkward to me to null a value that will be used later while also creating a local variable with that value.  If it gets any more complex, however, it might be worth revisiting.
Comment 4 WebKit Commit Bot 2017-05-18 15:33:33 PDT
Comment on attachment 310468 [details]
Patch

Clearing flags on attachment: 310468

Committed r217072: <http://trac.webkit.org/changeset/217072>
Comment 5 WebKit Commit Bot 2017-05-18 15:33:35 PDT
All reviewed patches have been landed.  Closing bug.