-static bool borderStyleHasInnerDetail(EBorderStyle style)
-{
- return style == GROOVE || style == RIDGE || style == DOUBLE;
-}
-
-static bool borderStyleIsDottedOrDashed(EBorderStyle style)
-{
- return style == DOTTED || style == DASHED;
-}
-
-// OUTSET darkens the bottom and right (and maybe lightens the top and left)
-// INSET darkens the top and left (and maybe lightens the bottom and right)
-static inline bool borderStyleHasUnmatchedColorsAtCorner(EBorderStyle style, BoxSide side, BoxSide adjacentSide)
-{
- // These styles match at the top/left and bottom/right.
- if (style == INSET || style == GROOVE || style == RIDGE || style == OUTSET) {
- const BorderEdgeFlags topRightFlags = edgeFlagForSide(BSTop) | edgeFlagForSide(BSRight);
- const BorderEdgeFlags bottomLeftFlags = edgeFlagForSide(BSBottom) | edgeFlagForSide(BSLeft);
-
- BorderEdgeFlags flags = edgeFlagForSide(side) | edgeFlagForSide(adjacentSide);
- return flags == topRightFlags || flags == bottomLeftFlags;
- }
- return false;
-}
-
-static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
-{
- if (edges[side].shouldRender() != edges[adjacentSide].shouldRender())
- return false;
-
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
- return false;
-
- return !borderStyleHasUnmatchedColorsAtCorner(edges[side].style, side, adjacentSide);
-}
-
-
-static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
-{
- if (!edges[side].color.hasAlpha())
- return false;
-
- if (edges[side].shouldRender() != edges[adjacentSide].shouldRender())
- return false;
-
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
- return true;
-
- return borderStyleHasUnmatchedColorsAtCorner(edges[side].style, side, adjacentSide);
-}
-
-// This assumes that we draw in order: top, bottom, left, right.
-static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
-{
- switch (side) {
- case BSTop:
- case BSBottom:
- if (edges[adjacentSide].presentButInvisible())
- return false;
-
- if (!edgesShareColor(edges[side], edges[adjacentSide]) && edges[adjacentSide].color.hasAlpha())
- return false;
-
- if (!borderStyleFillsBorderArea(edges[adjacentSide].style))
- return false;
-
- return true;
-
- case BSLeft:
- case BSRight:
- // These draw last, so are never overdrawn.
- return false;
- }
- return false;
-}
-
-static inline bool borderStylesRequireMitre(BoxSide side, BoxSide adjacentSide, EBorderStyle style, EBorderStyle adjacentStyle)
-{
- if (style == DOUBLE || adjacentStyle == DOUBLE || adjacentStyle == GROOVE || adjacentStyle == RIDGE)
- return true;
-
- if (borderStyleIsDottedOrDashed(style) != borderStyleIsDottedOrDashed(adjacentStyle))
- return true;
-
- if (style != adjacentStyle)
- return true;
-
- return borderStyleHasUnmatchedColorsAtCorner(style, side, adjacentSide);
-}
-
-static bool joinRequiresMitre(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[], bool allowOverdraw)
-{
- if ((edges[side].isTransparent && edges[adjacentSide].isTransparent) || !edges[adjacentSide].isPresent)
- return false;
-
- if (allowOverdraw && willBeOverdrawn(side, adjacentSide, edges))
- return false;
-
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
- return true;
-
- if (borderStylesRequireMitre(side, adjacentSide, edges[side].style, edges[adjacentSide].style))
- return true;
-
- return false;
-}
-
-void RenderBoxModelObject::paintOneBorderSide(GraphicsContext* graphicsContext, const RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const IntRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge edges[], const Path* path,
- BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor)
-{
- const BorderEdge& edgeToRender = edges[side];
- ASSERT(edgeToRender.width);
- const BorderEdge& adjacentEdge1 = edges[adjacentSide1];
- const BorderEdge& adjacentEdge2 = edges[adjacentSide2];
-
- bool mitreAdjacentSide1 = joinRequiresMitre(side, adjacentSide1, edges, !antialias);
- bool mitreAdjacentSide2 = joinRequiresMitre(side, adjacentSide2, edges, !antialias);
-
- bool adjacentSide1StylesMatch = colorsMatchAtCorner(side, adjacentSide1, edges);
- bool adjacentSide2StylesMatch = colorsMatchAtCorner(side, adjacentSide2, edges);
-
- const Color& colorToPaint = overrideColor ? *overrideColor : edgeToRender.color;
-
- if (path) {
- GraphicsContextStateSaver stateSaver(*graphicsContext);
- if (innerBorder.isRenderable())
- clipBorderSidePolygon(graphicsContext, outerBorder, innerBorder, side, adjacentSide1StylesMatch, adjacentSide2StylesMatch);
- else
- clipBorderSideForComplexInnerPath(graphicsContext, outerBorder, innerBorder, side, edges);
- float thickness = std::max(std::max(edgeToRender.width, adjacentEdge1.width), adjacentEdge2.width);
- drawBoxSideFromPath(graphicsContext, outerBorder.rect(), *path, edges, edgeToRender.width, thickness, side, style,
- colorToPaint, edgeToRender.style, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
- } else {
- bool clipForStyle = styleRequiresClipPolygon(edgeToRender.style) && (mitreAdjacentSide1 || mitreAdjacentSide2);
- bool clipAdjacentSide1 = colorNeedsAntiAliasAtCorner(side, adjacentSide1, edges) && mitreAdjacentSide1;
- bool clipAdjacentSide2 = colorNeedsAntiAliasAtCorner(side, adjacentSide2, edges) && mitreAdjacentSide2;
- bool shouldClip = clipForStyle || clipAdjacentSide1 || clipAdjacentSide2;
-
- GraphicsContextStateSaver clipStateSaver(*graphicsContext, shouldClip);
- if (shouldClip) {
- bool aliasAdjacentSide1 = clipAdjacentSide1 || (clipForStyle && mitreAdjacentSide1);
- bool aliasAdjacentSide2 = clipAdjacentSide2 || (clipForStyle && mitreAdjacentSide2);
- clipBorderSidePolygon(graphicsContext, outerBorder, innerBorder, side, !aliasAdjacentSide1, !aliasAdjacentSide2);
- // Since we clipped, no need to draw with a mitre.
- mitreAdjacentSide1 = false;
- mitreAdjacentSide2 = false;
- }
-
- drawLineForBoxSide(graphicsContext, sideRect.x(), sideRect.y(), sideRect.maxX(), sideRect.maxY(), side, colorToPaint, edgeToRender.style,
- mitreAdjacentSide1 ? adjacentEdge1.width : 0, mitreAdjacentSide2 ? adjacentEdge2.width : 0, antialias);
- }
-}
-
-static IntRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdge edges[], int side)
-{
- IntRect sideRect = outerBorder.rect();
- int width = edges[side].width;
-
- if (side == BSTop)
- sideRect.setHeight(width);
- else if (side == BSBottom)
- sideRect.shiftYEdgeTo(sideRect.maxY() - width);
- else if (side == BSLeft)
- sideRect.setWidth(width);
- else
- sideRect.shiftXEdgeTo(sideRect.maxX() - width);
-
- return sideRect;
-}
-
-void RenderBoxModelObject::paintBorderSides(GraphicsContext* graphicsContext, const RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const IntPoint& innerBorderAdjustment, const BorderEdge edges[], BorderEdgeFlags edgeSet, BackgroundBleedAvoidance bleedAvoidance,
- bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor)
-{
- bool renderRadii = outerBorder.isRounded();
-
- Path roundedPath;
- if (renderRadii)
- roundedPath.addRoundedRect(outerBorder);
-
- // The inner border adjustment for bleed avoidance mode BackgroundBleedBackgroundOverBorder
- // is only applied to sideRect, which is okay since BackgroundBleedBackgroundOverBorder
- // is only to be used for solid borders and the shape of the border painted by drawBoxSideFromPath
- // only depends on sideRect when painting solid borders.
-
- if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) {
- IntRect sideRect = outerBorder.rect();
- sideRect.setHeight(edges[BSTop].width + innerBorderAdjustment.y());
-
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSTop].style) || borderWillArcInnerEdge(innerBorder.radii().topLeft(), innerBorder.radii().topRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSTop, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-
- if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) {
- IntRect sideRect = outerBorder.rect();
- sideRect.shiftYEdgeTo(sideRect.maxY() - edges[BSBottom].width - innerBorderAdjustment.y());
-
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSBottom].style) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().bottomRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSBottom, BSLeft, BSRight, edges, usePath ? &roundedPath : 0, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-
- if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) {
- IntRect sideRect = outerBorder.rect();
- sideRect.setWidth(edges[BSLeft].width + innerBorderAdjustment.x());
-
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSLeft].style) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().topLeft()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSLeft, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-
- if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) {
- IntRect sideRect = outerBorder.rect();
- sideRect.shiftXEdgeTo(sideRect.maxX() - edges[BSRight].width - innerBorderAdjustment.x());
-
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSRight].style) || borderWillArcInnerEdge(innerBorder.radii().bottomRight(), innerBorder.radii().topRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSRight, BSTop, BSBottom, edges, usePath ? &roundedPath : 0, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-}
-
-void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext* graphicsContext, const RenderStyle* style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
- const BorderEdge edges[], BorderEdgeFlags edgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)
-{
- // willBeOverdrawn assumes that we draw in order: top, bottom, left, right.
- // This is different from BoxSide enum order.
- static const BoxSide paintOrder[] = { BSTop, BSBottom, BSLeft, BSRight };
-
- while (edgesToDraw) {
- // Find undrawn edges sharing a color.
- Color commonColor;
-
- BorderEdgeFlags commonColorEdgeSet = 0;
- for (size_t i = 0; i < sizeof(paintOrder) / sizeof(paintOrder[0]); ++i) {
- BoxSide currSide = paintOrder[i];
- if (!includesEdge(edgesToDraw, currSide))
- continue;
-
- bool includeEdge;
- if (!commonColorEdgeSet) {
- commonColor = edges[currSide].color;
- includeEdge = true;
- } else
- includeEdge = edges[currSide].color == commonColor;
-
- if (includeEdge)
- commonColorEdgeSet |= edgeFlagForSide(currSide);
- }
-
- bool useTransparencyLayer = includesAdjacentEdges(commonColorEdgeSet) && commonColor.hasAlpha();
- if (useTransparencyLayer) {
- graphicsContext->beginTransparencyLayer(static_cast<float>(commonColor.alpha()) / 255);
- commonColor = Color(commonColor.red(), commonColor.green(), commonColor.blue());
- }
-
- paintBorderSides(graphicsContext, style, outerBorder, innerBorder, innerBorderAdjustment, edges, commonColorEdgeSet, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, &commonColor);
-
- if (useTransparencyLayer)
- graphicsContext->endLayer();
-
- edgesToDraw &= ~commonColorEdgeSet;
- }
-}
-
-void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect& rect, const RenderStyle* style,
- BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
-{
- GraphicsContext* graphicsContext = info.context;
- // border-image is not affected by border-radius.
- if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
- return;
-
- BorderEdge edges[4];
- getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightEdge);
- RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
- RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge);
-
- if (outerBorder.rect().isEmpty())
- return;
-
- bool haveAlphaColor = false;
- bool haveAllSolidEdges = true;
- bool haveAllDoubleEdges = true;
- int numEdgesVisible = 4;
- bool allEdgesShareColor = true;
- bool allEdgesShareWidth = true;
- int firstVisibleEdge = -1;
- BorderEdgeFlags edgesToDraw = 0;
-
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
-
- if (edges[i].shouldRender())
- edgesToDraw |= edgeFlagForSide(static_cast<BoxSide>(i));
-
- if (currEdge.presentButInvisible()) {
- --numEdgesVisible;
- allEdgesShareColor = false;
- allEdgesShareWidth = false;
- continue;
- }
-
- if (!currEdge.shouldRender()) {
- --numEdgesVisible;
- continue;
- }
-
- if (firstVisibleEdge == -1) {
- firstVisibleEdge = i;
- } else {
- if (currEdge.color != edges[firstVisibleEdge].color)
- allEdgesShareColor = false;
- if (currEdge.width != edges[firstVisibleEdge].width)
- allEdgesShareWidth = false;
- }
-
- if (currEdge.color.hasAlpha())
- haveAlphaColor = true;
-
- if (currEdge.style != SOLID)
- haveAllSolidEdges = false;
-
- if (currEdge.style != DOUBLE)
- haveAllDoubleEdges = false;
- }
-
- // If no corner intersects the clip region, we can pretend outerBorder is
- // rectangular to improve performance.
- if (haveAllSolidEdges && outerBorder.isRounded() && allCornersClippedOut(outerBorder, info.rect))
- outerBorder.setRadii(RoundedRect::Radii());
-
- // isRenderable() check avoids issue described in https://bugs.webkit.org/show_bug.cgi?id=38787
- if ((haveAllSolidEdges || haveAllDoubleEdges) && allEdgesShareColor && innerBorder.isRenderable()) {
- // Fast path for drawing all solid edges and all unrounded double edges
-
- if (numEdgesVisible == 4 && (outerBorder.isRounded() || haveAlphaColor)
- && (haveAllSolidEdges || (!outerBorder.isRounded() && !innerBorder.isRounded()))) {
- Path path;
-
- if (outerBorder.isRounded() && allEdgesShareWidth) {
-
- // Very fast path for single stroked round rect with circular corners
-
- graphicsContext->fillBetweenRoundedRects(outerBorder, innerBorder, edges[firstVisibleEdge].color);
- return;
- }
- if (outerBorder.isRounded() && bleedAvoidance != BackgroundBleedClipBackground)
- path.addRoundedRect(outerBorder);
- else
- path.addRect(outerBorder.rect());
-
- if (haveAllDoubleEdges) {
- IntRect innerThirdRect = outerBorder.rect();
- IntRect outerThirdRect = outerBorder.rect();
- for (int side = BSTop; side <= BSLeft; ++side) {
- int outerWidth;
- int innerWidth;
- edges[side].getDoubleBorderStripeWidths(outerWidth, innerWidth);
-
- if (side == BSTop) {
- innerThirdRect.shiftYEdgeTo(innerThirdRect.y() + innerWidth);
- outerThirdRect.shiftYEdgeTo(outerThirdRect.y() + outerWidth);
- } else if (side == BSBottom) {
- innerThirdRect.setHeight(innerThirdRect.height() - innerWidth);
- outerThirdRect.setHeight(outerThirdRect.height() - outerWidth);
- } else if (side == BSLeft) {
- innerThirdRect.shiftXEdgeTo(innerThirdRect.x() + innerWidth);
- outerThirdRect.shiftXEdgeTo(outerThirdRect.x() + outerWidth);
- } else {
- innerThirdRect.setWidth(innerThirdRect.width() - innerWidth);
- outerThirdRect.setWidth(outerThirdRect.width() - outerWidth);
- }
- }
-
- RoundedRect outerThird = outerBorder;
- RoundedRect innerThird = innerBorder;
- innerThird.setRect(innerThirdRect);
- outerThird.setRect(outerThirdRect);
-
- if (outerThird.isRounded() && bleedAvoidance != BackgroundBleedClipBackground)
- path.addRoundedRect(outerThird);
- else
- path.addRect(outerThird.rect());
-
- if (innerThird.isRounded() && bleedAvoidance != BackgroundBleedClipBackground)
- path.addRoundedRect(innerThird);
- else
- path.addRect(innerThird.rect());
- }
-
- if (innerBorder.isRounded())
- path.addRoundedRect(innerBorder);
- else
- path.addRect(innerBorder.rect());
-
- graphicsContext->setFillRule(RULE_EVENODD);
- graphicsContext->setFillColor(edges[firstVisibleEdge].color);
- graphicsContext->fillPath(path);
- return;
- }
- // Avoid creating transparent layers
- if (haveAllSolidEdges && numEdgesVisible != 4 && !outerBorder.isRounded() && haveAlphaColor) {
- Path path;
-
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
- if (currEdge.shouldRender()) {
- IntRect sideRect = calculateSideRect(outerBorder, edges, i);
- path.addRect(sideRect);
- }
- }
-
- graphicsContext->setFillRule(RULE_NONZERO);
- graphicsContext->setFillColor(edges[firstVisibleEdge].color);
- graphicsContext->fillPath(path);
- return;
- }
- }
-
- bool clipToOuterBorder = outerBorder.isRounded();
- GraphicsContextStateSaver stateSaver(*graphicsContext, clipToOuterBorder);
- if (clipToOuterBorder) {
- // Clip to the inner and outer radii rects.
- if (bleedAvoidance != BackgroundBleedClipBackground)
- graphicsContext->clipRoundedRect(outerBorder);
- // isRenderable() check avoids issue described in https://bugs.webkit.org/show_bug.cgi?id=38787
- // The inside will be clipped out later (in clipBorderSideForComplexInnerPath)
- if (innerBorder.isRenderable() && !innerBorder.isEmpty())
- graphicsContext->clipOutRoundedRect(innerBorder);
- }
-
- // If only one edge visible antialiasing doesn't create seams
- bool antialias = shouldAntialiasLines(graphicsContext) || numEdgesVisible == 1;
- RoundedRect unadjustedInnerBorder = (bleedAvoidance == BackgroundBleedBackgroundOverBorder) ? style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge) : innerBorder;
- IntPoint innerBorderAdjustment(innerBorder.rect().x() - unadjustedInnerBorder.rect().x(), innerBorder.rect().y() - unadjustedInnerBorder.rect().y());
- if (haveAlphaColor)
- paintTranslucentBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, edgesToDraw, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
- else
- paintBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, edgesToDraw, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
-}
-
-void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdge edges[],
- float thickness, float drawThickness, BoxSide side, const RenderStyle* style, Color color, EBorderStyle borderStyle, BackgroundBleedAvoidance bleedAvoidance,
- bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
-{
- if (thickness <= 0)
- return;
-
- if (borderStyle == DOUBLE && thickness < 3)
- borderStyle = SOLID;
-
- switch (borderStyle) {
- case BNONE:
- case BHIDDEN:
- return;
- case DOTTED:
- case DASHED: {
- graphicsContext->setStrokeColor(color);
-
- // The stroke is doubled here because the provided path is the
- // outside edge of the border so half the stroke is clipped off.
- // The extra multiplier is so that the clipping mask can antialias
- // the edges to prevent jaggies.
- graphicsContext->setStrokeThickness(drawThickness * 2 * 1.1f);
- graphicsContext->setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke);
-
- // If the number of dashes that fit in the path is odd and non-integral then we
- // will have an awkwardly-sized dash at the end of the path. To try to avoid that
- // here, we simply make the whitespace dashes ever so slightly bigger.
- // FIXME: This could be even better if we tried to manipulate the dash offset
- // and possibly the gapLength to get the corners dash-symmetrical.
- float dashLength = thickness * ((borderStyle == DASHED) ? 3.0f : 1.0f);
- float gapLength = dashLength;
- float numberOfDashes = borderPath.length() / dashLength;
- // Don't try to show dashes if we have less than 2 dashes + 2 gaps.
- // FIXME: should do this test per side.
- if (numberOfDashes >= 4) {
- bool evenNumberOfFullDashes = !((int)numberOfDashes % 2);
- bool integralNumberOfDashes = !(numberOfDashes - (int)numberOfDashes);
- if (!evenNumberOfFullDashes && !integralNumberOfDashes) {
- float numberOfGaps = numberOfDashes / 2;
- gapLength += (dashLength / numberOfGaps);
- }
-
- DashArray lineDash;
- lineDash.append(dashLength);
- lineDash.append(gapLength);
- graphicsContext->setLineDash(lineDash, dashLength);
- }
-
- // FIXME: stroking the border path causes issues with tight corners:
- // https://bugs.webkit.org/show_bug.cgi?id=58711
- // Also, to get the best appearance we should stroke a path between the two borders.
- graphicsContext->strokePath(borderPath);
- return;
- }
- case DOUBLE: {
- // Get the inner border rects for both the outer border line and the inner border line
- int outerBorderTopWidth;
- int innerBorderTopWidth;
- edges[BSTop].getDoubleBorderStripeWidths(outerBorderTopWidth, innerBorderTopWidth);
-
- int outerBorderRightWidth;
- int innerBorderRightWidth;
- edges[BSRight].getDoubleBorderStripeWidths(outerBorderRightWidth, innerBorderRightWidth);
-
- int outerBorderBottomWidth;
- int innerBorderBottomWidth;
- edges[BSBottom].getDoubleBorderStripeWidths(outerBorderBottomWidth, innerBorderBottomWidth);
-
- int outerBorderLeftWidth;
- int innerBorderLeftWidth;
- edges[BSLeft].getDoubleBorderStripeWidths(outerBorderLeftWidth, innerBorderLeftWidth);
-
- // Draw inner border line
- {
- GraphicsContextStateSaver stateSaver(*graphicsContext);
- RoundedRect innerClip = style->getRoundedInnerBorderFor(borderRect,
- innerBorderTopWidth, innerBorderBottomWidth, innerBorderLeftWidth, innerBorderRightWidth,
- includeLogicalLeftEdge, includeLogicalRightEdge);
-
- graphicsContext->clipRoundedRect(innerClip);
- drawBoxSideFromPath(graphicsContext, borderRect, borderPath, edges, thickness, drawThickness, side, style, color, SOLID, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
- }
-
- // Draw outer border line
- {
- GraphicsContextStateSaver stateSaver(*graphicsContext);
- LayoutRect outerRect = borderRect;
- if (bleedAvoidance == BackgroundBleedClipBackground) {
- outerRect.inflate(1);
- ++outerBorderTopWidth;
- ++outerBorderBottomWidth;
- ++outerBorderLeftWidth;
- ++outerBorderRightWidth;
- }
-
- RoundedRect outerClip = style->getRoundedInnerBorderFor(outerRect,
- outerBorderTopWidth, outerBorderBottomWidth, outerBorderLeftWidth, outerBorderRightWidth,
- includeLogicalLeftEdge, includeLogicalRightEdge);
- graphicsContext->clipOutRoundedRect(outerClip);
- drawBoxSideFromPath(graphicsContext, borderRect, borderPath, edges, thickness, drawThickness, side, style, color, SOLID, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
- }
- return;
- }
- case RIDGE:
- case GROOVE:
- {
- EBorderStyle s1;
- EBorderStyle s2;
- if (borderStyle == GROOVE) {
- s1 = INSET;
- s2 = OUTSET;
- } else {
- s1 = OUTSET;
- s2 = INSET;
- }
-
- // Paint full border
- drawBoxSideFromPath(graphicsContext, borderRect, borderPath, edges, thickness, drawThickness, side, style, color, s1, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
-
- // Paint inner only
- GraphicsContextStateSaver stateSaver(*graphicsContext);
- LayoutUnit topWidth = edges[BSTop].usedWidth() / 2;
- LayoutUnit bottomWidth = edges[BSBottom].usedWidth() / 2;
- LayoutUnit leftWidth = edges[BSLeft].usedWidth() / 2;
- LayoutUnit rightWidth = edges[BSRight].usedWidth() / 2;
-
- RoundedRect clipRect = style->getRoundedInnerBorderFor(borderRect,
- topWidth, bottomWidth, leftWidth, rightWidth,
- includeLogicalLeftEdge, includeLogicalRightEdge);
-
- graphicsContext->clipRoundedRect(clipRect);
- drawBoxSideFromPath(graphicsContext, borderRect, borderPath, edges, thickness, drawThickness, side, style, color, s2, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge);
- return;
- }
- case INSET:
- if (side == BSTop || side == BSLeft)
- color = color.dark();
- break;
- case OUTSET:
- if (side == BSBottom || side == BSRight)
- color = color.dark();
- break;
- default:
- break;
- }
-
- graphicsContext->setStrokeStyle(NoStroke);
- graphicsContext->setFillColor(color);
- graphicsContext->drawRect(pixelSnappedIntRect(borderRect));
-}
-
-void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches)
-{
- FloatPoint quad[4];
-
- const LayoutRect& outerRect = outerBorder.rect();
- const LayoutRect& innerRect = innerBorder.rect();
-
- FloatPoint centerPoint(innerRect.location().x().toFloat() + innerRect.width().toFloat() / 2, innerRect.location().y().toFloat() + innerRect.height().toFloat() / 2);
-
- // For each side, create a quad that encompasses all parts of that side that may draw,
- // including areas inside the innerBorder.
- //
- // 0----------------3
- // 0 \ / 0
- // |\ 1----------- 2 /|
- // | 1 1 |
- // | | | |
- // | | | |
- // | 2 2 |
- // |/ 1------------2 \|
- // 3 / \ 3
- // 0----------------3
- //
- switch (side) {
- case BSTop:
- quad[0] = outerRect.minXMinYCorner();
- quad[1] = innerRect.minXMinYCorner();
- quad[2] = innerRect.maxXMinYCorner();
- quad[3] = outerRect.maxXMinYCorner();
-
- if (!innerBorder.radii().topLeft().isZero()) {
- findIntersection(quad[0], quad[1],
- FloatPoint(
- quad[1].x() + innerBorder.radii().topLeft().width(),
- quad[1].y()),
- FloatPoint(
- quad[1].x(),
- quad[1].y() + innerBorder.radii().topLeft().height()),
- quad[1]);
- }
-
- if (!innerBorder.radii().topRight().isZero()) {
- findIntersection(quad[3], quad[2],
- FloatPoint(
- quad[2].x() - innerBorder.radii().topRight().width(),
- quad[2].y()),
- FloatPoint(
- quad[2].x(),
- quad[2].y() + innerBorder.radii().topRight().height()),
- quad[2]);
- }
- break;
-
- case BSLeft:
- quad[0] = outerRect.minXMinYCorner();
- quad[1] = innerRect.minXMinYCorner();
- quad[2] = innerRect.minXMaxYCorner();
- quad[3] = outerRect.minXMaxYCorner();
-
- if (!innerBorder.radii().topLeft().isZero()) {
- findIntersection(quad[0], quad[1],
- FloatPoint(
- quad[1].x() + innerBorder.radii().topLeft().width(),
- quad[1].y()),
- FloatPoint(
- quad[1].x(),
- quad[1].y() + innerBorder.radii().topLeft().height()),
- quad[1]);
- }
-
- if (!innerBorder.radii().bottomLeft().isZero()) {
- findIntersection(quad[3], quad[2],
- FloatPoint(
- quad[2].x() + innerBorder.radii().bottomLeft().width(),
- quad[2].y()),
- FloatPoint(
- quad[2].x(),
- quad[2].y() - innerBorder.radii().bottomLeft().height()),
- quad[2]);
- }
- break;
-
- case BSBottom:
- quad[0] = outerRect.minXMaxYCorner();
- quad[1] = innerRect.minXMaxYCorner();
- quad[2] = innerRect.maxXMaxYCorner();
- quad[3] = outerRect.maxXMaxYCorner();
-
- if (!innerBorder.radii().bottomLeft().isZero()) {
- findIntersection(quad[0], quad[1],
- FloatPoint(
- quad[1].x() + innerBorder.radii().bottomLeft().width(),
- quad[1].y()),
- FloatPoint(
- quad[1].x(),
- quad[1].y() - innerBorder.radii().bottomLeft().height()),
- quad[1]);
- }
-
- if (!innerBorder.radii().bottomRight().isZero()) {
- findIntersection(quad[3], quad[2],
- FloatPoint(
- quad[2].x() - innerBorder.radii().bottomRight().width(),
- quad[2].y()),
- FloatPoint(
- quad[2].x(),
- quad[2].y() - innerBorder.radii().bottomRight().height()),
- quad[2]);
- }
- break;
-
- case BSRight:
- quad[0] = outerRect.maxXMinYCorner();
- quad[1] = innerRect.maxXMinYCorner();
- quad[2] = innerRect.maxXMaxYCorner();
- quad[3] = outerRect.maxXMaxYCorner();
-
- if (!innerBorder.radii().topRight().isZero()) {
- findIntersection(quad[0], quad[1],
- FloatPoint(
- quad[1].x() - innerBorder.radii().topRight().width(),
- quad[1].y()),
- FloatPoint(
- quad[1].x(),
- quad[1].y() + innerBorder.radii().topRight().height()),
- quad[1]);
- }
-
- if (!innerBorder.radii().bottomRight().isZero()) {
- findIntersection(quad[3], quad[2],
- FloatPoint(
- quad[2].x() - innerBorder.radii().bottomRight().width(),
- quad[2].y()),
- FloatPoint(
- quad[2].x(),
- quad[2].y() - innerBorder.radii().bottomRight().height()),
- quad[2]);
- }
- break;
- }
-
- // If the border matches both of its adjacent sides, don't anti-alias the clip, and
- // if neither side matches, anti-alias the clip.
- if (firstEdgeMatches == secondEdgeMatches) {
- graphicsContext->clipConvexPolygon(4, quad, !firstEdgeMatches);
- return;
- }
-
- // If antialiasing settings for the first edge and second edge is different,
- // they have to be addressed separately. We do this by breaking the quad into
- // two parallelograms, made by moving quad[1] and quad[2].
- float ax = quad[1].x() - quad[0].x();
- float ay = quad[1].y() - quad[0].y();
- float bx = quad[2].x() - quad[1].x();
- float by = quad[2].y() - quad[1].y();
- float cx = quad[3].x() - quad[2].x();
- float cy = quad[3].y() - quad[2].y();
-
- const static float kEpsilon = 1e-2f;
- float r1, r2;
- if (fabsf(bx) < kEpsilon && fabsf(by) < kEpsilon) {
- // The quad was actually a triangle.
- r1 = r2 = 1.0f;
- } else {
- // Extend parallelogram a bit to hide calculation error
- const static float kExtendFill = 1e-2f;
-
- r1 = (-ax * by + ay * bx) / (cx * by - cy * bx) + kExtendFill;
- r2 = (-cx * by + cy * bx) / (ax * by - ay * bx) + kExtendFill;
- }
-
- FloatPoint firstQuad[4];
- firstQuad[0] = quad[0];
- firstQuad[1] = quad[1];
- firstQuad[2] = FloatPoint(quad[3].x() + r2 * ax, quad[3].y() + r2 * ay);
- firstQuad[3] = quad[3];
- graphicsContext->clipConvexPolygon(4, firstQuad, !firstEdgeMatches);
-
- FloatPoint secondQuad[4];
- secondQuad[0] = quad[0];
- secondQuad[1] = FloatPoint(quad[0].x() - r1 * cx, quad[0].y() - r1 * cy);
- secondQuad[2] = quad[2];
- secondQuad[3] = quad[3];
- graphicsContext->clipConvexPolygon(4, secondQuad, !secondEdgeMatches);
-}
-
-static IntRect calculateSideRectIncludingInner(const RoundedRect& outerBorder, const BorderEdge edges[], BoxSide side)
-{
- IntRect sideRect = outerBorder.rect();
- int width;
-
- switch (side) {
- case BSTop:
- width = sideRect.height() - edges[BSBottom].width;
- sideRect.setHeight(width);
- break;
- case BSBottom:
- width = sideRect.height() - edges[BSTop].width;
- sideRect.shiftYEdgeTo(sideRect.maxY() - width);
- break;
- case BSLeft:
- width = sideRect.width() - edges[BSRight].width;
- sideRect.setWidth(width);
- break;
- case BSRight:
- width = sideRect.width() - edges[BSLeft].width;
- sideRect.shiftXEdgeTo(sideRect.maxX() - width);
- break;
- }
-
- return sideRect;
-}
-
-static RoundedRect calculateAdjustedInnerBorder(const RoundedRect&innerBorder, BoxSide side)
-{
- // Expand the inner border as necessary to make it a rounded rect (i.e. radii contained within each edge).
- // This function relies on the fact we only get radii not contained within each edge if one of the radii
- // for an edge is zero, so we can shift the arc towards the zero radius corner.
- RoundedRect::Radii newRadii = innerBorder.radii();
- IntRect newRect = innerBorder.rect();
-
- float overshoot;
- float maxRadii;
-
- switch (side) {
- case BSTop:
- overshoot = newRadii.topLeft().width() + newRadii.topRight().width() - newRect.width();
- if (overshoot > 0) {
- ASSERT(!(newRadii.topLeft().width() && newRadii.topRight().width()));
- newRect.setWidth(newRect.width() + overshoot);
- if (!newRadii.topLeft().width())
- newRect.move(-overshoot, 0);
- }
- newRadii.setBottomLeft(IntSize(0, 0));
- newRadii.setBottomRight(IntSize(0, 0));
- maxRadii = std::max(newRadii.topLeft().height(), newRadii.topRight().height());
- if (maxRadii > newRect.height())
- newRect.setHeight(maxRadii);
- break;
-
- case BSBottom:
- overshoot = newRadii.bottomLeft().width() + newRadii.bottomRight().width() - newRect.width();
- if (overshoot > 0) {
- ASSERT(!(newRadii.bottomLeft().width() && newRadii.bottomRight().width()));
- newRect.setWidth(newRect.width() + overshoot);
- if (!newRadii.bottomLeft().width())
- newRect.move(-overshoot, 0);
- }
- newRadii.setTopLeft(IntSize(0, 0));
- newRadii.setTopRight(IntSize(0, 0));
- maxRadii = std::max(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
- if (maxRadii > newRect.height()) {
- newRect.move(0, newRect.height() - maxRadii);
- newRect.setHeight(maxRadii);
- }
- break;
-
- case BSLeft:
- overshoot = newRadii.topLeft().height() + newRadii.bottomLeft().height() - newRect.height();
- if (overshoot > 0) {
- ASSERT(!(newRadii.topLeft().height() && newRadii.bottomLeft().height()));
- newRect.setHeight(newRect.height() + overshoot);
- if (!newRadii.topLeft().height())
- newRect.move(0, -overshoot);
- }
- newRadii.setTopRight(IntSize(0, 0));
- newRadii.setBottomRight(IntSize(0, 0));
- maxRadii = std::max(newRadii.topLeft().width(), newRadii.bottomLeft().width());
- if (maxRadii > newRect.width())
- newRect.setWidth(maxRadii);
- break;
-
- case BSRight:
- overshoot = newRadii.topRight().height() + newRadii.bottomRight().height() - newRect.height();
- if (overshoot > 0) {
- ASSERT(!(newRadii.topRight().height() && newRadii.bottomRight().height()));
- newRect.setHeight(newRect.height() + overshoot);
- if (!newRadii.topRight().height())
- newRect.move(0, -overshoot);
- }
- newRadii.setTopLeft(IntSize(0, 0));
- newRadii.setBottomLeft(IntSize(0, 0));
- maxRadii = std::max(newRadii.topRight().width(), newRadii.bottomRight().width());
- if (maxRadii > newRect.width()) {
- newRect.move(newRect.width() - maxRadii, 0);
- newRect.setWidth(maxRadii);
- }
- break;
- }
-
- return RoundedRect(newRect, newRadii);
-}
-
-void RenderBoxModelObject::clipBorderSideForComplexInnerPath(GraphicsContext* graphicsContext, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- BoxSide side, const class BorderEdge edges[])
-{
- graphicsContext->clip(calculateSideRectIncludingInner(outerBorder, edges, side));
- RoundedRect adjustedInnerRect = calculateAdjustedInnerBorder(innerBorder, side);
- if (!adjustedInnerRect.isEmpty())
- graphicsContext->clipOutRoundedRect(adjustedInnerRect);
-}
-
-void RenderBoxModelObject::getBorderEdgeInfo(BorderEdge edges[], const RenderStyle* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
-{
- bool horizontal = style->isHorizontalWritingMode();
-
- edges[BSTop] = BorderEdge(style->borderTopWidth(),
- resolveColor(style, CSSPropertyBorderTopColor),
- style->borderTopStyle(),
- style->borderTopIsTransparent(),
- horizontal || includeLogicalLeftEdge);
-
- edges[BSRight] = BorderEdge(style->borderRightWidth(),
- resolveColor(style, CSSPropertyBorderRightColor),
- style->borderRightStyle(),
- style->borderRightIsTransparent(),
- !horizontal || includeLogicalRightEdge);
-
- edges[BSBottom] = BorderEdge(style->borderBottomWidth(),
- resolveColor(style, CSSPropertyBorderBottomColor),
- style->borderBottomStyle(),
- style->borderBottomIsTransparent(),
- horizontal || includeLogicalRightEdge);
-
- edges[BSLeft] = BorderEdge(style->borderLeftWidth(),
- resolveColor(style, CSSPropertyBorderLeftColor),
- style->borderLeftStyle(),
- style->borderLeftIsTransparent(),
- !horizontal || includeLogicalLeftEdge);
-}
-
-bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& contextScale) const
-{
- BorderEdge edges[4];
- getBorderEdgeInfo(edges, style());
-
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
- // FIXME: for vertical text
- float axisScale = (i == BSTop || i == BSBottom) ? contextScale.height() : contextScale.width();
- if (!currEdge.obscuresBackgroundEdge(axisScale))
- return false;
- }
-
- return true;
-}
-
-bool RenderBoxModelObject::borderObscuresBackground() const
-{
- if (!style()->hasBorder())
- return false;
-
- // Bail if we have any border-image for now. We could look at the image alpha to improve this.
- if (style()->borderImage().image())
- return false;
-
- BorderEdge edges[4];
- getBorderEdgeInfo(edges, style());
-
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
- if (!currEdge.obscuresBackground())
- return false;
- }
-
- return true;
-}
-
-bool RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* inlineFlowBox) const
-{
- if (bleedAvoidance != BackgroundBleedNone)
- return false;
-
- if (style()->hasAppearance())
- return false;
-
- const ShadowList* shadowList = style()->boxShadow();
- if (!shadowList)
- return false;
-
- bool hasOneNormalBoxShadow = false;
- size_t shadowCount = shadowList->shadows().size();
- for (size_t i = 0; i < shadowCount; ++i) {
- const ShadowData& currentShadow = shadowList->shadows()[i];
- if (currentShadow.style() != Normal)
- continue;
-
- if (hasOneNormalBoxShadow)
- return false;
- hasOneNormalBoxShadow = true;
-
- if (currentShadow.spread())
- return false;
- }
-
- if (!hasOneNormalBoxShadow)
- return false;
-
- Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
- if (backgroundColor.hasAlpha())
- return false;
-
- const FillLayer* lastBackgroundLayer = &style()->backgroundLayers();
- for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastBackgroundLayer->next())
- lastBackgroundLayer = next;
-
- if (lastBackgroundLayer->clip() != BorderFillBox)
- return false;
-
- if (lastBackgroundLayer->image() && style()->hasBorderRadius())
- return false;
-
- if (inlineFlowBox && !inlineFlowBox->boxShadowCanBeAppliedToBackground(*lastBackgroundLayer))
- return false;
-
- if (hasOverflowClip() && lastBackgroundLayer->attachment() == LocalBackgroundAttachment)
- return false;
-
- return true;
-}
-
-void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRect& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
-{
- // FIXME: Deal with border-image. Would be great to use border-image as a mask.
- GraphicsContext* context = info.context;
- if (!s->boxShadow())
- return;
-
- RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge)
- : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge);
-
- bool hasBorderRadius = s->hasBorderRadius();
- bool isHorizontal = s->isHorizontalWritingMode();
- bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() == 255;
-
- GraphicsContextStateSaver stateSaver(*context, false);
-
- const ShadowList* shadowList = s->boxShadow();
- for (size_t i = shadowList->shadows().size(); i--; ) {
- const ShadowData& shadow = shadowList->shadows()[i];
- if (shadow.style() != shadowStyle)
- continue;
-
- FloatSize shadowOffset(shadow.x(), shadow.y());
- float shadowBlur = shadow.blur();
- float shadowSpread = shadow.spread();
-
- if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
- continue;
-
- const Color& shadowColor = shadow.color();
-
- if (shadow.style() == Normal) {
- FloatRect fillRect = border.rect();
- fillRect.inflate(shadowSpread);
- if (fillRect.isEmpty())
- continue;
-
- FloatRect shadowRect(border.rect());
- shadowRect.inflate(shadowBlur + shadowSpread);
- shadowRect.move(shadowOffset);
-
- // Save the state and clip, if not already done.
- // The clip does not depend on any shadow-specific properties.
- if (!stateSaver.saved()) {
- stateSaver.save();
- if (hasBorderRadius) {
- RoundedRect rectToClipOut = border;
-
- // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
- // when painting the shadow. On the other hand, it introduces subpixel gaps along the
- // corners. Those are avoided by insetting the clipping path by one pixel.
- if (hasOpaqueBackground)
- rectToClipOut.inflateWithRadii(-1);
-
- if (!rectToClipOut.isEmpty()) {
- context->clipOutRoundedRect(rectToClipOut);
- }
- } else {
- // This IntRect is correct even with fractional shadows, because it is used for the rectangle
- // of the box itself, which is always pixel-aligned.
- IntRect rectToClipOut = border.rect();
-
- // If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
- // when painting the shadow. On the other hand, it introduces subpixel gaps along the
- // edges if they are not pixel-aligned. Those are avoided by insetting the clipping path
- // by one pixel.
- if (hasOpaqueBackground) {
- // FIXME: The function to decide on the policy based on the transform should be a named function.
- // FIXME: It's not clear if this check is right. What about integral scale factors?
- // FIXME: See crbug.com/382491. The use of getCTM may also be wrong because it does not include
- // device zoom applied at raster time.
- AffineTransform transform = context->getCTM();
- if (transform.a() != 1 || (transform.d() != 1 && transform.d() != -1) || transform.b() || transform.c())
- rectToClipOut.inflate(-1);
- }
-
- if (!rectToClipOut.isEmpty()) {
- context->clipOut(rectToClipOut);
- }
- }
- }
-
- // Draw only the shadow.
- OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
- drawLooperBuilder->addShadow(shadowOffset, shadowBlur, shadowColor,
- DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha);
- context->setDrawLooper(drawLooperBuilder.release());
-
- if (hasBorderRadius) {
- RoundedRect influenceRect(pixelSnappedIntRect(LayoutRect(shadowRect)), border.radii());
- influenceRect.expandRadii(2 * shadowBlur + shadowSpread);
- if (allCornersClippedOut(influenceRect, info.rect))
- context->fillRect(fillRect, Color::black);
- else {
- // TODO: support non-integer shadows - crbug.com/334829
- RoundedRect roundedFillRect = border;
- roundedFillRect.inflate(shadowSpread);
-
- roundedFillRect.expandRadii(shadowSpread);
- if (!roundedFillRect.isRenderable())
- roundedFillRect.adjustRadii();
- context->fillRoundedRect(roundedFillRect, Color::black);
- }
- } else {
- context->fillRect(fillRect, Color::black);
- }
- } else {
- // The inset shadow case.
- GraphicsContext::Edges clippedEdges = GraphicsContext::NoEdge;
- if (!includeLogicalLeftEdge) {
- if (isHorizontal)
- clippedEdges |= GraphicsContext::LeftEdge;
- else
- clippedEdges |= GraphicsContext::TopEdge;
- }
- if (!includeLogicalRightEdge) {
- if (isHorizontal)
- clippedEdges |= GraphicsContext::RightEdge;
- else
- clippedEdges |= GraphicsContext::BottomEdge;
- }
- // TODO: support non-integer shadows - crbug.com/334828
- context->drawInnerShadow(border, shadowColor, flooredIntSize(shadowOffset), shadowBlur, shadowSpread, clippedEdges);
- }
- }
-}
-
-LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
-{
- return containingBlock()->availableLogicalWidth();
-}
-
-RenderBoxModelObject* RenderBoxModelObject::continuation() const
-{
- if (!continuationMap)
- return 0;
- return (*continuationMap)->get(this);
-}
-
-void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
-{
- if (continuation) {
- if (!continuationMap)
- continuationMap = new OwnPtrWillBePersistent<ContinuationMap>(adoptPtrWillBeNoop(new ContinuationMap));
- (*continuationMap)->set(this, continuation);
- } else {
- if (continuationMap)
- (*continuationMap)->remove(this);
- }
-}
-
-void RenderBoxModelObject::computeLayerHitTestRects(LayerHitTestRects& rects) const
-{
- RenderLayerModelObject::computeLayerHitTestRects(rects);
-
- // If there is a continuation then we need to consult it here, since this is
- // the root of the tree walk and it wouldn't otherwise get picked up.
- // Continuations should always be siblings in the tree, so any others should
- // get picked up already by the tree walk.
- if (continuation())
- continuation()->computeLayerHitTestRects(rects);
-}
-
-RenderTextFragment* RenderBoxModelObject::firstLetterRemainingText() const
-{
- if (!firstLetterRemainingTextMap)
- return 0;
- return (*firstLetterRemainingTextMap)->get(this);
-}
-
-void RenderBoxModelObject::setFirstLetterRemainingText(RenderTextFragment* remainingText)