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

Side by Side Diff: Source/modules/screen_orientation/PartialScreenOrientation.cpp

Issue 374623002: [screen-orientation] Update implementation to match recent spec changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix move Created 6 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/screen_orientation/PartialScreenOrientation.h"
7
8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/frame/Screen.h"
10 #include "modules/screen_orientation/ScreenOrientation.h"
11 #include "modules/screen_orientation/ScreenOrientationController.h"
12
13 namespace WebCore {
14
15 PartialScreenOrientation::PartialScreenOrientation(Screen& screen)
16 : DOMWindowProperty(screen.frame())
17 {
18 }
19
20 const char* PartialScreenOrientation::supplementName()
21 {
22 return "PartialScreenOrientation";
23 }
24
25 PartialScreenOrientation& PartialScreenOrientation::from(Screen& screen)
26 {
27 PartialScreenOrientation* supplement = static_cast<PartialScreenOrientation* >(WillBeHeapSupplement<Screen>::from(screen, supplementName()));
28 if (!supplement) {
29 supplement = new PartialScreenOrientation(screen);
30 provideTo(screen, supplementName(), adoptPtrWillBeNoop(supplement));
31 }
32 return *supplement;
33 }
34
35 PartialScreenOrientation::~PartialScreenOrientation()
36 {
37 }
38
39 // static
40 ScreenOrientation* PartialScreenOrientation::orientation(ScriptState* state, Scr een& screen)
41 {
42 PartialScreenOrientation& self = PartialScreenOrientation::from(screen);
43 if (!self.frame()) {
44 return 0;
45 }
46
47 if (!self.m_orientation) {
48 ScreenOrientationController* controller = ScreenOrientationController::f rom(*self.frame());
49 if (!controller) {
50 // FIXME: ideally, we would like to provide the
51 // ScreenOrientationController in this very particular call so we
52 // don't waste resources on every frame. Unfortunately, to provide a
53 // ScreenOrientationController, we need a WebFrameClient which we
54 // cannot access from modules/.
55 return 0;
56 }
57
58 self.m_orientation = ScreenOrientation::create(controller, state->execut ionContext());
59 }
60
61 return self.m_orientation.get();
62 }
63
64 void PartialScreenOrientation::trace(Visitor* visitor)
65 {
66 m_orientation->trace(visitor);
67 WillBeHeapSupplement<Screen>::trace(visitor);
68 }
69
70 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698