Ignore:
Timestamp:
Oct 28, 2013, 7:58:43 PM (12 years ago)
Author:
[email protected]
Message:

RenderElement::style() should return a reference.
<https://webkit.org/b/123414>

Now that renderers always have style, go ahead and make style()
return a RenderStyle&.

There are countless opportunities for further cleanup enabled by
this change. I'm simply passing &style() in many cases where we
can really do something nicer instead.

Reviewed by Anders Carlsson.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r158097 r158163  
    122122    // imageSize() returns 0 for the error image. We need the true size of the
    123123    // error image, so we have to get it by grabbing image() directly.
    124     return IntSize(paddingWidth + imageSize.width() * style()->effectiveZoom(), paddingHeight + imageSize.height() * style()->effectiveZoom());
     124    return IntSize(paddingWidth + imageSize.width() * style().effectiveZoom(), paddingHeight + imageSize.height() * style().effectiveZoom());
    125125}
    126126
     
    141141        FontCachePurgePreventer fontCachePurgePreventer;
    142142
    143         const Font& font = style()->font();
    144         IntSize paddedTextSize(paddingWidth + min(ceilf(font.width(RenderBlock::constructTextRun(this, font, m_altText, *style()))), maxAltTextWidth), paddingHeight + min(font.fontMetrics().height(), maxAltTextHeight));
     143        const Font& font = style().font();
     144        IntSize paddedTextSize(paddingWidth + min(ceilf(font.width(RenderBlock::constructTextRun(this, font, m_altText, style()))), maxAltTextWidth), paddingHeight + min(font.fontMetrics().height(), maxAltTextHeight));
    145145        imageSize = imageSize.expandedTo(paddedTextSize);
    146146    }
     
    162162    }
    163163#if ENABLE(CSS_IMAGE_ORIENTATION)
    164     if (diff == StyleDifferenceLayout && oldStyle->imageOrientation() != style()->imageOrientation())
     164    if (diff == StyleDifferenceLayout && oldStyle->imageOrientation() != style().imageOrientation())
    165165        return imageDimensionsChanged(true /* imageSizeChanged */);
    166166#endif
     
    168168#if ENABLE(CSS_IMAGE_RESOLUTION)
    169169    if (diff == StyleDifferenceLayout
    170         && (oldStyle->imageResolution() != style()->imageResolution()
    171             || oldStyle->imageResolutionSnap() != style()->imageResolutionSnap()
    172             || oldStyle->imageResolutionSource() != style()->imageResolutionSource()))
     170        && (oldStyle->imageResolution() != style().imageResolution()
     171            || oldStyle->imageResolutionSnap() != style().imageResolutionSnap()
     172            || oldStyle->imageResolutionSource() != style().imageResolutionSource()))
    173173        imageDimensionsChanged(true /* imageSizeChanged */);
    174174#endif
     
    238238{
    239239#if ENABLE(CSS_IMAGE_RESOLUTION)
    240     double scale = style()->imageResolution();
    241     if (style()->imageResolutionSnap() == ImageResolutionSnapPixels)
     240    double scale = style().imageResolution();
     241    if (style().imageResolutionSnap() == ImageResolutionSnapPixels)
    242242        scale = roundForImpreciseConversion<int>(scale);
    243243    if (scale <= 0)
    244244        scale = 1;
    245     bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->intrinsicSize(style()->effectiveZoom() / scale), imageSizeChanged);
     245    bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->intrinsicSize(style().effectiveZoom() / scale), imageSizeChanged);
    246246#else
    247     bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->intrinsicSize(style()->effectiveZoom()), imageSizeChanged);
     247    bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->intrinsicSize(style().effectiveZoom()), imageSizeChanged);
    248248#endif
    249249
     
    275275        // There's no easy way to detect that shrink-to-fit is needed, always force a layout.
    276276        bool containingBlockNeedsToRecomputePreferredSize =
    277             style()->logicalWidth().isPercent()
    278             || style()->logicalMaxWidth().isPercent()
    279             || style()->logicalMinWidth().isPercent();
     277            style().logicalWidth().isPercent()
     278            || style().logicalMaxWidth().isPercent()
     279            || style().logicalMinWidth().isPercent();
    280280
    281281        if (imageSizeChanged || hasOverrideSize || containingBlockNeedsToRecomputePreferredSize) {
     
    363363            // Draw an outline rect where the image should be.
    364364            context->setStrokeStyle(SolidStroke);
    365             context->setStrokeColor(Color::lightGray, style()->colorSpace());
    366             context->setFillColor(Color::transparent, style()->colorSpace());
     365            context->setStrokeColor(Color::lightGray, style().colorSpace());
     366            context->setFillColor(Color::transparent, style().colorSpace());
    367367            context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight)));
    368368
     
    394394                ImageOrientationDescription orientationDescription;
    395395#if ENABLE(CSS_IMAGE_ORIENTATION)
    396                 orientationDescription.setImageOrientationEnum(style()->imageOrientation());
     396                orientationDescription.setImageOrientationEnum(style().imageOrientation());
    397397                orientationDescription.setRespectImageOrientation(shouldRespectImageOrientation());
    398398#endif
    399                 context->drawImage(image.get(), style()->colorSpace(), pixelSnappedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOver, orientationDescription);
     399                context->drawImage(image.get(), style().colorSpace(), pixelSnappedIntRect(LayoutRect(paintOffset + imageOffset, imageSize)), CompositeSourceOver, orientationDescription);
    400400                errorPictureDrawn = true;
    401401            }
     
    403403            if (!m_altText.isEmpty()) {
    404404                String text = document().displayStringModifiedByEncoding(m_altText);
    405                 context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
    406                 const Font& font = style()->font();
     405                context->setFillColor(style().visitedDependentColor(CSSPropertyColor), style().colorSpace());
     406                const Font& font = style().font();
    407407                const FontMetrics& fontMetrics = font.fontMetrics();
    408408                LayoutUnit ascent = fontMetrics.ascent();
     
    412412                // Only draw the alt text if it'll fit within the content box,
    413413                // and only if it fits above the error image.
    414                 TextRun textRun = RenderBlock::constructTextRun(this, font, text, *style());
     414                TextRun textRun = RenderBlock::constructTextRun(this, font, text, style());
    415415                LayoutUnit textWidth = font.width(textRun);
    416416                if (errorPictureDrawn) {
     
    430430
    431431#if PLATFORM(MAC)
    432         if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
    433             paintCustomHighlight(toPoint(paintOffset - location()), style()->highlight(), true);
     432        if (style().highlight() != nullAtom && !paintInfo.context->paintingDisabled())
     433            paintCustomHighlight(toPoint(paintOffset - location()), style().highlight(), true);
    434434#endif
    435435
     
    526526    ImageOrientationDescription orientationDescription;
    527527#if ENABLE(CSS_IMAGE_ORIENTATION)
    528     orientationDescription.setImageOrientationEnum(style()->imageOrientation());
     528    orientationDescription.setImageOrientationEnum(style().imageOrientation());
    529529    orientationDescription.setRespectImageOrientation(shouldRespectImageOrientation());
    530530#endif
    531     context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, orientationDescription, useLowQualityScaling);
     531    context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style().colorSpace(), alignedRect, compositeOperator, orientationDescription, useLowQualityScaling);
    532532}
    533533
     
    549549    if (!contentBoxRect().contains(localRect))
    550550        return false;
    551     EFillBox backgroundClip = style()->backgroundClip();
     551    EFillBox backgroundClip = style().backgroundClip();
    552552    // Background paints under borders.
    553     if (backgroundClip == BorderFillBox && style()->hasBorder() && !borderObscuresBackground())
     553    if (backgroundClip == BorderFillBox && style().hasBorder() && !borderObscuresBackground())
    554554        return false;
    555555    // Background shows in padding area.
    556     if ((backgroundClip == BorderFillBox || backgroundClip == PaddingFillBox) && style()->hasPadding())
     556    if ((backgroundClip == BorderFillBox || backgroundClip == PaddingFillBox) && style().hasPadding())
    557557        return false;
    558558    // Object-fit may leave parts of the content box empty.
    559     ObjectFit objectFit = style()->objectFit();
     559    ObjectFit objectFit = style().objectFit();
    560560    if (objectFit != ObjectFitFill && objectFit != ObjectFitCover)
    561561        return false;
     
    594594        if (HTMLMapElement* map = imageMap()) {
    595595            LayoutRect contentBox = contentBoxRect();
    596             float scaleFactor = 1 / style()->effectiveZoom();
     596            float scaleFactor = 1 / style().effectiveZoom();
    597597            LayoutPoint mapLocation = locationInContainer.point() - toLayoutSize(accumulatedOffset) - locationOffset() - toLayoutSize(contentBox.location());
    598598            mapLocation.scale(scaleFactor, scaleFactor);
Note: See TracChangeset for help on using the changeset viewer.