FloatPoint3D Filter::resolve3dPoint(const FloatPoint3D& point) const { if (m_unitScaling != BoundingBox) return point; return FloatPoint3D(point.x() * referenceBox().width() + referenceBox().x(), point.y() * referenceBox().height() + referenceBox().y(), point.z() * sqrtf(referenceBox().size().diagonalLengthSquared() / 2)); }
void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize) { bool isHorizontalWritingMode = m_renderer.containingBlock()->style()->isHorizontalWritingMode(); switch (referenceBox(*m_renderer.style()->shapeOutside())) { case MarginBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.expand(m_renderer.marginWidth(), m_renderer.marginHeight()); else newReferenceBoxLogicalSize.expand(m_renderer.marginHeight(), m_renderer.marginWidth()); break; case BorderBox: break; case PaddingBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.shrink(m_renderer.borderWidth(), m_renderer.borderHeight()); else newReferenceBoxLogicalSize.shrink(m_renderer.borderHeight(), m_renderer.borderWidth()); break; case ContentBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingWidth(), m_renderer.borderAndPaddingHeight()); else newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingHeight(), m_renderer.borderAndPaddingWidth()); break; case BoxMissing: ASSERT_NOT_REACHED(); break; } if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) return; markShapeAsDirty(); m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; }
const Shape& ShapeOutsideInfo::computedShape() const { if (Shape* shape = m_shape.get()) return *shape; const RenderStyle& style = m_renderer.style(); ASSERT(m_renderer.containingBlock()); const RenderStyle& containingBlockStyle = m_renderer.containingBlock()->style(); WritingMode writingMode = containingBlockStyle.writingMode(); float margin = floatValueForLength(m_renderer.style().shapeMargin(), m_renderer.containingBlock() ? m_renderer.containingBlock()->contentWidth() : LayoutUnit()); float shapeImageThreshold = style.shapeImageThreshold(); const ShapeValue& shapeValue = *style.shapeOutside(); switch (shapeValue.type()) { case ShapeValue::Type::Shape: ASSERT(shapeValue.shape()); m_shape = Shape::createShape(shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin); break; case ShapeValue::Type::Image: ASSERT(shapeValue.isImageValid()); m_shape = createShapeForImage(shapeValue.image(), shapeImageThreshold, writingMode, margin); break; case ShapeValue::Type::Box: { RoundedRect shapeRect = computeRoundedRectForBoxShape(referenceBox(shapeValue), m_renderer); if (!containingBlockStyle.isHorizontalWritingMode()) shapeRect = shapeRect.transposedRect(); m_shape = Shape::createBoxShape(shapeRect, writingMode, margin); break; } } ASSERT(m_shape); return *m_shape; }
LayoutUnit ShapeOutsideInfo::logicalLeftOffset() const { switch (referenceBox(*m_renderer.style()->shapeOutside())) { case MarginBox: return -m_renderer.marginStart(m_renderer.containingBlock()->style()); case BorderBox: return LayoutUnit(); case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style()); case ContentBox: return borderAndPaddingStartWithStyleForWritingMode(m_renderer, m_renderer.containingBlock()->style()); case BoxMissing: break; } ASSERT_NOT_REACHED(); return LayoutUnit(); }
LayoutUnit ShapeOutsideInfo::logicalTopOffset() const { switch (referenceBox(*m_layoutBox.style()->shapeOutside())) { case MarginBox: return -m_layoutBox.marginBefore(m_layoutBox.containingBlock()->style()); case BorderBox: return LayoutUnit(); case PaddingBox: return borderBeforeInWritingMode(m_layoutBox, m_layoutBox.containingBlock()->style()->writingMode()); case ContentBox: return borderAndPaddingBeforeInWritingMode(m_layoutBox, m_layoutBox.containingBlock()->style()->writingMode()); case BoxMissing: break; } ASSERT_NOT_REACHED(); return LayoutUnit(); }
LayoutUnit ShapeInfo<RenderType>::logicalTopOffset() const { switch (referenceBox()) { case MarginBox: return -m_renderer.marginBefore(&styleForWritingMode()); case BorderBox: return LayoutUnit(); case PaddingBox: return borderBeforeInWritingMode(m_renderer, styleForWritingMode().writingMode()); case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer, styleForWritingMode().writingMode()); case Fill: break; case Stroke: break; case ViewBox: break; case BoxMissing: break; } ASSERT_NOT_REACHED(); return LayoutUnit(); }
LayoutUnit ShapeInfo<RenderType>::logicalLeftOffset() const { if (m_renderer.isRenderRegion()) return LayoutUnit(); switch (referenceBox()) { case MarginBox: return -m_renderer.marginStart(&styleForWritingMode()); case BorderBox: return LayoutUnit(); case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, styleForWritingMode()); case ContentBox: return borderAndPaddingStartWithStyleForWritingMode(m_renderer, styleForWritingMode()); case Fill: break; case Stroke: break; case ViewBox: break; case BoxMissing: break; } ASSERT_NOT_REACHED(); return LayoutUnit(); }
void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize) { bool isHorizontalWritingMode = m_renderer.containingBlock()->style().isHorizontalWritingMode(); switch (referenceBox(*m_renderer.style().shapeOutside())) { case MarginBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.expand(m_renderer.horizontalMarginExtent(), m_renderer.verticalMarginExtent()); else newReferenceBoxLogicalSize.expand(m_renderer.verticalMarginExtent(), m_renderer.horizontalMarginExtent()); break; case BorderBox: break; case PaddingBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderExtent(), m_renderer.verticalBorderExtent()); else newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderExtent(), m_renderer.horizontalBorderExtent()); break; case ContentBox: if (isHorizontalWritingMode) newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderAndPaddingExtent(), m_renderer.verticalBorderAndPaddingExtent()); else newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderAndPaddingExtent(), m_renderer.horizontalBorderAndPaddingExtent()); break; case Fill: case Stroke: case ViewBox: case BoxMissing: ASSERT_NOT_REACHED(); break; } if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) return; markShapeAsDirty(); m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; }
float Filter::applyVerticalScale(float value) const { if (m_unitScaling == BoundingBox) value *= referenceBox().height(); return m_scale * value; }
float Filter::applyHorizontalScale(float value) const { if (m_unitScaling == BoundingBox) value *= referenceBox().width(); return m_scale * value; }