Chromium Code Reviews| Index: content/browser/device_orientation/orientation.cc |
| diff --git a/content/browser/device_orientation/orientation.cc b/content/browser/device_orientation/orientation.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eabbfbaa1bf65773a0c56b1d0b616b55795219aa |
| --- /dev/null |
| +++ b/content/browser/device_orientation/orientation.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2012 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 "content/browser/device_orientation/orientation.h" |
| + |
| +namespace device_orientation { |
| + |
| +DeviceData* Orientation::Clone() const { |
| + Orientation* orientation = new Orientation(); |
|
bulach
2012/07/12 10:43:27
nit: odd indentation, remove one space from 10-19
aousterh
2012/07/12 17:13:57
Done.
|
| + orientation->alpha_ = alpha_; |
| + orientation->beta_ = beta_; |
| + orientation->gamma_ = gamma_; |
| + orientation->absolute_ = absolute_; |
| + orientation->can_provide_alpha_ = can_provide_alpha_; |
| + orientation->can_provide_beta_ = can_provide_beta_; |
| + orientation->can_provide_gamma_ = can_provide_gamma_; |
| + orientation->can_provide_absolute_ = can_provide_absolute_; |
| + return orientation; |
| +} |
| + |
| +bool Orientation::IsEmpty() const { |
| + return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_ |
| + && !can_provide_absolute_; |
|
bulach
2012/07/12 10:43:27
nit: I think the && needs to be in the previous li
aousterh
2012/07/12 17:13:57
Done.
|
| +} |
| + |
| +// Returns true if two orientations are considered different enough that |
| +// observers should be notified of the new orientation. |
| +bool Orientation::SignificantlyDifferentFrom( |
| + const DeviceData& other_device_data) { |
| + const Orientation& other_orientation = |
| + static_cast<const Orientation&>(other_device_data); |
| + |
| + return IsElementSignificantlyDifferent(can_provide_alpha_, |
| + other_orientation.can_provide_alpha(), |
| + alpha_, |
| + other_orientation.alpha()) || |
| + IsElementSignificantlyDifferent(can_provide_beta_, |
| + other_orientation.can_provide_beta(), |
| + beta_, |
| + other_orientation.beta()) || |
| + IsElementSignificantlyDifferent(can_provide_gamma_, |
| + other_orientation.can_provide_gamma(), |
| + gamma_, |
| + other_orientation.gamma()) || |
| + (can_provide_absolute_ != other_orientation.can_provide_absolute() || |
|
bulach
2012/07/12 10:43:27
nit: no need for this parens.
aousterh
2012/07/12 17:13:57
Done.
|
| + absolute_ != other_orientation.absolute()); |
| +} |
| + |
| +}; // namespace device_orientation |
|
bulach
2012/07/12 10:43:27
nit: remove the ;
aousterh
2012/07/12 17:13:57
Done.
|