LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned endPosition) const { startPosition = clampedOffset(startPosition); endPosition = clampedOffset(endPosition); if (startPosition >= endPosition) return LayoutRect(); auto& style = renderer().style(); AffineTransform fragmentTransform; FloatRect selectionRect; unsigned fragmentStartPosition = 0; unsigned fragmentEndPosition = 0; unsigned textFragmentsSize = m_textFragments.size(); for (unsigned i = 0; i < textFragmentsSize; ++i) { const SVGTextFragment& fragment = m_textFragments.at(i); fragmentStartPosition = startPosition; fragmentEndPosition = endPosition; if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition)) continue; FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style); fragment.buildFragmentTransform(fragmentTransform); if (!fragmentTransform.isIdentity()) fragmentRect = fragmentTransform.mapRect(fragmentRect); selectionRect.unite(fragmentRect); } return enclosingIntRect(selectionRect); }
FloatPoint PinchViewport::clampOffsetToBoundaries(const FloatPoint& offset) { FloatPoint clampedOffset(offset); clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPosition())); clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPosition())); return clampedOffset; }
void PinchViewport::setLocation(const FloatPoint& newLocation) { FloatPoint clampedOffset(clampOffsetToBoundaries(newLocation)); if (clampedOffset == m_offset) return; m_offset = clampedOffset; ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator(); ASSERT(coordinator); coordinator->scrollableAreaScrollLayerDidChange(this); mainFrame()->loader().saveScrollState(); }
void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location) { if (!mainFrame()) return; bool valuesChanged = false; if (scale != m_scale) { m_scale = scale; valuesChanged = true; frameHost().chromeClient().pageScaleFactorChanged(); } FloatPoint clampedOffset(clampOffsetToBoundaries(location)); if (clampedOffset != m_offset) { m_offset = clampedOffset; scrollAnimator()->setCurrentPosition(m_offset); // SVG runs with accelerated compositing disabled so no ScrollingCoordinator. if (ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordinator()) coordinator->scrollableAreaScrollLayerDidChange(this); if (!frameHost().settings().inertVisualViewport()) { if (Document* document = mainFrame()->document()) document->enqueueScrollEventForNode(document); } mainFrame()->loader().client()->didChangeScrollOffset(); valuesChanged = true; } if (!valuesChanged) return; InspectorInstrumentation::didUpdateLayout(mainFrame()); mainFrame()->loader().saveScrollState(); clampToBoundaries(); }