📄 renderboxmodelobject.cpp
字号:
secondAngleSpan = 45; } // Draw upper right arc drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan, BSTop, tc, style->color(), ts, false); if (applyRightInnerClip) graphicsContext->restore(); } } } if (renderBottom) { bool ignore_left = (renderRadii && bottomLeft.width() > 0) || (bc == lc && bt == lt && bs >= OUTSET && (ls == DOTTED || ls == DASHED || ls == SOLID || ls == OUTSET)); bool ignore_right = (renderRadii && bottomRight.width() > 0) || (bc == rc && bt == rt && bs >= OUTSET && (rs == DOTTED || rs == DASHED || rs == SOLID || rs == INSET)); int x = tx; int x2 = tx + w; if (renderRadii) { x += bottomLeft.width(); x2 -= bottomRight.width(); } drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bc, style->color(), bs, ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth()); if (renderRadii) { thickness = style->borderBottomWidth() * 2; if (bottomLeft.width()) { int leftX = tx; int leftY = ty + h - bottomLeft.height() * 2; bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width()) && (style->borderBottomWidth() < bottomLeft.height()) && (bs != DOUBLE || style->borderBottomWidth() > 6); if (applyLeftInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2), style->borderBottomWidth()); } if (lowerLeftBorderStylesMatch) { firstAngleStart = 180; firstAngleSpan = 90; } else { firstAngleStart = 225; firstAngleSpan = 45; } // Draw lower left arc drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan, BSBottom, bc, style->color(), bs, true); if (applyLeftInnerClip) graphicsContext->restore(); } if (bottomRight.width()) { int rightY = ty + h - bottomRight.height() * 2; int rightX = tx + w - bottomRight.width() * 2; bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width()) && (style->borderBottomWidth() < bottomRight.height()) && (bs != DOUBLE || style->borderBottomWidth() > 6); if (applyRightInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, bottomRight.width() * 2, bottomRight.height() * 2), style->borderBottomWidth()); } secondAngleStart = 270; secondAngleSpan = lowerRightBorderStylesMatch ? 90 : 45; // Draw lower right arc drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, bottomRight, secondAngleStart, secondAngleSpan, BSBottom, bc, style->color(), bs, false); if (applyRightInnerClip) graphicsContext->restore(); } } } if (renderLeft) { bool ignore_top = (renderRadii && topLeft.height() > 0) || (tc == lc && tt == lt && ls >= OUTSET && (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET)); bool ignore_bottom = (renderRadii && bottomLeft.height() > 0) || (bc == lc && bt == lt && ls >= OUTSET && (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET)); int y = ty; int y2 = ty + h; if (renderRadii) { y += topLeft.height(); y2 -= bottomLeft.height(); } drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, lc, style->color(), ls, ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) { int topX = tx; thickness = style->borderLeftWidth() * 2; if (!upperLeftBorderStylesMatch && topLeft.width()) { int topY = ty; bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width()) && (style->borderTopWidth() < topLeft.height()) && (ls != DOUBLE || style->borderLeftWidth() > 6); if (applyTopInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2), style->borderLeftWidth()); } firstAngleStart = 135; firstAngleSpan = 45; // Draw top left arc drawArcForBoxSide(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan, BSLeft, lc, style->color(), ls, true); if (applyTopInnerClip) graphicsContext->restore(); } if (!lowerLeftBorderStylesMatch && bottomLeft.width()) { int bottomY = ty + h - bottomLeft.height() * 2; bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width()) && (style->borderBottomWidth() < bottomLeft.height()) && (ls != DOUBLE || style->borderLeftWidth() > 6); if (applyBottomInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2), style->borderLeftWidth()); } secondAngleStart = 180; secondAngleSpan = 45; // Draw bottom left arc drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan, BSLeft, lc, style->color(), ls, false); if (applyBottomInnerClip) graphicsContext->restore(); } } } if (renderRight) { bool ignore_top = (renderRadii && topRight.height() > 0) || ((tc == rc) && (tt == rt) && (rs >= DOTTED || rs == INSET) && (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET)); bool ignore_bottom = (renderRadii && bottomRight.height() > 0) || ((bc == rc) && (bt == rt) && (rs >= DOTTED || rs == INSET) && (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET)); int y = ty; int y2 = ty + h; if (renderRadii) { y += topRight.height(); y2 -= bottomRight.height(); } drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rc, style->color(), rs, ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) { thickness = style->borderRightWidth() * 2; if (!upperRightBorderStylesMatch && topRight.width()) { int topX = tx + w - topRight.width() * 2; int topY = ty; bool applyTopInnerClip = (style->borderRightWidth() < topRight.width()) && (style->borderTopWidth() < topRight.height()) && (rs != DOUBLE || style->borderRightWidth() > 6); if (applyTopInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2), style->borderRightWidth()); } firstAngleStart = 0; firstAngleSpan = 45; // Draw top right arc drawArcForBoxSide(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan, BSRight, rc, style->color(), rs, true); if (applyTopInnerClip) graphicsContext->restore(); } if (!lowerRightBorderStylesMatch && bottomRight.width()) { int bottomX = tx + w - bottomRight.width() * 2; int bottomY = ty + h - bottomRight.height() * 2; bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width()) && (style->borderBottomWidth() < bottomRight.height()) && (rs != DOUBLE || style->borderRightWidth() > 6); if (applyBottomInnerClip) { graphicsContext->save(); graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2), style->borderRightWidth()); } secondAngleStart = 315; secondAngleSpan = 45; // Draw bottom right arc drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan, BSRight, rc, style->color(), rs, false); if (applyBottomInnerClip) graphicsContext->restore(); } } } if (renderRadii) graphicsContext->restore();}void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, bool begin, bool end){ // FIXME: Deal with border-image. Would be great to use border-image as a mask. IntRect rect(tx, ty, w, h); bool hasBorderRadius = s->hasBorderRadius(); bool hasOpaqueBackground = s->backgroundColor().isValid() && s->backgroundColor().alpha() == 255; for (ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next) { context->save(); IntSize shadowOffset(shadow->x, shadow->y); int shadowBlur = shadow->blur; IntRect fillRect(rect); if (hasBorderRadius) { IntRect shadowRect(rect); shadowRect.inflate(shadowBlur); shadowRect.move(shadowOffset); context->clip(shadowRect); // Move the fill just outside the clip, adding 1 pixel separation so that the fill does not // bleed in (due to antialiasing) if the context is transformed. IntSize extraOffset(w + max(0, shadowOffset.width()) + shadowBlur + 1, 0); shadowOffset -= extraOffset; fillRect.move(extraOffset); } context->setShadow(shadowOffset, shadowBlur, shadow->color); if (hasBorderRadius) { IntSize topLeft = begin ? s->borderTopLeftRadius() : IntSize(); IntSize topRight = end ? s->borderTopRightRadius() : IntSize(); IntSize bottomLeft = begin ? s->borderBottomLeftRadius() : IntSize(); IntSize bottomRight = end ? s->borderBottomRightRadius() : IntSize(); if (!hasOpaqueBackground) context->clipOutRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); context->fillRoundedRect(fillRect, topLeft, topRight, bottomLeft, bottomRight, Color::black); } else { if (!hasOpaqueBackground) context->clipOut(rect); context->fillRect(fillRect, Color::black); } context->restore(); }}int RenderBoxModelObject::containingBlockWidthForContent() const{ return containingBlock()->availableWidth();}} // namespace WebCore
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -