mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 523304 - expose text-underline-color and text-line-through-color text attributes, r=tbsaunde
This commit is contained in:
parent
ebd422385f
commit
d2543eab0e
@ -131,3 +131,12 @@ StyleInfo::FormatFontStyle(const nscoord& aValue, nsAString& aFormattedValue)
|
||||
nsCSSProps::ValueToKeywordEnum(aValue, nsCSSProps::kFontStyleKTable);
|
||||
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), aFormattedValue);
|
||||
}
|
||||
|
||||
void
|
||||
StyleInfo::FormatTextDecorationStyle(PRUint8 aValue, nsAString& aFormattedValue)
|
||||
{
|
||||
nsCSSKeyword keyword =
|
||||
nsCSSProps::ValueToKeywordEnum(aValue,
|
||||
nsCSSProps::kTextDecorationStyleKTable);
|
||||
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(keyword), aFormattedValue);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
static void FormatColor(const nscolor& aValue, nsString& aFormattedValue);
|
||||
static void FormatFontStyle(const nscoord& aValue, nsAString& aFormattedValue);
|
||||
static void FormatTextDecorationStyle(PRUint8 aValue, nsAString& aFormattedValue);
|
||||
|
||||
private:
|
||||
StyleInfo() MOZ_DELETE;
|
||||
|
@ -73,9 +73,7 @@ const char* const kCopyValue = nsnull;
|
||||
|
||||
static nsCSSTextAttrMapItem gCSSTextAttrsMap[] =
|
||||
{
|
||||
// CSS name CSS value Attribute name Attribute value
|
||||
{ "text-decoration", "line-through", &nsGkAtoms::textLineThroughStyle, "solid" },
|
||||
{ "text-decoration", "underline", &nsGkAtoms::textUnderlineStyle, "solid" },
|
||||
// CSS name CSS value Attribute name Attribute value
|
||||
{ "vertical-align", kAnyValue, &nsGkAtoms::textPosition, kCopyValue }
|
||||
};
|
||||
|
||||
@ -141,22 +139,14 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
||||
frame = offsetElm->GetPrimaryFrame();
|
||||
}
|
||||
|
||||
nsTArray<TextAttr*> textAttrArray(10);
|
||||
nsTArray<TextAttr*> textAttrArray(9);
|
||||
|
||||
// "language" text attribute
|
||||
LangTextAttr langTextAttr(mHyperTextAcc, hyperTextElm, offsetNode);
|
||||
textAttrArray.AppendElement(&langTextAttr);
|
||||
|
||||
// "text-line-through-style" text attribute
|
||||
CSSTextAttr lineThroughTextAttr(0, hyperTextElm, offsetElm);
|
||||
textAttrArray.AppendElement(&lineThroughTextAttr);
|
||||
|
||||
// "text-underline-style" text attribute
|
||||
CSSTextAttr underlineTextAttr(1, hyperTextElm, offsetElm);
|
||||
textAttrArray.AppendElement(&underlineTextAttr);
|
||||
|
||||
// "text-position" text attribute
|
||||
CSSTextAttr posTextAttr(2, hyperTextElm, offsetElm);
|
||||
CSSTextAttr posTextAttr(0, hyperTextElm, offsetElm);
|
||||
textAttrArray.AppendElement(&posTextAttr);
|
||||
|
||||
// "background-color" text attribute
|
||||
@ -183,6 +173,10 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
||||
FontWeightTextAttr fontWeightTextAttr(rootFrame, frame);
|
||||
textAttrArray.AppendElement(&fontWeightTextAttr);
|
||||
|
||||
// "text-underline(line-through)-style(color)" text attributes
|
||||
TextDecorTextAttr textDecorTextAttr(rootFrame, frame);
|
||||
textAttrArray.AppendElement(&textDecorTextAttr);
|
||||
|
||||
// Expose text attributes if applicable.
|
||||
if (aAttributes) {
|
||||
PRUint32 len = textAttrArray.Length();
|
||||
@ -669,3 +663,82 @@ TextAttrsMgr::FontWeightTextAttr::
|
||||
return fontEntry->Weight();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TextDecorTextAttr
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TextAttrsMgr::TextDecorValue::
|
||||
TextDecorValue(nsIFrame* aFrame)
|
||||
{
|
||||
const nsStyleTextReset* textReset = aFrame->GetStyleTextReset();
|
||||
mStyle = textReset->GetDecorationStyle();
|
||||
|
||||
bool isForegroundColor = false;
|
||||
textReset->GetDecorationColor(mColor, isForegroundColor);
|
||||
if (isForegroundColor)
|
||||
mColor = aFrame->GetStyleColor()->mColor;
|
||||
|
||||
mLine = textReset->mTextDecorationLine &
|
||||
(NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE |
|
||||
NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
|
||||
}
|
||||
|
||||
TextAttrsMgr::TextDecorTextAttr::
|
||||
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
||||
TTextAttr<TextDecorValue>(!aFrame)
|
||||
{
|
||||
mRootNativeValue = TextDecorValue(aRootFrame);
|
||||
mIsRootDefined = mRootNativeValue.IsDefined();
|
||||
|
||||
if (aFrame) {
|
||||
mNativeValue = TextDecorValue(aFrame);
|
||||
mIsDefined = mNativeValue.IsDefined();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TextAttrsMgr::TextDecorTextAttr::
|
||||
GetValueFor(nsIContent* aContent, TextDecorValue* aValue)
|
||||
{
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
*aValue = TextDecorValue(frame);
|
||||
return aValue->IsDefined();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
TextAttrsMgr::TextDecorTextAttr::
|
||||
ExposeValue(nsIPersistentProperties* aAttributes, const TextDecorValue& aValue)
|
||||
{
|
||||
if (aValue.IsUnderline()) {
|
||||
nsAutoString formattedStyle;
|
||||
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
||||
nsAccUtils::SetAccAttr(aAttributes,
|
||||
nsGkAtoms::textUnderlineStyle,
|
||||
formattedStyle);
|
||||
|
||||
nsAutoString formattedColor;
|
||||
StyleInfo::FormatColor(aValue.Color(), formattedColor);
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textUnderlineColor,
|
||||
formattedColor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aValue.IsLineThrough()) {
|
||||
nsAutoString formattedStyle;
|
||||
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
|
||||
nsAccUtils::SetAccAttr(aAttributes,
|
||||
nsGkAtoms::textLineThroughStyle,
|
||||
formattedStyle);
|
||||
|
||||
nsAutoString formattedColor;
|
||||
StyleInfo::FormatColor(aValue.Color(), formattedColor);
|
||||
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textLineThroughColor,
|
||||
formattedColor);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
class nsHyperTextAccessible;
|
||||
|
||||
@ -382,6 +383,58 @@ protected:
|
||||
private:
|
||||
PRInt32 GetFontWeight(nsIFrame* aFrame);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* TextDecorTextAttr class is used for the work with
|
||||
* "text-line-through-style", "text-line-through-color",
|
||||
* "text-underline-style" and "text-underline-color" text attributes.
|
||||
*/
|
||||
|
||||
class TextDecorValue
|
||||
{
|
||||
public:
|
||||
TextDecorValue() { }
|
||||
TextDecorValue(nsIFrame* aFrame);
|
||||
|
||||
nscolor Color() const { return mColor; }
|
||||
PRUint8 Style() const { return mStyle; }
|
||||
|
||||
bool IsDefined() const
|
||||
{ return IsUnderline() || IsLineThrough(); }
|
||||
bool IsUnderline() const
|
||||
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE; }
|
||||
bool IsLineThrough() const
|
||||
{ return mLine & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH; }
|
||||
|
||||
bool operator ==(const TextDecorValue& aValue)
|
||||
{
|
||||
return mColor == aValue.mColor && mLine == aValue.mLine &&
|
||||
mStyle == aValue.mStyle;
|
||||
}
|
||||
bool operator !=(const TextDecorValue& aValue)
|
||||
{ return !(*this == aValue); }
|
||||
|
||||
private:
|
||||
nscolor mColor;
|
||||
PRUint8 mLine;
|
||||
PRUint8 mStyle;
|
||||
};
|
||||
|
||||
class TextDecorTextAttr : public TTextAttr<TextDecorValue>
|
||||
{
|
||||
public:
|
||||
TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame);
|
||||
virtual ~TextDecorTextAttr() { }
|
||||
|
||||
protected:
|
||||
|
||||
// TextAttr
|
||||
virtual bool GetValueFor(nsIContent* aElm, TextDecorValue* aValue);
|
||||
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
|
||||
const TextDecorValue& aValue);
|
||||
};
|
||||
|
||||
}; // TextAttrMgr
|
||||
|
||||
} // namespace a11y
|
||||
|
@ -269,13 +269,19 @@
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 84, attrs, defAttrs, 83, 91);
|
||||
|
||||
attrs = { "text-underline-style": "solid" };
|
||||
attrs = {
|
||||
"text-underline-style": "solid",
|
||||
"text-underline-color": gComputedStyle.color
|
||||
};
|
||||
testTextAttrs(ID, 92, attrs, defAttrs, 91, 101);
|
||||
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 102, attrs, defAttrs, 101, 109);
|
||||
|
||||
attrs = { "text-line-through-style": "solid" };
|
||||
attrs = {
|
||||
"text-line-through-style": "solid",
|
||||
"text-line-through-color": gComputedStyle.color
|
||||
};
|
||||
testTextAttrs(ID, 110, attrs, defAttrs, 109, 122);
|
||||
|
||||
attrs = {};
|
||||
@ -323,13 +329,19 @@
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 85, attrs, defAttrs, 84, 92);
|
||||
|
||||
attrs = { "text-underline-style": "solid" };
|
||||
attrs = {
|
||||
"text-underline-style": "solid",
|
||||
"text-underline-color": gComputedStyle.color
|
||||
};
|
||||
testTextAttrs(ID, 93, attrs, defAttrs, 92, 102);
|
||||
|
||||
attrs = {};
|
||||
testTextAttrs(ID, 103, attrs, defAttrs, 102, 110);
|
||||
|
||||
attrs = { "text-line-through-style": "solid" };
|
||||
attrs = {
|
||||
"text-line-through-style": "solid",
|
||||
"text-line-through-color": gComputedStyle.color
|
||||
};
|
||||
testTextAttrs(ID, 111, attrs, defAttrs, 110, 123);
|
||||
|
||||
attrs = {};
|
||||
@ -437,6 +449,48 @@
|
||||
attrs = { };
|
||||
testTextAttrs(ID, 31, attrs, defAttrs, 31, 45);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// area17, "text-decoration" tests
|
||||
ID = "area17";
|
||||
defAttrs = buildDefaultTextAttrs(ID, "12pt");
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
attrs = {
|
||||
"text-underline-style": "solid",
|
||||
"text-underline-color": "rgb(0, 0, 0)",
|
||||
};
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 10);
|
||||
|
||||
attrs = {
|
||||
"text-underline-style": "solid",
|
||||
"text-underline-color": "rgb(0, 0, 255)",
|
||||
};
|
||||
testTextAttrs(ID, 10, attrs, defAttrs, 10, 15);
|
||||
|
||||
attrs = {
|
||||
"text-underline-style": "dotted",
|
||||
"text-underline-color": "rgb(0, 0, 0)",
|
||||
};
|
||||
testTextAttrs(ID, 15, attrs, defAttrs, 15, 22);
|
||||
|
||||
attrs = {
|
||||
"text-line-through-style": "solid",
|
||||
"text-line-through-color": "rgb(0, 0, 0)",
|
||||
};
|
||||
testTextAttrs(ID, 22, attrs, defAttrs, 22, 34);
|
||||
|
||||
attrs = {
|
||||
"text-line-through-style": "solid",
|
||||
"text-line-through-color": "rgb(0, 0, 255)",
|
||||
};
|
||||
testTextAttrs(ID, 34, attrs, defAttrs, 34, 39);
|
||||
|
||||
attrs = {
|
||||
"text-line-through-style": "wavy",
|
||||
"text-line-through-color": "rgb(0, 0, 0)",
|
||||
};
|
||||
testTextAttrs(ID, 39, attrs, defAttrs, 39, 44);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -450,12 +504,17 @@
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759"
|
||||
title="Implement text attributes">
|
||||
Mozilla Bug 345759
|
||||
</a><br>
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=473576"
|
||||
title="font-family text attribute should expose actual font used">
|
||||
Mozilla Bug 473576
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=523304"
|
||||
title="expose text-underline-color and text-line-through-color text attributes">
|
||||
Mozilla Bug 523304
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
@ -546,5 +605,15 @@
|
||||
<span style="font-family: Comic Sans MS, cursive;">text</span>text
|
||||
<span style="font-family: sans-serif, fantasy;">text</span>text
|
||||
</p>
|
||||
|
||||
<p id="area17">
|
||||
<span style="-moz-text-decoration-line: underline;">underline
|
||||
</span><span style="text-decoration: underline; -moz-text-decoration-color: blue;">blue
|
||||
</span><span style="text-decoration: underline; -moz-text-decoration-style: dotted;">dotted
|
||||
</span><span style="-moz-text-decoration-line: line-through;">linethrough
|
||||
</span><span style="text-decoration: line-through; -moz-text-decoration-color: blue;">blue
|
||||
</span><span style="text-decoration: line-through; -moz-text-decoration-style: wavy;">wavy
|
||||
</span>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -2004,8 +2004,10 @@ GK_ATOM(setsize, "setsize")
|
||||
GK_ATOM(tableCellIndex, "table-cell-index")
|
||||
GK_ATOM(textAlign, "text-align")
|
||||
GK_ATOM(textIndent, "text-indent")
|
||||
GK_ATOM(textLineThroughColor, "text-line-through-color")
|
||||
GK_ATOM(textLineThroughStyle, "text-line-through-style")
|
||||
GK_ATOM(textPosition, "text-position")
|
||||
GK_ATOM(textUnderlineColor, "text-underline-color")
|
||||
GK_ATOM(textUnderlineStyle, "text-underline-style")
|
||||
GK_ATOM(toolbarname, "toolbarname")
|
||||
GK_ATOM(toolbarseparator, "toolbarseparator")
|
||||
|
Loading…
Reference in New Issue
Block a user