示例#1
0
FloatPoint RotationViewportAnchor::getInnerOrigin(
    const FloatSize& innerSize) const {
  if (!m_anchorNode || !m_anchorNode->isConnected())
    return m_visualViewportInDocument;

  const LayoutRect currentNodeBounds = m_anchorNode->boundingBox();
  if (m_anchorNodeBounds == currentNodeBounds)
    return m_visualViewportInDocument;

  RootFrameViewport* rootFrameViewport =
      m_rootFrameView->getRootFrameViewport();
  const LayoutRect currentNodeBoundsInLayoutViewport =
      rootFrameViewport->rootContentsToLayoutViewportContents(
          *m_rootFrameView.get(), currentNodeBounds);

  // Compute the new anchor point relative to the node position
  FloatSize anchorOffsetFromNode(currentNodeBoundsInLayoutViewport.size());
  anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(),
                             m_anchorInNodeCoords.height());
  FloatPoint anchorPoint =
      FloatPoint(currentNodeBoundsInLayoutViewport.location()) +
      anchorOffsetFromNode;

  // Compute the new origin point relative to the new anchor point
  FloatSize anchorOffsetFromOrigin = innerSize;
  anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(),
                               m_anchorInInnerViewCoords.height());
  return anchorPoint - anchorOffsetFromOrigin;
}
示例#2
0
FloatPoint ViewportAnchor::getInnerOrigin(const FloatSize& innerSize) const
{
    if (!m_anchorNode || !m_anchorNode->inDocument())
        return m_pinchViewportInDocument;

    const LayoutRect currentNodeBounds = m_anchorNode->boundingBox();
    if (m_anchorNodeBounds == currentNodeBounds)
        return m_pinchViewportInDocument;

    // Compute the new anchor point relative to the node position
    FloatSize anchorOffsetFromNode(currentNodeBounds.size());
    anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoords.height());
    FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOffsetFromNode;

    // Compute the new origin point relative to the new anchor point
    FloatSize anchorOffsetFromOrigin = innerSize;
    anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInInnerViewCoords.height());
    return anchorPoint - anchorOffsetFromOrigin;
}