Diff
Modified: trunk/LayoutTests/ChangeLog (262298 => 262299)
--- trunk/LayoutTests/ChangeLog 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/LayoutTests/ChangeLog 2020-05-29 16:36:52 UTC (rev 262299)
@@ -1,3 +1,12 @@
+2020-05-27 Sergio Villar Senin <[email protected]>
+
+ [WebXR] Implement XRSession::requestReferenceSpace()
+ https://bugs.webkit.org/show_bug.cgi?id=212407
+
+ Reviewed by Youenn Fablet.
+
+ * platform/wpe/TestExpectations: Unskipped 3 more tests that are working now.
+
2020-05-29 Diego Pino Garcia <[email protected]>
[GLIB] Gardening, update test expectations after r262254
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (262298 => 262299)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-05-29 16:36:52 UTC (rev 262299)
@@ -1,3 +1,16 @@
+2020-05-27 Sergio Villar Senin <[email protected]>
+
+ [WebXR] Implement XRSession::requestReferenceSpace()
+ https://bugs.webkit.org/show_bug.cgi?id=212407
+
+ Reviewed by Youenn Fablet.
+
+ Added expectations.
+
+ * web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt: Added.
+ * web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt: Added.
+ * web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt: Added.
+
2020-05-29 Javier Fernandez <[email protected]>
[css-grid] Import tests for the grid as flexbox item case
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt (0 => 262299)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt 2020-05-29 16:36:52 UTC (rev 262299)
@@ -0,0 +1,3 @@
+
+PASS An XR-compatible webglCanvasContext can be created
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt (0 => 262299)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt 2020-05-29 16:36:52 UTC (rev 262299)
@@ -0,0 +1,3 @@
+
+PASS A lost webglCanvasContext should not be able to set xr compatibility
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt (0 => 262299)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt 2020-05-29 16:36:52 UTC (rev 262299)
@@ -0,0 +1,4 @@
+
+PASS Immersive XRSession requestReferenceSpace returns expected objects
+PASS Non-immersive XRSession requestReferenceSpace returns expected objects
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Modified: trunk/LayoutTests/platform/wpe/TestExpectations (262298 => 262299)
--- trunk/LayoutTests/platform/wpe/TestExpectations 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/LayoutTests/platform/wpe/TestExpectations 2020-05-29 16:36:52 UTC (rev 262299)
@@ -967,6 +967,8 @@
# WebXR
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/idlharness.https.window.html [ Pass ]
+webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https.html [ Pass ]
+webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https.html [ Pass ]
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrDevice_isSessionSupported_inline.https.html [ Pass ]
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrDevice_isSessionSupported_immersive.https.html [ Pass ]
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrDevice_isSessionSupported_immersive_unsupported.https.html [ Pass ]
@@ -981,6 +983,7 @@
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_cancelAnimationFrame_invalidhandle.https.html [ Pass ]
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html [ Pass ]
webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_requestAnimationFrame_callback_calls.https.html [ Pass ]
+webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https.html [ Pass ]
# Passing since r259532.
imported/w3c/web-platform-tests/css/css-ui/outline-019.html
Modified: trunk/Source/WebCore/ChangeLog (262298 => 262299)
--- trunk/Source/WebCore/ChangeLog 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/ChangeLog 2020-05-29 16:36:52 UTC (rev 262299)
@@ -1,3 +1,34 @@
+2020-05-27 Sergio Villar Senin <[email protected]>
+
+ [WebXR] Implement XRSession::requestReferenceSpace()
+ https://bugs.webkit.org/show_bug.cgi?id=212407
+
+ Reviewed by Youenn Fablet.
+
+ This patch implements the requestReferenceSpace() method of the XRSession which is used to
+ create reference spaces. A reference space establishes a space where pose data will be defined
+ and thus is mandatory to retrieve that pose information.
+
+ There are still some bits that have to implementated in follow up patches using platform code.
+
+ * Modules/webxr/WebXRBoundedReferenceSpace.cpp:
+ (WebCore::WebXRBoundedReferenceSpace::create): Added.
+ (WebCore::WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace): Ditto.
+ * Modules/webxr/WebXRBoundedReferenceSpace.h:
+ * Modules/webxr/WebXRReferenceSpace.cpp:
+ (WebCore::WebXRReferenceSpace::create): Added.
+ (WebCore::WebXRReferenceSpace::WebXRReferenceSpace): Ditto.
+ (WebCore::WebXRReferenceSpace::getOffsetReferenceSpace): Use the create() method.
+ * Modules/webxr/WebXRReferenceSpace.h:
+ * Modules/webxr/WebXRSession.cpp:
+ (WebCore::WebXRSession::referenceSpaceIsSupported const): New method to check whether a reference.
+ space is supported by session and device.
+ (WebCore::WebXRSession::requestReferenceSpace): New method that creates reference spaces for pose data.
+ * Modules/webxr/WebXRSession.h:
+ * Modules/webxr/WebXRSpace.cpp:
+ (WebCore::WebXRSpace::WebXRSpace): Store a reference to the session creating the space.
+ * Modules/webxr/WebXRSpace.h:
+
2020-05-29 Simon Fraser <[email protected]>
Update debug overlays at rendering update time
Modified: trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp 2020-05-29 16:36:52 UTC (rev 262299)
@@ -28,8 +28,25 @@
#if ENABLE(WEBXR)
+#include "DOMPointReadOnly.h"
+#include <wtf/IsoMallocInlines.h>
+
namespace WebCore {
+WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRBoundedReferenceSpace);
+
+Ref<WebXRBoundedReferenceSpace> WebXRBoundedReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
+{
+ return adoptRef(*new WebXRBoundedReferenceSpace(document, WTFMove(session), type));
+}
+
+WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
+ : WebXRReferenceSpace(document, WTFMove(session), type)
+{
+}
+
+WebXRBoundedReferenceSpace::~WebXRBoundedReferenceSpace() = default;
+
const Vector<Ref<DOMPointReadOnly>>& WebXRBoundedReferenceSpace::boundsGeometry() const
{
return m_boundsGeometry;
Modified: trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h 2020-05-29 16:36:52 UTC (rev 262299)
@@ -26,6 +26,7 @@
#pragma once
#include "WebXRReferenceSpace.h"
+#include <wtf/IsoMalloc.h>
#include <wtf/Ref.h>
#include <wtf/Vector.h>
@@ -36,12 +37,17 @@
class DOMPointReadOnly;
class WebXRBoundedReferenceSpace : public WebXRReferenceSpace {
+ WTF_MAKE_ISO_ALLOCATED(WebXRBoundedReferenceSpace);
public:
+ static Ref<WebXRBoundedReferenceSpace> create(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
+
virtual ~WebXRBoundedReferenceSpace();
const Vector<Ref<DOMPointReadOnly>>& boundsGeometry() const;
private:
+ WebXRBoundedReferenceSpace(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
+
Vector<Ref<DOMPointReadOnly>> m_boundsGeometry;
};
Modified: trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp 2020-05-29 16:36:52 UTC (rev 262299)
@@ -28,18 +28,33 @@
#if ENABLE(WEBXR)
+#include "Document.h"
+#include "WebXRSession.h"
+#include <wtf/IsoMallocInlines.h>
+
namespace WebCore {
-WebXRReferenceSpace::WebXRReferenceSpace(ScriptExecutionContext& context)
- : WebXRSpace(context)
+WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRReferenceSpace);
+
+Ref<WebXRReferenceSpace> WebXRReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
{
+ return adoptRef(*new WebXRReferenceSpace(document, WTFMove(session), type));
}
+WebXRReferenceSpace::WebXRReferenceSpace(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
+ : WebXRSpace(document, WTFMove(session))
+ , m_type(type)
+{
+}
+
WebXRReferenceSpace::~WebXRReferenceSpace() = default;
-Ref<WebXRReferenceSpace> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform&)
+RefPtr<WebXRReferenceSpace> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform&)
{
- return adoptRef(*new WebXRReferenceSpace(*scriptExecutionContext()));
+ if (!scriptExecutionContext())
+ return nullptr;
+ ASSERT(is<Document>(scriptExecutionContext()));
+ return create(downcast<Document>(*scriptExecutionContext()), m_session.copyRef(), m_type);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h 2020-05-29 16:36:52 UTC (rev 262299)
@@ -28,21 +28,28 @@
#if ENABLE(WEBXR)
#include "WebXRSpace.h"
-
+#include "XRReferenceSpaceType.h"
+#include <wtf/IsoMalloc.h>
#include <wtf/Ref.h>
namespace WebCore {
class WebXRRigidTransform;
+class WebXRSession;
class WebXRReferenceSpace : public WebXRSpace {
+ WTF_MAKE_ISO_ALLOCATED(WebXRReferenceSpace);
public:
+ static Ref<WebXRReferenceSpace> create(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
+
virtual ~WebXRReferenceSpace();
- Ref<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&);
+ RefPtr<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&);
-private:
- WebXRReferenceSpace(ScriptExecutionContext&);
+protected:
+ WebXRReferenceSpace(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
+
+ XRReferenceSpaceType m_type;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp 2020-05-29 16:36:52 UTC (rev 262299)
@@ -28,6 +28,8 @@
#if ENABLE(WEBXR)
+#include "JSWebXRReferenceSpace.h"
+#include "WebXRBoundedReferenceSpace.h"
#include "WebXRFrame.h"
#include "WebXRSystem.h"
#include "XRFrameRequestCallback.h"
@@ -83,10 +85,77 @@
{
}
-void WebXRSession::requestReferenceSpace(const XRReferenceSpaceType&, RequestReferenceSpacePromise&&)
+// https://immersive-web.github.io/webxr/#reference-space-is-supported
+bool WebXRSession::referenceSpaceIsSupported(XRReferenceSpaceType type) const
{
+ // 1. If type is not contained in session’s XR device's list of enabled features for mode return false.
+ if (!m_device->enabledFeatures(m_mode).contains(type))
+ return false;
+
+ // 2. If type is viewer, return true.
+ if (type == XRReferenceSpaceType::Viewer)
+ return true;
+
+ bool isImmersiveSession = m_mode == XRSessionMode::ImmersiveAr || m_mode == XRSessionMode::ImmersiveVr;
+ if (type == XRReferenceSpaceType::Local || type == XRReferenceSpaceType::LocalFloor) {
+ // 3. If type is local or local-floor, and session is an immersive session, return true.
+ if (isImmersiveSession)
+ return true;
+
+ // 4. If type is local or local-floor, and the XR device supports reporting orientation data, return true.
+ // TODO: add API to PlatformXR::Device
+ return true;
+ }
+
+
+ // 5. If type is bounded-floor and session is an immersive session, return the result of whether bounded
+ // reference spaces are supported by the XR device.
+ // https://immersive-web.github.io/webxr/#bounded-reference-spaces-are-supported
+ // TODO: add API to PlatformXR::Device
+ if (type == XRReferenceSpaceType::BoundedFloor && isImmersiveSession)
+ return true;
+
+ // 6. If type is unbounded, session is an immersive session, and the XR device supports stable tracking
+ // near the user over an unlimited distance, return true.
+ // TODO: add API to PlatformXR::Device to check stable tracking over unlimited distance.
+ if (type == XRReferenceSpaceType::Unbounded && isImmersiveSession)
+ return true;
+
+ // 7. Return false.
+ return false;
}
+// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
+void WebXRSession::requestReferenceSpace(XRReferenceSpaceType type, RequestReferenceSpacePromise&& promise)
+{
+ if (!scriptExecutionContext()) {
+ promise.reject(Exception { InvalidStateError });
+ return;
+ }
+ // 1. Let promise be a new Promise.
+ // 2. Run the following steps in parallel:
+ scriptExecutionContext()->postTask([this, promise = WTFMove(promise), type] (auto& context) mutable {
+ // 2.1. Create a reference space, referenceSpace, with the XRReferenceSpaceType type.
+ // 2.2. If referenceSpace is null, reject promise with a NotSupportedError and abort these steps.
+ if (!referenceSpaceIsSupported(type)) {
+ promise.reject(Exception { NotSupportedError });
+ return;
+ }
+
+ // https://immersive-web.github.io/webxr/#create-a-reference-space
+ RefPtr<WebXRReferenceSpace> referenceSpace;
+ ASSERT(is<Document>(context));
+ if (type == XRReferenceSpaceType::BoundedFloor)
+ referenceSpace = WebXRBoundedReferenceSpace::create(downcast<Document>(context), makeRef(*this), type);
+ else
+ referenceSpace = WebXRReferenceSpace::create(downcast<Document>(context), makeRef(*this), type);
+
+ // 2.3. Resolve promise with referenceSpace.
+ // 3. Return promise.
+ promise.resolve(referenceSpace.releaseNonNull());
+ });
+}
+
void WebXRSession::animationTimerFired()
{
m_lastAnimationFrameTimestamp = MonotonicTime::now();
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.h (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRSession.h 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.h 2020-05-29 16:36:52 UTC (rev 262299)
@@ -69,7 +69,7 @@
const WebXRInputSourceArray& inputSources() const;
void updateRenderState(const XRRenderStateInit&);
- void requestReferenceSpace(const XRReferenceSpaceType&, RequestReferenceSpacePromise&&);
+ void requestReferenceSpace(XRReferenceSpaceType, RequestReferenceSpacePromise&&);
XRFrameRequestCallback::Id requestAnimationFrame(Ref<XRFrameRequestCallback>&&);
void cancelAnimationFrame(int handle);
@@ -96,6 +96,8 @@
void animationTimerFired();
void scheduleAnimation();
+ bool referenceSpaceIsSupported(XRReferenceSpaceType) const;
+
XREnvironmentBlendMode m_environmentBlendMode;
XRVisibilityState m_visibilityState;
RefPtr<WebXRInputSourceArray> m_inputSources;
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSpace.cpp (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRSpace.cpp 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSpace.cpp 2020-05-29 16:36:52 UTC (rev 262299)
@@ -28,6 +28,8 @@
#if ENABLE(WEBXR)
+#include "Document.h"
+#include "WebXRSession.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
@@ -34,9 +36,11 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRSpace);
-WebXRSpace::WebXRSpace(ScriptExecutionContext& context)
- : ContextDestructionObserver(&context)
+WebXRSpace::WebXRSpace(Document& document, Ref<WebXRSession>&& session)
+ : ContextDestructionObserver(&document)
+ , m_session(WTFMove(session))
{
+ ASSERT(context);
}
WebXRSpace::~WebXRSpace() = default;
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSpace.h (262298 => 262299)
--- trunk/Source/WebCore/Modules/webxr/WebXRSpace.h 2020-05-29 16:29:07 UTC (rev 262298)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSpace.h 2020-05-29 16:36:52 UTC (rev 262299)
@@ -33,7 +33,9 @@
namespace WebCore {
+class Document;
class ScriptExecutionContext;
+class WebXRSession;
class WebXRSpace : public RefCounted<WebXRSpace>, public EventTargetWithInlineData, public ContextDestructionObserver {
WTF_MAKE_ISO_ALLOCATED(WebXRSpace);
@@ -44,11 +46,13 @@
using RefCounted<WebXRSpace>::deref;
protected:
- WebXRSpace(ScriptExecutionContext&);
+ WebXRSpace(Document&, Ref<WebXRSession>&&);
// EventTarget
ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
+ Ref<WebXRSession> m_session;
+
private:
// EventTarget
EventTargetInterface eventTargetInterface() const override { return WebXRSpaceEventTargetInterfaceType; }