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.
5 #ifndef ScreenOrientation_h
6 #define ScreenOrientation_h
8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/events/EventTarget.h"
10 #include "core/frame/DOMWindowProperty.h"
11 #include "platform/heap/Handle.h"
12 #include "public/platform/WebScreenOrientationType.h"
13 #include "wtf/text/AtomicString.h"
14 #include "wtf/text/WTFString.h"
18 class ExecutionContext;
22 class ScreenOrientationController;
24 class ScreenOrientation final
25 : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<ScreenOrientation>
26 , public EventTargetWithInlineData
27 , public DOMWindowProperty {
28 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<ScreenOrientation>);
29 DEFINE_WRAPPERTYPEINFO();
30 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientation);
32 static ScreenOrientation* create(LocalFrame*);
34 virtual ~ScreenOrientation();
36 // EventTarget implementation.
37 virtual const WTF::AtomicString& interfaceName() const override;
38 virtual ExecutionContext* executionContext() const override;
41 unsigned short angle() const;
43 void setType(WebScreenOrientationType);
44 void setAngle(unsigned short);
46 ScriptPromise lock(ScriptState*, const AtomicString& orientation);
49 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
51 // Helper being used by this class and LockOrientationCallback.
52 static const AtomicString& orientationTypeToString(WebScreenOrientationType);
54 virtual void trace(Visitor*) override;
57 explicit ScreenOrientation(LocalFrame*);
59 ScreenOrientationController* controller();
61 WebScreenOrientationType m_type;
62 unsigned short m_angle;
67 #endif // ScreenOrientation_h