OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h" | 5 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/TaskRunnerHelper.h" | 10 #include "core/dom/TaskRunnerHelper.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 const IntRect& rect, | 55 const IntRect& rect, |
56 uint16_t rotation) { | 56 uint16_t rotation) { |
57 // Bypass orientation detection in layout tests to get consistent results. | 57 // Bypass orientation detection in layout tests to get consistent results. |
58 // FIXME: The screen dimension should be fixed when running the layout tests | 58 // FIXME: The screen dimension should be fixed when running the layout tests |
59 // to avoid such issues. | 59 // to avoid such issues. |
60 if (LayoutTestSupport::IsRunningLayoutTest()) | 60 if (LayoutTestSupport::IsRunningLayoutTest()) |
61 return kWebScreenOrientationPortraitPrimary; | 61 return kWebScreenOrientationPortraitPrimary; |
62 | 62 |
63 bool is_tall_display = rotation % 180 ? rect.Height() < rect.Width() | 63 bool is_tall_display = rotation % 180 ? rect.Height() < rect.Width() |
64 : rect.Height() > rect.Width(); | 64 : rect.Height() > rect.Width(); |
| 65 |
| 66 // https://w3c.github.io/screen-orientation/#dfn-current-orientation-angle |
| 67 // allows the UA to associate *-primary and *-secondary values at will. Blink |
| 68 // arbitrarily chooses rotation 0 to always be portrait-primary or |
| 69 // landscape-primary, and portrait-primary + 90 to be landscape-primary, which |
| 70 // together fully determine the relationship. |
65 switch (rotation) { | 71 switch (rotation) { |
66 case 0: | 72 case 0: |
67 return is_tall_display ? kWebScreenOrientationPortraitPrimary | 73 return is_tall_display ? kWebScreenOrientationPortraitPrimary |
68 : kWebScreenOrientationLandscapePrimary; | 74 : kWebScreenOrientationLandscapePrimary; |
69 case 90: | 75 case 90: |
70 return is_tall_display ? kWebScreenOrientationLandscapePrimary | 76 return is_tall_display ? kWebScreenOrientationLandscapePrimary |
71 : kWebScreenOrientationPortraitSecondary; | 77 : kWebScreenOrientationPortraitSecondary; |
72 case 180: | 78 case 180: |
73 return is_tall_display ? kWebScreenOrientationPortraitSecondary | 79 return is_tall_display ? kWebScreenOrientationPortraitSecondary |
74 : kWebScreenOrientationLandscapeSecondary; | 80 : kWebScreenOrientationLandscapeSecondary; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 243 } |
238 | 244 |
239 DEFINE_TRACE(ScreenOrientationControllerImpl) { | 245 DEFINE_TRACE(ScreenOrientationControllerImpl) { |
240 visitor->Trace(orientation_); | 246 visitor->Trace(orientation_); |
241 ContextLifecycleObserver::Trace(visitor); | 247 ContextLifecycleObserver::Trace(visitor); |
242 Supplement<LocalFrame>::Trace(visitor); | 248 Supplement<LocalFrame>::Trace(visitor); |
243 PlatformEventController::Trace(visitor); | 249 PlatformEventController::Trace(visitor); |
244 } | 250 } |
245 | 251 |
246 } // namespace blink | 252 } // namespace blink |
OLD | NEW |