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

Unified Diff: chrome/renderer/device_orientation_dispatcher.cc

Issue 3104038: DeviceOrientationDispatcher: no orientation updates equal to lastOrientation(). (Closed)
Patch Set: Rebase Created 10 years, 4 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
« no previous file with comments | « chrome/renderer/device_orientation_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/device_orientation_dispatcher.cc
diff --git a/chrome/renderer/device_orientation_dispatcher.cc b/chrome/renderer/device_orientation_dispatcher.cc
index 816cda8bbacf5a2972bffab26085e7a200c7b370..edf9d03b984a3f79272ffecf48eecd546a0dace6 100644
--- a/chrome/renderer/device_orientation_dispatcher.cc
+++ b/chrome/renderer/device_orientation_dispatcher.cc
@@ -50,24 +50,44 @@ void DeviceOrientationDispatcher::stopUpdating() {
WebKit::WebDeviceOrientation DeviceOrientationDispatcher::lastOrientation()
const {
- if (!last_update_.get())
+ if (!last_orientation_.get())
return WebKit::WebDeviceOrientation::nullOrientation();
- return WebKit::WebDeviceOrientation(last_update_->can_provide_alpha,
- last_update_->alpha,
- last_update_->can_provide_beta,
- last_update_->beta,
- last_update_->can_provide_gamma,
- last_update_->gamma);
+ return *last_orientation_;
}
+namespace {
+bool OrientationsEqual(const ViewMsg_DeviceOrientationUpdated_Params& a,
+ WebKit::WebDeviceOrientation* b) {
+ if (a.can_provide_alpha != b->canProvideAlpha())
+ return false;
+ if (a.can_provide_alpha && a.alpha != b->alpha())
+ return false;
+ if (a.can_provide_beta != b->canProvideBeta())
+ return false;
+ if (a.can_provide_beta && a.beta != b->beta())
+ return false;
+ if (a.can_provide_gamma != b->canProvideGamma())
+ return false;
+ if (a.can_provide_gamma && a.gamma != b->gamma())
+ return false;
+
+ return true;
+}
+} // namespace
+
void DeviceOrientationDispatcher::OnDeviceOrientationUpdated(
const ViewMsg_DeviceOrientationUpdated_Params& p) {
- last_update_.reset(new ViewMsg_DeviceOrientationUpdated_Params(p));
- WebKit::WebDeviceOrientation orientation(p.can_provide_alpha, p.alpha,
- p.can_provide_beta, p.beta,
- p.can_provide_gamma, p.gamma);
+ if (last_orientation_.get() && OrientationsEqual(p, last_orientation_.get()))
+ return;
+
+ last_orientation_.reset(new WebKit::WebDeviceOrientation(p.can_provide_alpha,
+ p.alpha,
+ p.can_provide_beta,
+ p.beta,
+ p.can_provide_gamma,
+ p.gamma));
- controller_->didChangeDeviceOrientation(orientation);
+ controller_->didChangeDeviceOrientation(*last_orientation_);
}
« no previous file with comments | « chrome/renderer/device_orientation_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698