本文整理汇总了C++中LayoutObject::getMutableForPainting方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutObject::getMutableForPainting方法的具体用法?C++ LayoutObject::getMutableForPainting怎么用?C++ LayoutObject::getMutableForPainting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutObject
的用法示例。
在下文中一共展示了LayoutObject::getMutableForPainting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updatePerspective
void PaintPropertyTreeBuilder::updatePerspective(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
const ComputedStyle& style = object.styleRef();
if (object.isBox() && style.hasPerspective()) {
// The perspective node must not flatten (else nothing will get
// perspective), but it should still extend the rendering context as
// most transform nodes do.
TransformationMatrix matrix =
TransformationMatrix().applyPerspective(style.perspective());
FloatPoint3D origin = perspectiveOrigin(toLayoutBox(object)) +
toLayoutSize(context.current.paintOffset);
object.getMutableForPainting().ensurePaintProperties().updatePerspective(
context.current.transform, matrix, origin,
context.current.shouldFlattenInheritedTransform,
context.current.renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearPerspective();
}
const auto* properties = object.paintProperties();
if (properties && properties->perspective()) {
context.current.transform = properties->perspective();
context.current.shouldFlattenInheritedTransform = false;
}
}
示例2: updateTransformForNonRootSVG
// SVG does not use the general transform update of |updateTransform|, instead
// creating a transform node for SVG-specific transforms without 3D.
void PaintPropertyTreeBuilder::updateTransformForNonRootSVG(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
DCHECK(object.isSVG() && !object.isSVGRoot());
// SVG (other than SVGForeignObject) does not use paint offset internally.
DCHECK(object.isSVGForeignObject() ||
context.current.paintOffset == LayoutPoint());
// TODO(pdr): Refactor this so all non-root SVG objects use the same
// transform function.
const AffineTransform& transform = object.isSVGForeignObject()
? object.localSVGTransform()
: object.localToSVGParentTransform();
// TODO(pdr): Check for the presence of a transform instead of the value.
// Checking for an identity matrix will cause the property tree structure
// to change during animations if the animation passes through the
// identity matrix.
if (!transform.isIdentity()) {
// The origin is included in the local transform, so leave origin empty.
object.getMutableForPainting().ensurePaintProperties().updateTransform(
context.current.transform, TransformationMatrix(transform),
FloatPoint3D());
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearTransform();
}
if (object.paintProperties() && object.paintProperties()->transform()) {
context.current.transform = object.paintProperties()->transform();
context.current.shouldFlattenInheritedTransform = false;
context.current.renderingContextID = 0;
}
}
示例3: updateSvgLocalToBorderBoxTransform
void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (!object.isSVGRoot())
return;
AffineTransform transformToBorderBox =
SVGRootPainter(toLayoutSVGRoot(object))
.transformToPixelSnappedBorderBox(context.current.paintOffset);
// The paint offset is included in |transformToBorderBox| so SVG does not need
// to handle paint offset internally.
context.current.paintOffset = LayoutPoint();
if (transformToBorderBox.isIdentity()) {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearSvgLocalToBorderBoxTransform();
return;
}
context.current.transform =
object.getMutableForPainting()
.ensurePaintProperties()
.updateSvgLocalToBorderBoxTransform(
context.current.transform, transformToBorderBox, FloatPoint3D());
context.current.shouldFlattenInheritedTransform = false;
context.current.renderingContextID = 0;
}
示例4: updateTransform
void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (object.isSVG() && !object.isSVGRoot()) {
// SVG does not use paint offset internally.
DCHECK(context.paintOffset == LayoutPoint());
// FIXME(pdr): Check for the presence of a transform instead of the value. Checking for an
// identity matrix will cause the property tree structure to change during animations if
// the animation passes through the identity matrix.
// FIXME(pdr): Refactor this so all non-root SVG objects use the same transform function.
const AffineTransform& transform = object.isSVGForeignObject() ? object.localSVGTransform() : object.localToSVGParentTransform();
if (transform.isIdentity())
return;
// The origin is included in the local transform, so use an empty origin.
RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintPropertyNode::create(
transform, FloatPoint3D(0, 0, 0), context.currentTransform);
context.currentTransform = svgTransform.get();
object.getMutableForPainting().ensureObjectPaintProperties().setTransform(svgTransform.release());
return;
}
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasTransform())
return;
TransformationMatrix matrix;
style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin,
ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties);
RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNode::create(
matrix, transformOrigin(toLayoutBox(object)), context.currentTransform);
context.currentTransform = transformNode.get();
object.getMutableForPainting().ensureObjectPaintProperties().setTransform(transformNode.release());
}
示例5: updatePaintOffsetTranslation
void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
bool usesPaintOffsetTranslation = false;
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
object.isLayoutView()) {
// Root layer scrolling always creates a translation node for LayoutView to
// ensure fixed and absolute contexts use the correct transform space.
usesPaintOffsetTranslation = true;
} else if (object.isBoxModelObject() &&
context.current.paintOffset != LayoutPoint()) {
// TODO(trchen): Eliminate PaintLayer dependency.
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase))
usesPaintOffsetTranslation = true;
}
// We should use the same subpixel paint offset values for snapping
// regardless of whether a transform is present. If there is a transform
// we round the paint offset but keep around the residual fractional
// component for the transformed content to paint with. In spv1 this was
// called "subpixel accumulation". For more information, see
// PaintLayer::subpixelAccumulation() and
// PaintLayerPainter::paintFragmentByApplyingTransform.
IntPoint roundedPaintOffset = roundedIntPoint(context.current.paintOffset);
LayoutPoint fractionalPaintOffset =
LayoutPoint(context.current.paintOffset - roundedPaintOffset);
if (usesPaintOffsetTranslation) {
object.getMutableForPainting()
.ensurePaintProperties()
.updatePaintOffsetTranslation(
context.current.transform,
TransformationMatrix().translate(roundedPaintOffset.x(),
roundedPaintOffset.y()),
FloatPoint3D(), context.current.shouldFlattenInheritedTransform,
context.current.renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearPaintOffsetTranslation();
}
const auto* properties = object.paintProperties();
if (properties && properties->paintOffsetTranslation()) {
context.current.transform = properties->paintOffsetTranslation();
context.current.paintOffset = fractionalPaintOffset;
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
object.isLayoutView()) {
context.absolutePosition.transform = properties->paintOffsetTranslation();
context.fixedPosition.transform = properties->paintOffsetTranslation();
context.absolutePosition.paintOffset = LayoutPoint();
context.fixedPosition.paintOffset = LayoutPoint();
}
}
}
示例6: updateOutOfFlowContext
void PaintPropertyTreeBuilder::updateOutOfFlowContext(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (object.canContainAbsolutePositionObjects()) {
context.absolutePosition = context.current;
context.containerForAbsolutePosition = &object;
}
if (object.isLayoutView()) {
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
const auto* initialFixedTransform = context.fixedPosition.transform;
auto* initialFixedScroll = context.fixedPosition.scroll;
context.fixedPosition = context.current;
// Fixed position transform and scroll nodes should not be affected.
context.fixedPosition.transform = initialFixedTransform;
context.fixedPosition.scroll = initialFixedScroll;
}
} else if (object.canContainFixedPositionObjects()) {
context.fixedPosition = context.current;
} else if (object.getMutableForPainting().paintProperties() &&
object.paintProperties()->cssClip()) {
// CSS clip applies to all descendants, even if this object is not a
// containing block ancestor of the descendant. It is okay for
// absolute-position descendants because having CSS clip implies being
// absolute position container. However for fixed-position descendants we
// need to insert the clip here if we are not a containing block ancestor of
// them.
auto* cssClip = object.getMutableForPainting().paintProperties()->cssClip();
// Before we actually create anything, check whether in-flow context and
// fixed-position context has exactly the same clip. Reuse if possible.
if (context.fixedPosition.clip == cssClip->parent()) {
context.fixedPosition.clip = cssClip;
} else {
object.getMutableForPainting()
.ensurePaintProperties()
.updateCssClipFixedPosition(context.fixedPosition.clip,
const_cast<TransformPaintPropertyNode*>(
cssClip->localTransformSpace()),
cssClip->clipRect());
const auto* properties = object.paintProperties();
if (properties && properties->cssClipFixedPosition())
context.fixedPosition.clip = properties->cssClipFixedPosition();
return;
}
}
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearCssClipFixedPosition();
}
示例7: updateEffect
void PaintPropertyTreeBuilder::updateEffect(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (!object.styleRef().hasOpacity()) {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearEffect();
return;
}
context.currentEffect =
object.getMutableForPainting().ensurePaintProperties().updateEffect(
context.currentEffect, object.styleRef().opacity());
}
示例8: updateOverflowClip
void PaintPropertyTreeBuilder::updateOverflowClip(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (!object.isBox())
return;
const LayoutBox& box = toLayoutBox(object);
// The <input> elements can't have contents thus CSS overflow property
// doesn't apply. However for layout purposes we do generate child layout
// objects for them, e.g. button label. We should clip the overflow from
// those children. This is called control clip and we technically treat them
// like overflow clip.
LayoutRect clipRect;
if (box.hasControlClip()) {
clipRect = box.controlClipRect(context.current.paintOffset);
} else if (box.hasOverflowClip() || box.styleRef().containsPaint() ||
(box.isSVGRoot() &&
toLayoutSVGRoot(box).shouldApplyViewportClip())) {
clipRect = LayoutRect(
pixelSnappedIntRect(box.overflowClipRect(context.current.paintOffset)));
} else {
if (auto* properties = object.getMutableForPainting().paintProperties()) {
properties->clearInnerBorderRadiusClip();
properties->clearOverflowClip();
}
return;
}
const auto* currentClip = context.current.clip;
if (box.styleRef().hasBorderRadius()) {
auto innerBorder = box.styleRef().getRoundedInnerBorderFor(
LayoutRect(context.current.paintOffset, box.size()));
object.getMutableForPainting()
.ensurePaintProperties()
.updateInnerBorderRadiusClip(context.current.clip,
context.current.transform, innerBorder);
currentClip = object.paintProperties()->innerBorderRadiusClip();
} else if (auto* properties =
object.getMutableForPainting().paintProperties()) {
properties->clearInnerBorderRadiusClip();
}
object.getMutableForPainting().ensurePaintProperties().updateOverflowClip(
currentClip, context.current.transform,
FloatRoundedRect(FloatRect(clipRect)));
const auto* properties = object.paintProperties();
if (properties && properties->overflowClip())
context.current.clip = properties->overflowClip();
}
示例9: updatePaintOffsetTranslation
void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (object.isBoxModelObject()) {
// TODO(trchen): Eliminate PaintLayer dependency.
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
if (!layer || !layer->paintsWithTransform(GlobalPaintNormalPhase))
return;
}
if (context.paintOffset == LayoutPoint())
return;
// We should use the same subpixel paint offset values for snapping regardless of whether a
// transform is present. If there is a transform we round the paint offset but keep around
// the residual fractional component for the transformed content to paint with.
// In spv1 this was called "subpixel accumulation". For more information, see
// PaintLayer::subpixelAccumulation() and PaintLayerPainter::paintFragmentByApplyingTransform.
IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset);
LayoutPoint fractionalPaintOffset = LayoutPoint(context.paintOffset - roundedPaintOffset);
RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create(
TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()),
FloatPoint3D(), context.currentTransform);
context.currentTransform = paintOffsetTranslation.get();
context.paintOffset = fractionalPaintOffset;
object.getMutableForPainting().ensureObjectPaintProperties().setPaintOffsetTranslation(paintOffsetTranslation.release());
}
示例10: updateOverflowClip
void PaintPropertyTreeBuilder::updateOverflowClip(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (!object.isBox())
return;
const LayoutBox& box = toLayoutBox(object);
// The <input> elements can't have contents thus CSS overflow property doesn't apply.
// However for layout purposes we do generate child layout objects for them, e.g. button label.
// We should clip the overflow from those children. This is called control clip and we
// technically treat them like overflow clip.
LayoutRect clipRect;
if (box.hasControlClip())
clipRect = box.controlClipRect(context.paintOffset);
else if (box.hasOverflowClip())
clipRect = box.overflowClipRect(context.paintOffset);
else
return;
RefPtr<ClipPaintPropertyNode> borderRadiusClip;
if (box.styleRef().hasBorderRadius()) {
auto innerBorder = box.styleRef().getRoundedInnerBorderFor(
LayoutRect(context.paintOffset, box.size()));
borderRadiusClip = ClipPaintPropertyNode::create(
context.currentTransform, innerBorder, context.currentClip);
}
RefPtr<ClipPaintPropertyNode> overflowClip = ClipPaintPropertyNode::create(
context.currentTransform,
FloatRoundedRect(FloatRect(clipRect)),
borderRadiusClip ? borderRadiusClip.release() : context.currentClip);
context.currentClip = overflowClip.get();
object.getMutableForPainting().ensureObjectPaintProperties().setOverflowClip(overflowClip.release());
}
示例11: updateEffect
void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (!object.styleRef().hasOpacity())
return;
RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create(object.styleRef().opacity(), context.currentEffect);
context.currentEffect = effectNode.get();
object.getMutableForPainting().ensureObjectPaintProperties().setEffect(effectNode.release());
}
示例12: updateScrollAndScrollTranslation
void PaintPropertyTreeBuilder::updateScrollAndScrollTranslation(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (object.hasOverflowClip()) {
const LayoutBox& box = toLayoutBox(object);
const PaintLayerScrollableArea* scrollableArea = box.getScrollableArea();
IntSize scrollOffset = box.scrolledContentOffset();
if (!scrollOffset.isZero() || scrollableArea->scrollsOverflow()) {
TransformationMatrix matrix = TransformationMatrix().translate(
-scrollOffset.width(), -scrollOffset.height());
object.getMutableForPainting()
.ensurePaintProperties()
.updateScrollTranslation(
context.current.transform, matrix, FloatPoint3D(),
context.current.shouldFlattenInheritedTransform,
context.current.renderingContextID);
IntSize scrollClip = scrollableArea->visibleContentRect().size();
IntSize scrollBounds = scrollableArea->contentsSize();
bool userScrollableHorizontal =
scrollableArea->userInputScrollable(HorizontalScrollbar);
bool userScrollableVertical =
scrollableArea->userInputScrollable(VerticalScrollbar);
object.getMutableForPainting().ensurePaintProperties().updateScroll(
context.current.scroll, object.paintProperties()->scrollTranslation(),
scrollClip, scrollBounds, userScrollableHorizontal,
userScrollableVertical);
} else {
// Ensure pre-existing properties are cleared when there is no
// scrolling.
auto* properties = object.getMutableForPainting().paintProperties();
if (properties) {
properties->clearScrollTranslation();
properties->clearScroll();
}
}
}
if (object.paintProperties() && object.paintProperties()->scroll()) {
context.current.transform = object.paintProperties()->scrollTranslation();
const auto* scroll = object.paintProperties()->scroll();
// TODO(pdr): Remove this const cast.
context.current.scroll = const_cast<ScrollPaintPropertyNode*>(scroll);
context.current.shouldFlattenInheritedTransform = false;
}
}
示例13: updateTransform
void PaintPropertyTreeBuilder::updateTransform(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (object.isSVG() && !object.isSVGRoot()) {
updateTransformForNonRootSVG(object, context);
return;
}
const ComputedStyle& style = object.styleRef();
if (object.isBox() && (style.hasTransform() || style.preserves3D())) {
TransformationMatrix matrix;
style.applyTransform(matrix, toLayoutBox(object).size(),
ComputedStyle::ExcludeTransformOrigin,
ComputedStyle::IncludeMotionPath,
ComputedStyle::IncludeIndependentTransformProperties);
// TODO(trchen): transform-style should only be respected if a PaintLayer
// is created.
// If a node with transform-style: preserve-3d does not exist in an
// existing rendering context, it establishes a new one.
unsigned renderingContextID = context.current.renderingContextID;
if (style.preserves3D() && !renderingContextID)
renderingContextID = PtrHash<const LayoutObject>::hash(&object);
object.getMutableForPainting().ensurePaintProperties().updateTransform(
context.current.transform, matrix, transformOrigin(toLayoutBox(object)),
context.current.shouldFlattenInheritedTransform, renderingContextID);
} else {
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearTransform();
}
const auto* properties = object.paintProperties();
if (properties && properties->transform()) {
context.current.transform = properties->transform();
if (object.styleRef().preserves3D()) {
context.current.renderingContextID =
properties->transform()->renderingContextID();
context.current.shouldFlattenInheritedTransform = false;
} else {
context.current.renderingContextID = 0;
context.current.shouldFlattenInheritedTransform = true;
}
}
}
示例14: updatePaintOffsetTranslation
void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (object.isBoxModelObject() &&
context.current.paintOffset != LayoutPoint()) {
// TODO(trchen): Eliminate PaintLayer dependency.
PaintLayer* layer = toLayoutBoxModelObject(object).layer();
if (layer && layer->paintsWithTransform(GlobalPaintNormalPhase)) {
// We should use the same subpixel paint offset values for snapping
// regardless of whether a transform is present. If there is a transform
// we round the paint offset but keep around the residual fractional
// component for the transformed content to paint with. In spv1 this was
// called "subpixel accumulation". For more information, see
// PaintLayer::subpixelAccumulation() and
// PaintLayerPainter::paintFragmentByApplyingTransform.
IntPoint roundedPaintOffset =
roundedIntPoint(context.current.paintOffset);
LayoutPoint fractionalPaintOffset =
LayoutPoint(context.current.paintOffset - roundedPaintOffset);
context.current.transform =
object.getMutableForPainting()
.ensurePaintProperties()
.updatePaintOffsetTranslation(
context.current.transform,
TransformationMatrix().translate(roundedPaintOffset.x(),
roundedPaintOffset.y()),
FloatPoint3D(),
context.current.shouldFlattenInheritedTransform,
context.current.renderingContextID);
context.current.paintOffset = fractionalPaintOffset;
return;
}
}
if (object.isLayoutView())
return;
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearPaintOffsetTranslation();
}
示例15: updateCssClip
void PaintPropertyTreeBuilder::updateCssClip(
const LayoutObject& object,
PaintPropertyTreeBuilderContext& context) {
if (object.hasClip()) {
// Create clip node for descendants that are not fixed position.
// We don't have to setup context.absolutePosition.clip here because this
// object must be a container for absolute position descendants, and will
// copy from in-flow context later at updateOutOfFlowContext() step.
DCHECK(object.canContainAbsolutePositionObjects());
LayoutRect clipRect =
toLayoutBox(object).clipRect(context.current.paintOffset);
context.current.clip =
object.getMutableForPainting().ensurePaintProperties().updateCssClip(
context.current.clip, context.current.transform,
FloatRoundedRect(FloatRect(clipRect)));
return;
}
if (auto* properties = object.getMutableForPainting().paintProperties())
properties->clearCssClip();
}