Commit a62ed78c authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Remove usage of ExecutionContextLifecycleObserer::GetFrame() from modules/xr/

Change-Id: I303149a39f40702d6600fa7409f7cfc03146eb65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500429
Commit-Queue: Nate Chapin <japhet@chromium.org>
Auto-Submit: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821376}
parent 1421dac0
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/frame_request_callback_collection.h" #include "third_party/blink/renderer/core/dom/frame_request_callback_collection.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
...@@ -249,20 +250,14 @@ void XRFrameProvider::ScheduleNonImmersiveFrame( ...@@ -249,20 +250,14 @@ void XRFrameProvider::ScheduleNonImmersiveFrame(
return; return;
} }
LocalFrame* frame = xr_->GetFrame(); LocalDOMWindow* window = xr_->DomWindow();
if (!frame) if (!window)
return;
// TODO(https://crbug.com/856224) Review the lifetime of this object and
// ensure that doc can never be null and remove this check.
Document* doc = frame->GetDocument();
if (!doc)
return; return;
pending_non_immersive_vsync_ = true; pending_non_immersive_vsync_ = true;
// Calls |OnNonImmersiveVSync| // Calls |OnNonImmersiveVSync|
doc->RequestAnimationFrame( window->document()->RequestAnimationFrame(
MakeGarbageCollected<XRFrameProviderRequestCallback>(this)); MakeGarbageCollected<XRFrameProviderRequestCallback>(this));
} }
...@@ -279,11 +274,8 @@ void XRFrameProvider::OnImmersiveFrameData( ...@@ -279,11 +274,8 @@ void XRFrameProvider::OnImmersiveFrameData(
return; return;
} }
LocalFrame* frame = xr_->GetFrame(); LocalDOMWindow* window = xr_->DomWindow();
if (!frame) if (!window)
return;
Document* doc = frame->GetDocument();
if (!doc)
return; return;
if (!first_immersive_frame_time_) { if (!first_immersive_frame_time_) {
...@@ -299,7 +291,8 @@ void XRFrameProvider::OnImmersiveFrameData( ...@@ -299,7 +291,8 @@ void XRFrameProvider::OnImmersiveFrameData(
*first_immersive_frame_time_ + current_frame_time_from_first_frame; *first_immersive_frame_time_ + current_frame_time_from_first_frame;
double high_res_now_ms = double high_res_now_ms =
doc->Loader() window->document()
->Loader()
->GetTiming() ->GetTiming()
.MonotonicTimeToZeroBasedDocumentTime(current_frame_time) .MonotonicTimeToZeroBasedDocumentTime(current_frame_time)
.InMillisecondsF(); .InMillisecondsF();
...@@ -333,7 +326,7 @@ void XRFrameProvider::OnImmersiveFrameData( ...@@ -333,7 +326,7 @@ void XRFrameProvider::OnImmersiveFrameData(
// //
// Used kInternalMedia since 1) this is not spec-ed and 2) this is media // Used kInternalMedia since 1) this is not spec-ed and 2) this is media
// related then tasks should not be throttled or frozen in background tabs. // related then tasks should not be throttled or frozen in background tabs.
frame->GetTaskRunner(blink::TaskType::kInternalMedia) window->GetTaskRunner(blink::TaskType::kInternalMedia)
->PostTask(FROM_HERE, WTF::Bind(&XRFrameProvider::ProcessScheduledFrame, ->PostTask(FROM_HERE, WTF::Bind(&XRFrameProvider::ProcessScheduledFrame,
WrapWeakPersistent(this), std::move(data), WrapWeakPersistent(this), std::move(data),
high_res_now_ms)); high_res_now_ms));
...@@ -349,11 +342,11 @@ void XRFrameProvider::OnNonImmersiveVSync(double high_res_now_ms) { ...@@ -349,11 +342,11 @@ void XRFrameProvider::OnNonImmersiveVSync(double high_res_now_ms) {
if (immersive_session_) if (immersive_session_)
return; return;
LocalFrame* frame = xr_->GetFrame(); LocalDOMWindow* window = xr_->DomWindow();
if (!frame) if (!window)
return; return;
frame->GetTaskRunner(blink::TaskType::kInternalMedia) window->GetTaskRunner(blink::TaskType::kInternalMedia)
->PostTask(FROM_HERE, ->PostTask(FROM_HERE,
WTF::Bind(&XRFrameProvider::ProcessScheduledFrame, WTF::Bind(&XRFrameProvider::ProcessScheduledFrame,
WrapWeakPersistent(this), nullptr, high_res_now_ms)); WrapWeakPersistent(this), nullptr, high_res_now_ms));
...@@ -366,12 +359,8 @@ void XRFrameProvider::OnNonImmersiveFrameData( ...@@ -366,12 +359,8 @@ void XRFrameProvider::OnNonImmersiveFrameData(
DVLOG(2) << __FUNCTION__; DVLOG(2) << __FUNCTION__;
// TODO(https://crbug.com/837834): add unit tests for this code path. // TODO(https://crbug.com/837834): add unit tests for this code path.
LocalDOMWindow* window = xr_->DomWindow();
LocalFrame* frame = xr_->GetFrame(); if (!window)
if (!frame)
return;
Document* doc = frame->GetDocument();
if (!doc)
return; return;
// Look up the request for this session. The session may have ended between // Look up the request for this session. The session may have ended between
...@@ -396,7 +385,7 @@ void XRFrameProvider::OnNonImmersiveFrameData( ...@@ -396,7 +385,7 @@ void XRFrameProvider::OnNonImmersiveFrameData(
// Try to request a regular animation frame to avoid getting stuck. // Try to request a regular animation frame to avoid getting stuck.
DVLOG(1) << __FUNCTION__ << ": NO FRAME DATA!"; DVLOG(1) << __FUNCTION__ << ": NO FRAME DATA!";
request->value = nullptr; request->value = nullptr;
doc->RequestAnimationFrame( window->document()->RequestAnimationFrame(
MakeGarbageCollected<XRFrameProviderRequestCallback>(this)); MakeGarbageCollected<XRFrameProviderRequestCallback>(this));
} }
} }
...@@ -439,10 +428,9 @@ void XRFrameProvider::ProcessScheduledFrame( ...@@ -439,10 +428,9 @@ void XRFrameProvider::ProcessScheduledFrame(
TRACE_EVENT2("gpu", "XRFrameProvider::ProcessScheduledFrame", "frame", TRACE_EVENT2("gpu", "XRFrameProvider::ProcessScheduledFrame", "frame",
frame_id_, "timestamp", high_res_now_ms); frame_id_, "timestamp", high_res_now_ms);
LocalFrame* frame = xr_->GetFrame(); LocalDOMWindow* window = xr_->DomWindow();
if (!frame) { if (!window)
return; return;
}
if (!xr_->IsFrameFocused() && !immersive_session_) { if (!xr_->IsFrameFocused() && !immersive_session_) {
return; // Not currently focused, so we won't expose poses (except to return; // Not currently focused, so we won't expose poses (except to
...@@ -507,7 +495,7 @@ void XRFrameProvider::ProcessScheduledFrame( ...@@ -507,7 +495,7 @@ void XRFrameProvider::ProcessScheduledFrame(
// Run immersive_session_->OnFrame() in a posted task to ensure that // Run immersive_session_->OnFrame() in a posted task to ensure that
// createAnchor promises get a chance to run - the presentation frame state // createAnchor promises get a chance to run - the presentation frame state
// is already updated. // is already updated.
frame->GetTaskRunner(blink::TaskType::kInternalMedia) window->GetTaskRunner(blink::TaskType::kInternalMedia)
->PostTask(FROM_HERE, ->PostTask(FROM_HERE,
WTF::Bind(&XRSession::OnFrame, WTF::Bind(&XRSession::OnFrame,
WrapWeakPersistent(immersive_session_.Get()), WrapWeakPersistent(immersive_session_.Get()),
...@@ -566,7 +554,7 @@ void XRFrameProvider::ProcessScheduledFrame( ...@@ -566,7 +554,7 @@ void XRFrameProvider::ProcessScheduledFrame(
// Note that rather than call session->OnFrame() directly, we dispatch to // Note that rather than call session->OnFrame() directly, we dispatch to
// a helper method who can determine if the state requirements are still // a helper method who can determine if the state requirements are still
// met that would allow the frame to be served. // met that would allow the frame to be served.
frame->GetTaskRunner(blink::TaskType::kInternalMedia) window->GetTaskRunner(blink::TaskType::kInternalMedia)
->PostTask( ->PostTask(
FROM_HERE, FROM_HERE,
WTF::Bind(&XRFrameProvider::OnPreDispatchInlineFrame, WTF::Bind(&XRFrameProvider::OnPreDispatchInlineFrame,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatcher.h" #include "third_party/blink/renderer/core/dom/events/event_dispatcher.h"
#include "third_party/blink/renderer/core/dom/events/event_path.h" #include "third_party/blink/renderer/core/dom/events/event_path.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/html_frame_element_base.h" #include "third_party/blink/renderer/core/html/html_frame_element_base.h"
#include "third_party/blink/renderer/core/input/event_handling_util.h" #include "third_party/blink/renderer/core/input/event_handling_util.h"
...@@ -277,8 +278,7 @@ void XRInputSource::OnSelectEnd() { ...@@ -277,8 +278,7 @@ void XRInputSource::OnSelectEnd() {
state_.primary_input_pressed = false; state_.primary_input_pressed = false;
LocalFrame* frame = session_->xr()->GetFrame(); if (!session_->xr()->DomWindow())
if (!frame)
return; return;
DVLOG(3) << __func__ << ": dispatch selectend event"; DVLOG(3) << __func__ << ": dispatch selectend event";
...@@ -302,15 +302,16 @@ void XRInputSource::OnSelect() { ...@@ -302,15 +302,16 @@ void XRInputSource::OnSelect() {
OnSelectStart(); OnSelectStart();
} }
LocalFrame* frame = session_->xr()->GetFrame();
LocalFrame::NotifyUserActivation(
frame, mojom::blink::UserActivationNotificationType::kInteraction);
// If SelectStart caused the session to end, we shouldn't try to fire the // If SelectStart caused the session to end, we shouldn't try to fire the
// select event. // select event.
LocalDOMWindow* window = session_->xr()->DomWindow();
if (!window)
return;
LocalFrame::NotifyUserActivation(
window->GetFrame(),
mojom::blink::UserActivationNotificationType::kInteraction);
if (!state_.selection_cancelled && !session_->ended()) { if (!state_.selection_cancelled && !session_->ended()) {
if (!frame)
return;
DVLOG(3) << __func__ << ": dispatch select event"; DVLOG(3) << __func__ << ": dispatch select event";
XRInputSourceEvent* event = XRInputSourceEvent* event =
CreateInputSourceEvent(event_type_names::kSelect); CreateInputSourceEvent(event_type_names::kSelect);
...@@ -351,8 +352,7 @@ void XRInputSource::OnSqueezeEnd() { ...@@ -351,8 +352,7 @@ void XRInputSource::OnSqueezeEnd() {
state_.primary_squeeze_pressed = false; state_.primary_squeeze_pressed = false;
LocalFrame* frame = session_->xr()->GetFrame(); if (!session_->xr()->DomWindow())
if (!frame)
return; return;
DVLOG(3) << __func__ << ": dispatch squeezeend event"; DVLOG(3) << __func__ << ": dispatch squeezeend event";
...@@ -376,15 +376,18 @@ void XRInputSource::OnSqueeze() { ...@@ -376,15 +376,18 @@ void XRInputSource::OnSqueeze() {
OnSqueezeStart(); OnSqueezeStart();
} }
LocalFrame* frame = session_->xr()->GetFrame(); // If SelectStart caused the session to end, we shouldn't try to fire the
// select event.
LocalDOMWindow* window = session_->xr()->DomWindow();
if (!window)
return;
LocalFrame::NotifyUserActivation( LocalFrame::NotifyUserActivation(
frame, mojom::blink::UserActivationNotificationType::kInteraction); window->GetFrame(),
mojom::blink::UserActivationNotificationType::kInteraction);
// If SelectStart caused the session to end, we shouldn't try to fire the // If SelectStart caused the session to end, we shouldn't try to fire the
// select event. // select event.
if (!state_.squeezing_cancelled && !session_->ended()) { if (!state_.squeezing_cancelled && !session_->ended()) {
if (!frame)
return;
DVLOG(3) << __func__ << ": dispatch squeeze event"; DVLOG(3) << __func__ << ": dispatch squeeze event";
XRInputSourceEvent* event = XRInputSourceEvent* event =
CreateInputSourceEvent(event_type_names::kSqueeze); CreateInputSourceEvent(event_type_names::kSqueeze);
......
...@@ -364,13 +364,10 @@ class XRSystem final : public EventTargetWithInlineData, ...@@ -364,13 +364,10 @@ class XRSystem final : public EventTargetWithInlineData,
XRSessionInit* session_init, XRSessionInit* session_init,
mojom::ConsoleMessageLevel error_level); mojom::ConsoleMessageLevel error_level);
void RequestImmersiveSession(LocalFrame* frame, void RequestImmersiveSession(PendingRequestSessionQuery* query,
Document* doc,
PendingRequestSessionQuery* query,
ExceptionState* exception_state); ExceptionState* exception_state);
void RequestInlineSession(LocalFrame* frame, void RequestInlineSession(PendingRequestSessionQuery* query,
PendingRequestSessionQuery* query,
ExceptionState* exception_state); ExceptionState* exception_state);
void DoRequestSession( void DoRequestSession(
...@@ -390,7 +387,6 @@ class XRSystem final : public EventTargetWithInlineData, ...@@ -390,7 +387,6 @@ class XRSystem final : public EventTargetWithInlineData,
void RejectSessionRequest(PendingRequestSessionQuery*); void RejectSessionRequest(PendingRequestSessionQuery*);
void EnsureDevice(); void EnsureDevice();
void ReportImmersiveSupported(bool supported);
void AddedEventListener(const AtomicString& event_type, void AddedEventListener(const AtomicString& event_type,
RegisteredEventListener&) override; RegisteredEventListener&) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment