зеркало из https://github.com/mozilla/pjs.git
Bug 249159 - Part 2 Implement CSS3 Text word-break property. r=dbaron, smontagu
This commit is contained in:
Родитель
055929159a
Коммит
57d9e8c670
|
@ -660,6 +660,9 @@ interface nsIDOMCSS2Properties : nsISupports
|
|||
attribute DOMString MozColumnRuleColor;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
attribute DOMString wordBreak;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
attribute DOMString wordWrap;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
|
|
|
@ -708,6 +708,11 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
|
|||
#define NS_STYLE_WHITESPACE_PRE_WRAP 3
|
||||
#define NS_STYLE_WHITESPACE_PRE_LINE 4
|
||||
|
||||
// See nsStyleText
|
||||
#define NS_STYLE_WORDBREAK_NORMAL 0
|
||||
#define NS_STYLE_WORDBREAK_BREAK_ALL 1
|
||||
#define NS_STYLE_WORDBREAK_KEEP_ALL 2
|
||||
|
||||
// See nsStyleText
|
||||
#define NS_STYLE_WORDWRAP_NORMAL 0
|
||||
#define NS_STYLE_WORDWRAP_BREAK_WORD 1
|
||||
|
|
|
@ -1777,6 +1777,19 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
|||
(mLineContainer->GetStyleText()->mTextAlign == NS_STYLE_TEXT_ALIGN_JUSTIFY ||
|
||||
mLineContainer->GetStyleText()->mTextAlignLast == NS_STYLE_TEXT_ALIGN_JUSTIFY);
|
||||
|
||||
// for word-break style
|
||||
switch (mLineContainer->GetStyleText()->mWordBreak) {
|
||||
case NS_STYLE_WORDBREAK_BREAK_ALL:
|
||||
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_BreakAll);
|
||||
break;
|
||||
case NS_STYLE_WORDBREAK_KEEP_ALL:
|
||||
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_KeepAll);
|
||||
break;
|
||||
default:
|
||||
mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_Normal);
|
||||
break;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
const nsStyleText* textStyle = nsnull;
|
||||
const nsStyleFont* fontStyle = nsnull;
|
||||
|
|
|
@ -100,6 +100,8 @@ HTTP(..) != synthetic-bold-metrics-01.html synthetic-bold-metrics-01-notref.html
|
|||
== white-space-1a.html white-space-1-ref.html
|
||||
== white-space-1b.html white-space-1-ref.html
|
||||
== white-space-2.html white-space-2-ref.html
|
||||
== wordbreak-1.html wordbreak-1-ref.html
|
||||
== wordbreak-2.html wordbreak-2-ref.html
|
||||
== wordwrap-01.html wordwrap-01-ref.html
|
||||
HTTP(..) == wordwrap-02.html wordwrap-02-ref.html
|
||||
HTTP(..) == wordwrap-03.html wordwrap-03-ref.html
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Test - word-break: break-all</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>f<br/>o<br/>x<br/>f<br/>-<br/>o<br/></div><br/>
|
||||
<div>fox<br/>f-o</div><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
div.breakall { width: 0px; word-break: break-all; }
|
||||
div.keepall { width: 0px; word-break: keep-all; }
|
||||
</style>
|
||||
<title>Test - word-break: break-all</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="breakall">fox f-o</div><br />
|
||||
<div class="keepall">fox f-o</div><br />
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
</style>
|
||||
<title>Test - word-break: break-all</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>フ<br/>ォ<br/>ッ<br/>ク<br/>ス</div><br/>
|
||||
<div>フォックス</div><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
div.breakall { width: 0px; word-break: break-all; }
|
||||
div.keepall { width: 0px; word-break: keep-all; }
|
||||
</style>
|
||||
<title>Test - word-break: break-all</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="breakall">フォックス</div><br />
|
||||
<div class="keepall">フォックス</div><br />
|
||||
</body>
|
||||
</html>
|
|
@ -211,6 +211,7 @@ CSS_KEY(both, both)
|
|||
CSS_KEY(bottom, bottom)
|
||||
CSS_KEY(bottom-outside, bottom_outside)
|
||||
CSS_KEY(bounding-box, bounding_box)
|
||||
CSS_KEY(break-all, break_all)
|
||||
CSS_KEY(break-word, break_word)
|
||||
CSS_KEY(button, button)
|
||||
CSS_KEY(buttonface, buttonface)
|
||||
|
@ -315,6 +316,7 @@ CSS_KEY(italic, italic)
|
|||
CSS_KEY(justify, justify)
|
||||
CSS_KEY(katakana, katakana)
|
||||
CSS_KEY(katakana-iroha, katakana_iroha)
|
||||
CSS_KEY(keep-all, keep_all)
|
||||
CSS_KEY(khz, khz)
|
||||
CSS_KEY(landscape, landscape)
|
||||
CSS_KEY(large, large)
|
||||
|
|
|
@ -2535,6 +2535,15 @@ CSS_PROP_UIRESET(
|
|||
kWindowShadowKTable,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
CSS_PROP_TEXT(
|
||||
word-break,
|
||||
word_break,
|
||||
WordBreak,
|
||||
CSS_PROPERTY_PARSE_VALUE,
|
||||
VARIANT_HK,
|
||||
kWordBreakKTable,
|
||||
offsetof(nsStyleText, mWordBreak),
|
||||
eStyleAnimType_EnumU8)
|
||||
CSS_PROP_TEXT(
|
||||
word-spacing,
|
||||
word_spacing,
|
||||
|
@ -2551,7 +2560,7 @@ CSS_PROP_TEXT(
|
|||
WordWrap,
|
||||
CSS_PROPERTY_PARSE_VALUE,
|
||||
VARIANT_HK,
|
||||
kWordwrapKTable,
|
||||
kWordWrapKTable,
|
||||
CSS_PROP_NO_OFFSET,
|
||||
eStyleAnimType_None)
|
||||
CSS_PROP_TEXT(
|
||||
|
|
|
@ -1394,7 +1394,14 @@ const PRInt32 nsCSSProps::kWindowShadowKTable[] = {
|
|||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kWordwrapKTable[] = {
|
||||
const PRInt32 nsCSSProps::kWordBreakKTable[] = {
|
||||
eCSSKeyword_normal, NS_STYLE_WORDBREAK_NORMAL,
|
||||
eCSSKeyword_break_all, NS_STYLE_WORDBREAK_BREAK_ALL,
|
||||
eCSSKeyword_keep_all, NS_STYLE_WORDBREAK_KEEP_ALL,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kWordWrapKTable[] = {
|
||||
eCSSKeyword_normal, NS_STYLE_WORDWRAP_NORMAL,
|
||||
eCSSKeyword_break_word, NS_STYLE_WORDWRAP_BREAK_WORD,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
|
|
|
@ -437,7 +437,8 @@ public:
|
|||
static const PRInt32 kWhitespaceKTable[];
|
||||
static const PRInt32 kWidthKTable[]; // also min-width, max-width
|
||||
static const PRInt32 kWindowShadowKTable[];
|
||||
static const PRInt32 kWordwrapKTable[];
|
||||
static const PRInt32 kWordBreakKTable[];
|
||||
static const PRInt32 kWordWrapKTable[];
|
||||
static const PRInt32 kHyphensKTable[];
|
||||
};
|
||||
|
||||
|
|
|
@ -2699,6 +2699,15 @@ nsComputedDOMStyle::DoGetWindowShadow()
|
|||
return val;
|
||||
}
|
||||
|
||||
nsIDOMCSSValue*
|
||||
nsComputedDOMStyle::DoGetWordBreak()
|
||||
{
|
||||
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
|
||||
val->SetIdent(
|
||||
nsCSSProps::ValueToKeywordEnum(GetStyleText()->mWordBreak,
|
||||
nsCSSProps::kWordBreakKTable));
|
||||
return val;
|
||||
}
|
||||
|
||||
nsIDOMCSSValue*
|
||||
nsComputedDOMStyle::DoGetWordWrap()
|
||||
|
@ -2706,7 +2715,7 @@ nsComputedDOMStyle::DoGetWordWrap()
|
|||
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
|
||||
val->SetIdent(
|
||||
nsCSSProps::ValueToKeywordEnum(GetStyleText()->mWordWrap,
|
||||
nsCSSProps::kWordwrapKTable));
|
||||
nsCSSProps::kWordWrapKTable));
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -4655,6 +4664,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
|
|||
COMPUTED_STYLE_MAP_ENTRY(white_space, WhiteSpace),
|
||||
// COMPUTED_STYLE_MAP_ENTRY(widows, Widows),
|
||||
COMPUTED_STYLE_MAP_ENTRY_LAYOUT(width, Width),
|
||||
COMPUTED_STYLE_MAP_ENTRY(word_break, WordBreak),
|
||||
COMPUTED_STYLE_MAP_ENTRY(word_spacing, WordSpacing),
|
||||
COMPUTED_STYLE_MAP_ENTRY(word_wrap, WordWrap),
|
||||
COMPUTED_STYLE_MAP_ENTRY(z_index, ZIndex),
|
||||
|
|
|
@ -326,6 +326,7 @@ private:
|
|||
nsIDOMCSSValue* DoGetLetterSpacing();
|
||||
nsIDOMCSSValue* DoGetWordSpacing();
|
||||
nsIDOMCSSValue* DoGetWhiteSpace();
|
||||
nsIDOMCSSValue* DoGetWordBreak();
|
||||
nsIDOMCSSValue* DoGetWordWrap();
|
||||
nsIDOMCSSValue* DoGetHyphens();
|
||||
nsIDOMCSSValue* DoGetMozTabSize();
|
||||
|
|
|
@ -3434,6 +3434,11 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
|
|||
SETDSC_ENUMERATED, parentText->mWhiteSpace,
|
||||
NS_STYLE_WHITESPACE_NORMAL, 0, 0, 0, 0);
|
||||
|
||||
// word-break: enum, inherit, initial
|
||||
SetDiscrete(*aRuleData->ValueForWordBreak(), text->mWordBreak, canStoreInRuleTree,
|
||||
SETDSC_ENUMERATED, parentText->mWordBreak,
|
||||
NS_STYLE_WORDBREAK_NORMAL, 0, 0, 0, 0);
|
||||
|
||||
// word-spacing: normal, length, inherit
|
||||
nsStyleCoord tempCoord;
|
||||
const nsCSSValue* wordSpacingValue = aRuleData->ValueForWordSpacing();
|
||||
|
|
|
@ -2824,6 +2824,7 @@ nsStyleText::nsStyleText(void)
|
|||
mTextAlignLast = NS_STYLE_TEXT_ALIGN_AUTO;
|
||||
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
||||
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
||||
mWordBreak = NS_STYLE_WORDBREAK_NORMAL;
|
||||
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
|
||||
mHyphens = NS_STYLE_HYPHENS_MANUAL;
|
||||
mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO;
|
||||
|
@ -2842,6 +2843,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|||
mTextAlignLast(aSource.mTextAlignLast),
|
||||
mTextTransform(aSource.mTextTransform),
|
||||
mWhiteSpace(aSource.mWhiteSpace),
|
||||
mWordBreak(aSource.mWordBreak),
|
||||
mWordWrap(aSource.mWordWrap),
|
||||
mHyphens(aSource.mHyphens),
|
||||
mTextSizeAdjust(aSource.mTextSizeAdjust),
|
||||
|
@ -2871,6 +2873,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
|
|||
(mTextAlignLast != aOther.mTextAlignLast) ||
|
||||
(mTextTransform != aOther.mTextTransform) ||
|
||||
(mWhiteSpace != aOther.mWhiteSpace) ||
|
||||
(mWordBreak != aOther.mWordBreak) ||
|
||||
(mWordWrap != aOther.mWordWrap) ||
|
||||
(mHyphens != aOther.mHyphens) ||
|
||||
(mTextSizeAdjust != aOther.mTextSizeAdjust) ||
|
||||
|
|
|
@ -1319,6 +1319,7 @@ struct nsStyleText {
|
|||
PRUint8 mTextAlignLast; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mWordBreak; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mWordWrap; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mHyphens; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mTextSizeAdjust; // [inherited] see nsStyleConsts.h
|
||||
|
|
|
@ -2976,6 +2976,14 @@ var gCSSProperties = {
|
|||
"-moz-calc(3em * 3em / 100%)"
|
||||
]
|
||||
},
|
||||
"word-break": {
|
||||
domProp: "wordBreak",
|
||||
inherited: true,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "normal" ],
|
||||
other_values: [ "break-all", "keep-all" ],
|
||||
invalid_values: []
|
||||
},
|
||||
"word-spacing": {
|
||||
domProp: "wordSpacing",
|
||||
inherited: true,
|
||||
|
|
Загрузка…
Ссылка в новой задаче