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 { ...@@ -13,7 +13,7 @@ namespace content {
RenderViewObserver::RenderViewObserver(RenderView* render_view) RenderViewObserver::RenderViewObserver(RenderView* render_view)
: render_view_(render_view), : render_view_(render_view),
routing_id_(MSG_ROUTING_NONE) { 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) { if (render_view) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view); RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view);
routing_id_ = impl->routing_id(); routing_id_ = impl->routing_id();
...@@ -53,19 +53,4 @@ void RenderViewObserver::RenderViewGone() { ...@@ -53,19 +53,4 @@ void RenderViewObserver::RenderViewGone() {
render_view_ = NULL; 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 } // namespace content
...@@ -109,12 +109,6 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener, ...@@ -109,12 +109,6 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Listener,
explicit RenderViewObserver(RenderView* render_view); explicit RenderViewObserver(RenderView* render_view);
virtual ~RenderViewObserver(); 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: private:
friend class RenderViewImpl; friend class RenderViewImpl;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop_proxy.h" #include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
...@@ -1084,7 +1083,6 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting( ...@@ -1084,7 +1083,6 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
// static // static
void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting() void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting()
{ {
DCHECK(!(g_test_screen_orientation_controller == 0));
g_test_screen_orientation_controller.Get().ResetData(); g_test_screen_orientation_controller.Get().ResetData();
} }
...@@ -1179,10 +1177,9 @@ void RendererWebKitPlatformSupportImpl::unlockOrientation() { ...@@ -1179,10 +1177,9 @@ void RendererWebKitPlatformSupportImpl::unlockOrientation() {
// static // static
void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
RenderView* render_view,
blink::WebScreenOrientationType orientation) { blink::WebScreenOrientationType orientation) {
g_test_screen_orientation_controller.Get() g_test_screen_orientation_controller.Get()
.UpdateDeviceOrientation(render_view, orientation); .UpdateDeviceOrientation(orientation);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -41,7 +41,6 @@ class DeviceMotionEventPump; ...@@ -41,7 +41,6 @@ class DeviceMotionEventPump;
class DeviceOrientationEventPump; class DeviceOrientationEventPump;
class QuotaMessageFilter; class QuotaMessageFilter;
class RendererClipboardClient; class RendererClipboardClient;
class RenderView;
class ScreenOrientationDispatcher; class ScreenOrientationDispatcher;
class ThreadSafeSender; class ThreadSafeSender;
class WebClipboardImpl; class WebClipboardImpl;
...@@ -184,7 +183,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl ...@@ -184,7 +183,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
const blink::WebDeviceOrientationData& data); const blink::WebDeviceOrientationData& data);
// Forces the screen orientation for testing purposes. // Forces the screen orientation for testing purposes.
static void SetMockScreenOrientationForTesting( static void SetMockScreenOrientationForTesting(
RenderView* render_view,
blink::WebScreenOrientationType); blink::WebScreenOrientationType);
// Resets the mock screen orientation data used for testing. // Resets the mock screen orientation data used for testing.
static void ResetMockScreenOrientationForTesting(); static void ResetMockScreenOrientationForTesting();
......
...@@ -7,14 +7,12 @@ ...@@ -7,14 +7,12 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationListener.h" #include "third_party/WebKit/public/platform/WebScreenOrientationListener.h"
namespace content { namespace content {
MockScreenOrientationController::MockScreenOrientationController() MockScreenOrientationController::MockScreenOrientationController()
: RenderViewObserver(NULL), : current_lock_(blink::WebScreenOrientationLockDefault),
current_lock_(blink::WebScreenOrientationLockDefault),
device_orientation_(blink::WebScreenOrientationPortraitPrimary), device_orientation_(blink::WebScreenOrientationPortraitPrimary),
current_orientation_(blink::WebScreenOrientationPortraitPrimary), current_orientation_(blink::WebScreenOrientationPortraitPrimary),
listener_(NULL) { listener_(NULL) {
...@@ -32,9 +30,6 @@ void MockScreenOrientationController::SetListener( ...@@ -32,9 +30,6 @@ void MockScreenOrientationController::SetListener(
} }
void MockScreenOrientationController::ResetData() { void MockScreenOrientationController::ResetData() {
if (render_view_impl())
render_view_impl()->RemoveObserver(this);
current_lock_ = blink::WebScreenOrientationLockDefault; current_lock_ = blink::WebScreenOrientationLockDefault;
device_orientation_ = blink::WebScreenOrientationPortraitPrimary; device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
current_orientation_ = blink::WebScreenOrientationPortraitPrimary; current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
...@@ -69,15 +64,7 @@ void MockScreenOrientationController::ResetLockSync() { ...@@ -69,15 +64,7 @@ void MockScreenOrientationController::ResetLockSync() {
} }
void MockScreenOrientationController::UpdateDeviceOrientation( void MockScreenOrientationController::UpdateDeviceOrientation(
RenderView* render_view,
blink::WebScreenOrientationType orientation) { 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) if (device_orientation_ == orientation)
return; return;
device_orientation_ = orientation; device_orientation_ = orientation;
...@@ -86,18 +73,11 @@ void MockScreenOrientationController::UpdateDeviceOrientation( ...@@ -86,18 +73,11 @@ void MockScreenOrientationController::UpdateDeviceOrientation(
UpdateScreenOrientation(orientation); UpdateScreenOrientation(orientation);
} }
RenderViewImpl* MockScreenOrientationController::render_view_impl() const {
return static_cast<RenderViewImpl*>(render_view());
}
void MockScreenOrientationController::UpdateScreenOrientation( void MockScreenOrientationController::UpdateScreenOrientation(
blink::WebScreenOrientationType orientation) { blink::WebScreenOrientationType orientation) {
if (current_orientation_ == orientation) if (current_orientation_ == orientation)
return; return;
current_orientation_ = orientation; current_orientation_ = orientation;
if (render_view_impl())
render_view_impl()->SetScreenOrientationForTesting(orientation);
if (listener_) if (listener_)
listener_->didChangeScreenOrientation(current_orientation_); listener_->didChangeScreenOrientation(current_orientation_);
} }
...@@ -144,7 +124,4 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() { ...@@ -144,7 +124,4 @@ MockScreenOrientationController::SuitableOrientationForCurrentLock() {
} }
} }
void MockScreenOrientationController::OnDestruct() {
}
} // namespace content } // namespace content
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.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/WebScreenOrientationLockType.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h" #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
...@@ -17,12 +16,9 @@ class WebScreenOrientationListener; ...@@ -17,12 +16,9 @@ class WebScreenOrientationListener;
} }
namespace content { namespace content {
class RenderView;
class RenderViewImpl;
class MockScreenOrientationController class MockScreenOrientationController
: public base::RefCountedThreadSafe<MockScreenOrientationController>, : public base::RefCountedThreadSafe<MockScreenOrientationController> {
public RenderViewObserver {
public: public:
MockScreenOrientationController(); MockScreenOrientationController();
...@@ -30,9 +26,7 @@ class MockScreenOrientationController ...@@ -30,9 +26,7 @@ class MockScreenOrientationController
void ResetData(); void ResetData();
void UpdateLock(blink::WebScreenOrientationLockType); void UpdateLock(blink::WebScreenOrientationLockType);
void ResetLock(); void ResetLock();
void UpdateDeviceOrientation( void UpdateDeviceOrientation(blink::WebScreenOrientationType);
RenderView* render_view,
blink::WebScreenOrientationType);
private: private:
virtual ~MockScreenOrientationController(); virtual ~MockScreenOrientationController();
...@@ -42,10 +36,6 @@ class MockScreenOrientationController ...@@ -42,10 +36,6 @@ class MockScreenOrientationController
void UpdateScreenOrientation(blink::WebScreenOrientationType); void UpdateScreenOrientation(blink::WebScreenOrientationType);
bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType); bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType);
blink::WebScreenOrientationType SuitableOrientationForCurrentLock(); blink::WebScreenOrientationType SuitableOrientationForCurrentLock();
RenderViewImpl* render_view_impl() const;
// RenderViewObserver
virtual void OnDestruct() OVERRIDE;
blink::WebScreenOrientationLockType current_lock_; blink::WebScreenOrientationLockType current_lock_;
blink::WebScreenOrientationType device_orientation_; blink::WebScreenOrientationType device_orientation_;
......
...@@ -104,8 +104,11 @@ void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) { ...@@ -104,8 +104,11 @@ void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) {
void SetMockScreenOrientation( void SetMockScreenOrientation(
RenderView* render_view, RenderView* render_view,
const blink::WebScreenOrientationType& orientation) { const blink::WebScreenOrientationType& orientation) {
static_cast<RenderViewImpl*>(render_view)
->SetScreenOrientationForTesting(orientation);
// FIXME(ostap): Remove this when blink side gets updated.
RendererWebKitPlatformSupportImpl:: RendererWebKitPlatformSupportImpl::
SetMockScreenOrientationForTesting(render_view, orientation); SetMockScreenOrientationForTesting(orientation);
} }
void ResetMockScreenOrientation() 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