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

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

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/screen_orientation/ScreenOrientation.h" 6 #include "modules/screen_orientation/ScreenOrientation.h"
7 7
8 #include "core/frame/DOMWindow.h" 8 #include "core/frame/DOMWindow.h"
9 #include "core/frame/Frame.h" 9 #include "core/frame/Frame.h"
10 #include "core/frame/Screen.h" 10 #include "core/frame/Screen.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 for (unsigned i = 0; i < length; ++i) { 42 for (unsigned i = 0; i < length; ++i) {
43 if (orientationMap[i].orientation == orientation) 43 if (orientationMap[i].orientation == orientation)
44 return orientationMap[i].name; 44 return orientationMap[i].name;
45 } 45 }
46 // We do no handle OrientationInvalid and OrientationAny but this is fine be cause screen.orientation 46 // We do no handle OrientationInvalid and OrientationAny but this is fine be cause screen.orientation
47 // should never return these and WebScreenOrientation does not define those values. 47 // should never return these and WebScreenOrientation does not define those values.
48 ASSERT_NOT_REACHED(); 48 ASSERT_NOT_REACHED();
49 return nullAtom; 49 return nullAtom;
50 } 50 }
51 51
52 ScreenOrientation::ScreenOrientation(Screen* screen) 52 ScreenOrientation::ScreenOrientation(Screen& screen)
53 : DOMWindowProperty(screen->frame()) 53 : DOMWindowProperty(screen.frame())
54 { 54 {
55 } 55 }
56 56
57 const char* ScreenOrientation::supplementName() 57 const char* ScreenOrientation::supplementName()
58 { 58 {
59 return "ScreenOrientation"; 59 return "ScreenOrientation";
60 } 60 }
61 61
62 Document* ScreenOrientation::document() const 62 Document& ScreenOrientation::document() const
63 { 63 {
64 ASSERT(m_associatedDOMWindow); 64 ASSERT(m_associatedDOMWindow);
65 return m_associatedDOMWindow->document(); 65 ASSERT(m_associatedDOMWindow->document());
dcheng 2014/02/28 20:54:42 Please be careful when making these changes. The o
dcheng 2014/02/28 21:13:41 Actually, I'm wrong so ignore me for now. Sorry fo
66 return *m_associatedDOMWindow->document();
66 } 67 }
67 68
68 ScreenOrientation* ScreenOrientation::from(Screen* screen) 69 ScreenOrientation& ScreenOrientation::from(Screen& screen)
69 { 70 {
70 ScreenOrientation* supplement = static_cast<ScreenOrientation*>(Supplement<S creen>::from(screen, supplementName())); 71 ScreenOrientation* supplement = static_cast<ScreenOrientation*>(Supplement<S creen>::from(screen, supplementName()));
71 if (!supplement) { 72 if (!supplement) {
72 ASSERT(screen);
73 supplement = new ScreenOrientation(screen); 73 supplement = new ScreenOrientation(screen);
74 provideTo(screen, supplementName(), adoptPtr(supplement)); 74 provideTo(screen, supplementName(), adoptPtr(supplement));
75 } 75 }
76 return supplement; 76 return *supplement;
77 } 77 }
78 78
79 ScreenOrientation::~ScreenOrientation() 79 ScreenOrientation::~ScreenOrientation()
80 { 80 {
81 } 81 }
82 82
83 const AtomicString& ScreenOrientation::orientation(Screen* screen) 83 const AtomicString& ScreenOrientation::orientation(Screen& screen)
84 { 84 {
85 ScreenOrientation* screenOrientation = ScreenOrientation::from(screen); 85 ScreenOrientation& screenOrientation = ScreenOrientation::from(screen);
86 ScreenOrientationController* controller = ScreenOrientationController::from( screenOrientation->document()); 86 ScreenOrientationController& controller = ScreenOrientationController::from( screenOrientation.document());
87 ASSERT(controller); 87 return orientationToString(controller.orientation());
88 return orientationToString(controller->orientation());
89 } 88 }
90 89
91 bool ScreenOrientation::lockOrientation(Screen* screen, const Vector<String>& or ientations) 90 bool ScreenOrientation::lockOrientation(Screen& screen, const Vector<String>& or ientations)
92 { 91 {
93 // FIXME: Implement. 92 // FIXME: Implement.
94 return false; 93 return false;
95 } 94 }
96 95
97 bool ScreenOrientation::lockOrientation(Screen* screen, const AtomicString& orie ntation) 96 bool ScreenOrientation::lockOrientation(Screen& screen, const AtomicString& orie ntation)
98 { 97 {
99 // FIXME: Implement. 98 // FIXME: Implement.
100 return false; 99 return false;
101 } 100 }
102 101
103 void ScreenOrientation::unlockOrientation(Screen* screen) 102 void ScreenOrientation::unlockOrientation(Screen& screen)
104 { 103 {
105 // FIXME: Implement. 104 // FIXME: Implement.
106 } 105 }
107 106
108 } // namespace WebCore 107 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/screen_orientation/ScreenOrientation.h ('k') | Source/modules/screen_orientation/ScreenOrientationController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698