haikuwebkit/Source/WebCore/testing/WebFakeXRInputController.cpp

182 lines
6.5 KiB
C++
Raw Permalink Normal View History

[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
/*
* Copyright (C) 2020 Igalia S.L. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebFakeXRInputController.h"
#if ENABLE(WEBXR)
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
#include "WebFakeXRDevice.h"
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
namespace WebCore {
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
using InputSource = PlatformXR::Device::FrameData::InputSource;
using InputSourceButton = PlatformXR::Device::FrameData::InputSourceButton;
using InputSourcePose = PlatformXR::Device::FrameData::InputSourcePose;
using ButtonType = FakeXRButtonStateInit::Type;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
// https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping
constexpr std::array<ButtonType, 5> XR_STANDARD_BUTTONS = { ButtonType::Grip, ButtonType::Touchpad, ButtonType::Thumbstick, ButtonType::OptionalButton, ButtonType::OptionalThumbstick };
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
Ref<WebFakeXRInputController> WebFakeXRInputController::create(PlatformXR::InputSourceHandle handle, const FakeXRInputSourceInit& init)
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
return adoptRef(*new WebFakeXRInputController(handle, init));
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
WebFakeXRInputController::WebFakeXRInputController(PlatformXR::InputSourceHandle handle, const FakeXRInputSourceInit& init)
: m_handle(handle)
, m_handeness(init.handedness)
, m_targetRayMode(init.targetRayMode)
, m_profiles(init.profiles)
, m_primarySelected(init.selectionStarted)
, m_simulateSelect(init.selectionClicked)
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
setPointerOrigin(init.pointerOrigin, false);
setGripOrigin(init.gripOrigin, false);
setSupportedButtons(init.supportedButtons);
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
void WebFakeXRInputController::setGripOrigin(FakeXRRigidTransformInit gripOrigin, bool emulatedPosition)
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
auto transform = WebFakeXRDevice::parseRigidTransform(gripOrigin);
if (transform.hasException())
return;
m_gripOrigin = InputSourcePose { transform.releaseReturnValue(), emulatedPosition };
}
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
void WebFakeXRInputController::setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, bool emulatedPosition)
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
auto transform = WebFakeXRDevice::parseRigidTransform(pointerOrigin);
if (transform.hasException())
return;
m_pointerOrigin = { transform.releaseReturnValue(), emulatedPosition };
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
void WebFakeXRInputController::disconnect()
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
m_connected = false;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
void WebFakeXRInputController::reconnect()
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
m_connected = true;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
void WebFakeXRInputController::setSupportedButtons(const Vector<FakeXRButtonStateInit>& buttons)
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
m_buttons.clear();
for (auto& button : buttons)
m_buttons.add(button.buttonType, button);
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
void WebFakeXRInputController::updateButtonState(const FakeXRButtonStateInit& init)
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
auto it = m_buttons.find(init.buttonType);
if (it != m_buttons.end())
it->value = init;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
InputSource WebFakeXRInputController::getFrameData()
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
InputSource state;
state.handle = m_handle;
state.handeness = m_handeness;
state.targetRayMode = m_targetRayMode;
state.profiles = m_profiles;
state.pointerOrigin = m_pointerOrigin;
state.gripOrigin = m_gripOrigin;
if (m_simulateSelect)
m_primarySelected = true;
// https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping
// Mimic xr-standard gamepad layout
// Primary trigger is required and must be at index 0
state.buttons.append({
.touched = m_primarySelected,
.pressed = m_primarySelected,
.pressedValue = m_primarySelected ? 1.0f : 0.0f
});
// Next buttons in xr-standard order
for (auto buttonType : XR_STANDARD_BUTTONS) {
auto data = getButtonOrPlaceholder(buttonType);
if (data.button)
state.buttons.append(*data.button);
if (data.axes)
state.axes.appendVector(*data.axes);
}
if (m_simulateSelect) {
m_primarySelected = false;
m_simulateSelect = false;
}
return state;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
WebFakeXRInputController::ButtonOrPlaceholder WebFakeXRInputController::getButtonOrPlaceholder(FakeXRButtonStateInit::Type buttonType) const
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
{
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
ButtonOrPlaceholder result;
auto it = m_buttons.find(buttonType);
if (it != m_buttons.end()) {
result.button = InputSourceButton {
.touched = it->value.touched,
.pressed = it->value.pressed,
.pressedValue = it->value.pressedValue
};
if (buttonType == ButtonType::Touchpad || buttonType == ButtonType::Thumbstick)
result.axes = Vector<float> { it->value.xValue, it->value.yValue };
} else {
// Add a placeholder if needed
// Devices that lack one of the optional inputs listed in the tables above MUST preserve their place in the
// buttons or axes array, reporting a placeholder button or placeholder axis, respectively.
if (buttonType != ButtonType::OptionalButton && buttonType != ButtonType::OptionalThumbstick) {
Implement WebXR Input Sources https://bugs.webkit.org/show_bug.cgi?id=223257 Reviewed by Youenn Fablet. .: Enable WPE Gamepad when WebXR is enabled. * Source/cmake/OptionsWPE.cmake: LayoutTests/imported/w3c: Update WebXR Input Source test expectations. * web-platform-tests/webxr/events_input_source_recreation.https-expected.txt: Added. * web-platform-tests/webxr/events_input_sources_change.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select.https-expected.txt: Added. * web-platform-tests/webxr/events_session_select_subframe.https-expected.txt: Added. * web-platform-tests/webxr/events_session_squeeze.https-expected.txt: Added. * web-platform-tests/webxr/getInputPose_handedness.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_add_remove.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_emulatedPosition.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_profiles.https-expected.txt: Added. * web-platform-tests/webxr/xrInputSource_sameObject.https-expected.txt: Added. * web-platform-tests/webxr/xrReferenceSpace_originOffset.https-expected.txt: Added. Source/WebCore: This patch implements the platform data definition and the DOM bits required to support WebXR Input Sources, the input mechanism used in WebXR. Example XR input sources include, but are not limited to, handheld controllers, optically tracked hands, and gaze-based input methods. More info about the API in: - https://immersive-web.github.io/webxr/#input - https://immersive-web.github.io/webxr-gamepads-module/#webxr-device-api-integration Tested by WebXR WPT. * Modules/gamepad/Gamepad.h: Add setConnected method. * Modules/webxr/WebXRGamepad.cpp: Bridge between WebXRInputSource and Gamepad (WebCore::WebXRGamepad::WebXRGamepad): * Modules/webxr/WebXRGamepad.h: * Modules/webxr/WebXRInputSpace.cpp: Instance of WebXRSpace used for WebXRInputSource spaces. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): * Modules/webxr/WebXRInputSpace.h: * Modules/webxr/WebXRFrame.cpp: (WebCore::WebXRFrame::populatePose): set emulatedPosition based on the spaces. * Modules/webxr/WebXRInputSource.cpp: Complete WebXRInputSource implementation. (WebCore::WebXRInputSpace::create): (WebCore::WebXRInputSpace::WebXRInputSpace): (WebCore::WebXRInputSpace::nativeOrigin const): (WebCore::WebXRInputSource::create): (WebCore::WebXRInputSource::WebXRInputSource): (WebCore::WebXRInputSource::update): (WebCore::WebXRInputSource::requiresInputSourceChange): (WebCore::WebXRInputSource::disconnect): (WebCore::WebXRInputSource::pollEvents): (WebCore::WebXRInputSource::createEvent): * Modules/webxr/WebXRInputSource.h: (WebCore::WebXRInputSource::handle const): (WebCore::WebXRInputSource::handedness const): (WebCore::WebXRInputSource::targetRayMode const): (WebCore::WebXRInputSource::targetRaySpace const): (WebCore::WebXRInputSource::gripSpace const): (WebCore::WebXRInputSource::profiles const): (WebCore::WebXRInputSource::gamepad const): * Modules/webxr/WebXRInputSource.idl: Add gamepad attribute. * Modules/webxr/WebXRInputSourceArray.cpp: Implement input source updates and event dispatching. (WebCore::WebXRInputSourceArray::create): (WebCore::WebXRInputSourceArray::WebXRInputSourceArray): (WebCore::WebXRInputSourceArray::length const): (WebCore::WebXRInputSourceArray::item const): (WebCore::WebXRInputSourceArray::clear): (WebCore::WebXRInputSourceArray::update): (WebCore::WebXRInputSourceArray::handleRemovedInputSources): (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources): * Modules/webxr/WebXRInputSourceArray.h: * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): Set tracking delegate before initializing tracking and rendering. (WebCore::WebXRSession::isPositionEmulated const): Add helper method. (WebCore::WebXRSession::shutdown): Clear WebXRInputSourceArray instance. (WebCore::WebXRSession::sessionDidInitializeInputSources): Dispatch initial InputSource discovery event. (WebCore::WebXRSession::onFrame): Update WebXRInputSourceArray instance. * Modules/webxr/WebXRSession.h: * Modules/webxr/WebXRSpace.cpp: Add virtual class isPositionEmulated to be used in WebXRFrame. (WebCore::WebXRSpace::isPositionEmulated const): * Modules/webxr/WebXRSpace.h: * Modules/webxr/WebXRSystem.cpp: (WebCore::WebXRSystem::requestSession): update FIXME comment. * Modules/webxr/XRHandedness.h: Reuse PlatformXR enum. * Modules/webxr/XRInputSourceEvent.cpp: (WebCore::XRInputSourceEvent::XRInputSourceEvent): (WebCore::XRInputSourceEvent::setFrameActive): * Modules/webxr/XRInputSourceEvent.h: * Modules/webxr/XRInputSourcesChangeEvent.h: * Modules/webxr/XRTargetRayMode.h: Reuse PlatformXR enum. * platform/gamepad/GamepadConstants.cpp: (WebCore::xrStandardGamepadMappingString): Add xr-standard gamepad mapping name. * platform/gamepad/GamepadConstants.h: * platform/xr/PlatformXR.h: Add Input Source frame data. * testing/WebFakeXRDevice.cpp: Implement required changes to run and pass WebXR Input Source tests. (WebCore::SimulatedXRDevice::initializeTrackingAndRendering): (WebCore::SimulatedXRDevice::frameTimerFired): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.cpp: (WebCore::WebFakeXRInputController::create): (WebCore::WebFakeXRInputController::WebFakeXRInputController): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): (WebCore::WebFakeXRInputController::getFrameData): (WebCore::WebFakeXRInputController::getButtonOrPlaceholder const): * testing/WebFakeXRInputController.h: LayoutTests: Update WebXR Input Source test expectations. * platform/wpe/TestExpectations: Canonical link: https://commits.webkit.org/236896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-22 14:06:06 +00:00
auto priority = std::find(XR_STANDARD_BUTTONS.begin(), XR_STANDARD_BUTTONS.end(), buttonType);
ASSERT(priority != XR_STANDARD_BUTTONS.end());
for (auto it = priority + 1; it != XR_STANDARD_BUTTONS.end(); ++it) {
if (m_buttons.contains(*it)) {
result.button = InputSourceButton();
break;
}
}
}
if (buttonType == ButtonType::Touchpad && m_buttons.contains(ButtonType::Thumbstick))
result.axes = Vector<float> { 0.0, 0.0 };
}
return result;
[WebXR] Test IDLs and stubs https://bugs.webkit.org/show_bug.cgi?id=209859 Reviewed by Dean Jackson and Youenn Fablet. Source/WebCore: WebXR testing is hard as it might involve interaction with actual devices. That's why the WebXR testing API (https://immersive-web.github.io/webxr-test-api/) was proposed. In fact, all the current WebXR tests from web-platform-tests are using that testing API. This new testing API supplements navigator.xr and is accessed through navigator.xr.test. In order not to expose the API to the web we're adding the XRTest interface to Internals instead. The mapping from internals.xrTest to navigator.xr.test happens in the WPT code. We're adding the required IDLs and very basic (mostly empty) implementations for testing methods. We're adding testing infrastructure, adding tests make no sense for this change. * CMakeLists.txt: Added new files. * DerivedSources.make: Ditto. * Modules/webxr/NavigatorWebXR.h: Export API to be used in testing code. * Modules/webxr/WebXRSystem.h: Export ::from and ::xr methods. * WebCore.xcodeproj/project.pbxproj: Ditto. * bindings/js/WebCoreBuiltinNames.h: Added some new macros. * testing/FakeXRBoundsPoint.h: Added. * testing/FakeXRBoundsPoint.idl: Added. * testing/FakeXRButtonStateInit.h: Added. * testing/FakeXRButtonStateInit.idl: Added. * testing/FakeXRInputSourceInit.h: Added. * testing/FakeXRInputSourceInit.idl: Added. * testing/FakeXRRigidTransformInit.h: Added. * testing/FakeXRRigidTransformInit.idl: Added. * testing/FakeXRViewInit.h: Added. * testing/FakeXRViewInit.idl: Added. * testing/Internals.cpp: (WebCore::Internals::xrTest): Added WebXRTest to Internals. * testing/Internals.h: Added xrTest() accessor. * testing/Internals.idl: Added xrTest attribute. * testing/WebFakeXRDevice.cpp: Added. (WebCore::WebFakeXRDevice::setViews): (WebCore::WebFakeXRDevice::disconnect): (WebCore::WebFakeXRDevice::setViewerOrigin): (WebCore::WebFakeXRDevice::clearViewerOrigin): (WebCore::WebFakeXRDevice::simulateVisibilityChange): (WebCore::WebFakeXRDevice::setBoundsGeometry): (WebCore::WebFakeXRDevice::setFloorOrigin): (WebCore::WebFakeXRDevice::clearFloorOrigin): (WebCore::WebFakeXRDevice::simulateResetPose): (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: Added. * testing/WebFakeXRDevice.idl: Added. * testing/WebFakeXRInputController.cpp: Added. (WebCore::WebFakeXRInputController::setHandedness): (WebCore::WebFakeXRInputController::setTargetRayMode): (WebCore::WebFakeXRInputController::setProfiles): (WebCore::WebFakeXRInputController::setGripOrigin): (WebCore::WebFakeXRInputController::clearGripOrigin): (WebCore::WebFakeXRInputController::setPointerOrigin): (WebCore::WebFakeXRInputController::disconnect): (WebCore::WebFakeXRInputController::reconnect): (WebCore::WebFakeXRInputController::startSelection): (WebCore::WebFakeXRInputController::endSelection): (WebCore::WebFakeXRInputController::simulateSelect): (WebCore::WebFakeXRInputController::setSupportedButtons): (WebCore::WebFakeXRInputController::updateButtonState): * testing/WebFakeXRInputController.h: Added. * testing/WebFakeXRInputController.idl: Added. * testing/WebXRTest.cpp: Added. (WebCore::WebXRTest::simulateDeviceConnection const): (WebCore::WebXRTest::simulateUserActivation): (WebCore::WebXRTest::disconnectAllDevices): * testing/WebXRTest.h: Added. (WebCore::WebXRTest::create): * testing/WebXRTest.idl: Added. * testing/XRSimulateUserActivationFunction.h: Added. * testing/XRSimulateUserActivationFunction.idl: Ditto. LayoutTests: * platform/wpe/TestExpectations: Added bug number to the passing webxr test. Canonical link: https://commits.webkit.org/223740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260505 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-22 10:19:30 +00:00
}
} // namespace WebCore
#endif // ENABLE(WEBXR)