Changeset 120031 in webkit


Ignore:
Timestamp:
Jun 11, 2012 8:02:16 PM (12 years ago)
Author:
scheib@chromium.org
Message:

Add new Pointer Lock spec attribute webkitPointerLockElement.
https://bugs.webkit.org/show_bug.cgi?id=88799

Source/WebCore:

Reviewed by Dimitri Glazkov.

Part of a series of refactoring changes to update pointer lock API to
the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

  • bindings/generic/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::webkitPointerLockElementEnabled):

  • dom/Document.cpp:

(WebCore):
(WebCore::Document::webkitPointerLockElement):

  • dom/Document.h:

(Document):

  • dom/Document.idl:
  • page/PointerLockController.h:

(WebCore::PointerLockController::element):

Tools:

Reviewed by Dimitri Glazkov.

Part of a series of refactoring changes to update pointer lock API to
the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

WebViewHost logic required modification to correctly repond to
a lock, unlock, pointerLockElement call series. Specifically,
unlocking must be queued after a lock command is issued always
as the lock state may not be set yet with a lock request in flight.

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::requestPointerUnlock): Always post didLosePointerLock task.
(WebViewHost::didLosePointerLock): Signal didLosePointerLock only if pointer was locked.

LayoutTests:

Part of a series of refactoring changes to update pointer lock API to
the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402

New attribute webkitPointerLockElement added. Follow up patches
will remove the previous isLocked attribute. Tests updated to use
the new attribute.

Reviewed by Dimitri Glazkov.

  • pointer-lock/lock-already-locked-expected.txt:
  • pointer-lock/lock-already-locked.html:
  • pointer-lock/pointer-lock-api-expected.txt:
  • pointer-lock/pointer-lock-api.html:
  • pointer-lock/pointerlocklost-event-expected.txt:
  • pointer-lock/pointerlocklost-event.html:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120028 r120031  
     12012-06-11  Vincent Scheib  <scheib@chromium.org>
     2
     3        Add new Pointer Lock spec attribute webkitPointerLockElement.
     4        https://bugs.webkit.org/show_bug.cgi?id=88799
     5
     6        Part of a series of refactoring changes to update pointer lock API to
     7        the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402
     8
     9        New attribute webkitPointerLockElement added. Follow up patches
     10        will remove the previous isLocked attribute. Tests updated to use
     11        the new attribute.
     12
     13        Reviewed by Dimitri Glazkov.
     14
     15        * pointer-lock/lock-already-locked-expected.txt:
     16        * pointer-lock/lock-already-locked.html:
     17        * pointer-lock/pointer-lock-api-expected.txt:
     18        * pointer-lock/pointer-lock-api.html:
     19        * pointer-lock/pointerlocklost-event-expected.txt:
     20        * pointer-lock/pointerlocklost-event.html:
     21
    1222012-06-11  Dominic Cooney  <dominicc@chromium.org>
    223
  • trunk/LayoutTests/pointer-lock/lock-already-locked-expected.txt

    r119763 r120031  
    88PASS navigator.webkitPointer.isLocked is true
    99PASS document.onwebkitpointerlockchange event received.
     10PASS document.webkitPointerLockElement is targetdiv1
    1011PASS Lock target1 succeeded again.
    1112PASS navigator.webkitPointer.isLocked is true
    1213PASS document.onwebkitpointerlockchange event received.
     14PASS document.webkitPointerLockElement is targetdiv1
    1315PASS expectTarget1Unlock is true
    1416PASS Lock target2 succeeded.
    1517PASS navigator.webkitPointer.isLocked is true
    1618PASS document.onwebkitpointerlockchange event received.
     19PASS document.webkitPointerLockElement is targetdiv2
    1720PASS document.onwebkitpointerlockchange event received.
     21PASS document.webkitPointerLockElement is targetdiv2
    1822PASS successfullyParsed is true
    1923
  • trunk/LayoutTests/pointer-lock/lock-already-locked.html

    r119763 r120031  
    1717
    1818    // Expect change event only for all transitions below.
    19     document.onwebkitpointerlockchange =
    20         function () { testPassed("document.onwebkitpointerlockchange event received."); };
     19    expectedTargetToBeLockedString = "";
     20    document.onwebkitpointerlockchange = function ()
     21        {
     22            testPassed("document.onwebkitpointerlockchange event received.");
     23            shouldBe("document.webkitPointerLockElement", expectedTargetToBeLockedString);
     24        };
    2125    document.onwebkitpointerlockerror =
    2226        function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
     
    4650                    finishJSTest();
    4751                });
     52            expectedTargetToBeLockedString = "targetdiv1";
    4853        },
    4954        function () {
     
    5863                    finishJSTest();
    5964                });
    60 
     65            expectedTargetToBeLockedString = "targetdiv1";
    6166        },
    6267        function () {
     
    7277                    finishJSTest();
    7378                });
    74 
     79            expectedTargetToBeLockedString = "targetdiv2";
    7580        },
    7681        finishJSTest
  • trunk/LayoutTests/pointer-lock/pointer-lock-api-expected.txt

    r119763 r120031  
     1Basic API existence test for Pointer Lock.
     2
     3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     4
     5
    16PASS navigator.webkitPointer is defined.
    27PASS typeof navigator.webkitPointer.isLocked is 'boolean'
    38PASS navigator.webkitPointer.isLocked is false
    49PASS navigator.webkitPointer.lock() threw exception TypeError: Not enough arguments.
    5 PASS navigator.webkitPointer.lock(document) is undefined
     10PASS navigator.webkitPointer.lock(document.body) is undefined
    611PASS navigator.webkitPointer.unlock() is undefined
    712PASS document.onwebkitpointerlockchange is defined.
    813PASS document.onwebkitpointerlockerror is defined.
     14PASS document.webkitPointerLockElement is null
    915PASS successfullyParsed is true
    1016
    1117TEST COMPLETE
    12 
     18doNextStep for manual testing
  • trunk/LayoutTests/pointer-lock/pointer-lock-api.html

    r119763 r120031  
    55</head>
    66<body>
     7<button onclick="doNextStep('manual');">doNextStep for manual testing</button>
    78<script>
    8     shouldBeDefined("navigator.webkitPointer");
    9     shouldEvaluateTo("navigator.webkitPointer.isLocked", false);
    10     shouldThrow("navigator.webkitPointer.lock()", "'TypeError: Not enough arguments'");
    11     shouldEvaluateTo("navigator.webkitPointer.lock(document)", "undefined");
    12     shouldEvaluateTo("navigator.webkitPointer.unlock()", "undefined");
    13     shouldBeDefined("document.onwebkitpointerlockchange");
    14     shouldBeDefined("document.onwebkitpointerlockerror");
     9    description("Basic API existence test for Pointer Lock.")
     10    window.jsTestIsAsync = true;
     11
     12    currentStep = 0;
     13    function doNextStep(manual)
     14    {
     15        if (!window.layoutTestController && !manual)
     16            return;
     17        if (currentStep < todo.length)
     18            setTimeout(function () { todo[currentStep++](); }, 0);
     19        else if (currentStep++ == todo.length)
     20            setTimeout(function () { finishJSTest(); }, 0);
     21    }
     22    todo = [
     23        function () {
     24            shouldBeDefined("navigator.webkitPointer");
     25            shouldEvaluateTo("navigator.webkitPointer.isLocked", false);
     26            shouldThrow("navigator.webkitPointer.lock()", "'TypeError: Not enough arguments'");
     27            shouldEvaluateTo("navigator.webkitPointer.lock(document.body)", "undefined");
     28            // Exit call stack to allow lock to take effect.
     29            doNextStep();
     30        },
     31        function () {
     32            shouldEvaluateTo("navigator.webkitPointer.unlock()", "undefined");
     33            // Exit call stack to allow unlock to take effect.
     34            doNextStep();
     35        },
     36        function () {
     37            shouldBeDefined("document.onwebkitpointerlockchange");
     38            shouldBeDefined("document.onwebkitpointerlockerror");
     39            shouldEvaluateTo("document.webkitPointerLockElement", null);
     40            doNextStep();
     41        },
     42    ];
     43    doNextStep();
    1544</script>
    1645<script src="../fast/js/resources/js-test-post.js"></script>
  • trunk/LayoutTests/pointer-lock/pointerlocklost-event-expected.txt

    r119763 r120031  
    66PASS window.layoutTestController is defined.
    77PASS navigator.webkitPointer.isLocked is true
     8PASS document.webkitPointerLockElement is targetdiv
    89JavaScript initiated unlock.
    910PASS webkitpointerlocklost handler call 0
     
    1213PASS onwebkitpointerlockchange received.
    1314PASS All expected onwebkitpointerlockchange events received.
     15PASS document.webkitPointerLockElement is null
    1416PASS navigator.webkitPointer.isLocked is false
    1517PASS navigator.webkitPointer.isLocked is true
     18PASS document.webkitPointerLockElement is targetdiv
    1619Host initiated unlock.
    1720PASS webkitpointerlocklost handler call 0
     
    2124PASS All expected onwebkitpointerlockchange events received.
    2225PASS navigator.webkitPointer.isLocked is false
     26PASS document.webkitPointerLockElement is null
    2327PASS successfullyParsed is true
    2428
  • trunk/LayoutTests/pointer-lock/pointerlocklost-event.html

    r119763 r120031  
    6666        },
    6767        function () {
     68            shouldBe("document.webkitPointerLockElement", "targetdiv");
    6869            debug("JavaScript initiated unlock.")
    6970            locklostreceipts = 0;
     
    7273        function () {
    7374            // locklostHandler will catch unlocks and call doNextStep to bring us here.
     75            shouldBe("document.webkitPointerLockElement", "null");
    7476            shouldBe("navigator.webkitPointer.isLocked", "false");
    7577            doNextStep();
     
    8789        },
    8890        function () {
     91            shouldBe("document.webkitPointerLockElement", "targetdiv");
    8992            debug("Host initiated unlock.")
    9093            lockchangeToUnlockedReceipts = 0;
     
    9598            // locklostHandler will catch unlocks and call doNextStep to bring us here.
    9699            shouldBe("navigator.webkitPointer.isLocked", "false");
     100            shouldBe("document.webkitPointerLockElement", "null");
    97101            doNextStep();
    98102        },
  • trunk/Source/WebCore/ChangeLog

    r120030 r120031  
     12012-06-11  Vincent Scheib  <scheib@chromium.org>
     2
     3        Add new Pointer Lock spec attribute webkitPointerLockElement.
     4        https://bugs.webkit.org/show_bug.cgi?id=88799
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Part of a series of refactoring changes to update pointer lock API to
     9        the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402
     10
     11        New attribute webkitPointerLockElement added. Follow up patches
     12        will remove the previous isLocked attribute. Tests updated to use
     13        the new attribute.
     14
     15        * bindings/generic/RuntimeEnabledFeatures.h:
     16        (WebCore::RuntimeEnabledFeatures::webkitPointerLockElementEnabled):
     17        * dom/Document.cpp:
     18        (WebCore):
     19        (WebCore::Document::webkitPointerLockElement):
     20        * dom/Document.h:
     21        (Document):
     22        * dom/Document.idl:
     23        * page/PointerLockController.h:
     24        (WebCore::PointerLockController::element):
     25
    1262012-06-11  Vincent Scheib  <scheib@chromium.org>
    227
  • trunk/Source/WebCore/dom/Document.cpp

    r119895 r120031  
    121121#include "PlatformKeyboardEvent.h"
    122122#include "PluginDocument.h"
     123#include "PointerLockController.h"
    123124#include "PopStateEvent.h"
    124125#include "ProcessingInstruction.h"
     
    57325733#endif
    57335734
     5735#if ENABLE(POINTER_LOCK)
     5736Element* Document::webkitPointerLockElement() const
     5737{
     5738    return page() ? page()->pointerLockController()->element() : 0;
     5739}
     5740#endif
     5741
    57345742void Document::decrementLoadEventDelayCount()
    57355743{
  • trunk/Source/WebCore/dom/Document.h

    r119937 r120031  
    10651065#endif
    10661066
     1067#if ENABLE(POINTER_LOCK)
     1068    Element* webkitPointerLockElement() const;
     1069#endif
     1070
    10671071    // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
    10681072    void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
  • trunk/Source/WebCore/dom/Document.idl

    r120030 r120031  
    257257        [V8EnabledAtRuntime] void webkitExitFullscreen();
    258258#endif
     259
     260        readonly attribute [Conditional=POINTER_LOCK, V8EnabledAtRuntime=pointerLock] Element webkitPointerLockElement;
    259261
    260262#if defined(ENABLE_CSS_REGIONS) && ENABLE_CSS_REGIONS
  • trunk/Source/WebCore/page/PointerLockController.cpp

    r119763 r120031  
    9292}
    9393
     94Element* PointerLockController::element() const
     95{
     96    return m_element.get();
     97}
     98
    9499void PointerLockController::didAcquirePointerLock()
    95100{
  • trunk/Source/WebCore/page/PointerLockController.h

    r119763 r120031  
    4747    void requestPointerUnlock();
    4848    bool isLocked();
     49    Element* element() const;
    4950
    5051    void didAcquirePointerLock();
  • trunk/Tools/ChangeLog

    r120029 r120031  
     12012-06-11  Vincent Scheib  <scheib@chromium.org>
     2
     3        Add new Pointer Lock spec attribute webkitPointerLockElement.
     4        https://bugs.webkit.org/show_bug.cgi?id=88799
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Part of a series of refactoring changes to update pointer lock API to
     9        the fullscreen locking style. https://bugs.webkit.org/show_bug.cgi?id=84402
     10
     11        New attribute webkitPointerLockElement added. Follow up patches
     12        will remove the previous isLocked attribute. Tests updated to use
     13        the new attribute.
     14
     15        WebViewHost logic required modification to correctly repond to
     16        a lock, unlock, pointerLockElement call series. Specifically,
     17        unlocking must be queued after a lock command is issued always
     18        as the lock state may not be set yet with a lock request in flight.
     19
     20        * DumpRenderTree/chromium/WebViewHost.cpp:
     21        (WebViewHost::requestPointerUnlock): Always post didLosePointerLock task.
     22        (WebViewHost::didLosePointerLock): Signal didLosePointerLock only if pointer was locked.
     23
    1242012-06-11  Alexis Menard  <alexis.menard@openbossa.org>
    225
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r119832 r120031  
    846846void WebViewHost::requestPointerUnlock()
    847847{
    848     if (m_pointerLocked)
    849         postDelayedTask(new HostMethodTask(this, &WebViewHost::didLosePointerLock), 0);
     848    postDelayedTask(new HostMethodTask(this, &WebViewHost::didLosePointerLock), 0);
    850849}
    851850
     
    870869void WebViewHost::didLosePointerLock()
    871870{
    872     ASSERT(m_pointerLocked);
     871    bool wasLocked = m_pointerLocked;
    873872    m_pointerLocked = false;
    874     webWidget()->didLosePointerLock();
     873    if (wasLocked)
     874        webWidget()->didLosePointerLock();
    875875}
    876876#endif
Note: See TracChangeset for help on using the changeset viewer.