Fix up -moz-tab-size and unprefix it.
parent
020f796a23
commit
db50b22c68
|
@ -1233,7 +1233,7 @@ exports.CSS_PROPERTIES = {
|
|||
"-moz-tab-size": {
|
||||
"isInherited": true,
|
||||
"subproperties": [
|
||||
"-moz-tab-size"
|
||||
"tab-size"
|
||||
],
|
||||
"supports": [
|
||||
7
|
||||
|
@ -3052,7 +3052,7 @@ exports.CSS_PROPERTIES = {
|
|||
"stroke-opacity",
|
||||
"stroke-width",
|
||||
"-x-system-font",
|
||||
"-moz-tab-size",
|
||||
"tab-size",
|
||||
"table-layout",
|
||||
"text-align",
|
||||
"text-align-last",
|
||||
|
@ -8650,6 +8650,23 @@ exports.CSS_PROPERTIES = {
|
|||
"unset"
|
||||
]
|
||||
},
|
||||
"tab-size": {
|
||||
"isInherited": true,
|
||||
"subproperties": [
|
||||
"tab-size"
|
||||
],
|
||||
"supports": [
|
||||
6,
|
||||
7
|
||||
],
|
||||
"values": [
|
||||
"-moz-calc",
|
||||
"calc",
|
||||
"inherit",
|
||||
"initial",
|
||||
"unset"
|
||||
]
|
||||
},
|
||||
"table-layout": {
|
||||
"isInherited": false,
|
||||
"subproperties": [
|
||||
|
|
|
@ -75,11 +75,6 @@ const gMozillaSpecificProperties = {
|
|||
from: "ignore",
|
||||
to: "stretch-to-fit"
|
||||
},
|
||||
"-moz-tab-size": {
|
||||
// https://drafts.csswg.org/css-text-3/#propdef-tab-size
|
||||
from: "1",
|
||||
to: "5"
|
||||
},
|
||||
"-moz-text-size-adjust": {
|
||||
// https://drafts.csswg.org/css-size-adjust/#propdef-text-size-adjust
|
||||
from: "none",
|
||||
|
|
|
@ -1716,6 +1716,16 @@ GetSpaceWidthAppUnits(const gfxTextRun* aTextRun)
|
|||
return spaceWidthAppUnits;
|
||||
}
|
||||
|
||||
static gfxFloat
|
||||
GetMinTabAdvanceAppUnits(const gfxTextRun* aTextRun)
|
||||
{
|
||||
gfxFloat chWidthAppUnits =
|
||||
NS_round(GetFirstFontMetrics(aTextRun->GetFontGroup(),
|
||||
aTextRun->IsVertical()).zeroOrAveCharWidth *
|
||||
aTextRun->GetAppUnitsPerDevUnit());
|
||||
return 0.5 * chWidthAppUnits;
|
||||
}
|
||||
|
||||
static nscoord
|
||||
LetterSpacing(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr)
|
||||
{
|
||||
|
@ -3090,6 +3100,7 @@ public:
|
|||
mLength(aLength),
|
||||
mWordSpacing(WordSpacing(aFrame, mTextRun, aTextStyle)),
|
||||
mLetterSpacing(LetterSpacing(aFrame, aTextStyle)),
|
||||
mMinTabAdvance(-1.0),
|
||||
mHyphenWidth(-1),
|
||||
mOffsetFromBlockOriginForTabs(aOffsetFromBlockOriginForTabs),
|
||||
mReflowing(true),
|
||||
|
@ -3114,6 +3125,7 @@ public:
|
|||
mLength(aFrame->GetContentLength()),
|
||||
mWordSpacing(WordSpacing(aFrame, mTextRun)),
|
||||
mLetterSpacing(LetterSpacing(aFrame)),
|
||||
mMinTabAdvance(-1.0),
|
||||
mHyphenWidth(-1),
|
||||
mOffsetFromBlockOriginForTabs(0),
|
||||
mReflowing(false),
|
||||
|
@ -3176,7 +3188,14 @@ public:
|
|||
return mFontMetrics;
|
||||
}
|
||||
|
||||
void CalcTabWidths(Range aTransformedRange);
|
||||
void CalcTabWidths(Range aTransformedRange, gfxFloat aTabWidth);
|
||||
|
||||
gfxFloat MinTabAdvance() {
|
||||
if (mMinTabAdvance < 0.0) {
|
||||
mMinTabAdvance = GetMinTabAdvanceAppUnits(mTextRun);
|
||||
}
|
||||
return mMinTabAdvance;
|
||||
}
|
||||
|
||||
const gfxSkipCharsIterator& GetEndHint() { return mTempIterator; }
|
||||
|
||||
|
@ -3210,6 +3229,7 @@ protected:
|
|||
int32_t mLength; // DOM string length, may be INT32_MAX
|
||||
gfxFloat mWordSpacing; // space for each whitespace char
|
||||
gfxFloat mLetterSpacing; // space for each letter
|
||||
gfxFloat mMinTabAdvance; // min advance for <tab> char
|
||||
gfxFloat mHyphenWidth;
|
||||
gfxFloat mOffsetFromBlockOriginForTabs;
|
||||
|
||||
|
@ -3362,6 +3382,28 @@ CanAddSpacingAfter(const gfxTextRun* aTextRun, uint32_t aOffset)
|
|||
aTextRun->IsLigatureGroupStart(aOffset + 1);
|
||||
}
|
||||
|
||||
static gfxFloat
|
||||
ComputeTabWidthAppUnits(nsIFrame* aFrame, gfxTextRun* aTextRun)
|
||||
{
|
||||
const nsStyleText* textStyle = aFrame->StyleText();
|
||||
if (textStyle->mTabSize.GetUnit() != eStyleUnit_Factor) {
|
||||
nscoord w = textStyle->mTabSize.GetCoordValue();
|
||||
MOZ_ASSERT(w >= 0);
|
||||
return w;
|
||||
}
|
||||
|
||||
gfxFloat spaces = textStyle->mTabSize.GetFactorValue();
|
||||
MOZ_ASSERT(spaces >= 0);
|
||||
|
||||
// Round the space width when converting to appunits the same way
|
||||
// textruns do.
|
||||
gfxFloat spaceWidthAppUnits =
|
||||
NS_round(GetFirstFontMetrics(aTextRun->GetFontGroup(),
|
||||
aTextRun->IsVertical()).spaceWidth *
|
||||
aTextRun->GetAppUnitsPerDevUnit());
|
||||
return spaces * spaceWidthAppUnits;
|
||||
}
|
||||
|
||||
void
|
||||
PropertyProvider::GetSpacingInternal(Range aRange, Spacing* aSpacing,
|
||||
bool aIgnoreTabs)
|
||||
|
@ -3409,17 +3451,16 @@ PropertyProvider::GetSpacingInternal(Range aRange, Spacing* aSpacing,
|
|||
}
|
||||
}
|
||||
|
||||
// Ignore tab spacing rather than computing it, if the tab size is 0
|
||||
if (!aIgnoreTabs)
|
||||
aIgnoreTabs = mFrame->StyleText()->mTabSize == 0;
|
||||
|
||||
// Now add tab spacing, if there is any
|
||||
if (!aIgnoreTabs) {
|
||||
CalcTabWidths(aRange);
|
||||
if (mTabWidths) {
|
||||
mTabWidths->ApplySpacing(aSpacing,
|
||||
aRange.start - mStart.GetSkippedOffset(),
|
||||
aRange.Length());
|
||||
gfxFloat tabWidth = ComputeTabWidthAppUnits(mFrame, mTextRun);
|
||||
if (tabWidth > 0) {
|
||||
CalcTabWidths(aRange, tabWidth);
|
||||
if (mTabWidths) {
|
||||
mTabWidths->ApplySpacing(aSpacing,
|
||||
aRange.start - mStart.GetSkippedOffset(),
|
||||
aRange.Length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3442,33 +3483,22 @@ PropertyProvider::GetSpacingInternal(Range aRange, Spacing* aSpacing,
|
|||
}
|
||||
}
|
||||
|
||||
static gfxFloat
|
||||
ComputeTabWidthAppUnits(nsIFrame* aFrame, const gfxTextRun* aTextRun)
|
||||
{
|
||||
// Get the number of spaces from CSS -moz-tab-size
|
||||
const nsStyleText* textStyle = aFrame->StyleText();
|
||||
|
||||
return textStyle->mTabSize * GetSpaceWidthAppUnits(aTextRun);
|
||||
}
|
||||
|
||||
// aX and the result are in whole appunits.
|
||||
static gfxFloat
|
||||
AdvanceToNextTab(gfxFloat aX, nsIFrame* aFrame,
|
||||
const gfxTextRun* aTextRun, gfxFloat* aCachedTabWidth)
|
||||
AdvanceToNextTab(gfxFloat aX, nsIFrame* aFrame, gfxTextRun* aTextRun,
|
||||
gfxFloat aTabWidth, gfxFloat aMinAdvance)
|
||||
{
|
||||
if (*aCachedTabWidth < 0) {
|
||||
*aCachedTabWidth = ComputeTabWidthAppUnits(aFrame, aTextRun);
|
||||
}
|
||||
|
||||
// Advance aX to the next multiple of *aCachedTabWidth. We must advance
|
||||
// by at least 1 appunit.
|
||||
// XXX should we make this 1 CSS pixel?
|
||||
return ceil((aX + 1)/(*aCachedTabWidth))*(*aCachedTabWidth);
|
||||
// Advance aX to the next multiple of aTabWidth. We must advance
|
||||
// by at least aMinAdvance.
|
||||
return ceil((aX + aMinAdvance) / aTabWidth) * aTabWidth;
|
||||
}
|
||||
|
||||
void
|
||||
PropertyProvider::CalcTabWidths(Range aRange)
|
||||
PropertyProvider::CalcTabWidths(Range aRange, gfxFloat aTabWidth)
|
||||
{
|
||||
MOZ_ASSERT(aTabWidth > 0);
|
||||
|
||||
if (!mTabWidths) {
|
||||
if (mReflowing && !mLineContainer) {
|
||||
// Intrinsic width computation does its own tab processing. We
|
||||
|
@ -3503,7 +3533,6 @@ PropertyProvider::CalcTabWidths(Range aRange)
|
|||
NS_ASSERTION(mReflowing,
|
||||
"We need precomputed tab widths, but don't have enough.");
|
||||
|
||||
gfxFloat tabWidth = -1;
|
||||
for (uint32_t i = tabsEnd; i < aRange.end; ++i) {
|
||||
Spacing spacing;
|
||||
GetSpacingInternal(Range(i, i + 1), &spacing, true);
|
||||
|
@ -3525,7 +3554,7 @@ PropertyProvider::CalcTabWidths(Range aRange)
|
|||
mFrame->SetProperty(TabWidthProperty(), mTabWidths);
|
||||
}
|
||||
double nextTab = AdvanceToNextTab(mOffsetFromBlockOriginForTabs,
|
||||
mFrame, mTextRun, &tabWidth);
|
||||
mFrame, mTextRun, aTabWidth, MinTabAdvance());
|
||||
mTabWidths->mWidths.AppendElement(TabWidth(i - startOffset,
|
||||
NSToIntRound(nextTab - mOffsetFromBlockOriginForTabs)));
|
||||
mOffsetFromBlockOriginForTabs = nextTab;
|
||||
|
@ -8319,9 +8348,12 @@ nsTextFrame::AddInlineMinISizeForFlow(nsRenderingContext *aRenderingContext,
|
|||
PropertyProvider::Spacing spacing;
|
||||
provider.GetSpacing(Range(i, i + 1), &spacing);
|
||||
aData->mCurrentLine += nscoord(spacing.mBefore);
|
||||
if (tabWidth < 0) {
|
||||
tabWidth = ComputeTabWidthAppUnits(this, textRun);
|
||||
}
|
||||
gfxFloat afterTab =
|
||||
AdvanceToNextTab(aData->mCurrentLine, this,
|
||||
textRun, &tabWidth);
|
||||
AdvanceToNextTab(aData->mCurrentLine, this, textRun, tabWidth,
|
||||
provider.MinTabAdvance());
|
||||
aData->mCurrentLine = nscoord(afterTab + spacing.mAfter);
|
||||
wordStart = i + 1;
|
||||
} else if (i < flowEndInTextRun ||
|
||||
|
@ -8478,9 +8510,12 @@ nsTextFrame::AddInlinePrefISizeForFlow(nsRenderingContext *aRenderingContext,
|
|||
PropertyProvider::Spacing spacing;
|
||||
provider.GetSpacing(Range(i, i + 1), &spacing);
|
||||
aData->mCurrentLine += nscoord(spacing.mBefore);
|
||||
if (tabWidth < 0) {
|
||||
tabWidth = ComputeTabWidthAppUnits(this, textRun);
|
||||
}
|
||||
gfxFloat afterTab =
|
||||
AdvanceToNextTab(aData->mCurrentLine, this,
|
||||
textRun, &tabWidth);
|
||||
AdvanceToNextTab(aData->mCurrentLine, this, textRun, tabWidth,
|
||||
provider.MinTabAdvance());
|
||||
aData->mCurrentLine = nscoord(afterTab + spacing.mAfter);
|
||||
lineStart = i + 1;
|
||||
} else if (preformattedNewline) {
|
||||
|
|
|
@ -222,6 +222,10 @@ CSS_PROP_ALIAS(-moz-columns,
|
|||
columns,
|
||||
MozColumns,
|
||||
"")
|
||||
CSS_PROP_ALIAS(-moz-tab-size,
|
||||
tab_size,
|
||||
MozTabSize,
|
||||
"")
|
||||
|
||||
#define WEBKIT_PREFIX_PREF "layout.css.prefixes.webkit"
|
||||
|
||||
|
|
|
@ -3879,16 +3879,16 @@ CSS_PROP_FONT(
|
|||
eStyleAnimType_None)
|
||||
#endif // CSS_PROP_LIST_EXCLUDE_INTERNAL
|
||||
CSS_PROP_TEXT(
|
||||
-moz-tab-size,
|
||||
_moz_tab_size,
|
||||
CSS_PROP_DOMPROP_PREFIXED(TabSize),
|
||||
tab-size,
|
||||
tab_size,
|
||||
TabSize,
|
||||
CSS_PROPERTY_PARSE_VALUE |
|
||||
CSS_PROPERTY_VALUE_NONNEGATIVE,
|
||||
"",
|
||||
VARIANT_HI,
|
||||
VARIANT_INHERIT | VARIANT_LNCALC,
|
||||
nullptr,
|
||||
offsetof(nsStyleText, mTabSize),
|
||||
eStyleAnimType_Discrete)
|
||||
eStyleAnimType_Coord)
|
||||
CSS_PROP_TABLE(
|
||||
table-layout,
|
||||
table_layout,
|
||||
|
|
|
@ -4013,7 +4013,7 @@ already_AddRefed<CSSValue>
|
|||
nsComputedDOMStyle::DoGetTabSize()
|
||||
{
|
||||
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
|
||||
val->SetNumber(StyleText()->mTabSize);
|
||||
SetValueToCoord(val, StyleText()->mTabSize, true);
|
||||
return val.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ COMPUTED_STYLE_PROP(scroll_snap_type_x, ScrollSnapTypeX)
|
|||
COMPUTED_STYLE_PROP(scroll_snap_type_y, ScrollSnapTypeY)
|
||||
COMPUTED_STYLE_PROP(shape_outside, ShapeOutside)
|
||||
//// COMPUTED_STYLE_PROP(size, Size)
|
||||
COMPUTED_STYLE_PROP(tab_size, TabSize)
|
||||
COMPUTED_STYLE_PROP(table_layout, TableLayout)
|
||||
COMPUTED_STYLE_PROP(text_align, TextAlign)
|
||||
COMPUTED_STYLE_PROP(text_align_last, TextAlignLast)
|
||||
|
@ -295,7 +296,6 @@ COMPUTED_STYLE_PROP(_moz_outline_radius_bottomRight,OutlineRadiusBottomRight)
|
|||
COMPUTED_STYLE_PROP(_moz_outline_radius_topLeft, OutlineRadiusTopLeft)
|
||||
COMPUTED_STYLE_PROP(_moz_outline_radius_topRight, OutlineRadiusTopRight)
|
||||
COMPUTED_STYLE_PROP(stack_sizing, StackSizing)
|
||||
COMPUTED_STYLE_PROP(_moz_tab_size, TabSize)
|
||||
COMPUTED_STYLE_PROP(text_size_adjust, TextSizeAdjust)
|
||||
COMPUTED_STYLE_PROP(user_focus, UserFocus)
|
||||
COMPUTED_STYLE_PROP(user_input, UserInput)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3806,10 +3806,10 @@ nsStyleText::nsStyleText(StyleStructContext aContext)
|
|||
, mControlCharacterVisibility(nsCSSParser::ControlCharVisibilityDefault())
|
||||
, mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE)
|
||||
, mTextRendering(NS_STYLE_TEXT_RENDERING_AUTO)
|
||||
, mTabSize(NS_STYLE_TABSIZE_INITIAL)
|
||||
, mTextEmphasisColor(StyleComplexColor::CurrentColor())
|
||||
, mWebkitTextFillColor(StyleComplexColor::CurrentColor())
|
||||
, mWebkitTextStrokeColor(StyleComplexColor::CurrentColor())
|
||||
, mTabSize(float(NS_STYLE_TABSIZE_INITIAL), eStyleUnit_Factor)
|
||||
, mWordSpacing(0, nsStyleCoord::CoordConstructor)
|
||||
, mLetterSpacing(eStyleUnit_Normal)
|
||||
, mLineHeight(eStyleUnit_Normal)
|
||||
|
@ -3844,10 +3844,10 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|||
, mTextEmphasisPosition(aSource.mTextEmphasisPosition)
|
||||
, mTextEmphasisStyle(aSource.mTextEmphasisStyle)
|
||||
, mTextRendering(aSource.mTextRendering)
|
||||
, mTabSize(aSource.mTabSize)
|
||||
, mTextEmphasisColor(aSource.mTextEmphasisColor)
|
||||
, mWebkitTextFillColor(aSource.mWebkitTextFillColor)
|
||||
, mWebkitTextStrokeColor(aSource.mWebkitTextStrokeColor)
|
||||
, mTabSize(aSource.mTabSize)
|
||||
, mWordSpacing(aSource.mWordSpacing)
|
||||
, mLetterSpacing(aSource.mLetterSpacing)
|
||||
, mLineHeight(aSource.mLineHeight)
|
||||
|
|
|
@ -2087,11 +2087,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText
|
|||
uint8_t mTextEmphasisPosition; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mTextEmphasisStyle; // [inherited] see nsStyleConsts.h
|
||||
uint8_t mTextRendering; // [inherited] see nsStyleConsts.h
|
||||
int32_t mTabSize; // [inherited] see nsStyleConsts.h
|
||||
mozilla::StyleComplexColor mTextEmphasisColor; // [inherited]
|
||||
mozilla::StyleComplexColor mWebkitTextFillColor; // [inherited]
|
||||
mozilla::StyleComplexColor mWebkitTextStrokeColor; // [inherited]
|
||||
|
||||
nsStyleCoord mTabSize; // [inherited] coord, factor, calc
|
||||
nsStyleCoord mWordSpacing; // [inherited] coord, percent, calc
|
||||
nsStyleCoord mLetterSpacing; // [inherited] coord, normal
|
||||
nsStyleCoord mLineHeight; // [inherited] coord, factor, normal
|
||||
|
|
|
@ -2027,13 +2027,22 @@ var gCSSProperties = {
|
|||
other_values: [ "ignore" ],
|
||||
invalid_values: []
|
||||
},
|
||||
"-moz-tab-size": {
|
||||
domProp: "MozTabSize",
|
||||
"tab-size": {
|
||||
domProp: "TabSize",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "8" ],
|
||||
other_values: [ "0", "3", "99", "12000" ],
|
||||
invalid_values: [ "-1", "-808", "3.0", "17.5" ]
|
||||
other_values: [ "0", "2.5", "3", "99", "12000", "0px", "1em",
|
||||
"calc(1px + 1em)", "calc(1px - 2px)", "calc(1 + 1)", "calc(-2.5)" ],
|
||||
invalid_values: [ "9%", "calc(9% + 1px)", "calc(1 + 1em)", "-1", "-808",
|
||||
"auto" ]
|
||||
},
|
||||
"-moz-tab-size": {
|
||||
domProp: "MozTabSize",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_SHORTHAND_AND_LONGHAND
|
||||
alias_for: "tab-size",
|
||||
subproperties: [ "tab-size" ]
|
||||
},
|
||||
"-moz-text-size-adjust": {
|
||||
domProp: "MozTextSizeAdjust",
|
||||
|
|
|
@ -248,6 +248,8 @@ var supported_properties = {
|
|||
// test_length_percent_calc_transition.
|
||||
"stroke-width": [ test_length_transition_svg, test_percent_transition,
|
||||
test_length_clamped_svg, test_percent_clamped ],
|
||||
"tab-size": [ test_float_zeroToOne_transition,
|
||||
test_float_aboveOne_transition, test_length_clamped ],
|
||||
"text-decoration": [ test_color_shorthand_transition,
|
||||
test_true_currentcolor_shorthand_transition ],
|
||||
"text-decoration-color": [ test_color_transition,
|
||||
|
|
|
@ -31,7 +31,7 @@ nsHtml5ViewSourceUtils::NewBodyAttributes()
|
|||
int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
|
||||
if (tabSize > 0) {
|
||||
nsString style;
|
||||
style.AssignASCII("-moz-tab-size: ");
|
||||
style.AssignASCII("tab-size: ");
|
||||
style.AppendInt(tabSize);
|
||||
bodyAttrs->addAttribute(
|
||||
nsHtml5AttributeName::ATTR_STYLE, nsHtml5String::FromString(style), -1);
|
||||
|
|
Loading…
Reference in New Issue