Changeset 160539 in webkit


Ignore:
Timestamp:
Dec 13, 2013 1:56:26 AM (10 years ago)
Author:
akling@apple.com
Message:

StyleResolver::adjustRenderStyle() should take RenderStyle references.
<https://webkit.org/b/125623>

This function doesn't handle null styles being passed, so prevent
it at compile time.

Reviewed by Anders Carlsson.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r160536 r160539  
     12013-12-12  Andreas Kling  <akling@apple.com>
     2
     3        StyleResolver::adjustRenderStyle() should take RenderStyle references.
     4        <https://webkit.org/b/125623>
     5
     6        This function doesn't handle null styles being passed, so prevent
     7        it at compile time.
     8
     9        Reviewed by Anders Carlsson.
     10
    1112013-12-13  Darin Adler  <darin@apple.com>
    212
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r160528 r160539  
    845845
    846846    // Clean up our style object's display and text decorations (among other fixups).
    847     adjustRenderStyle(state.style(), state.parentStyle(), element);
     847    adjustRenderStyle(*state.style(), *state.parentStyle(), element);
    848848
    849849    state.clear(); // Clear out for the next resolve.
     
    10101010
    10111011    // Clean up our style object's display and text decorations (among other fixups).
    1012     adjustRenderStyle(state.style(), m_state.parentStyle(), 0);
     1012    adjustRenderStyle(*state.style(), *m_state.parentStyle(), 0);
    10131013
    10141014    // Start loading resources referenced by this style.
     
    10671067}
    10681068
    1069 static void addIntrinsicMargins(RenderStyle* style)
     1069static void addIntrinsicMargins(RenderStyle& style)
    10701070{
    10711071    // Intrinsic margin value.
    1072     const int intrinsicMargin = 2 * style->effectiveZoom();
     1072    const int intrinsicMargin = 2 * style.effectiveZoom();
    10731073
    10741074    // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
    10751075    // FIXME: Using "quirk" to decide the margin wasn't set is kind of lame.
    1076     if (style->width().isIntrinsicOrAuto()) {
    1077         if (style->marginLeft().quirk())
    1078             style->setMarginLeft(Length(intrinsicMargin, Fixed));
    1079         if (style->marginRight().quirk())
    1080             style->setMarginRight(Length(intrinsicMargin, Fixed));
    1081     }
    1082 
    1083     if (style->height().isAuto()) {
    1084         if (style->marginTop().quirk())
    1085             style->setMarginTop(Length(intrinsicMargin, Fixed));
    1086         if (style->marginBottom().quirk())
    1087             style->setMarginBottom(Length(intrinsicMargin, Fixed));
     1076    if (style.width().isIntrinsicOrAuto()) {
     1077        if (style.marginLeft().quirk())
     1078            style.setMarginLeft(Length(intrinsicMargin, Fixed));
     1079        if (style.marginRight().quirk())
     1080            style.setMarginRight(Length(intrinsicMargin, Fixed));
     1081    }
     1082
     1083    if (style.height().isAuto()) {
     1084        if (style.marginTop().quirk())
     1085            style.setMarginTop(Length(intrinsicMargin, Fixed));
     1086        if (style.marginBottom().quirk())
     1087            style.setMarginBottom(Length(intrinsicMargin, Fixed));
    10881088    }
    10891089}
     
    11371137// inline blocks, inline tables, run-ins, shadow DOM crossings, floating elements,
    11381138// and absolute or relatively positioned elements.
    1139 static bool doesNotInheritTextDecoration(RenderStyle* style, Element* e)
    1140 {
    1141     return style->display() == TABLE || style->display() == INLINE_TABLE || style->display() == RUN_IN
    1142         || style->display() == INLINE_BLOCK || style->display() == INLINE_BOX || isAtShadowBoundary(e)
    1143         || style->isFloating() || style->hasOutOfFlowPosition();
     1139static bool doesNotInheritTextDecoration(const RenderStyle& style, Element* e)
     1140{
     1141    return style.display() == TABLE || style.display() == INLINE_TABLE || style.display() == RUN_IN
     1142        || style.display() == INLINE_BLOCK || style.display() == INLINE_BOX || isAtShadowBoundary(e)
     1143        || style.isFloating() || style.hasOutOfFlowPosition();
    11441144}
    11451145
     
    11561156#endif
    11571157
    1158 void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
    1159 {
    1160     ASSERT(parentStyle);
    1161 
     1158void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, Element *e)
     1159{
    11621160    // Cache our original display.
    1163     style->setOriginalDisplay(style->display());
    1164 
    1165     if (style->display() != NONE) {
     1161    style.setOriginalDisplay(style.display());
     1162
     1163    if (style.display() != NONE) {
    11661164        // If we have a <td> that specifies a float property, in quirks mode we just drop the float
    11671165        // property.
     
    11701168        if (document().inQuirksMode() && e) {
    11711169            if (e->hasTagName(tdTag)) {
    1172                 style->setDisplay(TABLE_CELL);
    1173                 style->setFloating(NoFloat);
     1170                style.setDisplay(TABLE_CELL);
     1171                style.setFloating(NoFloat);
    11741172            } else if (isHTMLTableElement(e))
    1175                 style->setDisplay(style->isDisplayInlineType() ? INLINE_TABLE : TABLE);
     1173                style.setDisplay(style.isDisplayInlineType() ? INLINE_TABLE : TABLE);
    11761174        }
    11771175
    11781176        if (e && (e->hasTagName(tdTag) || e->hasTagName(thTag))) {
    1179             if (style->whiteSpace() == KHTML_NOWRAP) {
     1177            if (style.whiteSpace() == KHTML_NOWRAP) {
    11801178                // Figure out if we are really nowrapping or if we should just
    11811179                // use normal instead. If the width of the cell is fixed, then
    11821180                // we don't actually use NOWRAP.
    1183                 if (style->width().isFixed())
    1184                     style->setWhiteSpace(NORMAL);
     1181                if (style.width().isFixed())
     1182                    style.setWhiteSpace(NORMAL);
    11851183                else
    1186                     style->setWhiteSpace(NOWRAP);
     1184                    style.setWhiteSpace(NOWRAP);
    11871185            }
    11881186        }
    11891187
    11901188        // Tables never support the -webkit-* values for text-align and will reset back to the default.
    1191         if (e && isHTMLTableElement(e) && (style->textAlign() == WEBKIT_LEFT || style->textAlign() == WEBKIT_CENTER || style->textAlign() == WEBKIT_RIGHT))
    1192             style->setTextAlign(TASTART);
     1189        if (e && isHTMLTableElement(e) && (style.textAlign() == WEBKIT_LEFT || style.textAlign() == WEBKIT_CENTER || style.textAlign() == WEBKIT_RIGHT))
     1190            style.setTextAlign(TASTART);
    11931191
    11941192        // Frames and framesets never honor position:relative or position:absolute. This is necessary to
    11951193        // fix a crash where a site tries to position these objects. They also never honor display.
    11961194        if (e && (e->hasTagName(frameTag) || e->hasTagName(framesetTag))) {
    1197             style->setPosition(StaticPosition);
    1198             style->setDisplay(BLOCK);
     1195            style.setPosition(StaticPosition);
     1196            style.setDisplay(BLOCK);
    11991197        }
    12001198
    12011199        // Ruby text does not support float or position. This might change with evolution of the specification.
    12021200        if (e && e->hasTagName(rtTag)) {
    1203             style->setPosition(StaticPosition);
    1204             style->setFloating(NoFloat);
     1201            style.setPosition(StaticPosition);
     1202            style.setFloating(NoFloat);
    12051203        }
    12061204
    12071205        // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it in html.css instead.
    12081206        // Table headers with a text-align of -webkit-auto will change the text-align to center.
    1209         if (e && e->hasTagName(thTag) && style->textAlign() == TASTART)
    1210             style->setTextAlign(CENTER);
     1207        if (e && e->hasTagName(thTag) && style.textAlign() == TASTART)
     1208            style.setTextAlign(CENTER);
    12111209
    12121210        if (e && e->hasTagName(legendTag))
    1213             style->setDisplay(BLOCK);
     1211            style.setDisplay(BLOCK);
    12141212
    12151213        // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display.
    1216         if (style->hasOutOfFlowPosition() || style->isFloating() || (e && e->document().documentElement() == e))
    1217             style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document().inQuirksMode()));
     1214        if (style.hasOutOfFlowPosition() || style.isFloating() || (e && e->document().documentElement() == e))
     1215            style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloating(), !document().inQuirksMode()));
    12181216
    12191217        // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
    12201218        // clear how that should work.
    1221         if (style->display() == INLINE && style->styleType() == NOPSEUDO && style->writingMode() != parentStyle->writingMode())
    1222             style->setDisplay(INLINE_BLOCK);
     1219        if (style.display() == INLINE && style.styleType() == NOPSEUDO && style.writingMode() != parentStyle.writingMode())
     1220            style.setDisplay(INLINE_BLOCK);
    12231221
    12241222        // After performing the display mutation, check table rows. We do not honor position:relative or position:sticky on
    12251223        // table rows or cells. This has been established for position:relative in CSS2.1 (and caused a crash in containingBlock()
    12261224        // on some sites).
    1227         if ((style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW_GROUP
    1228             || style->display() == TABLE_FOOTER_GROUP || style->display() == TABLE_ROW)
    1229             && style->hasInFlowPosition())
    1230             style->setPosition(StaticPosition);
     1225        if ((style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_ROW_GROUP
     1226            || style.display() == TABLE_FOOTER_GROUP || style.display() == TABLE_ROW)
     1227            && style.hasInFlowPosition())
     1228            style.setPosition(StaticPosition);
    12311229
    12321230        // writing-mode does not apply to table row groups, table column groups, table rows, and table columns.
    12331231        // FIXME: Table cells should be allowed to be perpendicular or flipped with respect to the table, though.
    1234         if (style->display() == TABLE_COLUMN || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_FOOTER_GROUP
    1235             || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW || style->display() == TABLE_ROW_GROUP
    1236             || style->display() == TABLE_CELL)
    1237             style->setWritingMode(parentStyle->writingMode());
     1232        if (style.display() == TABLE_COLUMN || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_FOOTER_GROUP
     1233            || style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_ROW || style.display() == TABLE_ROW_GROUP
     1234            || style.display() == TABLE_CELL)
     1235            style.setWritingMode(parentStyle.writingMode());
    12381236
    12391237        // FIXME: Since we don't support block-flow on flexible boxes yet, disallow setting
    12401238        // of block-flow to anything other than TopToBottomWritingMode.
    12411239        // https://bugs.webkit.org/show_bug.cgi?id=46418 - Flexible box support.
    1242         if (style->writingMode() != TopToBottomWritingMode && (style->display() == BOX || style->display() == INLINE_BOX))
    1243             style->setWritingMode(TopToBottomWritingMode);
    1244 
    1245         if (isDisplayFlexibleBox(parentStyle->display())) {
    1246             style->setFloating(NoFloat);
    1247             style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), !document().inQuirksMode()));
     1240        if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX))
     1241            style.setWritingMode(TopToBottomWritingMode);
     1242
     1243        if (isDisplayFlexibleBox(parentStyle.display())) {
     1244            style.setFloating(NoFloat);
     1245            style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloating(), !document().inQuirksMode()));
    12481246        }
    12491247    }
    12501248
    12511249    // Make sure our z-index value is only applied if the object is positioned.
    1252     if (style->position() == StaticPosition && !isDisplayFlexibleBox(parentStyle->display()))
    1253         style->setHasAutoZIndex();
     1250    if (style.position() == StaticPosition && !isDisplayFlexibleBox(parentStyle.display()))
     1251        style.setHasAutoZIndex();
    12541252
    12551253    // Auto z-index becomes 0 for the root element and transparent objects. This prevents
    12561254    // cases where objects that should be blended as a single unit end up with a non-transparent
    12571255    // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections.
    1258     if (style->hasAutoZIndex() && ((e && e->document().documentElement() == e)
    1259         || style->opacity() < 1.0f
    1260         || style->hasTransformRelatedProperty()
    1261         || style->hasMask()
    1262         || style->clipPath()
    1263         || style->boxReflect()
    1264         || style->hasFilter()
    1265         || style->hasBlendMode()
    1266         || style->position() == StickyPosition
    1267         || (style->position() == FixedPosition && e && e->document().page() && e->document().page()->settings().fixedPositionCreatesStackingContext())
    1268         || style->hasFlowFrom()
     1256    if (style.hasAutoZIndex() && ((e && e->document().documentElement() == e)
     1257        || style.opacity() < 1.0f
     1258        || style.hasTransformRelatedProperty()
     1259        || style.hasMask()
     1260        || style.clipPath()
     1261        || style.boxReflect()
     1262        || style.hasFilter()
     1263        || style.hasBlendMode()
     1264        || style.position() == StickyPosition
     1265        || (style.position() == FixedPosition && e && e->document().page() && e->document().page()->settings().fixedPositionCreatesStackingContext())
     1266        || style.hasFlowFrom()
    12691267        ))
    1270         style->setZIndex(0);
     1268        style.setZIndex(0);
    12711269
    12721270    // Textarea considers overflow visible as auto.
    12731271    if (e && isHTMLTextAreaElement(e)) {
    1274         style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX());
    1275         style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY());
     1272        style.setOverflowX(style.overflowX() == OVISIBLE ? OAUTO : style.overflowX());
     1273        style.setOverflowY(style.overflowY() == OVISIBLE ? OAUTO : style.overflowY());
    12761274    }
    12771275
    12781276    if (doesNotInheritTextDecoration(style, e))
    1279         style->setTextDecorationsInEffect(style->textDecoration());
     1277        style.setTextDecorationsInEffect(style.textDecoration());
    12801278    else
    1281         style->addToTextDecorationsInEffect(style->textDecoration());
     1279        style.addToTextDecorationsInEffect(style.textDecoration());
    12821280
    12831281    // If either overflow value is not visible, change to auto.
    1284     if (style->overflowX() == OMARQUEE && style->overflowY() != OMARQUEE)
    1285         style->setOverflowY(OMARQUEE);
    1286     else if (style->overflowY() == OMARQUEE && style->overflowX() != OMARQUEE)
    1287         style->setOverflowX(OMARQUEE);
    1288     else if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) {
     1282    if (style.overflowX() == OMARQUEE && style.overflowY() != OMARQUEE)
     1283        style.setOverflowY(OMARQUEE);
     1284    else if (style.overflowY() == OMARQUEE && style.overflowX() != OMARQUEE)
     1285        style.setOverflowX(OMARQUEE);
     1286    else if (style.overflowX() == OVISIBLE && style.overflowY() != OVISIBLE) {
    12891287        // FIXME: Once we implement pagination controls, overflow-x should default to hidden
    12901288        // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll let it
    12911289        // default to auto so we can at least scroll through the pages.
    1292         style->setOverflowX(OAUTO);
    1293     } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
    1294         style->setOverflowY(OAUTO);
     1290        style.setOverflowX(OAUTO);
     1291    } else if (style.overflowY() == OVISIBLE && style.overflowX() != OVISIBLE)
     1292        style.setOverflowY(OAUTO);
    12951293
    12961294    // Call setStylesForPaginationMode() if a pagination mode is set for any non-root elements. If these
    12971295    // styles are specified on a root element, then they will be incorporated in
    12981296    // Style::createForDocument().
    1299     if ((style->overflowY() == OPAGEDX || style->overflowY() == OPAGEDY) && !(e && (e->hasTagName(htmlTag) || e->hasTagName(bodyTag))))
    1300         style->setColumnStylesFromPaginationMode(WebCore::paginationModeForRenderStyle(style));
     1297    if ((style.overflowY() == OPAGEDX || style.overflowY() == OPAGEDY) && !(e && (e->hasTagName(htmlTag) || e->hasTagName(bodyTag))))
     1298        style.setColumnStylesFromPaginationMode(WebCore::paginationModeForRenderStyle(style));
    13011299
    13021300    // Table rows, sections and the table itself will support overflow:hidden and will ignore scroll/auto.
    13031301    // FIXME: Eventually table sections will support auto and scroll.
    1304     if (style->display() == TABLE || style->display() == INLINE_TABLE
    1305         || style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
    1306         if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN)
    1307             style->setOverflowX(OVISIBLE);
    1308         if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN)
    1309             style->setOverflowY(OVISIBLE);
     1302    if (style.display() == TABLE || style.display() == INLINE_TABLE
     1303        || style.display() == TABLE_ROW_GROUP || style.display() == TABLE_ROW) {
     1304        if (style.overflowX() != OVISIBLE && style.overflowX() != OHIDDEN)
     1305            style.setOverflowX(OVISIBLE);
     1306        if (style.overflowY() != OVISIBLE && style.overflowY() != OHIDDEN)
     1307            style.setOverflowY(OVISIBLE);
    13101308    }
    13111309
    13121310    // Menulists should have visible overflow
    1313     if (style->appearance() == MenulistPart) {
    1314         style->setOverflowX(OVISIBLE);
    1315         style->setOverflowY(OVISIBLE);
     1311    if (style.appearance() == MenulistPart) {
     1312        style.setOverflowX(OVISIBLE);
     1313        style.setOverflowY(OVISIBLE);
    13161314    }
    13171315
    13181316#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
    13191317    // Touch overflow scrolling creates a stacking context.
    1320     if (style->hasAutoZIndex() && style->useTouchOverflowScrolling() && (isScrollableOverflow(style->overflowX()) || isScrollableOverflow(style->overflowY())))
    1321         style->setZIndex(0);
     1318    if (style.hasAutoZIndex() && style.useTouchOverflowScrolling() && (isScrollableOverflow(style.overflowX()) || isScrollableOverflow(style.overflowY())))
     1319        style.setZIndex(0);
    13221320#endif
    13231321
    13241322    // Cull out any useless layers and also repeat patterns into additional layers.
    1325     style->adjustBackgroundLayers();
    1326     style->adjustMaskLayers();
     1323    style.adjustBackgroundLayers();
     1324    style.adjustMaskLayers();
    13271325
    13281326    // Do the same for animations and transitions.
    1329     style->adjustAnimations();
    1330     style->adjustTransitions();
     1327    style.adjustAnimations();
     1328    style.adjustTransitions();
    13311329
    13321330    // Important: Intrinsic margins get added to controls before the theme has adjusted the style, since the theme will
    13331331    // alter fonts and heights/widths.
    1334     if (e && e->isFormControlElement() && style->fontSize() >= 11) {
     1332    if (e && e->isFormControlElement() && style.fontSize() >= 11) {
    13351333        // Don't apply intrinsic margins to image buttons. The designer knows how big the images are,
    13361334        // so we have to treat all image buttons as though they were explicitly sized.
     
    13401338
    13411339    // Let the theme also have a crack at adjusting the style.
    1342     if (style->hasAppearance())
    1343         RenderTheme::defaultTheme()->adjustStyle(this, style, e, m_state.hasUAAppearance(), m_state.borderData(), m_state.backgroundData(), m_state.backgroundColor());
     1340    if (style.hasAppearance())
     1341        RenderTheme::defaultTheme()->adjustStyle(*this, style, e, m_state.hasUAAppearance(), m_state.borderData(), m_state.backgroundData(), m_state.backgroundColor());
    13441342
    13451343    // If we have first-letter pseudo style, do not share this style.
    1346     if (style->hasPseudoStyle(FIRST_LETTER))
    1347         style->setUnique();
     1344    if (style.hasPseudoStyle(FIRST_LETTER))
     1345        style.setUnique();
    13481346
    13491347    // FIXME: when dropping the -webkit prefix on transform-style, we should also have opacity < 1 cause flattening.
    1350     if (style->preserves3D() && (style->overflowX() != OVISIBLE
    1351         || style->overflowY() != OVISIBLE
    1352         || style->hasFilter()))
    1353         style->setTransformStyle3D(TransformStyle3DFlat);
     1348    if (style.preserves3D() && (style.overflowX() != OVISIBLE
     1349        || style.overflowY() != OVISIBLE
     1350        || style.hasFilter()))
     1351        style.setTransformStyle3D(TransformStyle3DFlat);
    13541352
    13551353    // Seamless iframes behave like blocks. Map their display to inline-block when marked inline.
    1356     if (e && e->hasTagName(iframeTag) && style->display() == INLINE && toHTMLIFrameElement(e)->shouldDisplaySeamlessly())
    1357         style->setDisplay(INLINE_BLOCK);
     1354    if (e && e->hasTagName(iframeTag) && style.display() == INLINE && toHTMLIFrameElement(e)->shouldDisplaySeamlessly())
     1355        style.setDisplay(INLINE_BLOCK);
    13581356
    13591357    adjustGridItemPosition(style, parentStyle);
     
    13621360    if (e && e->isSVGElement()) {
    13631361        // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
    1364         if (style->overflowY() == OSCROLL)
    1365             style->setOverflowY(OHIDDEN);
    1366         else if (style->overflowY() == OAUTO)
    1367             style->setOverflowY(OVISIBLE);
    1368 
    1369         if (style->overflowX() == OSCROLL)
    1370             style->setOverflowX(OHIDDEN);
    1371         else if (style->overflowX() == OAUTO)
    1372             style->setOverflowX(OVISIBLE);
     1362        if (style.overflowY() == OSCROLL)
     1363            style.setOverflowY(OHIDDEN);
     1364        else if (style.overflowY() == OAUTO)
     1365            style.setOverflowY(OVISIBLE);
     1366
     1367        if (style.overflowX() == OSCROLL)
     1368            style.setOverflowX(OHIDDEN);
     1369        else if (style.overflowX() == OAUTO)
     1370            style.setOverflowX(OVISIBLE);
    13731371
    13741372        // Only the root <svg> element in an SVG document fragment tree honors css position
    13751373        if (!(e->hasTagName(SVGNames::svgTag) && e->parentNode() && !e->parentNode()->isSVGElement()))
    1376             style->setPosition(RenderStyle::initialPosition());
     1374            style.setPosition(RenderStyle::initialPosition());
    13771375
    13781376        // RenderSVGRoot handles zooming for the whole SVG subtree, so foreignObject content should
    13791377        // not be scaled again.
    13801378        if (e->hasTagName(SVGNames::foreignObjectTag))
    1381             style->setEffectiveZoom(RenderStyle::initialZoom());
    1382     }
    1383 #endif
    1384 }
    1385 
    1386 void StyleResolver::adjustGridItemPosition(RenderStyle* style, RenderStyle* parentStyle) const
    1387 {
    1388     const GridPosition& columnStartPosition = style->gridItemColumnStart();
    1389     const GridPosition& columnEndPosition = style->gridItemColumnEnd();
    1390     const GridPosition& rowStartPosition = style->gridItemRowStart();
    1391     const GridPosition& rowEndPosition = style->gridItemRowEnd();
     1379            style.setEffectiveZoom(RenderStyle::initialZoom());
     1380    }
     1381#endif
     1382}
     1383
     1384void StyleResolver::adjustGridItemPosition(RenderStyle& style, const RenderStyle& parentStyle) const
     1385{
     1386    const GridPosition& columnStartPosition = style.gridItemColumnStart();
     1387    const GridPosition& columnEndPosition = style.gridItemColumnEnd();
     1388    const GridPosition& rowStartPosition = style.gridItemRowStart();
     1389    const GridPosition& rowEndPosition = style.gridItemRowEnd();
    13921390
    13931391    // If opposing grid-placement properties both specify a grid span, they both compute to ‘auto’.
    13941392    if (columnStartPosition.isSpan() && columnEndPosition.isSpan()) {
    1395         style->setGridItemColumnStart(GridPosition());
    1396         style->setGridItemColumnEnd(GridPosition());
     1393        style.setGridItemColumnStart(GridPosition());
     1394        style.setGridItemColumnEnd(GridPosition());
    13971395    }
    13981396
    13991397    if (rowStartPosition.isSpan() && rowEndPosition.isSpan()) {
    1400         style->setGridItemRowStart(GridPosition());
    1401         style->setGridItemRowEnd(GridPosition());
     1398        style.setGridItemRowStart(GridPosition());
     1399        style.setGridItemRowEnd(GridPosition());
    14021400    }
    14031401
    14041402    // Unknown named grid area compute to 'auto'.
    1405     const NamedGridAreaMap& map = parentStyle->namedGridArea();
     1403    const NamedGridAreaMap& map = parentStyle.namedGridArea();
    14061404
    14071405#define CLEAR_UNKNOWN_NAMED_AREA(prop, Prop) \
    14081406    if (prop.isNamedGridArea() && !map.contains(prop.namedGridLine())) \
    1409         style->setGridItem##Prop(GridPosition());
     1407        style.setGridItem##Prop(GridPosition());
    14101408
    14111409    CLEAR_UNKNOWN_NAMED_AREA(columnStartPosition, ColumnStart);
  • trunk/Source/WebCore/css/StyleResolver.h

    r160528 r160539  
    346346#endif
    347347
    348     void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
    349     void adjustGridItemPosition(RenderStyle* styleToAdjust, RenderStyle* parentStyle) const;
     348    void adjustRenderStyle(RenderStyle& styleToAdjust, const RenderStyle& parentStyle, Element*);
     349    void adjustGridItemPosition(RenderStyle& styleToAdjust, const RenderStyle& parentStyle) const;
    350350
    351351    bool fastRejectSelector(const RuleData&) const;
  • trunk/Source/WebCore/page/FrameView.cpp

    r160397 r160539  
    142142}
    143143
    144 Pagination::Mode paginationModeForRenderStyle(RenderStyle* style)
    145 {
    146     EOverflow overflow = style->overflowY();
     144Pagination::Mode paginationModeForRenderStyle(const RenderStyle& style)
     145{
     146    EOverflow overflow = style.overflowY();
    147147    if (overflow != OPAGEDX && overflow != OPAGEDY)
    148148        return Pagination::Unpaginated;
    149149
    150     bool isHorizontalWritingMode = style->isHorizontalWritingMode();
    151     TextDirection textDirection = style->direction();
    152     WritingMode writingMode = style->writingMode();
     150    bool isHorizontalWritingMode = style.isHorizontalWritingMode();
     151    TextDirection textDirection = style.direction();
     152    WritingMode writingMode = style.writingMode();
    153153
    154154    // paged-x always corresponds to LeftToRightPaginated or RightToLeftPaginated. If the WritingMode
     
    674674    EOverflow overflowY = documentOrBodyRenderer->style().overflowY();
    675675    if (overflowY == OPAGEDX || overflowY == OPAGEDY) {
    676         pagination.mode = WebCore::paginationModeForRenderStyle(&documentOrBodyRenderer->style());
     676        pagination.mode = WebCore::paginationModeForRenderStyle(documentOrBodyRenderer->style());
    677677        pagination.gap = static_cast<unsigned>(documentOrBodyRenderer->style().columnGap());
    678678    }
  • trunk/Source/WebCore/page/FrameView.h

    r159300 r160539  
    5959class RenderWidget;
    6060
    61 Pagination::Mode paginationModeForRenderStyle(RenderStyle*);
     61Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
    6262
    6363typedef unsigned long long DOMTimeStamp;
  • trunk/Source/WebCore/rendering/RenderTheme.cpp

    r160236 r160539  
    8181}
    8282
    83 void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
     83void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, Element* e, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
    8484{
    8585    // Force inline and table display styles to be inline-block (except for table- which is block)
    86     ControlPart part = style->appearance();
    87     if (style->display() == INLINE || style->display() == INLINE_TABLE || style->display() == TABLE_ROW_GROUP
    88         || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_FOOTER_GROUP
    89         || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_COLUMN
    90         || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION)
    91         style->setDisplay(INLINE_BLOCK);
    92     else if (style->display() == COMPACT || style->display() == RUN_IN || style->display() == LIST_ITEM || style->display() == TABLE)
    93         style->setDisplay(BLOCK);
    94 
    95     if (UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {
     86    ControlPart part = style.appearance();
     87    if (style.display() == INLINE || style.display() == INLINE_TABLE || style.display() == TABLE_ROW_GROUP
     88        || style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_FOOTER_GROUP
     89        || style.display() == TABLE_ROW || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_COLUMN
     90        || style.display() == TABLE_CELL || style.display() == TABLE_CAPTION)
     91        style.setDisplay(INLINE_BLOCK);
     92    else if (style.display() == COMPACT || style.display() == RUN_IN || style.display() == LIST_ITEM || style.display() == TABLE)
     93        style.setDisplay(BLOCK);
     94
     95    if (UAHasAppearance && isControlStyled(&style, border, background, backgroundColor)) {
    9696        if (part == MenulistPart) {
    97             style->setAppearance(MenulistButtonPart);
     97            style.setAppearance(MenulistButtonPart);
    9898            part = MenulistButtonPart;
    9999        } else
    100             style->setAppearance(NoControlPart);
    101     }
    102 
    103     if (!style->hasAppearance())
     100            style.setAppearance(NoControlPart);
     101    }
     102
     103    if (!style.hasAppearance())
    104104        return;
    105105
    106106    // Never support box-shadow on native controls.
    107     style->setBoxShadow(nullptr);
     107    style.setBoxShadow(nullptr);
    108108   
    109109#if USE(NEW_THEME)
     
    117117    case ButtonPart: {
    118118        // Border
    119         LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(), style->borderBottomWidth(), style->borderLeftWidth());
    120         borderBox = m_theme->controlBorder(part, style->font(), borderBox, style->effectiveZoom());
    121         if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())) {
     119        LengthBox borderBox(style.borderTopWidth(), style.borderRightWidth(), style.borderBottomWidth(), style.borderLeftWidth());
     120        borderBox = m_theme->controlBorder(part, style.font(), borderBox, style.effectiveZoom());
     121        if (borderBox.top().value() != static_cast<int>(style.borderTopWidth())) {
    122122            if (borderBox.top().value())
    123                 style->setBorderTopWidth(borderBox.top().value());
     123                style.setBorderTopWidth(borderBox.top().value());
    124124            else
    125                 style->resetBorderTop();
     125                style.resetBorderTop();
    126126        }
    127         if (borderBox.right().value() != static_cast<int>(style->borderRightWidth())) {
     127        if (borderBox.right().value() != static_cast<int>(style.borderRightWidth())) {
    128128            if (borderBox.right().value())
    129                 style->setBorderRightWidth(borderBox.right().value());
     129                style.setBorderRightWidth(borderBox.right().value());
    130130            else
    131                 style->resetBorderRight();
     131                style.resetBorderRight();
    132132        }
    133         if (borderBox.bottom().value() != static_cast<int>(style->borderBottomWidth())) {
    134             style->setBorderBottomWidth(borderBox.bottom().value());
     133        if (borderBox.bottom().value() != static_cast<int>(style.borderBottomWidth())) {
     134            style.setBorderBottomWidth(borderBox.bottom().value());
    135135            if (borderBox.bottom().value())
    136                 style->setBorderBottomWidth(borderBox.bottom().value());
     136                style.setBorderBottomWidth(borderBox.bottom().value());
    137137            else
    138                 style->resetBorderBottom();
     138                style.resetBorderBottom();
    139139        }
    140         if (borderBox.left().value() != static_cast<int>(style->borderLeftWidth())) {
    141             style->setBorderLeftWidth(borderBox.left().value());
     140        if (borderBox.left().value() != static_cast<int>(style.borderLeftWidth())) {
     141            style.setBorderLeftWidth(borderBox.left().value());
    142142            if (borderBox.left().value())
    143                 style->setBorderLeftWidth(borderBox.left().value());
     143                style.setBorderLeftWidth(borderBox.left().value());
    144144            else
    145                 style->resetBorderLeft();
     145                style.resetBorderLeft();
    146146        }
    147147
    148148        // Padding
    149         LengthBox paddingBox = m_theme->controlPadding(part, style->font(), style->paddingBox(), style->effectiveZoom());
    150         if (paddingBox != style->paddingBox())
    151             style->setPaddingBox(paddingBox);
     149        LengthBox paddingBox = m_theme->controlPadding(part, style.font(), style.paddingBox(), style.effectiveZoom());
     150        if (paddingBox != style.paddingBox())
     151            style.setPaddingBox(paddingBox);
    152152
    153153        // Whitespace
    154154        if (m_theme->controlRequiresPreWhiteSpace(part))
    155             style->setWhiteSpace(PRE);
     155            style.setWhiteSpace(PRE);
    156156           
    157157        // Width / Height
    158158        // The width and height here are affected by the zoom.
    159159        // FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
    160         LengthSize controlSize = m_theme->controlSize(part, style->font(), LengthSize(style->width(), style->height()), style->effectiveZoom());
    161         if (controlSize.width() != style->width())
    162             style->setWidth(controlSize.width());
    163         if (controlSize.height() != style->height())
    164             style->setHeight(controlSize.height());
     160        LengthSize controlSize = m_theme->controlSize(part, style.font(), LengthSize(style.width(), style.height()), style.effectiveZoom());
     161        if (controlSize.width() != style.width())
     162            style.setWidth(controlSize.width());
     163        if (controlSize.height() != style.height())
     164            style.setHeight(controlSize.height());
    165165               
    166166        // Min-Width / Min-Height
    167         LengthSize minControlSize = m_theme->minimumControlSize(part, style->font(), style->effectiveZoom());
    168         if (minControlSize.width() != style->minWidth())
    169             style->setMinWidth(minControlSize.width());
    170         if (minControlSize.height() != style->minHeight())
    171             style->setMinHeight(minControlSize.height());
     167        LengthSize minControlSize = m_theme->minimumControlSize(part, style.font(), style.effectiveZoom());
     168        if (minControlSize.width() != style.minWidth())
     169            style.setMinWidth(minControlSize.width());
     170        if (minControlSize.height() != style.minHeight())
     171            style.setMinHeight(minControlSize.height());
    172172               
    173173        // Font
    174         FontDescription controlFont = m_theme->controlFont(part, style->font(), style->effectiveZoom());
    175         if (controlFont != style->font().fontDescription()) {
     174        FontDescription controlFont = m_theme->controlFont(part, style.font(), style.effectiveZoom());
     175        if (controlFont != style.font().fontDescription()) {
    176176            // Reset our line-height
    177             style->setLineHeight(RenderStyle::initialLineHeight());
     177            style.setLineHeight(RenderStyle::initialLineHeight());
    178178
    179179            // Now update our font.
    180             if (style->setFontDescription(controlFont))
    181                 style->font().update(0);
     180            if (style.setFontDescription(controlFont))
     181                style.font().update(0);
    182182        }
    183183    }
     
    188188
    189189    // Call the appropriate style adjustment method based off the appearance value.
    190     switch (style->appearance()) {
     190    switch (style.appearance()) {
    191191#if !USE(NEW_THEME)
    192192    case CheckboxPart:
    193         return adjustCheckboxStyle(styleResolver, style, e);
     193        return adjustCheckboxStyle(&styleResolver, &style, e);
    194194    case RadioPart:
    195         return adjustRadioStyle(styleResolver, style, e);
     195        return adjustRadioStyle(&styleResolver, &style, e);
    196196    case PushButtonPart:
    197197    case SquareButtonPart:
    198198    case DefaultButtonPart:
    199199    case ButtonPart:
    200         return adjustButtonStyle(styleResolver, style, e);
     200        return adjustButtonStyle(&styleResolver, &style, e);
    201201    case InnerSpinButtonPart:
    202         return adjustInnerSpinButtonStyle(styleResolver, style, e);
     202        return adjustInnerSpinButtonStyle(&styleResolver, &style, e);
    203203#endif
    204204    case TextFieldPart:
    205         return adjustTextFieldStyle(styleResolver, style, e);
     205        return adjustTextFieldStyle(&styleResolver, &style, e);
    206206    case TextAreaPart:
    207         return adjustTextAreaStyle(styleResolver, style, e);
     207        return adjustTextAreaStyle(&styleResolver, &style, e);
    208208    case MenulistPart:
    209         return adjustMenuListStyle(styleResolver, style, e);
     209        return adjustMenuListStyle(&styleResolver, &style, e);
    210210    case MenulistButtonPart:
    211         return adjustMenuListButtonStyle(styleResolver, style, e);
     211        return adjustMenuListButtonStyle(&styleResolver, &style, e);
    212212    case MediaPlayButtonPart:
    213213    case MediaCurrentTimePart:
     
    217217    case MediaMuteButtonPart:
    218218    case MediaVolumeSliderContainerPart:
    219         return adjustMediaControlStyle(styleResolver, style, e);
     219        return adjustMediaControlStyle(&styleResolver, &style, e);
    220220    case MediaSliderPart:
    221221    case MediaVolumeSliderPart:
     
    223223    case SliderHorizontalPart:
    224224    case SliderVerticalPart:
    225         return adjustSliderTrackStyle(styleResolver, style, e);
     225        return adjustSliderTrackStyle(&styleResolver, &style, e);
    226226    case SliderThumbHorizontalPart:
    227227    case SliderThumbVerticalPart:
    228         return adjustSliderThumbStyle(styleResolver, style, e);
     228        return adjustSliderThumbStyle(&styleResolver, &style, e);
    229229    case SearchFieldPart:
    230         return adjustSearchFieldStyle(styleResolver, style, e);
     230        return adjustSearchFieldStyle(&styleResolver, &style, e);
    231231    case SearchFieldCancelButtonPart:
    232         return adjustSearchFieldCancelButtonStyle(styleResolver, style, e);
     232        return adjustSearchFieldCancelButtonStyle(&styleResolver, &style, e);
    233233    case SearchFieldDecorationPart:
    234         return adjustSearchFieldDecorationPartStyle(styleResolver, style, e);
     234        return adjustSearchFieldDecorationPartStyle(&styleResolver, &style, e);
    235235    case SearchFieldResultsDecorationPart:
    236         return adjustSearchFieldResultsDecorationPartStyle(styleResolver, style, e);
     236        return adjustSearchFieldResultsDecorationPartStyle(&styleResolver, &style, e);
    237237    case SearchFieldResultsButtonPart:
    238         return adjustSearchFieldResultsButtonStyle(styleResolver, style, e);
     238        return adjustSearchFieldResultsButtonStyle(&styleResolver, &style, e);
    239239#if ENABLE(PROGRESS_ELEMENT)
    240240    case ProgressBarPart:
    241         return adjustProgressBarStyle(styleResolver, style, e);
     241        return adjustProgressBarStyle(&styleResolver, &style, e);
    242242#endif
    243243#if ENABLE(METER_ELEMENT)
     
    247247    case DiscreteCapacityLevelIndicatorPart:
    248248    case RatingLevelIndicatorPart:
    249         return adjustMeterStyle(styleResolver, style, e);
     249        return adjustMeterStyle(&styleResolver, &style, e);
    250250#endif
    251251#if ENABLE(INPUT_SPEECH)
    252252    case InputSpeechButtonPart:
    253         return adjustInputFieldSpeechButtonStyle(styleResolver, style, e);
     253        return adjustInputFieldSpeechButtonStyle(&styleResolver, &style, e);
    254254#endif
    255255    default:
  • trunk/Source/WebCore/rendering/RenderTheme.h

    r160236 r160539  
    7474    // selection of control size based off the font, the disabling of appearance when certain other properties like
    7575    // "border" are set, or if the appearance is not supported by the theme.
    76     void adjustStyle(StyleResolver*, RenderStyle*, Element*,  bool UAHasAppearance,
    77                      const BorderData&, const FillLayer&, const Color& backgroundColor);
     76    void adjustStyle(StyleResolver&, RenderStyle&, Element*,  bool UAHasAppearance, const BorderData&, const FillLayer&, const Color& backgroundColor);
    7877
    7978    // This method is called to paint the widget as a background of the RenderObject.  A widget's foreground, e.g., the
Note: See TracChangeset for help on using the changeset viewer.