Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp

Issue 2618713002: Remove ContextClient from NavigatorVR (Closed)
Patch Set: temp Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
diff --git a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
index 77a2f29dbdca2c5928e3e40c474af6430de2a556..a0169b014c0888227d127aa1df652a4a1fab927c 100644
--- a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
+++ b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
@@ -35,7 +35,7 @@ NavigatorVR& NavigatorVR::from(Navigator& navigator) {
NavigatorVR* supplement = static_cast<NavigatorVR*>(
Supplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
- supplement = new NavigatorVR(navigator.frame());
+ supplement = new NavigatorVR(navigator);
provideTo(navigator, supplementName(), supplement);
}
return *supplement;
@@ -50,21 +50,20 @@ ScriptPromise NavigatorVR::getVRDisplays(ScriptState* scriptState) {
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
- Document* document = frame() ? frame()->document() : 0;
-
- if (!document || !controller()) {
+ if (!document()) {
DOMException* exception = DOMException::create(
InvalidStateError, "The object is no longer associated to a document.");
resolver->reject(exception);
return promise;
}
- UseCounter::count(*document, UseCounter::VRGetDisplays);
+ UseCounter::count(*document(), UseCounter::VRGetDisplays);
ExecutionContext* executionContext = scriptState->getExecutionContext();
if (!executionContext->isSecureContext())
- UseCounter::count(*document, UseCounter::VRGetDisplaysInsecureOrigin);
+ UseCounter::count(*document(), UseCounter::VRGetDisplaysInsecureOrigin);
- Platform::current()->recordRapporURL("VR.WebVR.GetDisplays", document->url());
+ Platform::current()->recordRapporURL("VR.WebVR.GetDisplays",
+ document()->url());
controller()->getDisplays(resolver);
@@ -72,7 +71,7 @@ ScriptPromise NavigatorVR::getVRDisplays(ScriptState* scriptState) {
}
VRController* NavigatorVR::controller() {
- if (!frame())
+ if (!host()->frame())
return 0;
if (!m_controller) {
@@ -83,20 +82,19 @@ VRController* NavigatorVR::controller() {
}
Document* NavigatorVR::document() {
- return frame() ? frame()->document() : 0;
+ return host()->frame() ? host()->frame()->document() : nullptr;
}
DEFINE_TRACE(NavigatorVR) {
visitor->trace(m_controller);
-
Supplement<Navigator>::trace(visitor);
- ContextClient::trace(visitor);
PageVisibilityObserver::trace(visitor);
}
-NavigatorVR::NavigatorVR(LocalFrame* frame)
- : ContextClient(frame), PageVisibilityObserver(frame->page()) {
- frame->domWindow()->registerEventListenerObserver(this);
+NavigatorVR::NavigatorVR(Navigator& navigator)
+ : Supplement<Navigator>(navigator),
+ PageVisibilityObserver(navigator.frame()->page()) {
+ navigator.frame()->domWindow()->registerEventListenerObserver(this);
}
NavigatorVR::~NavigatorVR() {}
@@ -106,20 +104,20 @@ const char* NavigatorVR::supplementName() {
}
void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) {
- // TODO(dcheng): Why does this need to check both frame and domWindow?
- if (frame() && frame()->domWindow()) {
- frame()->domWindow()->enqueueWindowEvent(event);
+ if (host()->frame()) {
+ host()->frame()->domWindow()->enqueueWindowEvent(event);
}
}
void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
- // TODO(dcheng): Why does this need to check both frame and domWindow?
- if (frame() && frame()->domWindow()) {
- UserGestureIndicator gestureIndicator(
- DocumentUserGestureToken::create(frame()->document()));
- event->setTarget(frame()->domWindow());
- frame()->domWindow()->dispatchEvent(event);
- }
+ if (host()->frame())
+ return;
+ UserGestureIndicator gestureIndicator(
+ DocumentUserGestureToken::create(document()));
+ LocalDOMWindow* window = host()->frame()->domWindow();
+ DCHECK(window);
+ event->setTarget(window);
+ window->dispatchEvent(event);
}
void NavigatorVR::pageVisibilityChanged() {
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698