Commit 780a04c0 authored by akling@apple.com's avatar akling@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e6c627e6
2013-12-12 Andreas Kling <akling@apple.com>
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.
2013-12-13 Darin Adler <darin@apple.com>
Eliminate awkward virtualComputedStyle construction
This diff is collapsed.
......@@ -345,8 +345,8 @@ private:
void checkForTextSizeAdjust(RenderStyle*);
#endif
void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
void adjustGridItemPosition(RenderStyle* styleToAdjust, RenderStyle* parentStyle) const;
void adjustRenderStyle(RenderStyle& styleToAdjust, const RenderStyle& parentStyle, Element*);
void adjustGridItemPosition(RenderStyle& styleToAdjust, const RenderStyle& parentStyle) const;
bool fastRejectSelector(const RuleData&) const;
......
......@@ -141,15 +141,15 @@ static RenderLayer::UpdateLayerPositionsFlags updateLayerPositionFlags(RenderLay
return flags;
}
Pagination::Mode paginationModeForRenderStyle(RenderStyle* style)
Pagination::Mode paginationModeForRenderStyle(const RenderStyle& style)
{
EOverflow overflow = style->overflowY();
EOverflow overflow = style.overflowY();
if (overflow != OPAGEDX && overflow != OPAGEDY)
return Pagination::Unpaginated;
bool isHorizontalWritingMode = style->isHorizontalWritingMode();
TextDirection textDirection = style->direction();
WritingMode writingMode = style->writingMode();
bool isHorizontalWritingMode = style.isHorizontalWritingMode();
TextDirection textDirection = style.direction();
WritingMode writingMode = style.writingMode();
// paged-x always corresponds to LeftToRightPaginated or RightToLeftPaginated. If the WritingMode
// is horizontal, then we use TextDirection to choose between those options. If the WritingMode
......@@ -673,7 +673,7 @@ void FrameView::applyPaginationToViewport()
EOverflow overflowY = documentOrBodyRenderer->style().overflowY();
if (overflowY == OPAGEDX || overflowY == OPAGEDY) {
pagination.mode = WebCore::paginationModeForRenderStyle(&documentOrBodyRenderer->style());
pagination.mode = WebCore::paginationModeForRenderStyle(documentOrBodyRenderer->style());
pagination.gap = static_cast<unsigned>(documentOrBodyRenderer->style().columnGap());
}
......
......@@ -58,7 +58,7 @@ class RenderStyle;
class RenderView;
class RenderWidget;
Pagination::Mode paginationModeForRenderStyle(RenderStyle*);
Pagination::Mode paginationModeForRenderStyle(const RenderStyle&);
typedef unsigned long long DOMTimeStamp;
......
......@@ -80,31 +80,31 @@ RenderTheme::RenderTheme()
{
}
void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, Element* e, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
{
// Force inline and table display styles to be inline-block (except for table- which is block)
ControlPart part = style->appearance();
if (style->display() == INLINE || style->display() == INLINE_TABLE || style->display() == TABLE_ROW_GROUP
|| style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_FOOTER_GROUP
|| style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_COLUMN
|| style->display() == TABLE_CELL || style->display() == TABLE_CAPTION)
style->setDisplay(INLINE_BLOCK);
else if (style->display() == COMPACT || style->display() == RUN_IN || style->display() == LIST_ITEM || style->display() == TABLE)
style->setDisplay(BLOCK);
if (UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {
ControlPart part = style.appearance();
if (style.display() == INLINE || style.display() == INLINE_TABLE || style.display() == TABLE_ROW_GROUP
|| style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_FOOTER_GROUP
|| style.display() == TABLE_ROW || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_COLUMN
|| style.display() == TABLE_CELL || style.display() == TABLE_CAPTION)
style.setDisplay(INLINE_BLOCK);
else if (style.display() == COMPACT || style.display() == RUN_IN || style.display() == LIST_ITEM || style.display() == TABLE)
style.setDisplay(BLOCK);
if (UAHasAppearance && isControlStyled(&style, border, background, backgroundColor)) {
if (part == MenulistPart) {
style->setAppearance(MenulistButtonPart);
style.setAppearance(MenulistButtonPart);
part = MenulistButtonPart;
} else
style->setAppearance(NoControlPart);
style.setAppearance(NoControlPart);
}
if (!style->hasAppearance())
if (!style.hasAppearance())
return;
// Never support box-shadow on native controls.
style->setBoxShadow(nullptr);
style.setBoxShadow(nullptr);
#if USE(NEW_THEME)
switch (part) {
......@@ -116,69 +116,69 @@ void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style,
case DefaultButtonPart:
case ButtonPart: {
// Border
LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(), style->borderBottomWidth(), style->borderLeftWidth());
borderBox = m_theme->controlBorder(part, style->font(), borderBox, style->effectiveZoom());
if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())) {
LengthBox borderBox(style.borderTopWidth(), style.borderRightWidth(), style.borderBottomWidth(), style.borderLeftWidth());
borderBox = m_theme->controlBorder(part, style.font(), borderBox, style.effectiveZoom());
if (borderBox.top().value() != static_cast<int>(style.borderTopWidth())) {
if (borderBox.top().value())
style->setBorderTopWidth(borderBox.top().value());
style.setBorderTopWidth(borderBox.top().value());
else
style->resetBorderTop();
style.resetBorderTop();
}
if (borderBox.right().value() != static_cast<int>(style->borderRightWidth())) {
if (borderBox.right().value() != static_cast<int>(style.borderRightWidth())) {
if (borderBox.right().value())
style->setBorderRightWidth(borderBox.right().value());
style.setBorderRightWidth(borderBox.right().value());
else
style->resetBorderRight();
style.resetBorderRight();
}
if (borderBox.bottom().value() != static_cast<int>(style->borderBottomWidth())) {
style->setBorderBottomWidth(borderBox.bottom().value());
if (borderBox.bottom().value() != static_cast<int>(style.borderBottomWidth())) {
style.setBorderBottomWidth(borderBox.bottom().value());
if (borderBox.bottom().value())
style->setBorderBottomWidth(borderBox.bottom().value());
style.setBorderBottomWidth(borderBox.bottom().value());
else
style->resetBorderBottom();
style.resetBorderBottom();
}
if (borderBox.left().value() != static_cast<int>(style->borderLeftWidth())) {
style->setBorderLeftWidth(borderBox.left().value());
if (borderBox.left().value() != static_cast<int>(style.borderLeftWidth())) {
style.setBorderLeftWidth(borderBox.left().value());
if (borderBox.left().value())
style->setBorderLeftWidth(borderBox.left().value());
style.setBorderLeftWidth(borderBox.left().value());
else
style->resetBorderLeft();
style.resetBorderLeft();
}
// Padding
LengthBox paddingBox = m_theme->controlPadding(part, style->font(), style->paddingBox(), style->effectiveZoom());
if (paddingBox != style->paddingBox())
style->setPaddingBox(paddingBox);
LengthBox paddingBox = m_theme->controlPadding(part, style.font(), style.paddingBox(), style.effectiveZoom());
if (paddingBox != style.paddingBox())
style.setPaddingBox(paddingBox);
// Whitespace
if (m_theme->controlRequiresPreWhiteSpace(part))
style->setWhiteSpace(PRE);
style.setWhiteSpace(PRE);
// Width / Height
// The width and height here are affected by the zoom.
// FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
LengthSize controlSize = m_theme->controlSize(part, style->font(), LengthSize(style->width(), style->height()), style->effectiveZoom());
if (controlSize.width() != style->width())
style->setWidth(controlSize.width());
if (controlSize.height() != style->height())
style->setHeight(controlSize.height());
LengthSize controlSize = m_theme->controlSize(part, style.font(), LengthSize(style.width(), style.height()), style.effectiveZoom());
if (controlSize.width() != style.width())
style.setWidth(controlSize.width());
if (controlSize.height() != style.height())
style.setHeight(controlSize.height());
// Min-Width / Min-Height
LengthSize minControlSize = m_theme->minimumControlSize(part, style->font(), style->effectiveZoom());
if (minControlSize.width() != style->minWidth())
style->setMinWidth(minControlSize.width());
if (minControlSize.height() != style->minHeight())
style->setMinHeight(minControlSize.height());
LengthSize minControlSize = m_theme->minimumControlSize(part, style.font(), style.effectiveZoom());
if (minControlSize.width() != style.minWidth())
style.setMinWidth(minControlSize.width());
if (minControlSize.height() != style.minHeight())
style.setMinHeight(minControlSize.height());
// Font
FontDescription controlFont = m_theme->controlFont(part, style->font(), style->effectiveZoom());
if (controlFont != style->font().fontDescription()) {
FontDescription controlFont = m_theme->controlFont(part, style.font(), style.effectiveZoom());
if (controlFont != style.font().fontDescription()) {
// Reset our line-height
style->setLineHeight(RenderStyle::initialLineHeight());
style.setLineHeight(RenderStyle::initialLineHeight());
// Now update our font.
if (style->setFontDescription(controlFont))
style->font().update(0);
if (style.setFontDescription(controlFont))
style.font().update(0);
}
}
default:
......@@ -187,28 +187,28 @@ void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style,
#endif
// Call the appropriate style adjustment method based off the appearance value.
switch (style->appearance()) {
switch (style.appearance()) {
#if !USE(NEW_THEME)
case CheckboxPart:
return adjustCheckboxStyle(styleResolver, style, e);
return adjustCheckboxStyle(&styleResolver, &style, e);
case RadioPart:
return adjustRadioStyle(styleResolver, style, e);
return adjustRadioStyle(&styleResolver, &style, e);
case PushButtonPart:
case SquareButtonPart:
case DefaultButtonPart:
case ButtonPart:
return adjustButtonStyle(styleResolver, style, e);
return adjustButtonStyle(&styleResolver, &style, e);
case InnerSpinButtonPart:
return adjustInnerSpinButtonStyle(styleResolver, style, e);
return adjustInnerSpinButtonStyle(&styleResolver, &style, e);
#endif
case TextFieldPart:
return adjustTextFieldStyle(styleResolver, style, e);
return adjustTextFieldStyle(&styleResolver, &style, e);
case TextAreaPart:
return adjustTextAreaStyle(styleResolver, style, e);
return adjustTextAreaStyle(&styleResolver, &style, e);
case MenulistPart:
return adjustMenuListStyle(styleResolver, style, e);
return adjustMenuListStyle(&styleResolver, &style, e);
case MenulistButtonPart:
return adjustMenuListButtonStyle(styleResolver, style, e);
return adjustMenuListButtonStyle(&styleResolver, &style, e);
case MediaPlayButtonPart:
case MediaCurrentTimePart:
case MediaTimeRemainingPart:
......@@ -216,29 +216,29 @@ void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style,
case MediaExitFullscreenButtonPart:
case MediaMuteButtonPart:
case MediaVolumeSliderContainerPart:
return adjustMediaControlStyle(styleResolver, style, e);
return adjustMediaControlStyle(&styleResolver, &style, e);
case MediaSliderPart:
case MediaVolumeSliderPart:
case MediaFullScreenVolumeSliderPart:
case SliderHorizontalPart:
case SliderVerticalPart:
return adjustSliderTrackStyle(styleResolver, style, e);
return adjustSliderTrackStyle(&styleResolver, &style, e);
case SliderThumbHorizontalPart:
case SliderThumbVerticalPart:
return adjustSliderThumbStyle(styleResolver, style, e);
return adjustSliderThumbStyle(&styleResolver, &style, e);
case SearchFieldPart:
return adjustSearchFieldStyle(styleResolver, style, e);
return adjustSearchFieldStyle(&styleResolver, &style, e);
case SearchFieldCancelButtonPart:
return adjustSearchFieldCancelButtonStyle(styleResolver, style, e);
return adjustSearchFieldCancelButtonStyle(&styleResolver, &style, e);
case SearchFieldDecorationPart:
return adjustSearchFieldDecorationPartStyle(styleResolver, style, e);
return adjustSearchFieldDecorationPartStyle(&styleResolver, &style, e);
case SearchFieldResultsDecorationPart:
return adjustSearchFieldResultsDecorationPartStyle(styleResolver, style, e);
return adjustSearchFieldResultsDecorationPartStyle(&styleResolver, &style, e);
case SearchFieldResultsButtonPart:
return adjustSearchFieldResultsButtonStyle(styleResolver, style, e);
return adjustSearchFieldResultsButtonStyle(&styleResolver, &style, e);
#if ENABLE(PROGRESS_ELEMENT)
case ProgressBarPart:
return adjustProgressBarStyle(styleResolver, style, e);
return adjustProgressBarStyle(&styleResolver, &style, e);
#endif
#if ENABLE(METER_ELEMENT)
case MeterPart:
......@@ -246,11 +246,11 @@ void RenderTheme::adjustStyle(StyleResolver* styleResolver, RenderStyle* style,
case ContinuousCapacityLevelIndicatorPart:
case DiscreteCapacityLevelIndicatorPart:
case RatingLevelIndicatorPart:
return adjustMeterStyle(styleResolver, style, e);
return adjustMeterStyle(&styleResolver, &style, e);
#endif
#if ENABLE(INPUT_SPEECH)
case InputSpeechButtonPart:
return adjustInputFieldSpeechButtonStyle(styleResolver, style, e);
return adjustInputFieldSpeechButtonStyle(&styleResolver, &style, e);
#endif
default:
break;
......
......@@ -73,8 +73,7 @@ public:
// metrics and defaults given the contents of the style. This includes sophisticated operations like
// selection of control size based off the font, the disabling of appearance when certain other properties like
// "border" are set, or if the appearance is not supported by the theme.
void adjustStyle(StyleResolver*, RenderStyle*, Element*, bool UAHasAppearance,
const BorderData&, const FillLayer&, const Color& backgroundColor);
void adjustStyle(StyleResolver&, RenderStyle&, Element*, bool UAHasAppearance, const BorderData&, const FillLayer&, const Color& backgroundColor);
// This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the
// text of a button, is always rendered by the engine itself. The boolean return value indicates
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment