Commit 2cd9313e authored by abarth@chromium.org's avatar abarth@chromium.org

Revert of Call RenderViewImpl::SetScreenOrientationForTesting to make sure...

Revert of Call RenderViewImpl::SetScreenOrientationForTesting to make sure that events are not sent when orie… (https://codereview.chromium.org/302553007/)

Reason for revert:
Caused every LayoutTest to ASSERT in every configuration.

Original issue's description:
> Call RenderViewImpl::SetScreenOrientationForTesting from MockScreenOrientationController::UpdateScreenOrientation() to make sure that events are not sent when orientation is locked.
> 
> Existing implementation calls SetScreenOrientationForTesting and sends screen
> orientation events even when the test screen orientation is locked.
> 
> BUG=162827
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=275535

TBR=jochen@chromium.org,ch.dumez@samsung.com,mlamouri@chromium.org,sl.ostapenko@samsung.com
NOTREECHECKS=true
NOTRY=true
BUG=162827

Review URL: https://codereview.chromium.org/323663002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275566 0039d316-1c4b-4281-b951-d872f2087c98
parent 77a595ec
......@@ -13,7 +13,7 @@ namespace content {
RenderViewObserver::RenderViewObserver(RenderView* render_view)
: render_view_(render_view),
routing_id_(MSG_ROUTING_NONE) {
// |render_view| can be NULL on unit testing or if Observe() is used.
// |render_view| can be NULL on unit testing.
if (render_view) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view);
routing_id_ = impl->routing_id();
......@@ -53,19 +53,4 @@ void RenderViewObserver::RenderViewGone() {
render_view_ = NULL;
}
void RenderViewObserver::Observe(RenderView* render_view) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view_);
if (impl) {
impl->RemoveObserver(this);
routing_id_ = 0;
}
render_view_ = render_view;
impl = static_cast<RenderViewImpl*>(render_view_);
if (impl) {
routing_id_ = impl->routing_id();
impl->AddObserver(this);
}
}
} // namespace content
......@@ -109,12 +109,6 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener,
explicit RenderViewObserver(RenderView* render_view);
virtual ~RenderViewObserver();
// Sets |render_view_| to track.
// Removes itself of previous (if any) |render_view_| observer list and adds
// to the new |render_view|. Since it assumes that observer outlives
// render_view, OnDestruct should be overridden.
void Observe(RenderView* render_view);
private:
friend class RenderViewImpl;
......
......@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
......@@ -1084,7 +1083,6 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
// static
void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting()
{
DCHECK(!(g_test_screen_orientation_controller == 0));
g_test_screen_orientation_controller.Get().ResetData();
}
......@@ -1179,10 +1177,9 @@ void RendererWebKitPlatformSupportImpl::unlockOrientation() {
// static
void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
RenderView* render_view,
blink::WebScreenOrientationType orientation) {
g_test_screen_orientation_controller.Get()
.UpdateDeviceOrientation(render_view, orientation);
.UpdateDeviceOrientation(orientation);
}
//------------------------------------------------------------------------------
......
......@@ -41,7 +41,6 @@ class DeviceMotionEventPump;
class DeviceOrientationEventPump;
class QuotaMessageFilter;
class RendererClipboardClient;
class RenderView;
class ScreenOrientationDispatcher;
class ThreadSafeSender;
class WebClipboardImpl;
......@@ -184,7 +183,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
const blink::WebDeviceOrientationData& data);
// Forces the screen orientation for testing purposes.
static void SetMockScreenOrientationForTesting(
RenderView* render_view,
blink::WebScreenOrientationType);
// Resets the mock screen orientation data used for testing.
static void ResetMockScreenOrientationForTesting();
......
......@@ -7,14 +7,12 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
namespace content {
MockScreenOrientationController::MockScreenOrientationController()
: RenderViewObserver(NULL),
current_lock_(blink::WebScreenOrientationLockDefault),
: current_lock_(blink::WebScreenOrientationLockDefault),
device_orientation_(blink::WebScreenOrientationPortraitPrimary),
current_orientation_(blink::WebScreenOrientationPortraitPrimary),
listener_(NULL) {
......@@ -32,9 +30,6 @@ void MockScreenOrientationController::SetListener(
}
void MockScreenOrientationController::ResetData() {
if (render_view_impl())
render_view_impl()->RemoveObserver(this);
current_lock_ = blink::WebScreenOrientationLockDefault;
device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
......@@ -69,15 +64,7 @@ void MockScreenOrientationController::ResetLockSync() {
}
void MockScreenOrientationController::UpdateDeviceOrientation(
RenderView* render_view,
blink::WebScreenOrientationType orientation) {
if (this->render_view()) {
// Make sure that render_view_ did not change during test.
DCHECK_EQ(this->render_view(), render_view);
} else {
Observe(render_view);
}
if (device_orientation_ == orientation)
return;
device_orientation_ = orientation;
......@@ -86,18 +73,11 @@ void MockScreenOrientationController::UpdateDeviceOrientation(
UpdateScreenOrientation(orientation);
}
RenderViewImpl* MockScreenOrientationController::render_view_impl() const {
return static_cast<RenderViewImpl*>(render_view());
}
void MockScreenOrientationController::UpdateScreenOrientation(
blink::WebScreenOrientationType orientation) {
if (current_orientation_ == orientation)
return;
current_orientation_ = orientation;
if (render_view_impl())
render_view_impl()->SetScreenOrientationForTesting(orientation);
if (listener_)
listener_->didChangeScreenOrientation(current_orientation_);
}
......@@ -144,7 +124,4 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() {
}
}
void MockScreenOrientationController::OnDestruct() {
}
} // namespace content
......@@ -8,7 +8,6 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
......@@ -17,12 +16,9 @@ class WebScreenOrientationListener;
}
namespace content {
class RenderView;
class RenderViewImpl;
class MockScreenOrientationController
: public base::RefCountedThreadSafe<MockScreenOrientationController>,
public RenderViewObserver {
: public base::RefCountedThreadSafe<MockScreenOrientationController> {
public:
MockScreenOrientationController();
......@@ -30,9 +26,7 @@ class MockScreenOrientationController
void ResetData();
void UpdateLock(blink::WebScreenOrientationLockType);
void ResetLock();
void UpdateDeviceOrientation(
RenderView* render_view,
blink::WebScreenOrientationType);
void UpdateDeviceOrientation(blink::WebScreenOrientationType);
private:
virtual ~MockScreenOrientationController();
......@@ -42,10 +36,6 @@ class MockScreenOrientationController
void UpdateScreenOrientation(blink::WebScreenOrientationType);
bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType);
blink::WebScreenOrientationType SuitableOrientationForCurrentLock();
RenderViewImpl* render_view_impl() const;
// RenderViewObserver
virtual void OnDestruct() OVERRIDE;
blink::WebScreenOrientationLockType current_lock_;
blink::WebScreenOrientationType device_orientation_;
......
......@@ -104,8 +104,11 @@ void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) {
void SetMockScreenOrientation(
RenderView* render_view,
const blink::WebScreenOrientationType& orientation) {
static_cast<RenderViewImpl*>(render_view)
->SetScreenOrientationForTesting(orientation);
// FIXME(ostap): Remove this when blink side gets updated.
RendererWebKitPlatformSupportImpl::
SetMockScreenOrientationForTesting(render_view, orientation);
SetMockScreenOrientationForTesting(orientation);
}
void ResetMockScreenOrientation()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment