| 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 "config.h" | 5 #include "config.h" |
| 6 #include "web/RotationViewportAnchor.h" | 6 #include "web/RotationViewportAnchor.h" |
| 7 | 7 |
| 8 #include "core/dom/ContainerNode.h" | 8 #include "core/dom/ContainerNode.h" |
| 9 #include "core/dom/Node.h" | 9 #include "core/dom/Node.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 absPinchViewportOffset.scale(outerSize.width(), outerSize.height()); | 176 absPinchViewportOffset.scale(outerSize.width(), outerSize.height()); |
| 177 | 177 |
| 178 FloatPoint innerOrigin = getInnerOrigin(innerSize); | 178 FloatPoint innerOrigin = getInnerOrigin(innerSize); |
| 179 FloatPoint outerOrigin = innerOrigin - absPinchViewportOffset; | 179 FloatPoint outerOrigin = innerOrigin - absPinchViewportOffset; |
| 180 | 180 |
| 181 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize); | 181 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize); |
| 182 FloatRect innerRect = FloatRect(innerOrigin, innerSize); | 182 FloatRect innerRect = FloatRect(innerOrigin, innerSize); |
| 183 | 183 |
| 184 moveToEncloseRect(outerRect, innerRect); | 184 moveToEncloseRect(outerRect, innerRect); |
| 185 | 185 |
| 186 outerRect.setLocation(m_rootFrameView->adjustScrollPositionWithinRange(outer
Rect.location())); | 186 outerRect.setLocation(m_rootFrameView->clampScrollPosition(outerRect.locatio
n())); |
| 187 | 187 |
| 188 moveIntoRect(innerRect, outerRect); | 188 moveIntoRect(innerRect, outerRect); |
| 189 | 189 |
| 190 mainFrameOffset = outerRect.location(); | 190 mainFrameOffset = outerRect.location(); |
| 191 pinchViewportOffset = FloatPoint(innerRect.location() - outerRect.location()
); | 191 pinchViewportOffset = FloatPoint(innerRect.location() - outerRect.location()
); |
| 192 } | 192 } |
| 193 | 193 |
| 194 FloatPoint RotationViewportAnchor::getInnerOrigin(const FloatSize& innerSize) co
nst | 194 FloatPoint RotationViewportAnchor::getInnerOrigin(const FloatSize& innerSize) co
nst |
| 195 { | 195 { |
| 196 if (!m_anchorNode || !m_anchorNode->inDocument()) | 196 if (!m_anchorNode || !m_anchorNode->inDocument()) |
| 197 return m_pinchViewportInDocument; | 197 return m_pinchViewportInDocument; |
| 198 | 198 |
| 199 const LayoutRect currentNodeBounds = m_anchorNode->boundingBox(); | 199 const LayoutRect currentNodeBounds = m_anchorNode->boundingBox(); |
| 200 if (m_anchorNodeBounds == currentNodeBounds) | 200 if (m_anchorNodeBounds == currentNodeBounds) |
| 201 return m_pinchViewportInDocument; | 201 return m_pinchViewportInDocument; |
| 202 | 202 |
| 203 // Compute the new anchor point relative to the node position | 203 // Compute the new anchor point relative to the node position |
| 204 FloatSize anchorOffsetFromNode(currentNodeBounds.size()); | 204 FloatSize anchorOffsetFromNode(currentNodeBounds.size()); |
| 205 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord
s.height()); | 205 anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoord
s.height()); |
| 206 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf
fsetFromNode; | 206 FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOf
fsetFromNode; |
| 207 | 207 |
| 208 // Compute the new origin point relative to the new anchor point | 208 // Compute the new origin point relative to the new anchor point |
| 209 FloatSize anchorOffsetFromOrigin = innerSize; | 209 FloatSize anchorOffsetFromOrigin = innerSize; |
| 210 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn
nerViewCoords.height()); | 210 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInIn
nerViewCoords.height()); |
| 211 return anchorPoint - anchorOffsetFromOrigin; | 211 return anchorPoint - anchorOffsetFromOrigin; |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |