OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/paint/GeometryMapper.h" | 5 #include "platform/graphics/paint/GeometryMapper.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 FloatRect GeometryMapper::mapToVisualRectInDestinationSpace( | 12 FloatRect GeometryMapper::mapToVisualRectInDestinationSpace( |
13 const FloatRect& rect, | 13 const FloatRect& rect, |
14 const PropertyTreeState& sourceState, | 14 const PropertyTreeState& sourceState, |
15 const PropertyTreeState& destinationState, | 15 const PropertyTreeState& destinationState, |
16 bool& success) { | 16 bool& success) { |
| 17 if (sourceState == destinationState) { |
| 18 success = true; |
| 19 return rect; |
| 20 } |
17 FloatRect result = localToVisualRectInAncestorSpace( | 21 FloatRect result = localToVisualRectInAncestorSpace( |
18 rect, sourceState, destinationState, success); | 22 rect, sourceState, destinationState, success); |
19 if (success) | 23 if (success) |
20 return result; | 24 return result; |
21 return slowMapToVisualRectInDestinationSpace(rect, sourceState, | 25 return slowMapToVisualRectInDestinationSpace(rect, sourceState, |
22 destinationState, success); | 26 destinationState, success); |
23 } | 27 } |
24 | 28 |
25 FloatRect GeometryMapper::mapRectToDestinationSpace( | 29 FloatRect GeometryMapper::mapRectToDestinationSpace( |
26 const FloatRect& rect, | 30 const FloatRect& rect, |
27 const PropertyTreeState& sourceState, | 31 const PropertyTreeState& sourceState, |
28 const PropertyTreeState& destinationState, | 32 const PropertyTreeState& destinationState, |
29 bool& success) { | 33 bool& success) { |
| 34 if (sourceState == destinationState) { |
| 35 success = true; |
| 36 return rect; |
| 37 } |
30 FloatRect result = | 38 FloatRect result = |
31 localToAncestorRect(rect, sourceState, destinationState, success); | 39 localToAncestorRect(rect, sourceState, destinationState, success); |
32 if (success) | 40 if (success) |
33 return result; | 41 return result; |
34 return slowMapRectToDestinationSpace(rect, sourceState, destinationState, | 42 return slowMapRectToDestinationSpace(rect, sourceState, destinationState, |
35 success); | 43 success); |
36 } | 44 } |
37 | 45 |
38 FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace( | 46 FloatRect GeometryMapper::slowMapToVisualRectInDestinationSpace( |
39 const FloatRect& rect, | 47 const FloatRect& rect, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 312 |
305 // Walk up until we find the ancestor. | 313 // Walk up until we find the ancestor. |
306 while (a != b) { | 314 while (a != b) { |
307 a = a->parent(); | 315 a = a->parent(); |
308 b = b->parent(); | 316 b = b->parent(); |
309 } | 317 } |
310 return a; | 318 return a; |
311 } | 319 } |
312 | 320 |
313 } // namespace blink | 321 } // namespace blink |
OLD | NEW |