void PaintPropertyTreeBuilder::walk(FrameView& frameView, const PaintPropertyTreeBuilderContext& context) { PaintPropertyTreeBuilderContext localContext(context); TransformationMatrix frameTranslate; frameTranslate.translate(frameView.x(), frameView.y()); // The frame owner applies paint offset already. // This assumption may change in the future. ASSERT(context.paintOffset == LayoutPoint()); RefPtr<TransformPaintPropertyNode> newTransformNodeForPreTranslation = TransformPaintPropertyNode::create(frameTranslate, FloatPoint3D(), context.currentTransform); localContext.transformForFixedPositioned = newTransformNodeForPreTranslation.get(); localContext.paintOffsetForFixedPositioned = LayoutPoint(); // This is going away in favor of Settings::rootLayerScrolls. DoubleSize scrollOffset = frameView.scrollOffsetDouble(); TransformationMatrix frameScroll; frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create(frameScroll, FloatPoint3D(), newTransformNodeForPreTranslation); localContext.currentTransform = localContext.transformForOutOfFlowPositioned = newTransformNodeForScrollTranslation.get(); localContext.paintOffset = localContext.paintOffsetForOutOfFlowPositioned = LayoutPoint(); frameView.setPreTranslation(newTransformNodeForPreTranslation.release()); frameView.setScrollTranslation(newTransformNodeForScrollTranslation.release()); if (LayoutView* layoutView = frameView.layoutView()) walk(*layoutView, localContext); }
void RootFrameViewport::distributeScrollBetweenViewports(const DoublePoint& offset, ScrollType scrollType, ScrollBehavior behavior) { // Make sure we use the scroll positions as reported by each viewport's ScrollAnimatorBase, since its // ScrollableArea's position may have the fractional part truncated off. DoublePoint oldPosition = scrollOffsetFromScrollAnimators(); DoubleSize delta = offset - oldPosition; if (delta.isZero()) return; DoublePoint targetPosition = visualViewport().clampScrollPosition( visualViewport().scrollAnimator().currentPosition() + delta); visualViewport().setScrollPosition(targetPosition, scrollType, behavior); // Scroll the secondary viewport if all of the scroll was not applied to the // primary viewport. DoublePoint updatedPosition = layoutViewport().scrollAnimator().currentPosition() + FloatPoint(targetPosition); DoubleSize applied = updatedPosition - oldPosition; delta -= applied; if (delta.isZero()) return; targetPosition = layoutViewport().clampScrollPosition(layoutViewport().scrollAnimator().currentPosition() + delta); layoutViewport().setScrollPosition(targetPosition, scrollType, behavior); }
void RootFrameViewport::setScrollOffset(const DoublePoint& offset, ScrollType scrollType) { // Make sure we use the scroll positions as reported by each viewport's ScrollAnimator, since its // ScrollableArea's position may have the fractional part truncated off. DoublePoint oldPosition = scrollOffsetFromScrollAnimators(); DoubleSize delta = offset - oldPosition; if (delta.isZero()) return; ScrollableArea& primary = !m_invertScrollOrder ? layoutViewport() : visualViewport(); ScrollableArea& secondary = !m_invertScrollOrder ? visualViewport() : layoutViewport(); DoublePoint targetPosition = primary.clampScrollPosition(primary.scrollAnimator()->currentPosition() + delta); primary.setScrollPosition(targetPosition, scrollType); DoubleSize applied = scrollOffsetFromScrollAnimators() - oldPosition; delta -= applied; if (delta.isZero()) return; targetPosition = secondary.clampScrollPosition(secondary.scrollAnimator()->currentPosition() + delta); secondary.setScrollPosition(targetPosition, scrollType); }
void GeometryTabWidget::updateTrussAreaSpinBoxes ( const DoubleSize& areaSize ) { updateTrussAreaSpinBoxLimits(); xSizeEdit->setValue( areaSize.width() ); ySizeEdit->setValue( areaSize.height() ); }
void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropertyTreeBuilderContext& context) { // TODO(pdr): Creating paint properties for FrameView here will not be // needed once settings()->rootLayerScrolls() is enabled. // TODO(pdr): Make this conditional on the rootLayerScrolls setting. TransformationMatrix frameTranslate; frameTranslate.translate(frameView.x() + context.paintOffset.x(), frameView.y() + context.paintOffset.y()); RefPtr<TransformPaintPropertyNode> newTransformNodeForPreTranslation = TransformPaintPropertyNode::create(frameTranslate, FloatPoint3D(), context.currentTransform); context.transformForFixedPosition = newTransformNodeForPreTranslation.get(); context.paintOffsetForFixedPosition = LayoutPoint(); FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSize())); RefPtr<ClipPaintPropertyNode> newClipNodeForContentClip = ClipPaintPropertyNode::create(newTransformNodeForPreTranslation.get(), contentClip, context.currentClip); context.currentClip = context.clipForAbsolutePosition = context.clipForFixedPosition = newClipNodeForContentClip.get(); DoubleSize scrollOffset = frameView.scrollOffsetDouble(); TransformationMatrix frameScroll; frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create(frameScroll, FloatPoint3D(), newTransformNodeForPreTranslation); context.currentTransform = context.transformForAbsolutePosition = newTransformNodeForScrollTranslation.get(); context.paintOffset = LayoutPoint(); context.paintOffsetForAbsolutePosition = LayoutPoint(); context.containerForAbsolutePosition = nullptr; frameView.setPreTranslation(newTransformNodeForPreTranslation.release()); frameView.setScrollTranslation(newTransformNodeForScrollTranslation.release()); frameView.setContentClip(newClipNodeForContentClip.release()); }
bool LinkHighlightImpl::computeHighlightLayerPathAndPosition(const LayoutBoxModelObject& paintInvalidationContainer) { if (!m_node || !m_node->layoutObject() || !m_currentGraphicsLayer) return false; // FIXME: This is defensive code to avoid crashes such as those described in // crbug.com/440887. This should be cleaned up once we fix the root cause of // of the paint invalidation container not being composited. if (!paintInvalidationContainer.layer()->compositedLayerMapping() && !paintInvalidationContainer.layer()->groupedMapping()) return false; // Get quads for node in absolute coordinates. Vector<FloatQuad> quads; computeQuads(*m_node, quads); DCHECK(quads.size()); Path newPath; for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) { FloatQuad absoluteQuad = quads[quadIndex]; // Scrolling content layers have the same offset from layout object as the non-scrolling layers. Thus we need // to adjust for their scroll offset. if (m_isScrollingGraphicsLayer) { DoubleSize adjustedScrollOffset = paintInvalidationContainer.layer()->getScrollableArea()->adjustedScrollOffset(); absoluteQuad.move(adjustedScrollOffset.width(), adjustedScrollOffset.height()); } // Transform node quads in target absolute coords to local coordinates in the compositor layer. FloatQuad transformedQuad; convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->layoutObject(), paintInvalidationContainer, transformedQuad); // FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that // we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage // links: these should ideally be merged into a single rect before creating the path, but that's // another CL. if (quads.size() == 1 && transformedQuad.isRectilinear() && !m_owningWebViewImpl->settingsImpl()->mockGestureTapHighlightsEnabled()) { FloatSize rectRoundingRadii(3, 3); newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRadii); } else { addQuadToPath(transformedQuad, newPath); } } FloatRect boundingRect = newPath.boundingRect(); newPath.translate(-toFloatSize(boundingRect.location())); bool pathHasChanged = !(newPath == m_path); if (pathHasChanged) { m_path = newPath; m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size()); } m_contentLayer->layer()->setPosition(boundingRect.location()); return pathHasChanged; }
void GeometryTabWidget::updateTrussAreaSize ( double newValue ) { if ( blockUpdateAreaSignals || ! focusWindow ) return; DoubleSize areaSize = focusWindow->getTrussAreaSize(); if ( sender() == xSizeEdit && areaSize.width() != newValue ) focusWindow->setTrussAreaSize(DoubleSize(newValue, areaSize.height())); else if ( sender() == ySizeEdit && areaSize.height() != newValue ) focusWindow->setTrussAreaSize(DoubleSize(areaSize.width(), newValue)); }
/* Updates area tab spin boxes minimum values after changing node position. It's need to ensure that area size is larger than or equal to the truss size. */ void GeometryTabWidget::updateTrussAreaSpinBoxLimits() { if ( ! focusWindow ) return; DoubleSize trussSize = focusWindow->getTrussSize(); blockUpdateAreaSignals = true; if ( xSizeEdit->minimum() != trussSize.width() ) xSizeEdit->setMinimum( trussSize.width() ); if ( ySizeEdit->minimum() != trussSize.height() ) ySizeEdit->setMinimum( trussSize.height() ); blockUpdateAreaSignals = false; }
static PassRefPtr<TransformPaintPropertyNode> createScrollTranslationIfNeeded(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) { if (!object.isBoxModelObject() || !object.hasOverflowClip()) return nullptr; PaintLayer* layer = toLayoutBoxModelObject(object).layer(); ASSERT(layer); DoubleSize scrollOffset = layer->scrollableArea()->scrollOffset(); if (scrollOffset.isZero() && !layer->scrollsOverflow()) return nullptr; RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create( TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()), FloatPoint3D(), context.currentTransform); context.currentTransform = newTransformNodeForScrollTranslation.get(); return newTransformNodeForScrollTranslation.release(); }
void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) { if (!object.isBoxModelObject() || !object.hasOverflowClip()) return; PaintLayer* layer = toLayoutBoxModelObject(object).layer(); ASSERT(layer); DoubleSize scrollOffset = layer->getScrollableArea()->scrollOffset(); if (scrollOffset.isZero() && !layer->scrollsOverflow()) return; RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropertyNode::create( TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()), FloatPoint3D(), context.currentTransform); context.currentTransform = scrollTranslation.get(); object.getMutableForPainting().ensureObjectPaintProperties().setScrollTranslation(scrollTranslation.release()); }
void PaintPropertyTreeBuilder::walk(FrameView& frameView, const PaintPropertyTreeBuilderContext& context) { PaintPropertyTreeBuilderContext localContext(context); // TODO(pdr): Creating paint properties for FrameView here will not be // needed once settings()->rootLayerScrolls() is enabled. // TODO(pdr): Make this conditional on the rootLayerScrolls setting. TransformationMatrix frameTranslate; frameTranslate.translate(frameView.x(), frameView.y()); // The frame owner applies paint offset already. // This assumption may change in the future. ASSERT(context.paintOffset == LayoutPoint()); RefPtr<TransformPaintPropertyNode> newTransformNodeForPreTranslation = TransformPaintPropertyNode::create(frameTranslate, FloatPoint3D(), context.currentTransform); localContext.transformForFixedPositioned = newTransformNodeForPreTranslation.get(); localContext.paintOffsetForFixedPositioned = LayoutPoint(); FloatRoundedRect contentClip(IntRect(IntPoint(), frameView.visibleContentSize())); RefPtr<ClipPaintPropertyNode> newClipNodeForContentClip = ClipPaintPropertyNode::create(newTransformNodeForPreTranslation.get(), contentClip, localContext.currentClip); localContext.currentClip = localContext.clipForOutOfFlowPositioned = localContext.clipForFixedPositioned = newClipNodeForContentClip.get(); DoubleSize scrollOffset = frameView.scrollOffsetDouble(); TransformationMatrix frameScroll; frameScroll.translate(-scrollOffset.width(), -scrollOffset.height()); RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create(frameScroll, FloatPoint3D(), newTransformNodeForPreTranslation); localContext.currentTransform = localContext.transformForOutOfFlowPositioned = newTransformNodeForScrollTranslation.get(); localContext.paintOffset = localContext.paintOffsetForOutOfFlowPositioned = LayoutPoint(); frameView.setPreTranslation(newTransformNodeForPreTranslation.release()); frameView.setScrollTranslation(newTransformNodeForScrollTranslation.release()); frameView.setContentClip(newClipNodeForContentClip.release()); if (LayoutView* layoutView = frameView.layoutView()) walk(*layoutView, localContext); for (Frame* child = frameView.frame().tree().firstChild(); child; child = child->tree().nextSibling()) { if (!child->isLocalFrame()) continue; if (FrameView* childView = toLocalFrame(child)->view()) walk(*childView, localContext); } }
void PrintTo(const DoubleSize& size, std::ostream* os) { *os << size.toString(); }