diff options
Diffstat (limited to 'WebCore/rendering/RenderBoxModelObject.cpp')
| -rw-r--r-- | WebCore/rendering/RenderBoxModelObject.cpp | 102 |
1 files changed, 57 insertions, 45 deletions
diff --git a/WebCore/rendering/RenderBoxModelObject.cpp b/WebCore/rendering/RenderBoxModelObject.cpp index f8bf05e..9caf46f 100644 --- a/WebCore/rendering/RenderBoxModelObject.cpp +++ b/WebCore/rendering/RenderBoxModelObject.cpp @@ -131,7 +131,7 @@ bool RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality(GraphicsCont data = gBoxModelObjects->get(object); const AffineTransform& currentTransform = context->getCTM(); - bool contextIsScaled = !currentTransform.isIdentityOrTranslation(); + bool contextIsScaled = !currentTransform.isIdentityOrTranslationOrFlipped(); if (!contextIsScaled && imageSize == size) { // There is no scale in effect. If we had a scale in effect before, we can just delete this data. if (data) { @@ -158,8 +158,10 @@ bool RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality(GraphicsCont return false; } + const AffineTransform& tr = data->transform(); + bool scaleUnchanged = tr.a() == currentTransform.a() && tr.b() == currentTransform.b() && tr.c() == currentTransform.c() && tr.d() == currentTransform.d(); // We are scaled, but we painted already at this size, so just keep using whatever mode we last painted with. - if ((!contextIsScaled || data->transform() == currentTransform) && data->size() == size) + if ((!contextIsScaled || scaleUnchanged) && data->size() == size) return data->useLowQualityScale(); // We have data and our size just changed. If this change happened quickly, go into low quality mode and then set a repaint @@ -479,7 +481,9 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co context->clip(toRenderBox(this)->overflowClipRect(tx, ty)); // Now adjust our tx, ty, w, h to reflect a scrolled content box with borders at the ends. - layer()->subtractScrolledContentOffset(tx, ty); + IntSize offset = layer()->scrolledContentOffset(); + tx -= offset.width(); + ty -= offset.height(); w = bLeft + layer()->scrollWidth() + bRight; h = borderTop() + layer()->scrollHeight() + borderBottom(); } @@ -604,7 +608,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op; RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this; Image* image = bg->image(clientForBackgroundImage, tileSize); - bool useLowQualityScaling = RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality(context, this, image, destRect.size()); + bool useLowQualityScaling = RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality(context, this, image, tileSize); context->drawTiledImage(image, style()->colorSpace(), destRect, phase, tileSize, compositeOp, useLowQualityScaling); } } @@ -632,6 +636,7 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, case SizeLength: { int w = positioningAreaSize.width(); int h = positioningAreaSize.height(); + Length layerWidth = fillLayer->size().size.width(); Length layerHeight = fillLayer->size().size.height(); @@ -647,15 +652,19 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, // If one of the values is auto we have to use the appropriate // scale to maintain our aspect ratio. - if (layerWidth.isAuto() && !layerHeight.isAuto()) - w = image->imageSize(this, style()->effectiveZoom()).width() * h / image->imageSize(this, style()->effectiveZoom()).height(); - else if (!layerWidth.isAuto() && layerHeight.isAuto()) - h = image->imageSize(this, style()->effectiveZoom()).height() * w / image->imageSize(this, style()->effectiveZoom()).width(); - else if (layerWidth.isAuto() && layerHeight.isAuto()) { - // If both width and height are auto, we just want to use the image's - // intrinsic size. - w = image->imageSize(this, style()->effectiveZoom()).width(); - h = image->imageSize(this, style()->effectiveZoom()).height(); + if (layerWidth.isAuto() && !layerHeight.isAuto()) { + IntSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom()); + if (imageIntrinsicSize.height()) + w = imageIntrinsicSize.width() * h / imageIntrinsicSize.height(); + } else if (!layerWidth.isAuto() && layerHeight.isAuto()) { + IntSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom()); + if (imageIntrinsicSize.width()) + h = imageIntrinsicSize.height() * w / imageIntrinsicSize.width(); + } else if (layerWidth.isAuto() && layerHeight.isAuto()) { + // If both width and height are auto, use the image's intrinsic size. + IntSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom()); + w = imageIntrinsicSize.width(); + h = imageIntrinsicSize.height(); } return IntSize(max(1, w), max(1, h)); @@ -663,15 +672,17 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, case Contain: case Cover: { IntSize imageIntrinsicSize = image->imageSize(this, 1); - float horizontalScaleFactor = static_cast<float>(positioningAreaSize.width()) / imageIntrinsicSize.width(); - float verticalScaleFactor = static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height(); + float horizontalScaleFactor = imageIntrinsicSize.width() + ? static_cast<float>(positioningAreaSize.width()) / imageIntrinsicSize.width() : 1; + float verticalScaleFactor = imageIntrinsicSize.height() + ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height() : 1; float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor); - return IntSize(max<int>(1, imageIntrinsicSize.width() * scaleFactor), max<int>(1, imageIntrinsicSize.height() * scaleFactor)); } case SizeNone: break; } + return image->imageSize(this, style()->effectiveZoom()); } @@ -791,7 +802,8 @@ int RenderBoxModelObject::verticalPosition(bool firstLine) const vpos += -static_cast<int>(f.xHeight() / 2) - lineHeight(firstLine) / 2 + baselinePosition(firstLine); else if (va == TEXT_BOTTOM) { vpos += f.descent(); - if (!isReplaced()) // lineHeight - baselinePosition is always 0 for replaced elements, so don't bother wasting time in that case. + // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case. + if (!isReplaced() || style()->display() == INLINE_BLOCK) vpos -= (lineHeight(firstLine) - baselinePosition(firstLine)); } else if (va == BASELINE_MIDDLE) vpos += -lineHeight(firstLine) / 2 + baselinePosition(firstLine); @@ -822,10 +834,10 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, int imageWidth = imageSize.width(); int imageHeight = imageSize.height(); - int topSlice = min(imageHeight, ninePieceImage.m_slices.top().calcValue(imageHeight)); - int bottomSlice = min(imageHeight, ninePieceImage.m_slices.bottom().calcValue(imageHeight)); - int leftSlice = min(imageWidth, ninePieceImage.m_slices.left().calcValue(imageWidth)); - int rightSlice = min(imageWidth, ninePieceImage.m_slices.right().calcValue(imageWidth)); + int topSlice = min(imageHeight, ninePieceImage.slices().top().calcValue(imageHeight)); + int bottomSlice = min(imageHeight, ninePieceImage.slices().bottom().calcValue(imageHeight)); + int leftSlice = min(imageWidth, ninePieceImage.slices().left().calcValue(imageWidth)); + int rightSlice = min(imageWidth, ninePieceImage.slices().right().calcValue(imageWidth)); ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); ENinePieceImageRule vRule = ninePieceImage.verticalRule(); @@ -915,15 +927,15 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, } void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, - const RenderStyle* style, bool begin, bool end) + const RenderStyle* style, bool begin, bool end) { if (paintNinePieceImage(graphicsContext, tx, ty, w, h, style, style->borderImage())) return; - const Color& topColor = style->borderTopColor(); - const Color& bottomColor = style->borderBottomColor(); - const Color& leftColor = style->borderLeftColor(); - const Color& rightColor = style->borderRightColor(); + const Color& topColor = style->visitedDependentColor(CSSPropertyBorderTopColor); + const Color& bottomColor = style->visitedDependentColor(CSSPropertyBorderBottomColor); + const Color& leftColor = style->visitedDependentColor(CSSPropertyBorderLeftColor); + const Color& rightColor = style->visitedDependentColor(CSSPropertyBorderRightColor); bool topTransparent = style->borderTopIsTransparent(); bool bottomTransparent = style->borderBottomIsTransparent(); @@ -988,7 +1000,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, x2 -= topRight.width(); } - drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, style->color(), topStyle, + drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, topStyle, ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth()); if (renderRadii) { @@ -1016,7 +1028,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw upper left arc drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan, - BSTop, topColor, style->color(), topStyle, true); + BSTop, topColor, topStyle, true); if (applyLeftInnerClip) graphicsContext->restore(); } @@ -1042,7 +1054,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw upper right arc drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan, - BSTop, topColor, style->color(), topStyle, false); + BSTop, topColor, topStyle, false); if (applyRightInnerClip) graphicsContext->restore(); } @@ -1065,7 +1077,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, x2 -= bottomRight.width(); } - drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, style->color(), bottomStyle, + drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, bottomStyle, ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth()); if (renderRadii) { @@ -1093,7 +1105,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw lower left arc drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan, - BSBottom, bottomColor, style->color(), bottomStyle, true); + BSBottom, bottomColor, bottomStyle, true); if (applyLeftInnerClip) graphicsContext->restore(); } @@ -1115,7 +1127,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw lower right arc drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, bottomRight, secondAngleStart, secondAngleSpan, - BSBottom, bottomColor, style->color(), bottomStyle, false); + BSBottom, bottomColor, bottomStyle, false); if (applyRightInnerClip) graphicsContext->restore(); } @@ -1138,7 +1150,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, y2 -= bottomLeft.height(); } - drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, style->color(), leftStyle, + drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, leftStyle, ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) { @@ -1161,7 +1173,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw top left arc drawArcForBoxSide(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan, - BSLeft, leftColor, style->color(), leftStyle, true); + BSLeft, leftColor, leftStyle, true); if (applyTopInnerClip) graphicsContext->restore(); } @@ -1182,7 +1194,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw bottom left arc drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan, - BSLeft, leftColor, style->color(), leftStyle, false); + BSLeft, leftColor, leftStyle, false); if (applyBottomInnerClip) graphicsContext->restore(); } @@ -1207,7 +1219,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, y2 -= bottomRight.height(); } - drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, style->color(), rightStyle, + drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, rightStyle, ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth()); if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) { @@ -1230,7 +1242,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw top right arc drawArcForBoxSide(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan, - BSRight, rightColor, style->color(), rightStyle, true); + BSRight, rightColor, rightStyle, true); if (applyTopInnerClip) graphicsContext->restore(); } @@ -1252,7 +1264,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, // Draw bottom right arc drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan, - BSRight, rightColor, style->color(), rightStyle, false); + BSRight, rightColor, rightStyle, false); if (applyBottomInnerClip) graphicsContext->restore(); } @@ -1310,16 +1322,16 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int } bool hasOpaqueBackground = s->backgroundColor().isValid() && s->backgroundColor().alpha() == 255; - for (ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next) { - if (shadow->style != shadowStyle) + for (const ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next()) { + if (shadow->style() != shadowStyle) continue; - IntSize shadowOffset(shadow->x, shadow->y); - int shadowBlur = shadow->blur; - int shadowSpread = shadow->spread; - Color& shadowColor = shadow->color; + IntSize shadowOffset(shadow->x(), shadow->y()); + int shadowBlur = shadow->blur(); + int shadowSpread = shadow->spread(); + const Color& shadowColor = shadow->color(); - if (shadow->style == Normal) { + if (shadow->style() == Normal) { IntRect fillRect(rect); fillRect.inflate(shadowSpread); if (fillRect.isEmpty()) |
