2009-02-15 00:35:10 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
|
|
|
*
|
|
|
|
* 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"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
#include "TextAttrs.h"
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2009-02-15 00:35:10 -08:00
|
|
|
#include "nsHyperTextAccessibleWrap.h"
|
2012-02-27 06:43:39 -08:00
|
|
|
#include "StyleInfo.h"
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2009-03-03 22:46:29 -08:00
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
2011-04-07 18:05:49 -07:00
|
|
|
#include "nsFontMetrics.h"
|
2011-08-14 10:08:04 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2009-03-03 22:46:29 -08:00
|
|
|
|
2012-02-27 06:43:39 -08:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constants and structures
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Item of the gCSSTextAttrsMap map.
|
|
|
|
*/
|
|
|
|
struct nsCSSTextAttrMapItem
|
|
|
|
{
|
|
|
|
const char* mCSSName;
|
|
|
|
const char* mCSSValue;
|
|
|
|
nsIAtom** mAttrName;
|
|
|
|
const char* mAttrValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The map of CSS properties to text attributes.
|
|
|
|
*/
|
|
|
|
const char* const kAnyValue = nsnull;
|
|
|
|
const char* const kCopyValue = nsnull;
|
|
|
|
|
|
|
|
static nsCSSTextAttrMapItem gCSSTextAttrsMap[] =
|
|
|
|
{
|
2012-03-10 07:35:02 -08:00
|
|
|
// CSS name CSS value Attribute name Attribute value
|
2011-06-03 14:35:17 -07:00
|
|
|
{ "vertical-align", kAnyValue, &nsGkAtoms::textPosition, kCopyValue }
|
2009-02-15 00:35:10 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-09 23:29:51 -08:00
|
|
|
// TextAttrsMgr
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
void
|
|
|
|
TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|
|
|
PRInt32* aStartHTOffset,
|
|
|
|
PRInt32* aEndHTOffset)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2010-05-25 01:40:26 -07:00
|
|
|
// 1. Hyper text accessible must be specified always.
|
|
|
|
// 2. Offset accessible and result hyper text offsets must be specified in
|
2009-02-15 00:35:10 -08:00
|
|
|
// the case of text attributes.
|
2010-05-25 01:40:26 -07:00
|
|
|
// 3. Offset accessible and result hyper text offsets must not be specified
|
|
|
|
// but include default text attributes flag and attributes list must be
|
|
|
|
// specified in the case of default text attributes.
|
|
|
|
NS_PRECONDITION(mHyperTextAcc &&
|
|
|
|
((mOffsetAcc && mOffsetAccIdx != -1 &&
|
|
|
|
aStartHTOffset && aEndHTOffset) ||
|
|
|
|
(!mOffsetAcc && mOffsetAccIdx == -1 &&
|
|
|
|
!aStartHTOffset && !aEndHTOffset &&
|
2009-02-15 00:35:10 -08:00
|
|
|
mIncludeDefAttrs && aAttributes)),
|
2012-03-09 23:29:51 -08:00
|
|
|
"Wrong usage of TextAttrsMgr!");
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Embedded objects are combined into own range with empty attributes set.
|
|
|
|
if (mOffsetAcc && nsAccUtils::IsEmbeddedObject(mOffsetAcc)) {
|
|
|
|
for (PRInt32 childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
|
|
|
nsAccessible *currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
|
|
|
if (!nsAccUtils::IsEmbeddedObject(currAcc))
|
|
|
|
break;
|
|
|
|
|
|
|
|
(*aStartHTOffset)--;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 childCount = mHyperTextAcc->GetChildCount();
|
|
|
|
for (PRInt32 childIdx = mOffsetAccIdx + 1; childIdx < childCount;
|
|
|
|
childIdx++) {
|
|
|
|
nsAccessible *currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
|
|
|
if (!nsAccUtils::IsEmbeddedObject(currAcc))
|
|
|
|
break;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
(*aEndHTOffset)++;
|
|
|
|
}
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
return;
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
// Get the content and frame of the accessible. In the case of document
|
|
|
|
// accessible it's role content and root frame.
|
|
|
|
nsIContent *hyperTextElm = mHyperTextAcc->GetContent();
|
|
|
|
nsIFrame *rootFrame = mHyperTextAcc->GetFrame();
|
|
|
|
NS_ASSERTION(rootFrame, "No frame for accessible!");
|
|
|
|
if (!rootFrame)
|
2012-03-09 23:29:51 -08:00
|
|
|
return;
|
2010-05-25 01:40:26 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsIContent *offsetNode = nsnull, *offsetElm = nsnull;
|
2009-02-15 00:35:10 -08:00
|
|
|
nsIFrame *frame = nsnull;
|
2010-05-25 01:40:26 -07:00
|
|
|
if (mOffsetAcc) {
|
2010-06-11 01:23:18 -07:00
|
|
|
offsetNode = mOffsetAcc->GetContent();
|
2010-05-25 01:40:26 -07:00
|
|
|
offsetElm = nsCoreUtils::GetDOMElementFor(offsetNode);
|
2010-06-11 01:23:18 -07:00
|
|
|
frame = offsetElm->GetPrimaryFrame();
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
// "language" text attribute
|
2012-03-09 23:29:51 -08:00
|
|
|
LangTextAttr langTextAttr(mHyperTextAcc, hyperTextElm, offsetNode);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
// "text-position" text attribute
|
2012-03-10 07:35:02 -08:00
|
|
|
CSSTextAttr posTextAttr(0, hyperTextElm, offsetElm);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
// "background-color" text attribute
|
2012-03-09 23:29:51 -08:00
|
|
|
BGColorTextAttr bgColorTextAttr(rootFrame, frame);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-02-27 06:43:39 -08:00
|
|
|
// "color" text attribute
|
|
|
|
ColorTextAttr colorTextAttr(rootFrame, frame);
|
|
|
|
|
2012-02-28 16:25:06 -08:00
|
|
|
// "font-family" text attribute
|
|
|
|
FontFamilyTextAttr fontFamilyTextAttr(rootFrame, frame);
|
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
// "font-size" text attribute
|
2012-03-09 23:29:51 -08:00
|
|
|
FontSizeTextAttr fontSizeTextAttr(rootFrame, frame);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-02-28 23:35:51 -08:00
|
|
|
// "font-style" text attribute
|
|
|
|
FontStyleTextAttr fontStyleTextAttr(rootFrame, frame);
|
|
|
|
|
2009-03-03 22:46:29 -08:00
|
|
|
// "font-weight" text attribute
|
2012-03-09 23:29:51 -08:00
|
|
|
FontWeightTextAttr fontWeightTextAttr(rootFrame, frame);
|
2009-03-03 22:46:29 -08:00
|
|
|
|
2012-03-10 07:35:02 -08:00
|
|
|
// "text-underline(line-through)-style(color)" text attributes
|
|
|
|
TextDecorTextAttr textDecorTextAttr(rootFrame, frame);
|
2012-03-11 20:37:30 -07:00
|
|
|
|
|
|
|
TextAttr* attrArray[] =
|
|
|
|
{
|
|
|
|
&langTextAttr,
|
|
|
|
&posTextAttr,
|
|
|
|
&bgColorTextAttr,
|
|
|
|
&colorTextAttr,
|
|
|
|
&fontFamilyTextAttr,
|
|
|
|
&fontSizeTextAttr,
|
|
|
|
&fontStyleTextAttr,
|
|
|
|
&fontWeightTextAttr,
|
|
|
|
&textDecorTextAttr
|
|
|
|
};
|
2012-03-10 07:35:02 -08:00
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
// Expose text attributes if applicable.
|
|
|
|
if (aAttributes) {
|
2012-03-11 20:37:30 -07:00
|
|
|
for (PRUint32 idx = 0; idx < NS_ARRAY_LENGTH(attrArray); idx++)
|
|
|
|
attrArray[idx]->Expose(aAttributes, mIncludeDefAttrs);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Expose text attributes range where they are applied if applicable.
|
2012-03-11 20:37:30 -07:00
|
|
|
if (mOffsetAcc) {
|
|
|
|
GetRange(attrArray, NS_ARRAY_LENGTH(attrArray),
|
|
|
|
aStartHTOffset, aEndHTOffset);
|
|
|
|
}
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
void
|
2012-03-11 20:37:30 -07:00
|
|
|
TextAttrsMgr::GetRange(TextAttr* aAttrArray[], PRUint32 aAttrArrayLen,
|
2012-03-09 23:29:51 -08:00
|
|
|
PRInt32* aStartHTOffset, PRInt32* aEndHTOffset)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2010-05-25 01:40:26 -07:00
|
|
|
// Navigate backward from anchor accessible to find start offset.
|
|
|
|
for (PRInt32 childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
|
|
|
|
nsAccessible *currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Stop on embedded accessible since embedded accessibles are combined into
|
|
|
|
// own range.
|
|
|
|
if (nsAccUtils::IsEmbeddedObject(currAcc))
|
|
|
|
break;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIContent* currElm = nsCoreUtils::GetDOMElementFor(currAcc->GetContent());
|
|
|
|
if (!currElm)
|
|
|
|
return;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool offsetFound = false;
|
2012-03-11 20:37:30 -07:00
|
|
|
for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
|
|
|
|
TextAttr* textAttr = aAttrArray[attrIdx];
|
2010-05-25 01:40:26 -07:00
|
|
|
if (!textAttr->Equal(currElm)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
offsetFound = true;
|
2009-02-15 00:35:10 -08:00
|
|
|
break;
|
2010-05-25 01:40:26 -07:00
|
|
|
}
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
if (offsetFound)
|
|
|
|
break;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
*(aStartHTOffset) -= nsAccUtils::TextLength(currAcc);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Navigate forward from anchor accessible to find end offset.
|
|
|
|
PRInt32 childLen = mHyperTextAcc->GetChildCount();
|
|
|
|
for (PRInt32 childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
|
|
|
|
nsAccessible *currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
|
|
|
if (nsAccUtils::IsEmbeddedObject(currAcc))
|
|
|
|
break;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIContent* currElm = nsCoreUtils::GetDOMElementFor(currAcc->GetContent());
|
|
|
|
if (!currElm)
|
|
|
|
return;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool offsetFound = false;
|
2012-03-11 20:37:30 -07:00
|
|
|
for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) {
|
|
|
|
TextAttr* textAttr = aAttrArray[attrIdx];
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
// Alter the end offset when text attribute changes its value and stop
|
|
|
|
// the search.
|
|
|
|
if (!textAttr->Equal(currElm)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
offsetFound = true;
|
2009-02-15 00:35:10 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
if (offsetFound)
|
2009-02-15 00:35:10 -08:00
|
|
|
break;
|
|
|
|
|
2010-05-25 01:40:26 -07:00
|
|
|
(*aEndHTOffset) += nsAccUtils::TextLength(currAcc);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LangTextAttr
|
2009-02-15 00:35:10 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::LangTextAttr::
|
|
|
|
LangTextAttr(nsHyperTextAccessible* aRoot,
|
|
|
|
nsIContent* aRootElm, nsIContent* aElm) :
|
|
|
|
TTextAttr<nsString>(!aElm), mRootContent(aRootElm)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
aRoot->Language(mRootNativeValue);
|
2012-02-07 05:18:33 -08:00
|
|
|
mIsRootDefined = !mRootNativeValue.IsEmpty();
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
if (aElm)
|
|
|
|
mIsDefined = GetLang(aElm, mNativeValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::LangTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nsString* aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
return GetLang(aElm, *aValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::LangTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::LangTextAttr::
|
|
|
|
GetLang(nsIContent* aElm, nsAString& aLang)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsCoreUtils::GetLanguageFor(aElm, mRootContent, aLang);
|
2009-02-15 00:35:10 -08:00
|
|
|
return !aLang.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-09 23:29:51 -08:00
|
|
|
// CSSTextAttr
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::CSSTextAttr::
|
|
|
|
CSSTextAttr(PRUint32 aIndex, nsIContent* aRootElm, nsIContent* aElm) :
|
|
|
|
TTextAttr<nsString>(!aElm), mIndex(aIndex)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
mIsRootDefined = GetValueFor(aRootElm, &mRootNativeValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
if (aElm)
|
|
|
|
mIsDefined = GetValueFor(aElm, &mNativeValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::CSSTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nsString* aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> currStyleDecl =
|
2012-03-09 23:29:51 -08:00
|
|
|
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), aElm);
|
2009-02-15 00:35:10 -08:00
|
|
|
if (!currStyleDecl)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
NS_ConvertASCIItoUTF16 cssName(gCSSTextAttrsMap[mIndex].mCSSName);
|
|
|
|
|
|
|
|
nsresult rv = currStyleDecl->GetPropertyValue(cssName, *aValue);
|
|
|
|
if (NS_FAILED(rv))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
const char *cssValue = gCSSTextAttrsMap[mIndex].mCSSValue;
|
|
|
|
if (cssValue != kAnyValue && !aValue->EqualsASCII(cssValue))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::CSSTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
|
|
|
|
{
|
|
|
|
const char* attrValue = gCSSTextAttrsMap[mIndex].mAttrValue;
|
|
|
|
if (attrValue != kCopyValue) {
|
|
|
|
nsAutoString formattedValue;
|
|
|
|
AppendASCIItoUTF16(attrValue, formattedValue);
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, *gCSSTextAttrsMap[mIndex].mAttrName,
|
|
|
|
formattedValue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, *gCSSTextAttrsMap[mIndex].mAttrName,
|
|
|
|
aValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-09 23:29:51 -08:00
|
|
|
// BGColorTextAttr
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::BGColorTextAttr::
|
|
|
|
BGColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<nscolor>(!aFrame), mRootFrame(aRootFrame)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
|
|
|
mIsRootDefined = GetColor(mRootFrame, &mRootNativeValue);
|
|
|
|
if (aFrame)
|
|
|
|
mIsDefined = GetColor(aFrame, &mNativeValue);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::BGColorTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nscolor* aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIFrame* frame = aElm->GetPrimaryFrame();
|
|
|
|
return frame ? GetColor(frame, aValue) : false;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::BGColorTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAutoString formattedValue;
|
|
|
|
StyleInfo::FormatColor(aValue, formattedValue);
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::backgroundColor,
|
|
|
|
formattedValue);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::BGColorTextAttr::
|
|
|
|
GetColor(nsIFrame* aFrame, nscolor* aColor)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
const nsStyleBackground* styleBackground = aFrame->GetStyleBackground();
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2009-06-16 08:00:20 -07:00
|
|
|
if (NS_GET_A(styleBackground->mBackgroundColor) > 0) {
|
|
|
|
*aColor = styleBackground->mBackgroundColor;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame *parentFrame = aFrame->GetParent();
|
|
|
|
if (!parentFrame) {
|
|
|
|
*aColor = aFrame->PresContext()->DefaultBackgroundColor();
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Each frame of parents chain for the initially passed 'aFrame' has
|
|
|
|
// transparent background color. So background color isn't changed from
|
|
|
|
// 'mRootFrame' to initially passed 'aFrame'.
|
|
|
|
if (parentFrame == mRootFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
return GetColor(parentFrame, aColor);
|
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
|
2012-02-27 06:43:39 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ColorTextAttr
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::ColorTextAttr::
|
|
|
|
ColorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<nscolor>(!aFrame)
|
2012-02-27 06:43:39 -08:00
|
|
|
{
|
|
|
|
mRootNativeValue = aRootFrame->GetStyleColor()->mColor;
|
|
|
|
mIsRootDefined = true;
|
|
|
|
|
|
|
|
if (aFrame) {
|
|
|
|
mNativeValue = aFrame->GetStyleColor()->mColor;
|
|
|
|
mIsDefined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::ColorTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nscolor* aValue)
|
2012-02-27 06:43:39 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIFrame* frame = aElm->GetPrimaryFrame();
|
2012-02-27 06:43:39 -08:00
|
|
|
if (frame) {
|
|
|
|
*aValue = frame->GetStyleColor()->mColor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::ColorTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nscolor& aValue)
|
2012-02-27 06:43:39 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAutoString formattedValue;
|
|
|
|
StyleInfo::FormatColor(aValue, formattedValue);
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::color, formattedValue);
|
2012-02-27 06:43:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-28 16:25:06 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FontFamilyTextAttr
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontFamilyTextAttr::
|
|
|
|
FontFamilyTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<nsString>(!aFrame)
|
2012-02-28 16:25:06 -08:00
|
|
|
{
|
|
|
|
mIsRootDefined = GetFontFamily(aRootFrame, mRootNativeValue);
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
mIsDefined = GetFontFamily(aFrame, mNativeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontFamilyTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nsString* aValue)
|
2012-02-28 16:25:06 -08:00
|
|
|
{
|
|
|
|
nsIFrame* frame = aElm->GetPrimaryFrame();
|
2012-03-09 23:29:51 -08:00
|
|
|
return frame ? GetFontFamily(frame, *aValue) : false;
|
2012-02-28 16:25:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontFamilyTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nsString& aValue)
|
2012-02-28 16:25:06 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_family, aValue);
|
2012-02-28 16:25:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontFamilyTextAttr::
|
|
|
|
GetFontFamily(nsIFrame* aFrame, nsString& aFamily)
|
2012-02-28 16:25:06 -08:00
|
|
|
{
|
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
|
|
|
|
|
|
|
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
|
|
|
|
gfxFont* font = fontGroup->GetFontAt(0);
|
|
|
|
gfxFontEntry* fontEntry = font->GetFontEntry();
|
|
|
|
aFamily = fontEntry->FamilyName();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-15 00:35:10 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-09 23:29:51 -08:00
|
|
|
// FontSizeTextAttr
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-02-15 00:35:10 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontSizeTextAttr::
|
|
|
|
FontSizeTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<nscoord>(!aFrame)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
|
|
|
mDC = aRootFrame->PresContext()->DeviceContext();
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
mRootNativeValue = aRootFrame->GetStyleFont()->mSize;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsRootDefined = true;
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
if (aFrame) {
|
2012-03-09 23:29:51 -08:00
|
|
|
mNativeValue = aFrame->GetStyleFont()->mSize;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsDefined = true;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontSizeTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, nscoord* aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIFrame* frame = aElm->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
|
|
|
*aValue = frame->GetStyleFont()->mSize;
|
|
|
|
return true;
|
|
|
|
}
|
2012-02-28 16:25:06 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
return false;
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontSizeTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nscoord& aValue)
|
2009-02-15 00:35:10 -08:00
|
|
|
{
|
|
|
|
// Convert from nscoord to pt.
|
|
|
|
//
|
|
|
|
// Note: according to IA2, "The conversion doesn't have to be exact.
|
|
|
|
// The intent is to give the user a feel for the size of the text."
|
2012-02-28 16:25:06 -08:00
|
|
|
//
|
2009-02-15 00:35:10 -08:00
|
|
|
// ATK does not specify a unit and will likely follow IA2 here.
|
|
|
|
//
|
|
|
|
// XXX todo: consider sharing this code with layout module? (bug 474621)
|
2010-08-13 02:58:02 -07:00
|
|
|
float px =
|
2011-04-16 18:22:44 -07:00
|
|
|
NSAppUnitsToFloatPixels(aValue, nsDeviceContext::AppUnitsPerCSSPixel());
|
2010-08-13 02:58:02 -07:00
|
|
|
// Each pt is 4/3 of a CSS pixel.
|
|
|
|
int pts = NS_lround(px*3/4);
|
2009-02-15 00:35:10 -08:00
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
value.AppendInt(pts);
|
|
|
|
value.Append(NS_LITERAL_STRING("pt"));
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_size, value);
|
2009-02-15 00:35:10 -08:00
|
|
|
}
|
2009-03-03 22:46:29 -08:00
|
|
|
|
|
|
|
|
2012-02-28 23:35:51 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FontStyleTextAttr
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontStyleTextAttr::
|
|
|
|
FontStyleTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<nscoord>(!aFrame)
|
2012-02-28 23:35:51 -08:00
|
|
|
{
|
|
|
|
mRootNativeValue = aRootFrame->GetStyleFont()->mFont.style;
|
|
|
|
mIsRootDefined = true;
|
|
|
|
|
|
|
|
if (aFrame) {
|
|
|
|
mNativeValue = aFrame->GetStyleFont()->mFont.style;
|
|
|
|
mIsDefined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontStyleTextAttr::
|
|
|
|
GetValueFor(nsIContent* aContent, nscoord* aValue)
|
2012-02-28 23:35:51 -08:00
|
|
|
{
|
|
|
|
nsIFrame* frame = aContent->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
|
|
|
*aValue = frame->GetStyleFont()->mFont.style;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontStyleTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const nscoord& aValue)
|
2012-02-28 23:35:51 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAutoString formattedValue;
|
|
|
|
StyleInfo::FormatFontStyle(aValue, formattedValue);
|
|
|
|
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_style, formattedValue);
|
2012-02-28 23:35:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-03 22:46:29 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-09 23:29:51 -08:00
|
|
|
// FontWeightTextAttr
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-03-03 22:46:29 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontWeightTextAttr::
|
|
|
|
FontWeightTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
|
|
|
|
TTextAttr<PRInt32>(!aFrame)
|
2009-03-03 22:46:29 -08:00
|
|
|
{
|
|
|
|
mRootNativeValue = GetFontWeight(aRootFrame);
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsRootDefined = true;
|
2009-03-03 22:46:29 -08:00
|
|
|
|
|
|
|
if (aFrame) {
|
|
|
|
mNativeValue = GetFontWeight(aFrame);
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsDefined = true;
|
2009-03-03 22:46:29 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontWeightTextAttr::
|
|
|
|
GetValueFor(nsIContent* aElm, PRInt32* aValue)
|
2009-03-03 22:46:29 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsIFrame* frame = aElm->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
|
|
|
*aValue = GetFontWeight(frame);
|
|
|
|
return true;
|
|
|
|
}
|
2009-03-03 22:46:29 -08:00
|
|
|
|
2012-03-09 23:29:51 -08:00
|
|
|
return false;
|
2009-03-03 22:46:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontWeightTextAttr::
|
|
|
|
ExposeValue(nsIPersistentProperties* aAttributes, const PRInt32& aValue)
|
2009-03-03 22:46:29 -08:00
|
|
|
{
|
2012-03-09 23:29:51 -08:00
|
|
|
nsAutoString formattedValue;
|
|
|
|
formattedValue.AppendInt(aValue);
|
|
|
|
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
|
2009-03-03 22:46:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
2012-03-09 23:29:51 -08:00
|
|
|
TextAttrsMgr::FontWeightTextAttr::
|
|
|
|
GetFontWeight(nsIFrame* aFrame)
|
2009-03-03 22:46:29 -08:00
|
|
|
{
|
|
|
|
// nsFont::width isn't suitable here because it's necessary to expose real
|
|
|
|
// value of font weight (used font might not have some font weight values).
|
2011-04-07 18:05:49 -07:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-08-14 10:08:04 -07:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
2009-03-03 22:46:29 -08:00
|
|
|
|
2011-04-07 18:05:25 -07:00
|
|
|
gfxFontGroup *fontGroup = fm->GetThebesFontGroup();
|
2009-03-03 22:46:29 -08:00
|
|
|
gfxFont *font = fontGroup->GetFontAt(0);
|
|
|
|
|
|
|
|
// When there doesn't exist a bold font in the family and so the rendering of
|
|
|
|
// a non-bold font face is changed so that the user sees what looks like a
|
|
|
|
// bold font, i.e. synthetic bolding is used. IsSyntheticBold method is only
|
|
|
|
// needed on Mac, but it is "safe" to use on all platforms. (For non-Mac
|
|
|
|
// platforms it always return false.)
|
|
|
|
if (font->IsSyntheticBold())
|
|
|
|
return 700;
|
|
|
|
|
|
|
|
#ifdef MOZ_PANGO
|
|
|
|
// On Linux, font->GetStyle()->weight will give the absolute weight requested
|
|
|
|
// of the font face. The Linux code uses the gfxFontEntry constructor which
|
|
|
|
// doesn't initialize the weight field.
|
|
|
|
return font->GetStyle()->weight;
|
|
|
|
#else
|
|
|
|
// On Windows, font->GetStyle()->weight will give the same weight as
|
|
|
|
// fontEntry->Weight(), the weight of the first font in the font group, which
|
|
|
|
// may not be the weight of the font face used to render the characters.
|
|
|
|
// On Mac, font->GetStyle()->weight will just give the same number as
|
|
|
|
// getComputedStyle(). fontEntry->Weight() will give the weight of the font
|
|
|
|
// face used.
|
|
|
|
gfxFontEntry *fontEntry = font->GetFontEntry();
|
|
|
|
return fontEntry->Weight();
|
|
|
|
#endif
|
|
|
|
}
|
2012-03-10 07:35:02 -08:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|