Bug 167126 - Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
Summary: Page should be able to request pointer lock without user gesture if it relinq...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jeremy Jones
URL:
Keywords: InRadar
: 167013 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-17 11:05 PST by Jeremy Jones
Modified: 2017-01-26 18:18 PST (History)
3 users (show)

See Also:


Attachments
Patch (7.83 KB, patch)
2017-01-17 11:22 PST, Jeremy Jones
no flags Details | Formatted Diff | Diff
Patch (8.74 KB, patch)
2017-01-26 11:51 PST, Jeremy Jones
no flags Details | Formatted Diff | Diff
Patch (8.87 KB, patch)
2017-01-26 16:39 PST, Jeremy Jones
no flags Details | Formatted Diff | Diff
Patch (8.92 KB, patch)
2017-01-26 17:02 PST, Jeremy Jones
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Jones 2017-01-17 11:05:00 PST
Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
Comment 1 Jeremy Jones 2017-01-17 11:06:55 PST
rdar://problem/29539389
Comment 2 Jeremy Jones 2017-01-17 11:07:16 PST
*** Bug 167013 has been marked as a duplicate of this bug. ***
Comment 3 Jeremy Jones 2017-01-17 11:22:20 PST
Created attachment 299046 [details]
Patch
Comment 4 Jon Lee 2017-01-25 17:51:30 PST
Comment on attachment 299046 [details]
Patch

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

> Source/WebCore/ChangeLog:11
> +        This change allows a page to lock the pointer pointer again without a user gesture if it was unlocked by

"pointer pointer"

> Source/WebCore/ChangeLog:14
> +        * page/PointerLockController.cpp:

Please provide some more detail here.

> Source/WebCore/page/PointerLockController.cpp:116
> +        m_lockPending = false;

Replacing clearElement() with two variable assignments seems fragile. Can we factor this out to a separate version of clearElement that indicates leaving m_unlockPending alone?

> Source/WebCore/page/PointerLockController.h:69
> +    RefPtr<Document> m_documentCanSkipUserGesture;

The variable name took a little time for me to understand its purpose since it sounded like a bool type rather than a RefPtr. Maybe m_documentAllowedToRelockWithoutUserGesture?
Comment 5 Jeremy Jones 2017-01-26 11:49:48 PST
(In reply to comment #4)
> Comment on attachment 299046 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299046&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        This change allows a page to lock the pointer pointer again without a user gesture if it was unlocked by
> 
> "pointer pointer"

Done.

> 
> > Source/WebCore/ChangeLog:14
> > +        * page/PointerLockController.cpp:
> 
> Please provide some more detail here.

Added detail.

> 
> > Source/WebCore/page/PointerLockController.cpp:116
> > +        m_lockPending = false;
> 
> Replacing clearElement() with two variable assignments seems fragile. Can we
> factor this out to a separate version of clearElement that indicates leaving
> m_unlockPending alone?

Actually, the default should be to leave m_unlockPending alone. So, I've changed clearElement to do that. The two places that need to modify m_unlockPending, should directly modify that flag since it is explicitly part of their function. didNotAcquirePointerLock means we are no longer waiting on unlockPending, it should set the flag explicitly. This also means that more locations can use clearElement.

> 
> > Source/WebCore/page/PointerLockController.h:69
> > +    RefPtr<Document> m_documentCanSkipUserGesture;
> 
> The variable name took a little time for me to understand its purpose since
> it sounded like a bool type rather than a RefPtr. Maybe
> m_documentAllowedToRelockWithoutUserGesture?

Done.
Comment 6 Jeremy Jones 2017-01-26 11:51:40 PST
Created attachment 299830 [details]
Patch
Comment 7 Jon Lee 2017-01-26 13:54:34 PST
Rebase, please
Comment 8 Jon Lee 2017-01-26 13:57:25 PST
Comment on attachment 299830 [details]
Patch

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

> Source/WebCore/page/PointerLockController.cpp:114
> +        clearElement();

Is this expectation that m_unlockPending is always false in clearElement()? I'd suggest adding an ASSERT there, then. On untrained eyes, one might expect that m_unlockPending should also be set to false in that function.
Comment 9 Jeremy Jones 2017-01-26 16:37:10 PST
(In reply to comment #8)
> Comment on attachment 299830 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299830&action=review
> 
> > Source/WebCore/page/PointerLockController.cpp:114
> > +        clearElement();
> 
> Is this expectation that m_unlockPending is always false in clearElement()?
> I'd suggest adding an ASSERT there, then. On untrained eyes, one might
> expect that m_unlockPending should also be set to false in that function.

That is not the expected case. clearElement() is used when document or element are removed, so the element is cleared, but the unlock is still pending. The unlock must be round tripped to the chrome client after the element is cleared. This feature requires knowing that there was a pending request when the unlock completes, so it can't be cleared by clearElement.
Comment 10 Jeremy Jones 2017-01-26 16:39:04 PST
Created attachment 299878 [details]
Patch
Comment 11 Jeremy Jones 2017-01-26 17:02:31 PST
Created attachment 299883 [details]
Patch
Comment 12 WebKit Commit Bot 2017-01-26 18:18:45 PST
Comment on attachment 299883 [details]
Patch

Clearing flags on attachment: 299883

Committed r211249: <http://trac.webkit.org/changeset/211249>
Comment 13 WebKit Commit Bot 2017-01-26 18:18:48 PST
All reviewed patches have been landed.  Closing bug.