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/RenderReplaced.cpp

    r158097 r158163  
    8282    bool hadStyle = (oldStyle != 0);
    8383    float oldZoom = hadStyle ? oldStyle->effectiveZoom() : RenderStyle::initialZoom();
    84     if (style() && style()->effectiveZoom() != oldZoom)
     84    if (style().effectiveZoom() != oldZoom)
    8585        intrinsicSizeChanged();
    8686}
     
    109109void RenderReplaced::intrinsicSizeChanged()
    110110{
    111     int scaledWidth = static_cast<int>(cDefaultWidth * style()->effectiveZoom());
    112     int scaledHeight = static_cast<int>(cDefaultHeight * style()->effectiveZoom());
     111    int scaledWidth = static_cast<int>(cDefaultWidth * style().effectiveZoom());
     112    int scaledHeight = static_cast<int>(cDefaultHeight * style().effectiveZoom());
    113113    m_intrinsicSize = IntSize(scaledWidth, scaledHeight);
    114114    setNeedsLayoutAndPrefWidthsRecalc();
     
    131131
    132132    LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size());
    133     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
     133    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style().outlineWidth())
    134134        paintOutline(paintInfo, paintRect);
    135135   
     
    148148
    149149    bool completelyClippedOut = false;
    150     if (style()->hasBorderRadius()) {
     150    if (style().hasBorderRadius()) {
    151151        LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());
    152152
     
    156156            // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
    157157            paintInfo.context->save();
    158             RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(paintRect,
     158            RoundedRect roundedInnerRect = style().getRoundedInnerBorderFor(paintRect,
    159159                paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
    160160            clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect);
     
    165165        paintReplaced(paintInfo, adjustedPaintOffset);
    166166
    167         if (style()->hasBorderRadius())
     167        if (style().hasBorderRadius())
    168168            paintInfo.context->restore();
    169169    }
     
    174174        LayoutRect selectionPaintingRect = localSelectionRect();
    175175        selectionPaintingRect.moveBy(adjustedPaintOffset);
    176         paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect), selectionBackgroundColor(), style()->colorSpace());
     176        paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect), selectionBackgroundColor(), style().colorSpace());
    177177    }
    178178}
     
    188188       
    189189    // if we're invisible or haven't received a layout yet, then just bail.
    190     if (style()->visibility() != VISIBLE)
     190    if (style().visibility() != VISIBLE)
    191191        return false;
    192192
     
    225225
    226226    for (; !containingBlock->isRenderView() && !containingBlock->isBody(); containingBlock = containingBlock->containingBlock()) {
    227         if (containingBlock->style()->logicalWidth().isSpecified())
     227        if (containingBlock->style().logicalWidth().isSpecified())
    228228            return containingBlock;
    229229    }
     
    234234bool RenderReplaced::hasReplacedLogicalWidth() const
    235235{
    236     if (style()->logicalWidth().isSpecified())
     236    if (style().logicalWidth().isSpecified())
    237237        return true;
    238238
    239     if (style()->logicalWidth().isAuto())
     239    if (style().logicalWidth().isAuto())
    240240        return false;
    241241
     
    245245bool RenderReplaced::hasReplacedLogicalHeight() const
    246246{
    247     if (style()->logicalHeight().isAuto())
    248         return false;
    249 
    250     if (style()->logicalHeight().isSpecified()) {
     247    if (style().logicalHeight().isAuto())
     248        return false;
     249
     250    if (style().logicalHeight().isSpecified()) {
    251251        if (hasAutoHeightOrContainingBlockWithAutoHeight())
    252252            return false;
     
    267267        // Handle zoom & vertical writing modes here, as the embedded document doesn't know about them.
    268268        if (!isPercentageIntrinsicSize)
    269             intrinsicSize.scale(style()->effectiveZoom());
     269            intrinsicSize.scale(style().effectiveZoom());
    270270
    271271        if (hasAspectRatio() && isPercentageIntrinsicSize)
     
    299299    // function was added, since all it has done is make the code more unclear.
    300300    constrainedSize = intrinsicSize;
    301     if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty() && style()->logicalWidth().isAuto() && style()->logicalHeight().isAuto()) {
     301    if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty() && style().logicalWidth().isAuto() && style().logicalHeight().isAuto()) {
    302302        // We can't multiply or divide by 'intrinsicRatio' here, it breaks tests, like fast/images/zoomed-img-size.html, which
    303303        // can only be fixed once subpixel precision is available for things like intrinsicWidth/Height - which include zoom!
     
    310310{
    311311    LayoutRect contentRect = contentBoxRect();
    312     ObjectFit objectFit = style()->objectFit();
     312    ObjectFit objectFit = style().objectFit();
    313313    if (objectFit == ObjectFitFill)
    314314        return contentRect;
     
    358358LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
    359359{
    360     if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntrinsic())
    361         return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(style()->logicalWidth()), shouldComputePreferred);
     360    if (style().logicalWidth().isSpecified() || style().logicalWidth().isIntrinsic())
     361        return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(style().logicalWidth()), shouldComputePreferred);
    362362
    363363    RenderBox* contentRenderer = embeddedContentBox();
     
    369369    computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize, intrinsicRatio, isPercentageIntrinsicSize);
    370370
    371     if (style()->logicalWidth().isAuto()) {
    372         bool heightIsAuto = style()->logicalHeight().isAuto();
     371    if (style().logicalWidth().isAuto()) {
     372        bool heightIsAuto = style().logicalHeight().isAuto();
    373373        bool hasIntrinsicWidth = !isPercentageIntrinsicSize && constrainedSize.width() > 0;
    374374
     
    395395                LayoutUnit logicalWidth;
    396396                if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
    397                     logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWidth->style()->logicalWidth()), shouldComputePreferred);
     397                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWidth->style().logicalWidth()), shouldComputePreferred);
    398398                else
    399399                    logicalWidth = containingBlock()->availableLogicalWidth();
    400400
    401401                // This solves above equation for 'width' (== logicalWidth).
    402                 LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), logicalWidth);
    403                 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), logicalWidth);
     402                LayoutUnit marginStart = minimumValueForLength(style().marginStart(), logicalWidth);
     403                LayoutUnit marginEnd = minimumValueForLength(style().marginEnd(), logicalWidth);
    404404                logicalWidth = max<LayoutUnit>(0, logicalWidth - (marginStart + marginEnd + (width() - clientWidth())));
    405405                if (isPercentageIntrinsicSize)
     
    427427    // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
    428428    if (hasReplacedLogicalHeight())
    429         return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
     429        return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style().logicalHeight()));
    430430
    431431    RenderBox* contentRenderer = embeddedContentBox();
     
    437437    computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize, intrinsicRatio, isPercentageIntrinsicSize);
    438438
    439     bool widthIsAuto = style()->logicalWidth().isAuto();
     439    bool widthIsAuto = style().logicalWidth().isAuto();
    440440    bool hasIntrinsicHeight = !isPercentageIntrinsicSize && constrainedSize.height() > 0;
    441441
     
    469469    // We cannot resolve any percent logical width here as the available logical
    470470    // width may not be set on our containing block.
    471     if (style()->logicalWidth().isPercent())
     471    if (style().logicalWidth().isPercent())
    472472        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    473473    else
    474474        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);
    475475
    476     RenderStyle* styleToUse = style();
    477     if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().isPercent() || hasRelativeIntrinsicLogicalWidth())
     476    const RenderStyle& styleToUse = style();
     477    if (styleToUse.logicalWidth().isPercent() || styleToUse.logicalMaxWidth().isPercent() || hasRelativeIntrinsicLogicalWidth())
    478478        m_minPreferredLogicalWidth = 0;
    479479
    480     if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0) {
    481         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
    482         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
    483     }
    484    
    485     if (styleToUse->logicalMaxWidth().isFixed()) {
    486         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
    487         m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
     480    if (styleToUse.logicalMinWidth().isFixed() && styleToUse.logicalMinWidth().value() > 0) {
     481        m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMinWidth().value()));
     482        m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMinWidth().value()));
     483    }
     484   
     485    if (styleToUse.logicalMaxWidth().isFixed()) {
     486        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
     487        m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
    488488    }
    489489
     
    548548   
    549549    const RootInlineBox& rootBox = m_inlineBoxWrapper->root();
    550     LayoutUnit newLogicalTop = rootBox.blockFlow().style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - rootBox.selectionBottom() : rootBox.selectionTop() - m_inlineBoxWrapper->logicalTop();
    551     if (rootBox.blockFlow().style()->isHorizontalWritingMode())
     550    LayoutUnit newLogicalTop = rootBox.blockFlow().style().isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - rootBox.selectionBottom() : rootBox.selectionTop() - m_inlineBoxWrapper->logicalTop();
     551    if (rootBox.blockFlow().style().isHorizontalWritingMode())
    552552        return LayoutRect(0, newLogicalTop, width(), rootBox.selectionHeight());
    553553    return LayoutRect(newLogicalTop, 0, rootBox.selectionHeight(), height());
     
    588588LayoutRect RenderReplaced::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
    589589{
    590     if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
     590    if (style().visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
    591591        return LayoutRect();
    592592
     
    599599    r.move(view().layoutDelta());
    600600
    601     if (style())
    602         r.inflate(style()->outlineSize());
     601    r.inflate(style().outlineSize());
    603602
    604603    computeRectForRepaint(repaintContainer, r);
Note: See TracChangeset for help on using the changeset viewer.