Bug 312156 - Implement CSS3 text-overflow. r=dbaron

This commit is contained in:
Mats Palmgren 2011-06-22 20:11:47 +02:00
Родитель 5b08cd1f9d
Коммит 8506a31912
14 изменённых файлов: 112 добавлений и 9 удалений

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

@ -24,6 +24,7 @@
* Johnny Stenback <jst@netscape.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
* Robert Longson <longsonr@gmail.com>
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -50,7 +51,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[scriptable, uuid(249755DF-EEFE-4AF4-8127-BE3D6BDAED2D)]
[scriptable, uuid(7cf11a5f-4be5-4e31-b427-58d82746b5f5)]
interface nsIDOMCSS2Properties : nsISupports
{
attribute DOMString background;
@ -344,6 +345,9 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString textIndent;
// raises(DOMException) on setting
attribute DOMString textOverflow;
// raises(DOMException) on setting
attribute DOMString textShadow;
// raises(DOMException) on setting

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

@ -20,7 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of
@ -660,6 +660,11 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_TEXT_DECORATION_STYLE_WAVY 5
#define NS_STYLE_TEXT_DECORATION_STYLE_MAX NS_STYLE_TEXT_DECORATION_STYLE_WAVY
// See nsStyleTextOverflow
#define NS_STYLE_TEXT_OVERFLOW_CLIP 0
#define NS_STYLE_TEXT_OVERFLOW_ELLIPSIS 1
#define NS_STYLE_TEXT_OVERFLOW_STRING 2
// See nsStyleText
#define NS_STYLE_TEXT_TRANSFORM_NONE 0
#define NS_STYLE_TEXT_TRANSFORM_CAPITALIZE 1

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

@ -19,6 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -45,6 +46,7 @@
*|*::-moz-fieldset-content {
display: block;
unicode-bidi: inherit;
text-overflow: inherit;
height: 100%; /* Need this so percentage heights of kids work right */
}
@ -624,6 +626,7 @@ input > .anonymous-div,
*|*::-moz-display-comboboxcontrol-frame,
optgroup:before {
unicode-bidi: inherit;
text-overflow: inherit;
}
/*

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

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -221,6 +222,7 @@ CSS_KEY(center, center)
CSS_KEY(ch, ch)
CSS_KEY(circle, circle)
CSS_KEY(cjk-ideographic, cjk_ideographic)
CSS_KEY(clip, clip)
CSS_KEY(close-quote, close_quote)
CSS_KEY(closest-corner, closest_corner)
CSS_KEY(closest-side, closest_side)
@ -257,6 +259,7 @@ CSS_KEY(ease-out, ease_out)
CSS_KEY(element, element)
CSS_KEY(elements, elements)
CSS_KEY(ellipse, ellipse)
CSS_KEY(ellipsis, ellipsis)
CSS_KEY(em, em)
CSS_KEY(embed, embed)
CSS_KEY(enabled, enabled)

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

@ -21,7 +21,7 @@
*
* Contributor(s):
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -2207,6 +2207,15 @@ CSS_PROP_TEXT(
nsnull,
offsetof(nsStyleText, mTextIndent),
eStyleAnimType_Coord)
CSS_PROP_TEXTRESET(
text-overflow,
text_overflow,
TextOverflow,
CSS_PROPERTY_PARSE_VALUE,
VARIANT_HK | VARIANT_STRING,
kTextOverflowKTable,
offsetof(nsStyleTextReset, mTextOverflow),
eStyleAnimType_None)
CSS_PROP_TEXT(
text-shadow,
text_shadow,

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

@ -20,7 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of
@ -1214,6 +1214,12 @@ const PRInt32 nsCSSProps::kTextDecorationStyleKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
const PRInt32 nsCSSProps::kTextOverflowKTable[] = {
eCSSKeyword_clip, NS_STYLE_TEXT_OVERFLOW_CLIP,
eCSSKeyword_ellipsis, NS_STYLE_TEXT_OVERFLOW_ELLIPSIS,
eCSSKeyword_UNKNOWN, -1
};
const PRInt32 nsCSSProps::kTextTransformKTable[] = {
eCSSKeyword_none, NS_STYLE_TEXT_TRANSFORM_NONE,
eCSSKeyword_capitalize, NS_STYLE_TEXT_TRANSFORM_CAPITALIZE,

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

@ -20,7 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of
@ -407,6 +407,7 @@ public:
static const PRInt32 kTextBlinkKTable[];
static const PRInt32 kTextDecorationLineKTable[];
static const PRInt32 kTextDecorationStyleKTable[];
static const PRInt32 kTextOverflowKTable[];
static const PRInt32 kTextTransformKTable[];
static const PRInt32 kTransitionTimingFunctionKTable[];
static const PRInt32 kUnicodeBidiKTable[];

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

@ -23,7 +23,7 @@
* Daniel Glazman <glazman@netscape.com>
* Boris Zbarsky <bzbarsky@mit.edu>
* Christopher A. Aillon <christopher@aillon.com>
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* Christian Biesinger <cbiesinger@web.de>
* Michael Ventnor <m.ventnor@gmail.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
@ -2384,6 +2384,24 @@ nsComputedDOMStyle::DoGetTextIndent()
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetTextOverflow()
{
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
const nsStyleTextReset *style = GetStyleTextReset();
if (style->mTextOverflow.mType == NS_STYLE_TEXT_OVERFLOW_STRING) {
nsString str;
nsStyleUtil::AppendEscapedCSSString(style->mTextOverflow.mString, str);
val->SetString(str);
} else {
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(style->mTextOverflow.mType,
nsCSSProps::kTextOverflowKTable));
}
return val;
}
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetTextShadow()
{
@ -4314,6 +4332,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
COMPUTED_STYLE_MAP_ENTRY(text_align, TextAlign),
COMPUTED_STYLE_MAP_ENTRY(text_decoration, TextDecoration),
COMPUTED_STYLE_MAP_ENTRY_LAYOUT(text_indent, TextIndent),
COMPUTED_STYLE_MAP_ENTRY(text_overflow, TextOverflow),
COMPUTED_STYLE_MAP_ENTRY(text_shadow, TextShadow),
COMPUTED_STYLE_MAP_ENTRY(text_transform, TextTransform),
COMPUTED_STYLE_MAP_ENTRY_LAYOUT(top, Top),

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

@ -313,6 +313,7 @@ private:
nsIDOMCSSValue* DoGetMozTextDecorationLine();
nsIDOMCSSValue* DoGetMozTextDecorationStyle();
nsIDOMCSSValue* DoGetTextIndent();
nsIDOMCSSValue* DoGetTextOverflow();
nsIDOMCSSValue* DoGetTextTransform();
nsIDOMCSSValue* DoGetTextShadow();
nsIDOMCSSValue* DoGetLetterSpacing();

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

@ -23,7 +23,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Daniel Glazman <glazman@netscape.com>
* Roger B. Sidje <rbs@maths.uq.edu.au>
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* L. David Baron <dbaron@dbaron.org>
* Christian Biesinger <cbiesinger@web.de>
* Michael Ventnor <m.ventnor@gmail.com>
@ -3450,6 +3450,24 @@ nsRuleNode::ComputeTextResetData(void* aStartStruct,
text->SetDecorationStyle(NS_STYLE_TEXT_DECORATION_STYLE_SOLID);
}
// text-overflow: enum, string, inherit, initial
const nsCSSValue* textOverflowValue =
aRuleData->ValueForTextOverflow();
if (eCSSUnit_Enumerated == textOverflowValue->GetUnit() ||
eCSSUnit_Initial == textOverflowValue->GetUnit()) {
SetDiscrete(*textOverflowValue, text->mTextOverflow.mType,
canStoreInRuleTree,
SETDSC_ENUMERATED, parentText->mTextOverflow.mType,
NS_STYLE_TEXT_OVERFLOW_CLIP, 0, 0, 0, 0);
text->mTextOverflow.mString.Truncate();
} else if (eCSSUnit_Inherit == textOverflowValue->GetUnit()) {
canStoreInRuleTree = PR_FALSE;
text->mTextOverflow = parentText->mTextOverflow;
} else if (eCSSUnit_String == textOverflowValue->GetUnit()) {
textOverflowValue->GetStringValue(text->mTextOverflow.mString);
text->mTextOverflow.mType = NS_STYLE_TEXT_OVERFLOW_STRING;
}
// unicode-bidi: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForUnicodeBidi(), text->mUnicodeBidi, canStoreInRuleTree,
SETDSC_ENUMERATED, parentText->mUnicodeBidi,

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

@ -21,7 +21,7 @@
*
* Contributor(s):
* David Hyatt (hyatt@netscape.com)
* Mats Palmgren <mats.palmgren@bredband.net>
* Mats Palmgren <matspal@gmail.com>
* Michael Ventnor <m.ventnor@gmail.com>
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
@ -2606,7 +2606,7 @@ nsStyleTextReset::nsStyleTextReset(void)
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
{
MOZ_COUNT_CTOR(nsStyleTextReset);
memcpy((nsStyleTextReset*)this, &aSource, sizeof(nsStyleTextReset));
*this = aSource;
}
nsStyleTextReset::~nsStyleTextReset(void)
@ -2649,6 +2649,9 @@ nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) co
return NS_STYLE_HINT_VISUAL;
}
if (mTextOverflow != aOther.mTextOverflow) {
return NS_STYLE_HINT_VISUAL;
}
return NS_STYLE_HINT_NONE;
}
return NS_STYLE_HINT_REFLOW;

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

@ -1130,6 +1130,22 @@ private:
}
};
struct nsStyleTextOverflow {
nsStyleTextOverflow() : mType(NS_STYLE_TEXT_OVERFLOW_CLIP) {}
bool operator==(const nsStyleTextOverflow& aOther) const {
return mType == aOther.mType &&
(mType != NS_STYLE_TEXT_OVERFLOW_STRING ||
mString == aOther.mString);
}
bool operator!=(const nsStyleTextOverflow& aOther) const {
return !(*this == aOther);
}
nsString mString;
PRUint8 mType;
};
struct nsStyleTextReset {
nsStyleTextReset(void);
nsStyleTextReset(const nsStyleTextReset& aOther);
@ -1187,6 +1203,7 @@ struct nsStyleTextReset {
static PRBool ForceCompare() { return PR_FALSE; }
nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
nsStyleTextOverflow mTextOverflow; // [reset] enum, string
PRUint8 mTextBlink; // [reset] see nsStyleConsts.h
PRUint8 mTextDecorationLine; // [reset] see nsStyleConsts.h

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -2498,6 +2499,14 @@ var gCSSProperties = {
],
invalid_values: []
},
"text-overflow": {
domProp: "textOverflow",
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "clip" ],
other_values: [ "ellipsis", '""', "''", '"hello"' ],
invalid_values: [ "none", "auto" ]
},
"text-shadow": {
domProp: "textShadow",
inherited: true,

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

@ -19,6 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mats Palmgren <matspal@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -122,6 +123,7 @@
display: block !important;
position: static !important;
unicode-bidi: inherit;
text-overflow: inherit;
}
*|*::-moz-anonymous-block, *|*::-moz-anonymous-positioned-block {
@ -153,6 +155,7 @@
/* make unicode-bidi inherit, otherwise it has no effect on text inputs and
blocks with overflow: scroll; */
unicode-bidi: inherit;
text-overflow: inherit;
-moz-column-count: inherit;
-moz-column-width: inherit;
-moz-column-gap: inherit;
@ -179,6 +182,7 @@
/* the column boxes inside a column-flowed block */
/* make unicode-bidi inherit, otherwise it has no effect on column boxes */
unicode-bidi: inherit;
text-overflow: inherit;
/* inherit the outer frame's display, otherwise we turn into an inline */
display: inherit !important;
/* Carry through our parent's height so that %-height children get
@ -222,6 +226,7 @@
clip: inherit;
opacity: inherit;
unicode-bidi: inherit;
text-overflow: inherit;
}
/* Printing */