OLD | NEW |
(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 #ifndef ScreenOrientation_h |
| 6 #define ScreenOrientation_h |
| 7 |
| 8 #include "core/events/EventTarget.h" |
| 9 #include "core/frame/DOMWindowProperty.h" |
| 10 #include "platform/Supplementable.h" |
| 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/AtomicString.h" |
| 13 #include "wtf/text/WTFString.h" |
| 14 |
| 15 namespace WebCore { |
| 16 |
| 17 class Frame; |
| 18 class Page; |
| 19 class Screen; |
| 20 |
| 21 enum ScreenOrientationValue { |
| 22 OrientationInvalid = 0, |
| 23 OrientationPortraitPrimary = 1, |
| 24 OrientationLandscapePrimary = 1 << 1, |
| 25 OrientationPortraitSecondary = 1 << 2, |
| 26 OrientationLandscapeSecondary = 1 << 3, |
| 27 OrientationPortrait = OrientationPortraitPrimary | OrientationPortraitSecond
ary, |
| 28 OrientationLandscape = OrientationLandscapePrimary | OrientationLandscapeSec
ondary, |
| 29 OrientationAny = OrientationPortrait | OrientationLandscape |
| 30 }; |
| 31 typedef unsigned char ScreenOrientationValues; |
| 32 |
| 33 class ScreenOrientation FINAL : public Supplement<Screen>, public DOMWindowPrope
rty { |
| 34 public: |
| 35 static ScreenOrientation* from(Screen*); |
| 36 virtual ~ScreenOrientation(); |
| 37 |
| 38 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(orientationchange); |
| 39 |
| 40 static const AtomicString& orientation(Screen*); |
| 41 static bool lockOrientation(Screen*, const Vector<String>& orientations); |
| 42 static bool lockOrientation(Screen*, const AtomicString& orientation); |
| 43 static void unlockOrientation(Screen*); |
| 44 |
| 45 void orientationChanged(); |
| 46 |
| 47 private: |
| 48 explicit ScreenOrientation(Screen*); |
| 49 static const char* supplementName(); |
| 50 |
| 51 Page* page() const; |
| 52 |
| 53 struct ScreenOrientationInfo { |
| 54 const AtomicString& name; |
| 55 ScreenOrientationValues orientation; |
| 56 }; |
| 57 static ScreenOrientationInfo* orientationMap(unsigned& length); |
| 58 static const AtomicString& orientationToString(ScreenOrientationValue); |
| 59 static ScreenOrientationValues stringToOrientationValues(const AtomicString&
); |
| 60 bool lockOrientation(ScreenOrientationValues orientations); |
| 61 |
| 62 Screen* m_screen; |
| 63 ScreenOrientationValues m_lockedOrientations; |
| 64 |
| 65 friend class InternalsScreenOrientation; |
| 66 }; |
| 67 |
| 68 } // namespace WebCore |
| 69 |
| 70 #endif // ScreenOrientation_h |
OLD | NEW |