OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/device_orientation/orientation.h" |
| 6 |
| 7 namespace device_orientation { |
| 8 |
| 9 DeviceData* Orientation::Clone() const { |
| 10 Orientation* orientation = new Orientation(); |
| 11 orientation->device_data_type_ = DeviceData::kDeviceOrientationData; |
| 12 orientation->alpha_ = alpha_; |
| 13 orientation->beta_ = beta_; |
| 14 orientation->gamma_ = gamma_; |
| 15 orientation->absolute_ = absolute_; |
| 16 orientation->can_provide_alpha_ = can_provide_alpha_; |
| 17 orientation->can_provide_beta_ = can_provide_beta_; |
| 18 orientation->can_provide_gamma_ = can_provide_gamma_; |
| 19 orientation->can_provide_absolute_ = can_provide_absolute_; |
| 20 return orientation; |
| 21 } |
| 22 |
| 23 bool Orientation::IsEmpty() const { |
| 24 return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_ |
| 25 && !can_provide_absolute_; |
| 26 } |
| 27 |
| 28 // Returns true if two orientations are considered different enough that |
| 29 // observers should be notified of the new orientation. |
| 30 bool Orientation::SignificantlyDifferentFrom( |
| 31 const DeviceData& other_device_data) { |
| 32 const Orientation& other_orientation = |
| 33 static_cast<const Orientation&>(other_device_data); |
| 34 |
| 35 return IsElementSignificantlyDifferent(can_provide_alpha_, |
| 36 other_orientation.can_provide_alpha(), |
| 37 alpha_, |
| 38 other_orientation.alpha()) || |
| 39 IsElementSignificantlyDifferent(can_provide_beta_, |
| 40 other_orientation.can_provide_beta(), |
| 41 beta_, |
| 42 other_orientation.beta()) || |
| 43 IsElementSignificantlyDifferent(can_provide_gamma_, |
| 44 other_orientation.can_provide_gamma(), |
| 45 gamma_, |
| 46 other_orientation.gamma()) || |
| 47 (can_provide_absolute_ != other_orientation.can_provide_absolute() || |
| 48 absolute_ != other_orientation.absolute()); |
| 49 } |
| 50 |
| 51 }; // namespace device_orientation |
OLD | NEW |