| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "web/RotationViewportAnchor.h" | 5 #include "web/RotationViewportAnchor.h" |
| 6 | 6 |
| 7 #include "core/dom/ContainerNode.h" | 7 #include "core/dom/ContainerNode.h" |
| 8 #include "core/dom/Node.h" | 8 #include "core/dom/Node.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 m_normalizedVisualViewportOffset = FloatSize(); | 115 m_normalizedVisualViewportOffset = FloatSize(); |
| 116 | 116 |
| 117 if (innerViewRect.isEmpty()) | 117 if (innerViewRect.isEmpty()) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 // Preserve origins at the absolute screen origin | 120 // Preserve origins at the absolute screen origin |
| 121 if (innerViewRect.location() == IntPoint::zero()) | 121 if (innerViewRect.location() == IntPoint::zero()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 // Inner rectangle should be within the outer one. | 124 // Inner rectangle should be within the outer one. |
| 125 ASSERT(outerViewRect.contains(innerViewRect)); | 125 DCHECK(outerViewRect.contains(innerViewRect)); |
| 126 | 126 |
| 127 // Outer rectangle is used as a scale, we need positive width and height. | 127 // Outer rectangle is used as a scale, we need positive width and height. |
| 128 ASSERT(!outerViewRect.isEmpty()); | 128 DCHECK(!outerViewRect.isEmpty()); |
| 129 | 129 |
| 130 m_normalizedVisualViewportOffset = FloatSize(innerViewRect.location() - oute
rViewRect.location()); | 130 m_normalizedVisualViewportOffset = FloatSize(innerViewRect.location() - oute
rViewRect.location()); |
| 131 | 131 |
| 132 // Normalize by the size of the outer rect | 132 // Normalize by the size of the outer rect |
| 133 m_normalizedVisualViewportOffset.scale(1.0 / outerViewRect.width(), 1.0 / ou
terViewRect.height()); | 133 m_normalizedVisualViewportOffset.scale(1.0 / outerViewRect.width(), 1.0 / ou
terViewRect.height()); |
| 134 | 134 |
| 135 FloatSize anchorOffset(innerViewRect.size()); | 135 FloatSize anchorOffset(innerViewRect.size()); |
| 136 anchorOffset.scale(m_anchorInInnerViewCoords.width(), m_anchorInInnerViewCoo
rds.height()); | 136 anchorOffset.scale(m_anchorInInnerViewCoords.width(), m_anchorInInnerViewCoo
rds.height()); |
| 137 const FloatPoint anchorPoint = FloatPoint(innerViewRect.location()) + anchor
Offset; | 137 const FloatPoint anchorPoint = FloatPoint(innerViewRect.location()) + anchor
Offset; |
| 138 | 138 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord
s.height()); | 204 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord
s.height()); |
| 205 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf
fsetFromNode; | 205 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf
fsetFromNode; |
| 206 | 206 |
| 207 // Compute the new origin point relative to the new anchor point | 207 // Compute the new origin point relative to the new anchor point |
| 208 FloatSize anchorOffsetFromOrigin = innerSize; | 208 FloatSize anchorOffsetFromOrigin = innerSize; |
| 209 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn
nerViewCoords.height()); | 209 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn
nerViewCoords.height()); |
| 210 return anchorPoint - anchorOffsetFromOrigin; | 210 return anchorPoint - anchorOffsetFromOrigin; |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace blink | 213 } // namespace blink |
| OLD | NEW |