Bug 1097499 part 2 - Add a macro to simplify usage of nsStyleContext::GetUniqueStyleData. r=heycam

MozReview-Commit-ID: IS8KUbkXp8m

--HG--
extra : source : 5ee7bfeb7ceafcfff6c0bbd90507ed0b7b8de351
This commit is contained in:
Xidorn Quan 2016-04-22 09:18:41 +10:00
parent b1521c643f
commit 747a0b5474

View File

@ -639,6 +639,9 @@ ShouldBlockifyChildren(const nsStyleDisplay* aStyleDisp)
void
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
#define GET_UNIQUE_STYLE_DATA(name_) \
static_cast<nsStyle##name_*>(GetUniqueStyleData(eStyleStruct_##name_))
// See if we have any text decorations.
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
if (mParent && mParent->HasTextDecorationLines()) {
@ -664,8 +667,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
presContext->StyleSet()->ResolveStyleFor(docElement, nullptr);
auto dir = rootStyle->StyleVisibility()->mDirection;
if (dir != StyleVisibility()->mDirection) {
nsStyleVisibility* uniqueVisibility =
(nsStyleVisibility*)GetUniqueStyleData(eStyleStruct_Visibility);
nsStyleVisibility* uniqueVisibility = GET_UNIQUE_STYLE_DATA(Visibility);
uniqueVisibility->mDirection = dir;
}
}
@ -683,7 +685,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER ||
text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)
{
nsStyleText* uniqueText = (nsStyleText*)GetUniqueStyleData(eStyleStruct_Text);
nsStyleText* uniqueText = GET_UNIQUE_STYLE_DATA(Text);
uniqueText->mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
}
}
@ -706,8 +708,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
displayVal = NS_STYLE_DISPLAY_BLOCK;
}
if (displayVal != disp->mDisplay) {
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
nsStyleDisplay* mutable_display = GET_UNIQUE_STYLE_DATA(Display);
disp = mutable_display;
// If we're in this code, then mOriginalDisplay doesn't matter
@ -757,8 +758,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
"We shouldn't be changing the display value of "
"positioned content (and we should have already "
"converted its display value to be block-level...)");
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
nsStyleDisplay* mutable_display = GET_UNIQUE_STYLE_DATA(Display);
disp = mutable_display;
mutable_display->mDisplay = displayVal;
}
@ -777,8 +777,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal);
if (displayVal != disp->mDisplay) {
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
nsStyleDisplay* mutable_display = GET_UNIQUE_STYLE_DATA(Display);
disp = mutable_display;
mutable_display->mDisplay = displayVal;
}
@ -802,8 +801,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
unicodeBidi = NS_STYLE_UNICODE_BIDI_ISOLATE_OVERRIDE;
}
if (unicodeBidi != textReset->mUnicodeBidi) {
auto mutableTextReset = static_cast<nsStyleTextReset*>(
GetUniqueStyleData(eStyleStruct_TextReset));
nsStyleTextReset* mutableTextReset = GET_UNIQUE_STYLE_DATA(TextReset);
mutableTextReset->mUnicodeBidi = unicodeBidi;
}
}
@ -828,8 +826,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
// and text-orientation) here; just the writing-mode property is enough.
if (StyleVisibility()->mWritingMode !=
cbContext->StyleVisibility()->mWritingMode) {
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
nsStyleDisplay* mutable_display = GET_UNIQUE_STYLE_DATA(Display);
disp = mutable_display;
mutable_display->mOriginalDisplay = mutable_display->mDisplay =
NS_STYLE_DISPLAY_INLINE_BLOCK;
@ -838,6 +835,7 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
// Compute User Interface style, to trigger loads of cursors
StyleUserInterface();
#undef GET_UNIQUE_STYLE_DATA
}
nsChangeHint