| Index: Source/modules/screen_orientation/PartialScreenOrientation.cpp
|
| diff --git a/Source/modules/screen_orientation/PartialScreenOrientation.cpp b/Source/modules/screen_orientation/PartialScreenOrientation.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a07bb95538ed9f103e1677952e95faebb4a47bcc
|
| --- /dev/null
|
| +++ b/Source/modules/screen_orientation/PartialScreenOrientation.cpp
|
| @@ -0,0 +1,70 @@
|
| +// 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.
|
| +
|
| +#include "config.h"
|
| +#include "modules/screen_orientation/PartialScreenOrientation.h"
|
| +
|
| +#include "bindings/core/v8/ScriptState.h"
|
| +#include "core/frame/Screen.h"
|
| +#include "modules/screen_orientation/ScreenOrientation.h"
|
| +#include "modules/screen_orientation/ScreenOrientationController.h"
|
| +
|
| +namespace WebCore {
|
| +
|
| +PartialScreenOrientation::PartialScreenOrientation(Screen& screen)
|
| + : DOMWindowProperty(screen.frame())
|
| +{
|
| +}
|
| +
|
| +const char* PartialScreenOrientation::supplementName()
|
| +{
|
| + return "PartialScreenOrientation";
|
| +}
|
| +
|
| +PartialScreenOrientation& PartialScreenOrientation::from(Screen& screen)
|
| +{
|
| + PartialScreenOrientation* supplement = static_cast<PartialScreenOrientation*>(WillBeHeapSupplement<Screen>::from(screen, supplementName()));
|
| + if (!supplement) {
|
| + supplement = new PartialScreenOrientation(screen);
|
| + provideTo(screen, supplementName(), adoptPtrWillBeNoop(supplement));
|
| + }
|
| + return *supplement;
|
| +}
|
| +
|
| +PartialScreenOrientation::~PartialScreenOrientation()
|
| +{
|
| +}
|
| +
|
| +// static
|
| +ScreenOrientation* PartialScreenOrientation::orientation(ScriptState* state, Screen& screen)
|
| +{
|
| + PartialScreenOrientation& self = PartialScreenOrientation::from(screen);
|
| + if (!self.frame()) {
|
| + return 0;
|
| + }
|
| +
|
| + if (!self.m_orientation) {
|
| + ScreenOrientationController* controller = ScreenOrientationController::from(*self.frame());
|
| + if (!controller) {
|
| + // FIXME: ideally, we would like to provide the
|
| + // ScreenOrientationController in this very particular call so we
|
| + // don't waste resources on every frame. Unfortunately, to provide a
|
| + // ScreenOrientationController, we need a WebFrameClient which we
|
| + // cannot access from modules/.
|
| + return 0;
|
| + }
|
| +
|
| + self.m_orientation = ScreenOrientation::create(controller, state->executionContext());
|
| + }
|
| +
|
| + return self.m_orientation.get();
|
| +}
|
| +
|
| +void PartialScreenOrientation::trace(Visitor* visitor)
|
| +{
|
| + m_orientation->trace(visitor);
|
| + WillBeHeapSupplement<Screen>::trace(visitor);
|
| +}
|
| +
|
| +} // namespace WebCore
|
|
|