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

Unified Diff: Source/modules/screen_orientation/ScreenOrientation.h

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update compile-time assertion for matching enum 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/screen_orientation/ScreenOrientation.h
diff --git a/Source/modules/screen_orientation/ScreenOrientation.h b/Source/modules/screen_orientation/ScreenOrientation.h
new file mode 100644
index 0000000000000000000000000000000000000000..af9cd350550df3437990a496b6b2df9f64efd326
--- /dev/null
+++ b/Source/modules/screen_orientation/ScreenOrientation.h
@@ -0,0 +1,82 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ScreenOrientation_h
+#define ScreenOrientation_h
+
+#include "core/dom/ActiveDOMObject.h"
+#include "core/events/EventTarget.h"
+#include "core/frame/DOMWindowProperty.h"
+#include "core/page/PageLifecycleObserver.h"
+#include "platform/Supplementable.h"
+#include "platform/Timer.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+class Frame;
+class Page;
+class Screen;
+
+enum ScreenOrientationValue {
+ OrientationInvalid = 0,
+ OrientationPortraitPrimary = 1,
+ OrientationLandscapePrimary = 1 << 1,
+ OrientationPortraitSecondary = 1 << 2,
+ OrientationLandscapeSecondary = 1 << 3,
+ OrientationPortrait = OrientationPortraitPrimary | OrientationPortraitSecondary,
+ OrientationLandscape = OrientationLandscapePrimary | OrientationLandscapeSecondary,
+ OrientationAny = OrientationPortrait | OrientationLandscape
+};
+typedef unsigned char ScreenOrientationValues;
+
+class ScreenOrientation FINAL : public Supplement<Screen>, public DOMWindowProperty, public PageLifecycleObserver, public ActiveDOMObject {
abarth-chromium 2014/02/15 18:44:27 This seems like a lot of base classes. It's odd t
+public:
+ static ScreenOrientation* from(Screen*);
+ virtual ~ScreenOrientation();
+
+ DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(orientationchange);
+
+ static const AtomicString& orientation(Screen*);
+ static bool lockOrientation(Screen*, const Vector<String>& orientations);
+ static bool lockOrientation(Screen*, const AtomicString& orientation);
+ static void unlockOrientation(Screen*);
+
+ void orientationChanged();
+
+private:
+ explicit ScreenOrientation(Screen*);
+ static const char* supplementName();
+
+ // PageLifecycleObserver API.
+ virtual void didCommitLoad(Frame*) OVERRIDE;
+
+ // DOMWindowProperty API
+ virtual void willDestroyGlobalObjectInFrame() OVERRIDE;
+ virtual void willDetachGlobalObjectFromFrame() OVERRIDE;
+
+ // ActiveDOMObject.
+ virtual void stop() OVERRIDE;
+
+ Page* page() const;
+
+ static const AtomicString& orientationToString(ScreenOrientationValue);
+ static ScreenOrientationValues stringToOrientationValues(const AtomicString&);
+
+ void orientationLockTimerFired(Timer<ScreenOrientation>*);
+ void lockOrientationAsync(ScreenOrientationValues orientations);
+ void unlockOrientation();
+
+ Screen* m_screen;
+ Timer<ScreenOrientation> m_orientationLockTimer;
+ ScreenOrientationValues m_lockedOrientations;
+
+ friend class InternalsScreenOrientation;
+};
+
+} // namespace WebCore
+
+#endif // ScreenOrientation_h

Powered by Google App Engine
This is Rietveld 408576698