haikuwebkit/Source/WebCore/testing/WebFakeXRInputController.h

87 lines
3.8 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.
*/
#pragma once
#if ENABLE(WEBXR)
#include "FakeXRButtonStateInit.h"
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 "FakeXRInputSourceInit.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
#include "FakeXRRigidTransformInit.h"
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 "PlatformXR.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
#include "XRHandedness.h"
#include "XRTargetRayMode.h"
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 <wtf/HashMap.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
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
class WebFakeXRInputController final : public RefCounted<WebFakeXRInputController> {
public:
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
static Ref<WebFakeXRInputController> create(PlatformXR::InputSourceHandle, const FakeXRInputSourceInit&);
[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 setHandedness(XRHandedness handeness) { m_handeness = handeness; }
void setTargetRayMode(XRTargetRayMode mode) { m_targetRayMode = mode; }
void setProfiles(Vector<String>&& profiles) { m_profiles = WTFMove(profiles); }
[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 setGripOrigin(FakeXRRigidTransformInit gripOrigin, bool emulatedPosition = false);
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
void clearGripOrigin() { m_gripOrigin = std::nullopt; }
[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 setPointerOrigin(FakeXRRigidTransformInit pointerOrigin, bool emulatedPosition = false);
void disconnect();
void 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
void startSelection() { m_primarySelected = true; }
void endSelection() { m_primarySelected = false; }
void simulateSelect() { m_simulateSelect = true; }
void setSupportedButtons(const Vector<FakeXRButtonStateInit>&);
void updateButtonState(const FakeXRButtonStateInit&);
bool isConnected() const { return m_connected; }
[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
PlatformXR::Device::FrameData::InputSource getFrameData();
[WebXR] Implement XRSession::requestAnimationFrame() https://bugs.webkit.org/show_bug.cgi?id=212099 Reviewed by Youenn Fablet. LayoutTests/imported/w3c: * web-platform-tests/webxr/xrSession_cancelAnimationFrame.https-expected.txt: Added. * web-platform-tests/webxr/xrSession_cancelAnimationFrame_invalidhandle.https-expected.txt: Added. * web-platform-tests/webxr/xrSession_requestAnimationFrame_callback_calls.https-expected.txt: Added. Source/WebCore: The WebXR spec defines a requestAnimationFrame() mechanism to provide information about XR tracking devices using callbacks. It's pretty similar to the requestAnimationFrame() exposed by Window but only used to update WebXR content. We're adding a basic implementation of this mechanism as long as cancellation support. It requires some platform code that will be added in follow up patches. That platform code will provide information like devices' refresh rates, pose (position & orientation), display resolution, etc... This patch also replaces the type of the callback id from int to unsigned int as per the following change in specs https://github.com/immersive-web/webxr/pull/1062. Apart from that we're adding a missing adoptRef() in the testing code that was causing assertions in some of the tests that are being unskipped as part of this change. * Modules/webxr/WebXRSession.cpp: (WebCore::WebXRSession::WebXRSession): (WebCore::WebXRSession::animationTimerFired): Added. (WebCore::WebXRSession::scheduleAnimation): Ditto. (WebCore::WebXRSession::requestAnimationFrame): Ditto. (WebCore::WebXRSession::cancelAnimationFrame): * Modules/webxr/WebXRSession.h: * Modules/webxr/XRFrameRequestCallback.h: (WebCore::XRFrameRequestCallback::callbackId): (WebCore::XRFrameRequestCallback::setCallbackId): (WebCore::XRFrameRequestCallback::cancel): (WebCore::XRFrameRequestCallback::isCancelled const): * testing/WebFakeXRDevice.cpp: (WebCore::WebFakeXRDevice::simulateInputSourceConnection): * testing/WebFakeXRDevice.h: * testing/WebFakeXRInputController.h: LayoutTests: * platform/wpe/TestExpectations: Unskipped several tests that are now passing. Canonical link: https://commits.webkit.org/225248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-27 09:36:47 +00:00
private:
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(PlatformXR::InputSourceHandle, const FakeXRInputSourceInit&);
struct ButtonOrPlaceholder {
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<PlatformXR::Device::FrameData::InputSourceButton> button;
std::optional<Vector<float>> axes;
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 getButtonOrPlaceholder(FakeXRButtonStateInit::Type) const;
PlatformXR::InputSourceHandle m_handle { 0 };
XRHandedness m_handeness { XRHandedness::None };
XRTargetRayMode m_targetRayMode { XRTargetRayMode::Gaze };
Vector<String> m_profiles;
PlatformXR::Device::FrameData::InputSourcePose m_pointerOrigin;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<PlatformXR::Device::FrameData::InputSourcePose> m_gripOrigin;
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
HashMap<FakeXRButtonStateInit::Type, FakeXRButtonStateInit, WTF::IntHash<FakeXRButtonStateInit::Type>, WTF::StrongEnumHashTraits<FakeXRButtonStateInit::Type>> m_buttons;
bool m_connected { true };
bool m_primarySelected { false };
bool m_simulateSelect { 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
};
} // namespace WebCore
#endif // ENABLE(WEBXR)