Bug 1261754 - Part 6: Move vertical-align from nsStyleTextReset to nsStyleDisplay. r=dholbert

This commit is contained in:
Cameron McCormack 2016-04-12 15:52:41 +10:00
Родитель d7db2f5ade
Коммит cb363fa1df
16 изменённых файлов: 83 добавлений и 80 удалений

Просмотреть файл

@ -828,7 +828,7 @@ TextAttrsMgr::TextPosValue
TextAttrsMgr::TextPosTextAttr::
GetTextPosValue(nsIFrame* aFrame) const
{
const nsStyleCoord& styleCoord = aFrame->StyleTextReset()->mVerticalAlign;
const nsStyleCoord& styleCoord = aFrame->StyleDisplay()->mVerticalAlign;
switch (styleCoord.GetUnit()) {
case eStyleUnit_Enumerated:
switch (styleCoord.GetIntValue()) {

Просмотреть файл

@ -493,7 +493,7 @@ HTMLTableCellElement::MapAttributesIntoRule(const nsMappedAttributes* aAttribute
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum

Просмотреть файл

@ -111,7 +111,7 @@ HTMLTableColElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum

Просмотреть файл

@ -286,7 +286,7 @@ HTMLTableRowElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum

Просмотреть файл

@ -186,7 +186,7 @@ HTMLTableSectionElement::MapAttributesIntoRule(const nsMappedAttributes* aAttrib
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum

Просмотреть файл

@ -1431,32 +1431,27 @@ void
nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttributes,
nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & (NS_STYLE_INHERIT_BIT(Display) |
NS_STYLE_INHERIT_BIT(TextReset))) {
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
int32_t align = value->GetEnumValue();
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* cssFloat = aRuleData->ValueForFloat();
if (cssFloat->GetUnit() == eCSSUnit_Null) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
}
nsCSSValue* cssFloat = aRuleData->ValueForFloat();
if (cssFloat->GetUnit() == eCSSUnit_Null) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_LEFT, eCSSUnit_Enumerated);
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
cssFloat->SetIntValue(NS_STYLE_FLOAT_RIGHT, eCSSUnit_Enumerated);
}
}
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset)) {
nsCSSValue* verticalAlign = aRuleData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
verticalAlign->SetIntValue(align, eCSSUnit_Enumerated);
break;
}
nsCSSValue* verticalAlign = aRuleData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
verticalAlign->SetIntValue(align, eCSSUnit_Enumerated);
break;
}
}
}

Просмотреть файл

@ -8544,7 +8544,7 @@ nsIFrame::VerticalAlignEnum() const
return ConvertSVGDominantBaselineToVerticalAlign(dominantBaseline);
}
const nsStyleCoord& verticalAlign = StyleTextReset()->mVerticalAlign;
const nsStyleCoord& verticalAlign = StyleDisplay()->mVerticalAlign;
if (verticalAlign.GetUnit() == eStyleUnit_Enumerated) {
return verticalAlign.GetIntValue();
}

Просмотреть файл

@ -2002,8 +2002,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// Get vertical-align property ("vertical-align" is the CSS name for
// block-direction align)
const nsStyleCoord& verticalAlign =
frame->StyleTextReset()->mVerticalAlign;
const nsStyleCoord& verticalAlign = frame->StyleDisplay()->mVerticalAlign;
uint8_t verticalAlignEnum = frame->VerticalAlignEnum();
#ifdef NOISY_BLOCKDIR_ALIGN
printf(" [frame]");

Просмотреть файл

@ -3644,7 +3644,7 @@ CSS_PROP_UIRESET(
// NOTE: vertical-align is only supposed to apply to :first-letter when
// 'float' is 'none', but we don't worry about that since it has no
// effect otherwise
CSS_PROP_TEXTRESET(
CSS_PROP_DISPLAY(
vertical-align,
vertical_align,
VerticalAlign,
@ -3657,7 +3657,7 @@ CSS_PROP_TEXTRESET(
"",
VARIANT_HKLP | VARIANT_CALC,
kVerticalAlignKTable,
offsetof(nsStyleTextReset, mVerticalAlign),
offsetof(nsStyleDisplay, mVerticalAlign),
eStyleAnimType_Coord)
CSS_PROP_VISIBILITY(
visibility,

Просмотреть файл

@ -3533,7 +3533,7 @@ already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetVerticalAlign()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueToCoord(val, StyleTextReset()->mVerticalAlign, false,
SetValueToCoord(val, StyleDisplay()->mVerticalAlign, false,
&nsComputedDOMStyle::GetLineHeightCoord,
nsCSSProps::kVerticalAlignKTable);
return val.forget();

Просмотреть файл

@ -4726,19 +4726,6 @@ nsRuleNode::ComputeTextResetData(void* aStartStruct,
{
COMPUTE_START_RESET(TextReset, text, parentText)
// vertical-align: enum, length, percent, calc, inherit
const nsCSSValue* verticalAlignValue = aRuleData->ValueForVerticalAlign();
if (!SetCoord(*verticalAlignValue, text->mVerticalAlign,
parentText->mVerticalAlign,
SETCOORD_LPH | SETCOORD_ENUMERATED | SETCOORD_STORE_CALC,
aContext, mPresContext, conditions)) {
if (eCSSUnit_Initial == verticalAlignValue->GetUnit() ||
eCSSUnit_Unset == verticalAlignValue->GetUnit()) {
text->mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE,
eStyleUnit_Enumerated);
}
}
// text-decoration-line: enum (bit field), inherit, initial
const nsCSSValue* decorationLineValue =
aRuleData->ValueForTextDecorationLine();
@ -6257,6 +6244,19 @@ nsRuleNode::ComputeDisplayData(void* aStartStruct,
MOZ_ASSERT(false, "unrecognized will-change unit");
}
// vertical-align: enum, length, percent, calc, inherit
const nsCSSValue* verticalAlignValue = aRuleData->ValueForVerticalAlign();
if (!SetCoord(*verticalAlignValue, display->mVerticalAlign,
parentDisplay->mVerticalAlign,
SETCOORD_LPH | SETCOORD_ENUMERATED | SETCOORD_STORE_CALC,
aContext, mPresContext, conditions)) {
if (eCSSUnit_Initial == verticalAlignValue->GetUnit() ||
eCSSUnit_Unset == verticalAlignValue->GetUnit()) {
display->mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE,
eStyleUnit_Enumerated);
}
}
/* Convert -moz-transform-origin. */
const nsCSSValue* transformOriginValue =
aRuleData->ValueForTransformOrigin();

Просмотреть файл

@ -2903,6 +2903,7 @@ nsStyleDisplay::nsStyleDisplay(StyleStructContext aContext)
mPerspectiveOrigin[0].SetPercentValue(0.5f);
mPerspectiveOrigin[1].SetPercentValue(0.5f);
mChildPerspective.SetNoneValue();
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
mBackfaceVisibility = NS_STYLE_BACKFACE_VISIBILITY_VISIBLE;
mTransformStyle = NS_STYLE_TRANSFORM_STYLE_FLAT;
mTransformBox = NS_STYLE_TRANSFORM_BOX_BORDER_BOX;
@ -2981,6 +2982,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
, mTransformBox(aSource.mTransformBox)
, mSpecifiedTransform(aSource.mSpecifiedTransform)
, mChildPerspective(aSource.mChildPerspective)
, mVerticalAlign(aSource.mVerticalAlign)
, mTransitions(aSource.mTransitions)
, mTransitionTimingFunctionCount(aSource.mTransitionTimingFunctionCount)
, mTransitionDurationCount(aSource.mTransitionDurationCount)
@ -3060,6 +3062,12 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
nsChangeHint_NeedDirtyReflow)));
}
if (mVerticalAlign != aOther.mVerticalAlign) {
// XXX Can this just be AllReflowHints + RepaintFrame, and be included in
// the block below?
NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
}
// XXX the following is conservative, for now: changing float breaking shouldn't
// necessarily require a repaint, reflow should suffice.
if (mBreakType != aOther.mBreakType
@ -3566,7 +3574,6 @@ nsresult nsStyleContent::AllocateContents(uint32_t aCount)
nsStyleTextReset::nsStyleTextReset(StyleStructContext aContext)
{
MOZ_COUNT_CTOR(nsStyleTextReset);
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
mTextDecorationLine = NS_STYLE_TEXT_DECORATION_LINE_NONE;
mTextDecorationColor = NS_RGB(0,0,0);
mTextDecorationStyle =
@ -3585,38 +3592,39 @@ nsStyleTextReset::~nsStyleTextReset(void)
MOZ_COUNT_DTOR(nsStyleTextReset);
}
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
nsChangeHint
nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
{
if (mVerticalAlign == aOther.mVerticalAlign
&& mUnicodeBidi == aOther.mUnicodeBidi) {
uint8_t lineStyle = GetDecorationStyle();
uint8_t otherLineStyle = aOther.GetDecorationStyle();
if (mTextDecorationLine != aOther.mTextDecorationLine ||
lineStyle != otherLineStyle) {
// Changes to our text-decoration line can impact our overflow area &
// also our descendants' overflow areas (particularly for text-frame
// descendants). So, we update those areas & trigger a repaint.
nsChangeHint hint = nsChangeHint_RepaintFrame;
NS_UpdateHint(hint, nsChangeHint_UpdateSubtreeOverflow);
NS_UpdateHint(hint, nsChangeHint_SchedulePaint);
return hint;
}
// Repaint for decoration color changes
nscolor decColor, otherDecColor;
bool isFG, otherIsFG;
GetDecorationColor(decColor, isFG);
aOther.GetDecorationColor(otherDecColor, otherIsFG);
if (isFG != otherIsFG || (!isFG && decColor != otherDecColor)) {
return nsChangeHint_RepaintFrame;
}
if (mTextOverflow != aOther.mTextOverflow) {
return nsChangeHint_RepaintFrame;
}
return NS_STYLE_HINT_NONE;
if (mUnicodeBidi != aOther.mUnicodeBidi) {
return NS_STYLE_HINT_REFLOW;
}
return NS_STYLE_HINT_REFLOW;
uint8_t lineStyle = GetDecorationStyle();
uint8_t otherLineStyle = aOther.GetDecorationStyle();
if (mTextDecorationLine != aOther.mTextDecorationLine ||
lineStyle != otherLineStyle) {
// Changes to our text-decoration line can impact our overflow area &
// also our descendants' overflow areas (particularly for text-frame
// descendants). So, we update those areas & trigger a repaint.
return nsChangeHint_RepaintFrame |
nsChangeHint_UpdateSubtreeOverflow |
nsChangeHint_SchedulePaint;
}
// Repaint for decoration color changes
nscolor decColor, otherDecColor;
bool isFG, otherIsFG;
GetDecorationColor(decColor, isFG);
aOther.GetDecorationColor(otherDecColor, otherIsFG);
if (isFG != otherIsFG || (!isFG && decColor != otherDecColor)) {
return nsChangeHint_RepaintFrame;
}
if (mTextOverflow != aOther.mTextOverflow) {
return nsChangeHint_RepaintFrame;
}
return NS_STYLE_HINT_NONE;
}
// Returns true if the given shadow-arrays are equal.

Просмотреть файл

@ -1922,7 +1922,6 @@ struct nsStyleTextReset
nsChangeHint_ClearAncestorIntrinsics;
}
nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
nsStyleTextOverflow mTextOverflow; // [reset] enum, string
uint8_t mTextDecorationLine; // [reset] see nsStyleConsts.h
@ -2527,6 +2526,8 @@ struct nsStyleDisplay
nsStyleCoord mChildPerspective; // [reset] none, coord
nsStyleCoord mPerspectiveOrigin[2]; // [reset] percent, coord, calc
nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
AutoTArray<mozilla::StyleTransition, 1> mTransitions; // [reset]
// The number of elements in mTransitions that are not from repeating
// a list due to another property being longer.

Просмотреть файл

@ -677,7 +677,7 @@ nsTableCellFrame::UpdateOverflow()
uint8_t
nsTableCellFrame::GetVerticalAlign() const
{
const nsStyleCoord& verticalAlign = StyleTextReset()->mVerticalAlign;
const nsStyleCoord& verticalAlign = StyleDisplay()->mVerticalAlign;
if (verticalAlign.GetUnit() == eStyleUnit_Enumerated) {
uint8_t value = verticalAlign.GetIntValue();
if (value == NS_STYLE_VERTICAL_ALIGN_TOP ||

Просмотреть файл

@ -474,7 +474,7 @@ uint8_t
nsTableOuterFrame::GetCaptionVerticalAlign()
{
const nsStyleCoord& va =
mCaptionFrames.FirstChild()->StyleTextReset()->mVerticalAlign;
mCaptionFrames.FirstChild()->StyleDisplay()->mVerticalAlign;
return (va.GetUnit() == eStyleUnit_Enumerated)
? va.GetIntValue()
: NS_STYLE_VERTICAL_ALIGN_TOP;

Просмотреть файл

@ -956,7 +956,7 @@ static float VerticalAlignFactor(nsIFrame *aFrame)
if (!aFrame)
return 0.5f; // default: center
const nsStyleCoord& va = aFrame->StyleTextReset()->mVerticalAlign;
const nsStyleCoord& va = aFrame->StyleDisplay()->mVerticalAlign;
uint8_t intval = (va.GetUnit() == eStyleUnit_Enumerated)
? va.GetIntValue()
: NS_STYLE_VERTICAL_ALIGN_MIDDLE;