667
edits
Changes
→High-Level Mouse Lock Implementation Tasks
# Convert Rescue Fox to use Mouse Lock, see https://github.com/mozilla/rescuefox
# <strike>Convert http://cjcliffe.github.com/CubicVR.js/cubicvr/samples/fps_demo/level1.html to use Mouse Lock</strike> - JSilver999
# "Once mouse lock is acquired, stop mouse events from being fired to other elements that are not locked (e.g., only fire to locked element)."
# "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus"
# "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)"
# "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero"
# "User agents may prompt for confirmation before locking, this preference may be saved as a content setting" How to deal with this? What UI do we use? See also, "Repeated escapes of mouse lock can signal user agent to not re-lock the mouse without more specific user intent gesture, e.g. similar to how Chrome suppresses repeated alert() calls"
# Tests, tests, tests. We need tests for all aspects of the spec. List tests we need below:
## "there is no limit to how far movement can go...not limited by screen boundaries" -- mouse lock should mean infinite movement in the X and Y axes...There will be no limit to movementX/Y values if the mouse is continuously moved in a single direction"
## "The concept of the mouse cursor will have been removed, and it will not move off the window or be clamped by a screen edge"
## "no mouse cursor is displayed" -- mouse cursor should be hidden while locked
## navigator.pointer (readonly) is a MouseLockable
## MouseLockable has lock(), unlock(), islocked()
## islocked() returns true if mouse is locked, false if not locked
## lock(target) expects a DOM element, and takes two optional callbacks: successcallback, failurecallback.
## lock() should return immediately and call callbacks when lock succeeds or fails
## "Mouse lock must succeed only if the window is in focus"
## "Mouse lock must succeed only if...the user-agent is the active application of the operating system"
## "The target of lock need not be in focus"
## "Mouse lock must succeed only if the target is in the DOM tree"
## "If the target is removed from the DOM tree after mouse lock is entered then mouse lock will be lost."
## "If the mouse is already locked to the same element, a repeated call to lock will succeed and the successCallback called"
## "If another element is locked [and lock() is called] a user agent must transfer the mouse lock to the new target and call the mouselocklost callback for the previous target"
## "The Mouse Lock API must provide a default system action to unlock the mouse" namely ESC.
## "Once in the locked state the user agent must fire all relevant user generated MouseEvent events (for example: mousemove, mousedown, mouseup, click, wheel)[DOM-LEVEL-3-CORE] to the target of mouse lock, and not fire mouse events to other elements"
## "Events that require the concept of a mouse cursor must not be dispatched (for example: mouseover, mouseout)"
## "Movement and button presses of the mouse must not cause the window to lose focus"
## "Synthetic mouse events created by application script act the same regardless of lock state"
## "The unlock method cancels the mouse lock state"
## "[Upon unlock() t]he system mouse cursor must be displayed again and positioned at the same location that it was when mouse lock was entered (the same location that is reported in screenX/Y when the mouse is locked)"
## "When mouse lock is lost or disabled for any reason user agents must fire an event named mouselocklost with its bubble attribute set to true to the mouse lock target element"
## MouseEvent must contain (readonly) movementX and movementY
## "The members movementX and movementY must provide the change in position of the mouse, as if the values of screenX/Y were stored between two subsequent mousemove events eNow and ePrevious and the difference taken movementX = eNow.screenX-ePrevious.screenX"
## "movementX/Y must be valid regardless of mouse lock state"
## "When unlocked, the system cursor can exit and re-enter the user agent window. If it does so and the user agent was not the target of operating system mouse move events then the most recent mouse position will be unknown to the user agent and movementX/Y can not be computed and must be set to zero"
## "When mouse lock is enabled clientX, clientY, screenX, and screenY must hold constant values as if the mouse did not move at all once mouse lock was entered"
## "The Mouse Lock API must exit the mouse lock state if the user agent, window, or tab loses focus"
## Check the mouse cursor during mouse lock and after mouse lock. (Needs content scripts?)
## Test to make sure that mouse lock only occurs when an element is in full screen mode (not F11 or done via the menus). This includes:
### Switching focus to another window
## Tests for mouselocklost event
# Create a tutorial on how to use Mouse Lock, with code examples
# Add demo pages to [http://humphd.github.com/mozilla-central/mouselock/index.html gh-pages branch]