#ifndef RenderBoxModelObject_h
#define RenderBoxModelObject_h
#include "core/animation/ActiveAnimations.h"
#include "core/rendering/RenderLayerModelObject.h"
#include "core/rendering/style/ShadowData.h"
#include "platform/geometry/LayoutRect.h"
namespace WebCore {
enum LinePositionMode { PositionOnContainingLine, PositionOfInteriorLineBoxes };
enum LineDirectionMode { HorizontalLine, VerticalLine };
typedef unsigned BorderEdgeFlags;
enum BackgroundBleedAvoidance {
BackgroundBleedNone,
BackgroundBleedShrinkBackground,
BackgroundBleedClipBackground,
BackgroundBleedBackgroundOverBorder
};
enum ContentChangeType {
ImageChanged,
MaskImageChanged,
CanvasChanged,
CanvasPixelsChanged,
VideoChanged,
FullScreenChanged,
CanvasContextChanged
};
class KeyframeList;
class RenderTextFragment;
class StickyPositionViewportConstraints;
class RenderBoxModelObject : public RenderLayerModelObject {
public:
RenderBoxModelObject(ContainerNode*);
virtual ~RenderBoxModelObject();
LayoutSize relativePositionOffset() const;
LayoutSize relativePositionLogicalOffset() const { return style()->isHorizontalWritingMode() ? relativePositionOffset() : relativePositionOffset().transposedSize(); }
void computeStickyPositionConstraints(StickyPositionViewportConstraints&, const FloatRect& constrainingRect) const;
LayoutSize stickyPositionOffset() const;
LayoutSize stickyPositionLogicalOffset() const { return style()->isHorizontalWritingMode() ? stickyPositionOffset() : stickyPositionOffset().transposedSize(); }
LayoutSize offsetForInFlowPosition() const;
virtual LayoutUnit offsetLeft() const;
virtual LayoutUnit offsetTop() const;
virtual LayoutUnit offsetWidth() const = 0;
virtual LayoutUnit offsetHeight() const = 0;
int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); }
int pixelSnappedOffsetTop() const { return roundToInt(offsetTop()); }
virtual int pixelSnappedOffsetWidth() const;
virtual int pixelSnappedOffsetHeight() const;
virtual void updateFromStyle() OVERRIDE;
virtual LayerType layerTypeRequired() const OVERRIDE
{
if (isRoot() || isPositioned() || createsGroup() || hasClipPath() || hasTransform() || hasHiddenBackface() || hasReflection() || style()->specifiesColumns() || style()->hasWillChangeCompositingHint() || style()->hasWillChangeGpuRasterizationHint() || shouldCompositeForActiveAnimations(*this))
return NormalLayer;
return NoLayer;
}
virtual IntRect borderBoundingBox() const = 0;
LayoutUnit computedCSSPaddingTop() const { return computedCSSPadding(style()->paddingTop()); }
LayoutUnit computedCSSPaddingBottom() const { return computedCSSPadding(style()->paddingBottom()); }
LayoutUnit computedCSSPaddingLeft() const { return computedCSSPadding(style()->paddingLeft()); }
LayoutUnit computedCSSPaddingRight() const { return computedCSSPadding(style()->paddingRight()); }
LayoutUnit computedCSSPaddingBefore() const { return computedCSSPadding(style()->paddingBefore()); }
LayoutUnit computedCSSPaddingAfter() const { return computedCSSPadding(style()->paddingAfter()); }
LayoutUnit computedCSSPaddingStart() const { return computedCSSPadding(style()->paddingStart()); }
LayoutUnit computedCSSPaddingEnd() const { return computedCSSPadding(style()->paddingEnd()); }
virtual LayoutUnit paddingTop() const { return computedCSSPaddingTop(); }
virtual LayoutUnit paddingBottom() const { return computedCSSPaddingBottom(); }
virtual LayoutUnit paddingLeft() const { return computedCSSPaddingLeft(); }
virtual LayoutUnit paddingRight() const { return computedCSSPaddingRight(); }
virtual LayoutUnit paddingBefore() const { return computedCSSPaddingBefore(); }
virtual LayoutUnit paddingAfter() const { return computedCSSPaddingAfter(); }
virtual LayoutUnit paddingStart() const { return computedCSSPaddingStart(); }
virtual LayoutUnit paddingEnd() const { return computedCSSPaddingEnd(); }
virtual int borderTop() const { return style()->borderTopWidth(); }
virtual int borderBottom() const { return style()->borderBottomWidth(); }
virtual int borderLeft() const { return style()->borderLeftWidth(); }
virtual int borderRight() const { return style()->borderRightWidth(); }
virtual int borderBefore() const { return style()->borderBeforeWidth(); }
virtual int borderAfter() const { return style()->borderAfterWidth(); }
virtual int borderStart() const { return style()->borderStartWidth(); }
virtual int borderEnd() const { return style()->borderEndWidth(); }
int borderWidth() const { return borderLeft() + borderRight(); }
int borderHeight() const { return borderTop() + borderBottom(); }
LayoutUnit borderAndPaddingStart() const { return borderStart() + paddingStart(); }
LayoutUnit borderAndPaddingBefore() const { return borderBefore() + paddingBefore(); }
LayoutUnit borderAndPaddingAfter() const { return borderAfter() + paddingAfter(); }
LayoutUnit borderAndPaddingHeight() const { return borderTop() + borderBottom() + paddingTop() + paddingBottom(); }
LayoutUnit borderAndPaddingWidth() const { return borderLeft() + borderRight() + paddingLeft() + paddingRight(); }
LayoutUnit borderAndPaddingLogicalHeight() const { return borderAndPaddingBefore() + borderAndPaddingAfter(); }
LayoutUnit borderAndPaddingLogicalWidth() const { return borderStart() + borderEnd() + paddingStart() + paddingEnd(); }
LayoutUnit borderAndPaddingLogicalLeft() const { return style()->isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
LayoutUnit borderLogicalLeft() const { return style()->isHorizontalWritingMode() ? borderLeft() : borderTop(); }
LayoutUnit borderLogicalRight() const { return style()->isHorizontalWritingMode() ? borderRight() : borderBottom(); }
LayoutUnit borderLogicalWidth() const { return borderStart() + borderEnd(); }
LayoutUnit borderLogicalHeight() const { return borderBefore() + borderAfter(); }
LayoutUnit paddingLogicalLeft() const { return style()->isHorizontalWritingMode() ? paddingLeft() : paddingTop(); }
LayoutUnit paddingLogicalRight() const { return style()->isHorizontalWritingMode() ? paddingRight() : paddingBottom(); }
LayoutUnit paddingLogicalWidth() const { return paddingStart() + paddingEnd(); }
LayoutUnit paddingLogicalHeight() const { return paddingBefore() + paddingAfter(); }
virtual LayoutUnit marginTop() const = 0;
virtual LayoutUnit marginBottom() const = 0;
virtual LayoutUnit marginLeft() const = 0;
virtual LayoutUnit marginRight() const = 0;
virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const = 0;
virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const = 0;
virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const = 0;
virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const = 0;
LayoutUnit marginHeight() const { return marginTop() + marginBottom(); }
LayoutUnit marginWidth() const { return marginLeft() + marginRight(); }
LayoutUnit marginLogicalHeight() const { return marginBefore() + marginAfter(); }
LayoutUnit marginLogicalWidth() const { return marginStart() + marginEnd(); }
bool hasInlineDirectionBordersPaddingOrMargin() const { return hasInlineDirectionBordersOrPadding() || marginStart()|| marginEnd(); }
bool hasInlineDirectionBordersOrPadding() const { return borderStart() || borderEnd() || paddingStart()|| paddingEnd(); }
virtual LayoutUnit containingBlockLogicalWidthForContent() const;
virtual void childBecameNonInline(RenderObject* ) { }
void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
bool paintNinePieceImage(GraphicsContext*, const LayoutRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox* = 0) const;
virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;
virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;
virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const OVERRIDE;
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const OVERRIDE;
virtual void setSelectionState(SelectionState) OVERRIDE;
void contentChanged(ContentChangeType);
bool hasAcceleratedCompositing() const;
virtual void computeLayerHitTestRects(LayerHitTestRects&) const OVERRIDE;
protected:
virtual void willBeDestroyed() OVERRIDE;
class BackgroundImageGeometry {
public:
BackgroundImageGeometry()
: m_hasNonLocalGeometry(false)
{ }
IntPoint destOrigin() const { return m_destOrigin; }
void setDestOrigin(const IntPoint& destOrigin)
{
m_destOrigin = destOrigin;
}
IntRect destRect() const { return m_destRect; }
void setDestRect(const IntRect& destRect)
{
m_destRect = destRect;
}
IntPoint relativePhase() const;
IntPoint phase() const { return m_phase; }
void setPhase(const IntPoint& phase)
{
m_phase = phase;
}
IntSize tileSize() const { return m_tileSize; }
void setTileSize(const IntSize& tileSize)
{
m_tileSize = tileSize;
}
IntSize spaceSize() const { return m_repeatSpacing; }
void setSpaceSize(const IntSize& repeatSpacing)
{
m_repeatSpacing = repeatSpacing;
}
void setPhaseX(int x) { m_phase.setX(x); }
void setPhaseY(int y) { m_phase.setY(y); }
void setNoRepeatX(int xOffset);
void setNoRepeatY(int yOffset);
void useFixedAttachment(const IntPoint& attachmentPoint);
void clip(const IntRect&);
void setHasNonLocalGeometry(bool hasNonLocalGeometry = true) { m_hasNonLocalGeometry = hasNonLocalGeometry; }
bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; }
private:
IntRect m_destRect;
IntPoint m_destOrigin;
IntPoint m_phase;
IntSize m_tileSize;
IntSize m_repeatSpacing;
bool m_hasNonLocalGeometry;
};
LayoutPoint adjustedPositionRelativeToOffsetParent(const LayoutPoint&) const;
void calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&, RenderObject* = 0) const;
void getBorderEdgeInfo(class BorderEdge[], const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;
bool borderObscuresBackground() const;
RoundedRect backgroundRoundedRectAdjustedForBleedAvoidance(GraphicsContext*, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox*, const LayoutSize&, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
LayoutRect borderInnerRectAdjustedForBleedAvoidance(GraphicsContext*, const LayoutRect&, BackgroundBleedAvoidance) const;
InterpolationQuality chooseInterpolationQuality(GraphicsContext*, Image*, const void*, const LayoutSize&);
RenderBoxModelObject* continuation() const;
void setContinuation(RenderBoxModelObject*);
LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIndentOffset);
static void clipRoundedInnerRect(GraphicsContext*, const LayoutRect&, const RoundedRect& clipRect);
bool hasAutoHeightOrContainingBlockWithAutoHeight() const;
public:
static bool shouldAntialiasLines(GraphicsContext*);
RenderTextFragment* firstLetterRemainingText() const;
void setFirstLetterRemainingText(RenderTextFragment*);
void moveChildTo(RenderBoxModelObject* toBoxModelObject, RenderObject* child, RenderObject* beforeChild, bool fullRemoveInsert = false);
void moveChildTo(RenderBoxModelObject* toBoxModelObject, RenderObject* child, bool fullRemoveInsert = false)
{
moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert);
}
void moveAllChildrenTo(RenderBoxModelObject* toBoxModelObject, bool fullRemoveInsert = false)
{
moveAllChildrenTo(toBoxModelObject, 0, fullRemoveInsert);
}
void moveAllChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderObject* beforeChild, bool fullRemoveInsert = false)
{
moveChildrenTo(toBoxModelObject, firstChild(), 0, beforeChild, fullRemoveInsert);
}
void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderObject* startChild, RenderObject* endChild, bool fullRemoveInsert = false)
{
moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInsert);
}
void moveChildrenTo(RenderBoxModelObject* toBoxModelObject, RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRemoveInsert = false);
enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffectiveZoom };
IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
private:
LayoutUnit computedCSSPadding(Length) const;
virtual bool isBoxModelObject() const OVERRIDE FINAL { return true; }
virtual LayoutRect frameRectForStickyPositioning() const = 0;
IntSize calculateFillTileSize(const FillLayer*, const IntSize& scaledPositioningAreaSize) const;
RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
bool fixedBackgroundPaintsInLocalCoordinates() const;
void clipBorderSidePolygon(GraphicsContext*, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
BoxSide, bool firstEdgeMatches, bool secondEdgeMatches);
void clipBorderSideForComplexInnerPath(GraphicsContext*, const RoundedRect&, const RoundedRect&, BoxSide, const class BorderEdge[]);
void paintOneBorderSide(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
const IntRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const class BorderEdge[],
const Path*, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor = 0);
void paintTranslucentBorderSides(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
const class BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);
void paintBorderSides(GraphicsContext*, const RenderStyle*, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
const IntPoint& innerBorderAdjustment, const class BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false, const Color* overrideColor = 0);
void drawBoxSideFromPath(GraphicsContext*, const LayoutRect&, const Path&, const class BorderEdge[],
float thickness, float drawThickness, BoxSide, const RenderStyle*,
Color, EBorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
};
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBoxModelObject, isBoxModelObject());
}
#endif