1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Daniel Glazman <glazman@netscape.com>
24 * Boris Zbarsky <bzbarsky@mit.edu>
25 * Christopher A. Aillon <christopher@aillon.com>
26 * Mats Palmgren <mats.palmgren@bredband.net>
27 * Christian Biesinger <cbiesinger@web.de>
28 * Michael Ventnor <m.ventnor@gmail.com>
30 * Alternatively, the contents of this file may be used under the terms of
31 * either of the GNU General Public License Version 2 or later (the "GPL"),
32 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33 * in which case the provisions of the GPL or the LGPL are applicable instead
34 * of those above. If you wish to allow use of your version of this file only
35 * under the terms of either the GPL or the LGPL, and not to allow others to
36 * use your version of this file under the terms of the MPL, indicate your
37 * decision by deleting the provisions above and replace them with the notice
38 * and other provisions required by the GPL or the LGPL. If you do not delete
39 * the provisions above, a recipient may use your version of this file under
40 * the terms of any one of the MPL, the GPL or the LGPL.
42 * ***** END LICENSE BLOCK ***** */
44 /* DOM object returned from element.getComputedStyle() */
46 #include "nsComputedDOMStyle.h"
48 #include "nsDOMError.h"
49 #include "nsDOMString.h"
50 #include "nsIDOMCSS2Properties.h"
51 #include "nsIDOMElement.h"
52 #include "nsIDOMCSSPrimitiveValue.h"
53 #include "nsStyleContext.h"
54 #include "nsIScrollableFrame.h"
55 #include "nsContentUtils.h"
58 #include "nsCSSProps.h"
59 #include "nsCSSKeywords.h"
60 #include "nsDOMCSSRect.h"
61 #include "nsGkAtoms.h"
62 #include "nsHTMLReflowState.h"
63 #include "nsThemeConstants.h"
64 #include "nsStyleUtil.h"
65 #include "nsStyleStructInlines.h"
67 #include "nsPresContext.h"
68 #include "nsIDocument.h"
70 #include "nsCSSPseudoElements.h"
71 #include "nsStyleSet.h"
72 #include "imgIRequest.h"
73 #include "nsInspectorCSSUtils.h"
74 #include "nsLayoutUtils.h"
75 #include "nsFrameManager.h"
76 #include "nsCSSKeywords.h"
77 #include "nsStyleCoord.h"
78 #include "nsDisplayList.h"
80 #if defined(DEBUG_bzbarsky) || defined(DEBUG_caillon)
81 #define DEBUG_ComputedDOMStyle
85 * This is the implementation of the readonly CSSStyleDeclaration that is
86 * returned by the getComputedStyle() function.
89 static nsComputedDOMStyle
*sCachedComputedDOMStyle
;
92 NS_NewComputedDOMStyle(nsIComputedDOMStyle
** aComputedStyle
)
94 NS_ENSURE_ARG_POINTER(aComputedStyle
);
96 if (sCachedComputedDOMStyle
) {
97 // There's an unused nsComputedDOMStyle cached, use it.
98 // But before we use it, re-initialize the object.
100 // Oh yeah baby, placement new!
101 *aComputedStyle
= new (sCachedComputedDOMStyle
) nsComputedDOMStyle();
103 sCachedComputedDOMStyle
= nsnull
;
105 // No nsComputedDOMStyle cached, create a new one.
107 *aComputedStyle
= new nsComputedDOMStyle();
108 NS_ENSURE_TRUE(*aComputedStyle
, NS_ERROR_OUT_OF_MEMORY
);
111 NS_ADDREF(*aComputedStyle
);
117 GetContainingBlockFor(nsIFrame
* aFrame
) {
121 return nsHTMLReflowState::GetContainingBlockFor(aFrame
);
124 nsComputedDOMStyle::nsComputedDOMStyle()
125 : mInner(this), mDocumentWeak(nsnull
), mOuterFrame(nsnull
),
126 mInnerFrame(nsnull
), mPresShell(nsnull
), mAppUnitsPerInch(0)
131 nsComputedDOMStyle::~nsComputedDOMStyle()
136 nsComputedDOMStyle::Shutdown()
138 // We want to de-allocate without calling the dtor since we
139 // already did that manually in doDestroyComputedDOMStyle(),
140 // so cast our cached object to something that doesn't know
142 delete reinterpret_cast<char*>(sCachedComputedDOMStyle
);
143 sCachedComputedDOMStyle
= nsnull
;
147 // QueryInterface implementation for nsComputedDOMStyle
148 NS_INTERFACE_MAP_BEGIN(nsComputedDOMStyle
)
149 NS_INTERFACE_MAP_ENTRY(nsIComputedDOMStyle
)
150 NS_INTERFACE_MAP_ENTRY(nsICSSDeclaration
)
151 NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration
)
152 NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMCSS2Properties
, &mInner
)
153 NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMNSCSS2Properties
, &mInner
)
154 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports
, nsIComputedDOMStyle
)
155 NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ComputedCSSStyleDeclaration
)
159 static void doDestroyComputedDOMStyle(nsComputedDOMStyle
*aComputedStyle
)
161 if (!sCachedComputedDOMStyle
) {
162 // The cache is empty, store aComputedStyle in the cache.
164 sCachedComputedDOMStyle
= aComputedStyle
;
165 sCachedComputedDOMStyle
->~nsComputedDOMStyle();
167 // The cache is full, delete aComputedStyle
169 delete aComputedStyle
;
173 NS_IMPL_ADDREF(nsComputedDOMStyle
)
174 NS_IMPL_RELEASE_WITH_DESTROY(nsComputedDOMStyle
,
175 doDestroyComputedDOMStyle(this))
179 nsComputedDOMStyle::Init(nsIDOMElement
*aElement
,
180 const nsAString
& aPseudoElt
,
181 nsIPresShell
*aPresShell
)
183 NS_ENSURE_ARG_POINTER(aElement
);
184 NS_ENSURE_ARG_POINTER(aPresShell
);
186 mDocumentWeak
= do_GetWeakReference(aPresShell
->GetDocument());
188 mContent
= do_QueryInterface(aElement
);
190 // This should not happen, all our elements support nsIContent!
192 return NS_ERROR_FAILURE
;
195 if (!DOMStringIsNull(aPseudoElt
) && !aPseudoElt
.IsEmpty() &&
196 aPseudoElt
.First() == PRUnichar(':')) {
197 // deal with two-colon forms of aPseudoElt
198 nsAString::const_iterator start
, end
;
199 aPseudoElt
.BeginReading(start
);
200 aPseudoElt
.EndReading(end
);
201 NS_ASSERTION(start
!= end
, "aPseudoElt is not empty!");
203 PRBool haveTwoColons
= PR_TRUE
;
204 if (start
== end
|| *start
!= PRUnichar(':')) {
206 haveTwoColons
= PR_FALSE
;
208 mPseudo
= do_GetAtom(Substring(start
, end
));
209 NS_ENSURE_TRUE(mPseudo
, NS_ERROR_OUT_OF_MEMORY
);
211 // There aren't any non-CSS2 pseudo-elements with a single ':'
212 if (!haveTwoColons
&&
213 !nsCSSPseudoElements::IsCSS2PseudoElement(mPseudo
)) {
214 // XXXbz I'd really rather we threw an exception or something, but
215 // the DOM spec sucks.
220 nsPresContext
*presCtx
= aPresShell
->GetPresContext();
221 NS_ENSURE_TRUE(presCtx
, NS_ERROR_FAILURE
);
223 mAppUnitsPerInch
= presCtx
->AppUnitsPerInch();
229 nsComputedDOMStyle::GetPropertyValue(const nsCSSProperty aPropID
,
232 // This is mostly to avoid code duplication with GetPropertyCSSValue(); if
233 // perf ever becomes an issue here (doubtful), we can look into changing
235 return GetPropertyValue(
236 NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(aPropID
)),
241 nsComputedDOMStyle::SetPropertyValue(const nsCSSProperty aPropID
,
242 const nsAString
& aValue
)
244 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR
;
249 nsComputedDOMStyle::GetCssText(nsAString
& aCssText
)
258 nsComputedDOMStyle::SetCssText(const nsAString
& aCssText
)
260 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR
;
265 nsComputedDOMStyle::GetLength(PRUint32
* aLength
)
267 NS_PRECONDITION(aLength
, "Null aLength! Prepare to die!");
269 (void)GetQueryablePropertyMap(aLength
);
276 nsComputedDOMStyle::GetParentRule(nsIDOMCSSRule
** aParentRule
)
278 NS_ENSURE_ARG_POINTER(aParentRule
);
279 *aParentRule
= nsnull
;
286 nsComputedDOMStyle::GetPropertyValue(const nsAString
& aPropertyName
,
289 nsCOMPtr
<nsIDOMCSSValue
> val
;
293 nsresult rv
= GetPropertyCSSValue(aPropertyName
, getter_AddRefs(val
));
294 NS_ENSURE_SUCCESS(rv
, rv
);
297 rv
= val
->GetCssText(aReturn
);
305 nsComputedDOMStyle::GetPropertyCSSValue(const nsAString
& aPropertyName
,
306 nsIDOMCSSValue
** aReturn
)
308 NS_ENSURE_ARG_POINTER(aReturn
);
311 nsCOMPtr
<nsIDocument
> document
= do_QueryReferent(mDocumentWeak
);
312 NS_ENSURE_TRUE(document
, NS_ERROR_NOT_AVAILABLE
);
314 // Flush _before_ getting the presshell, since that could create a new
315 // presshell. Also note that we want to flush the style on the document
316 // we're computing style in, not on the document mContent is in -- the two
318 document
->FlushPendingNotifications(Flush_Style
);
320 mPresShell
= document
->GetPrimaryShell();
321 NS_ENSURE_TRUE(mPresShell
&& mPresShell
->GetPresContext(),
322 NS_ERROR_NOT_AVAILABLE
);
324 mOuterFrame
= mPresShell
->GetPrimaryFrameFor(mContent
);
325 mInnerFrame
= mOuterFrame
;
326 if (!mOuterFrame
|| mPseudo
) {
327 // Need to resolve a style context
328 mStyleContextHolder
=
329 nsInspectorCSSUtils::GetStyleContextForContent(mContent
,
332 NS_ENSURE_TRUE(mStyleContextHolder
, NS_ERROR_OUT_OF_MEMORY
);
334 nsIAtom
* type
= mOuterFrame
->GetType();
335 if (type
== nsGkAtoms::tableOuterFrame
) {
336 // If the frame is an outer table frame then we should get the style
337 // from the inner table frame.
338 mInnerFrame
= mOuterFrame
->GetFirstChild(nsnull
);
339 NS_ASSERTION(mInnerFrame
, "Outer table must have an inner");
340 NS_ASSERTION(!mInnerFrame
->GetNextSibling(),
341 "Outer table frames should have just one child, the inner "
345 mStyleContextHolder
= mInnerFrame
->GetStyleContext();
346 NS_ASSERTION(mStyleContextHolder
, "Frame without style context?");
351 nsCSSProperty prop
= nsCSSProps::LookupProperty(aPropertyName
);
355 const ComputedStyleMapEntry
* propMap
= GetQueryablePropertyMap(&length
);
356 for (; i
< length
; ++i
) {
357 if (prop
== propMap
[i
].mProperty
) {
358 // Call our pointer-to-member-function.
359 rv
= (this->*(propMap
[i
].mGetter
))(aReturn
);
364 #ifdef DEBUG_ComputedDOMStyle
366 NS_WARNING(PromiseFlatCString(NS_ConvertUTF16toUTF8(aPropertyName
) +
367 NS_LITERAL_CSTRING(" is not queryable!")).get());
375 mOuterFrame
= nsnull
;
376 mInnerFrame
= nsnull
;
379 // Release the current style context for it should be re-resolved
380 // whenever a frame is not available.
381 mStyleContextHolder
= nsnull
;
388 nsComputedDOMStyle::RemoveProperty(const nsAString
& aPropertyName
,
391 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR
;
396 nsComputedDOMStyle::GetPropertyPriority(const nsAString
& aPropertyName
,
406 nsComputedDOMStyle::SetProperty(const nsAString
& aPropertyName
,
407 const nsAString
& aValue
,
408 const nsAString
& aPriority
)
410 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR
;
415 nsComputedDOMStyle::Item(PRUint32 aIndex
, nsAString
& aReturn
)
420 const ComputedStyleMapEntry
* propMap
= GetQueryablePropertyMap(&length
);
421 if (aIndex
< length
) {
422 CopyASCIItoUTF16(nsCSSProps::GetStringValue(propMap
[aIndex
].mProperty
),
430 // Property getters...
433 nsComputedDOMStyle::GetBinding(nsIDOMCSSValue
** aValue
)
435 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
436 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
438 const nsStyleDisplay
* display
= GetStyleDisplay();
440 if (display
->mBinding
) {
441 val
->SetURI(display
->mBinding
->mURI
);
443 val
->SetIdent(nsGkAtoms::none
);
446 return CallQueryInterface(val
, aValue
);
450 nsComputedDOMStyle::GetClear(nsIDOMCSSValue
** aValue
)
452 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
453 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
455 const nsStyleDisplay
*display
= GetStyleDisplay();
457 if (display
->mBreakType
!= NS_STYLE_CLEAR_NONE
) {
458 const nsAFlatCString
& clear
=
459 nsCSSProps::ValueToKeyword(display
->mBreakType
,
460 nsCSSProps::kClearKTable
);
461 val
->SetIdent(clear
);
463 val
->SetIdent(nsGkAtoms::none
);
466 return CallQueryInterface(val
, aValue
);
470 nsComputedDOMStyle::GetCssFloat(nsIDOMCSSValue
** aValue
)
472 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
473 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
475 const nsStyleDisplay
* display
= GetStyleDisplay();
477 if (display
->mFloats
!= NS_STYLE_FLOAT_NONE
) {
478 const nsAFlatCString
& cssFloat
=
479 nsCSSProps::ValueToKeyword(display
->mFloats
,
480 nsCSSProps::kFloatKTable
);
481 val
->SetIdent(cssFloat
);
483 val
->SetIdent(nsGkAtoms::none
);
486 return CallQueryInterface(val
, aValue
);
490 nsComputedDOMStyle::GetBottom(nsIDOMCSSValue
** aValue
)
492 return GetOffsetWidthFor(NS_SIDE_BOTTOM
, aValue
);
496 nsComputedDOMStyle::GetStackSizing(nsIDOMCSSValue
** aValue
)
498 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
499 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
501 val
->SetIdent(GetStyleXUL()->mStretchStack
? nsGkAtoms::stretch_to_fit
:
504 return CallQueryInterface(val
, aValue
);
508 nsComputedDOMStyle::SetToRGBAColor(nsROCSSPrimitiveValue
* aValue
,
511 if (NS_GET_A(aColor
) == 0) {
512 aValue
->SetIdent(nsGkAtoms::transparent
);
516 nsROCSSPrimitiveValue
*red
= GetROCSSPrimitiveValue();
517 nsROCSSPrimitiveValue
*green
= GetROCSSPrimitiveValue();
518 nsROCSSPrimitiveValue
*blue
= GetROCSSPrimitiveValue();
519 nsROCSSPrimitiveValue
*alpha
= GetROCSSPrimitiveValue();
521 if (red
&& green
&& blue
&& alpha
) {
522 PRUint8 a
= NS_GET_A(aColor
);
523 nsDOMCSSRGBColor
*rgbColor
=
524 new nsDOMCSSRGBColor(red
, green
, blue
, alpha
, a
< 255);
527 red
->SetNumber(NS_GET_R(aColor
));
528 green
->SetNumber(NS_GET_G(aColor
));
529 blue
->SetNumber(NS_GET_B(aColor
));
530 alpha
->SetNumber(nsStyleUtil::ColorComponentToFloat(a
));
532 aValue
->SetColor(rgbColor
);
542 return NS_ERROR_OUT_OF_MEMORY
;
546 nsComputedDOMStyle::GetColor(nsIDOMCSSValue
** aValue
)
548 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
549 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
551 const nsStyleColor
* color
= GetStyleColor();
553 nsresult rv
= SetToRGBAColor(val
, color
->mColor
);
559 return CallQueryInterface(val
, aValue
);
563 nsComputedDOMStyle::GetOpacity(nsIDOMCSSValue
** aValue
)
565 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
566 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
568 val
->SetNumber(GetStyleDisplay()->mOpacity
);
570 return CallQueryInterface(val
, aValue
);
574 nsComputedDOMStyle::GetColumnCount(nsIDOMCSSValue
** aValue
)
576 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
577 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
579 const nsStyleColumn
* column
= GetStyleColumn();
581 if (column
->mColumnCount
== NS_STYLE_COLUMN_COUNT_AUTO
) {
582 val
->SetIdent(nsGkAtoms::_auto
);
584 val
->SetNumber(column
->mColumnCount
);
587 return CallQueryInterface(val
, aValue
);
591 nsComputedDOMStyle::GetColumnWidth(nsIDOMCSSValue
** aValue
)
593 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
594 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
596 // XXX fix the auto case. When we actually have a column frame, I think
597 // we should return the computed column width.
598 SetValueToCoord(val
, GetStyleColumn()->mColumnWidth
);
600 return CallQueryInterface(val
, aValue
);
604 nsComputedDOMStyle::GetColumnGap(nsIDOMCSSValue
** aValue
)
606 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
607 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
609 const nsStyleColumn
* column
= GetStyleColumn();
610 if (column
->mColumnGap
.GetUnit() == eStyleUnit_Normal
) {
611 val
->SetAppUnits(GetStyleFont()->mFont
.size
);
613 SetValueToCoord(val
, GetStyleColumn()->mColumnGap
);
616 return CallQueryInterface(val
, aValue
);
620 nsComputedDOMStyle::GetColumnRuleWidth(nsIDOMCSSValue
** aValue
)
622 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
624 return NS_ERROR_OUT_OF_MEMORY
;
626 SetValueToCoord(val
, GetStyleColumn()->GetComputedColumnRuleWidth());
627 return CallQueryInterface(val
, aValue
);
631 nsComputedDOMStyle::GetColumnRuleStyle(nsIDOMCSSValue
** aValue
)
633 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
635 return NS_ERROR_OUT_OF_MEMORY
;
637 const nsStyleColumn
* column
= GetStyleColumn();
638 if (column
->mColumnRuleStyle
== NS_STYLE_BORDER_STYLE_NONE
) {
639 val
->SetIdent(nsGkAtoms::none
);
641 const nsAFlatCString
& style
=
642 nsCSSProps::ValueToKeyword(column
->mColumnRuleStyle
,
643 nsCSSProps::kBorderStyleKTable
);
644 val
->SetIdent(style
);
646 return CallQueryInterface(val
, aValue
);
650 nsComputedDOMStyle::GetColumnRuleColor(nsIDOMCSSValue
** aValue
)
652 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
654 return NS_ERROR_OUT_OF_MEMORY
;
656 const nsStyleColumn
* column
= GetStyleColumn();
658 if (column
->mColumnRuleColorIsForeground
) {
659 ruleColor
= GetStyleColor()->mColor
;
661 ruleColor
= column
->mColumnRuleColor
;
664 SetToRGBAColor(val
, ruleColor
);
665 return CallQueryInterface(val
, aValue
);
669 nsComputedDOMStyle::GetContent(nsIDOMCSSValue
** aValue
)
671 const nsStyleContent
*content
= GetStyleContent();
673 if (content
->ContentCount() == 0) {
674 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
675 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
676 val
->SetIdent(nsGkAtoms::none
);
677 return CallQueryInterface(val
, aValue
);
680 if (content
->ContentCount() == 1 &&
681 content
->ContentAt(0).mType
== eStyleContentType_AltContent
) {
682 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
683 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
684 val
->SetIdent(eCSSKeyword__moz_alt_content
);
685 return CallQueryInterface(val
, aValue
);
688 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
689 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
691 for (PRUint32 i
= 0, i_end
= content
->ContentCount(); i
< i_end
; ++i
) {
692 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
693 if (!val
|| !valueList
->AppendCSSValue(val
)) {
696 return NS_ERROR_OUT_OF_MEMORY
;
699 const nsStyleContentData
&data
= content
->ContentAt(i
);
700 switch (data
.mType
) {
701 case eStyleContentType_String
:
704 nsStyleUtil::EscapeCSSString(nsDependentString(data
.mContent
.mString
),
706 str
.Insert(PRUnichar('"'), 0);
707 str
.Append(PRUnichar('"'));
711 case eStyleContentType_Image
:
713 nsCOMPtr
<nsIURI
> uri
;
714 if (data
.mContent
.mImage
) {
715 data
.mContent
.mImage
->GetURI(getter_AddRefs(uri
));
720 case eStyleContentType_Attr
:
721 val
->SetString(nsDependentString(data
.mContent
.mString
),
722 nsIDOMCSSPrimitiveValue::CSS_ATTR
);
724 case eStyleContentType_Counter
:
725 case eStyleContentType_Counters
:
727 /* FIXME: counters should really use an object */
729 if (data
.mType
== eStyleContentType_Counter
) {
730 str
.AppendLiteral("counter(");
733 str
.AppendLiteral("counters(");
736 nsCSSValue::Array
*a
= data
.mContent
.mCounters
;
738 str
.Append(a
->Item(0).GetStringBufferValue());
739 PRInt32 typeItem
= 1;
740 if (data
.mType
== eStyleContentType_Counters
) {
742 str
.AppendLiteral(", \"");
744 nsStyleUtil::EscapeCSSString(
745 nsDependentString(a
->Item(1).GetStringBufferValue()), itemstr
);
747 str
.Append(PRUnichar('"'));
749 PRInt32 type
= a
->Item(typeItem
).GetIntValue();
750 if (type
!= NS_STYLE_LIST_STYLE_DECIMAL
) {
751 str
.AppendLiteral(", ");
755 str
.Append(PRUnichar(')'));
756 val
->SetString(str
, nsIDOMCSSPrimitiveValue::CSS_COUNTER
);
759 case eStyleContentType_OpenQuote
:
760 val
->SetIdent(eCSSKeyword_open_quote
);
762 case eStyleContentType_CloseQuote
:
763 val
->SetIdent(eCSSKeyword_close_quote
);
765 case eStyleContentType_NoOpenQuote
:
766 val
->SetIdent(eCSSKeyword_no_open_quote
);
768 case eStyleContentType_NoCloseQuote
:
769 val
->SetIdent(eCSSKeyword_no_close_quote
);
771 case eStyleContentType_AltContent
:
773 NS_NOTREACHED("unexpected type");
778 return CallQueryInterface(valueList
, aValue
);
782 nsComputedDOMStyle::GetCounterIncrement(nsIDOMCSSValue
** aValue
)
784 const nsStyleContent
*content
= GetStyleContent();
786 if (content
->CounterIncrementCount() == 0) {
787 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
788 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
789 val
->SetIdent(nsGkAtoms::none
);
790 return CallQueryInterface(val
, aValue
);
793 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
794 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
796 for (PRUint32 i
= 0, i_end
= content
->CounterIncrementCount(); i
< i_end
; ++i
) {
797 nsROCSSPrimitiveValue
* name
= GetROCSSPrimitiveValue();
798 if (!name
|| !valueList
->AppendCSSValue(name
)) {
801 return NS_ERROR_OUT_OF_MEMORY
;
804 nsROCSSPrimitiveValue
* value
= GetROCSSPrimitiveValue();
805 if (!value
|| !valueList
->AppendCSSValue(value
)) {
808 return NS_ERROR_OUT_OF_MEMORY
;
811 const nsStyleCounterData
*data
= content
->GetCounterIncrementAt(i
);
812 name
->SetString(data
->mCounter
);
813 value
->SetNumber(data
->mValue
); // XXX This should really be integer
816 return CallQueryInterface(valueList
, aValue
);
819 /* Convert the stored representation into a list of two values and then hand
822 nsresult
nsComputedDOMStyle::GetMozTransformOrigin(nsIDOMCSSValue
**aValue
)
824 /* We need to build up a list of two values. We'll call them
827 nsAutoPtr
<nsROCSSPrimitiveValue
> width(GetROCSSPrimitiveValue());
828 nsAutoPtr
<nsROCSSPrimitiveValue
> height(GetROCSSPrimitiveValue());
829 if (!width
|| !height
)
830 return NS_ERROR_OUT_OF_MEMORY
;
832 /* Now, get the values. */
833 const nsStyleDisplay
* display
= GetStyleDisplay();
834 SetValueToCoord(width
, display
->mTransformOrigin
[0],
835 &nsComputedDOMStyle::GetFrameBoundsWidthForTransform
);
836 SetValueToCoord(height
, display
->mTransformOrigin
[1],
837 &nsComputedDOMStyle::GetFrameBoundsHeightForTransform
);
839 /* Store things as a value list, fail if we can't get one. */
840 nsAutoPtr
<nsDOMCSSValueList
> valueList(GetROCSSValueList(PR_FALSE
));
842 return NS_ERROR_OUT_OF_MEMORY
;
844 /* Chain on width and height, fail if we can't. */
845 if (!valueList
->AppendCSSValue(width
))
846 return NS_ERROR_OUT_OF_MEMORY
;
848 if (!valueList
->AppendCSSValue(height
))
849 return NS_ERROR_OUT_OF_MEMORY
;
852 /* Release the pointer and call query interface! We're done. */
853 return CallQueryInterface(valueList
.forget(), aValue
);
856 /* If the property is "none", hand back "none" wrapped in a value.
857 * Otherwise, compute the aggregate transform matrix and hands it back in a
860 nsresult
nsComputedDOMStyle::GetMozTransform(nsIDOMCSSValue
**aValue
)
862 static const PRInt32 NUM_FLOATS
= 4;
864 /* First, get the display data. We'll need it. */
865 const nsStyleDisplay
* display
= GetStyleDisplay();
867 /* If the "no transforms" flag is set, then we should construct a
868 * single-element entry and hand it back.
870 if (!display
->mTransformPresent
) {
871 nsROCSSPrimitiveValue
*val(GetROCSSPrimitiveValue());
873 return NS_ERROR_OUT_OF_MEMORY
;
875 /* Set it to "none." */
876 val
->SetIdent(eCSSKeyword_none
);
877 return CallQueryInterface(val
, aValue
);
880 /* Otherwise, we need to compute the current value of the transform matrix,
881 * store it in a string, and hand it back to the caller.
883 nsAutoString
resultString(NS_LITERAL_STRING("matrix("));
885 /* Now, we need to convert the matrix into a string. We'll start by taking
886 * the first four entries and converting them directly to floating-point
889 for (PRInt32 index
= 0; index
< NUM_FLOATS
; ++index
) {
890 resultString
.AppendFloat(display
->mTransform
.GetMainMatrixEntry(index
));
891 resultString
.Append(NS_LITERAL_STRING(", "));
894 /* Use the inner frame for width and height. If we fail, assume zero.
895 * TODO: There is no good way for us to represent the case where there's no
896 * frame, which is problematic. The reason is that when we have percentage
897 * transforms, there are a total of four stored matrix entries that influence
898 * the transform based on the size of the element. However, this poses a
899 * problem, because only two of these values can be explicitly referenced
900 * using the named transforms. Until a real solution is found, we'll just
904 (mInnerFrame
? nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame
) :
907 /* Now, compute the dX and dY components by adding the stored coord value
908 * (in CSS pixels) to the translate values.
911 float deltaX
= nsPresContext::AppUnitsToFloatCSSPixels
912 (display
->mTransform
.GetXTranslation(bounds
));
913 float deltaY
= nsPresContext::AppUnitsToFloatCSSPixels
914 (display
->mTransform
.GetYTranslation(bounds
));
917 /* Append these values! */
918 resultString
.AppendFloat(deltaX
);
919 resultString
.Append(NS_LITERAL_STRING("px, "));
920 resultString
.AppendFloat(deltaY
);
921 resultString
.Append(NS_LITERAL_STRING("px)"));
923 /* Create a value to hold our result. */
924 nsROCSSPrimitiveValue
* rv(GetROCSSPrimitiveValue());
927 return NS_ERROR_OUT_OF_MEMORY
;
929 rv
->SetString(resultString
);
930 return CallQueryInterface(rv
, aValue
);
934 nsComputedDOMStyle::GetCounterReset(nsIDOMCSSValue
** aValue
)
936 const nsStyleContent
*content
= GetStyleContent();
938 if (content
->CounterResetCount() == 0) {
939 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
940 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
941 val
->SetIdent(nsGkAtoms::none
);
942 return CallQueryInterface(val
, aValue
);
945 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
946 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
948 for (PRUint32 i
= 0, i_end
= content
->CounterResetCount(); i
< i_end
; ++i
) {
949 nsROCSSPrimitiveValue
* name
= GetROCSSPrimitiveValue();
950 if (!name
|| !valueList
->AppendCSSValue(name
)) {
953 return NS_ERROR_OUT_OF_MEMORY
;
956 nsROCSSPrimitiveValue
* value
= GetROCSSPrimitiveValue();
957 if (!value
|| !valueList
->AppendCSSValue(value
)) {
960 return NS_ERROR_OUT_OF_MEMORY
;
963 const nsStyleCounterData
*data
= content
->GetCounterResetAt(i
);
964 name
->SetString(data
->mCounter
);
965 value
->SetNumber(data
->mValue
); // XXX This should really be integer
968 return CallQueryInterface(valueList
, aValue
);
972 nsComputedDOMStyle::GetQuotes(nsIDOMCSSValue
** aValue
)
974 const nsStyleQuotes
*quotes
= GetStyleQuotes();
976 if (quotes
->QuotesCount() == 0) {
977 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
978 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
979 val
->SetIdent(nsGkAtoms::none
);
980 return CallQueryInterface(val
, aValue
);
983 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
984 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
986 for (PRUint32 i
= 0, i_end
= quotes
->QuotesCount(); i
< i_end
; ++i
) {
987 nsROCSSPrimitiveValue
* openVal
= GetROCSSPrimitiveValue();
988 if (!openVal
|| !valueList
->AppendCSSValue(openVal
)) {
991 return NS_ERROR_OUT_OF_MEMORY
;
994 nsROCSSPrimitiveValue
* closeVal
= GetROCSSPrimitiveValue();
995 if (!closeVal
|| !valueList
->AppendCSSValue(closeVal
)) {
998 return NS_ERROR_OUT_OF_MEMORY
;
1002 nsStyleUtil::EscapeCSSString(*quotes
->OpenQuoteAt(i
), s
);
1003 s
.Insert(PRUnichar('"'), 0);
1004 s
.Append(PRUnichar('"'));
1005 openVal
->SetString(s
);
1006 nsStyleUtil::EscapeCSSString(*quotes
->CloseQuoteAt(i
), s
);
1007 s
.Insert(PRUnichar('"'), 0);
1008 s
.Append(PRUnichar('"'));
1009 closeVal
->SetString(s
);
1012 return CallQueryInterface(valueList
, aValue
);
1016 nsComputedDOMStyle::GetFontFamily(nsIDOMCSSValue
** aValue
)
1018 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1019 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1021 const nsStyleFont
* font
= GetStyleFont();
1023 nsCOMPtr
<nsIDocument
> doc
= do_QueryReferent(mDocumentWeak
);
1024 NS_ASSERTION(doc
, "document is required");
1025 nsIPresShell
* presShell
= doc
->GetPrimaryShell();
1026 NS_ASSERTION(presShell
, "pres shell is required");
1027 nsPresContext
*presContext
= presShell
->GetPresContext();
1028 NS_ASSERTION(presContext
, "pres context is required");
1030 const nsString
& fontName
= font
->mFont
.name
;
1031 PRUint8 generic
= font
->mFlags
& NS_STYLE_FONT_FACE_MASK
;
1032 if (generic
== kGenericFont_NONE
&& !font
->mFont
.systemFont
) {
1033 const nsFont
* defaultFont
=
1034 presContext
->GetDefaultFont(kPresContext_DefaultVariableFont_ID
);
1036 PRInt32 lendiff
= fontName
.Length() - defaultFont
->name
.Length();
1038 val
->SetString(Substring(fontName
, 0, lendiff
-1)); // -1 removes comma
1040 val
->SetString(fontName
);
1043 val
->SetString(fontName
);
1046 return CallQueryInterface(val
, aValue
);
1050 nsComputedDOMStyle::GetFontSize(nsIDOMCSSValue
** aValue
)
1052 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1053 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1055 // Note: GetStyleFont()->mSize is the 'computed size';
1056 // GetStyleFont()->mFont.size is the 'actual size'
1057 val
->SetAppUnits(GetStyleFont()->mSize
);
1059 return CallQueryInterface(val
, aValue
);
1063 nsComputedDOMStyle::GetFontSizeAdjust(nsIDOMCSSValue
** aValue
)
1065 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1066 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1068 const nsStyleFont
*font
= GetStyleFont();
1070 if (font
->mFont
.sizeAdjust
) {
1071 val
->SetNumber(font
->mFont
.sizeAdjust
);
1073 val
->SetIdent(nsGkAtoms::none
);
1076 return CallQueryInterface(val
, aValue
);
1080 nsComputedDOMStyle::GetFontStyle(nsIDOMCSSValue
** aValue
)
1082 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1083 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1085 const nsStyleFont
* font
= GetStyleFont();
1087 if (font
->mFont
.style
!= NS_STYLE_FONT_STYLE_NORMAL
) {
1088 const nsAFlatCString
& style
=
1089 nsCSSProps::ValueToKeyword(font
->mFont
.style
,
1090 nsCSSProps::kFontStyleKTable
);
1091 val
->SetIdent(style
);
1093 val
->SetIdent(nsGkAtoms::normal
);
1096 return CallQueryInterface(val
, aValue
);
1100 nsComputedDOMStyle::GetFontWeight(nsIDOMCSSValue
** aValue
)
1102 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1103 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1105 const nsStyleFont
* font
= GetStyleFont();
1107 const nsAFlatCString
& str_weight
=
1108 nsCSSProps::ValueToKeyword(font
->mFont
.weight
,
1109 nsCSSProps::kFontWeightKTable
);
1110 if (!str_weight
.IsEmpty()) {
1111 val
->SetIdent(str_weight
);
1113 val
->SetNumber(font
->mFont
.weight
);
1116 return CallQueryInterface(val
, aValue
);
1120 nsComputedDOMStyle::GetFontVariant(nsIDOMCSSValue
** aValue
)
1122 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1123 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1125 const nsStyleFont
* font
= GetStyleFont();
1127 if (font
->mFont
.variant
!= NS_STYLE_FONT_VARIANT_NORMAL
) {
1128 const nsAFlatCString
& variant
=
1129 nsCSSProps::ValueToKeyword(font
->mFont
.variant
,
1130 nsCSSProps::kFontVariantKTable
);
1131 val
->SetIdent(variant
);
1133 val
->SetIdent(nsGkAtoms::normal
);
1136 return CallQueryInterface(val
, aValue
);
1140 nsComputedDOMStyle::GetBackgroundAttachment(nsIDOMCSSValue
** aValue
)
1142 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1143 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1145 const nsStyleBackground
*background
= GetStyleBackground();
1147 const nsAFlatCString
& backgroundAttachment
=
1148 nsCSSProps::ValueToKeyword(background
->mBackgroundAttachment
,
1149 nsCSSProps::kBackgroundAttachmentKTable
);
1150 val
->SetIdent(backgroundAttachment
);
1152 return CallQueryInterface(val
, aValue
);
1156 nsComputedDOMStyle::GetBackgroundClip(nsIDOMCSSValue
** aValue
)
1158 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1159 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1161 const nsAFlatCString
& backgroundClip
=
1162 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundClip
,
1163 nsCSSProps::kBackgroundClipKTable
);
1165 val
->SetIdent(backgroundClip
);
1167 return CallQueryInterface(val
, aValue
);
1171 nsComputedDOMStyle::GetBackgroundColor(nsIDOMCSSValue
** aValue
)
1173 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1174 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1176 const nsStyleBackground
* color
= GetStyleBackground();
1177 nsresult rv
= SetToRGBAColor(val
, color
->mBackgroundColor
);
1178 if (NS_FAILED(rv
)) {
1183 return CallQueryInterface(val
, aValue
);
1187 nsComputedDOMStyle::GetBackgroundImage(nsIDOMCSSValue
** aValue
)
1189 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1190 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1192 const nsStyleBackground
* color
= GetStyleBackground();
1194 if (color
->mBackgroundFlags
& NS_STYLE_BG_IMAGE_NONE
) {
1195 val
->SetIdent(nsGkAtoms::none
);
1197 nsCOMPtr
<nsIURI
> uri
;
1198 if (color
->mBackgroundImage
) {
1199 color
->mBackgroundImage
->GetURI(getter_AddRefs(uri
));
1204 return CallQueryInterface(val
, aValue
);
1208 nsComputedDOMStyle::GetBackgroundInlinePolicy(nsIDOMCSSValue
** aValue
)
1210 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1211 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1213 const nsAFlatCString
& backgroundPolicy
=
1214 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundInlinePolicy
,
1215 nsCSSProps::kBackgroundInlinePolicyKTable
);
1217 val
->SetIdent(backgroundPolicy
);
1219 return CallQueryInterface(val
, aValue
);
1223 nsComputedDOMStyle::GetBackgroundOrigin(nsIDOMCSSValue
** aValue
)
1225 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1226 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1228 const nsAFlatCString
& backgroundOrigin
=
1229 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundOrigin
,
1230 nsCSSProps::kBackgroundOriginKTable
);
1232 val
->SetIdent(backgroundOrigin
);
1234 return CallQueryInterface(val
, aValue
);
1238 nsComputedDOMStyle::GetBackgroundPosition(nsIDOMCSSValue
** aValue
)
1240 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
1241 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1243 nsROCSSPrimitiveValue
*valX
= GetROCSSPrimitiveValue();
1244 if (!valX
|| !valueList
->AppendCSSValue(valX
)) {
1247 return NS_ERROR_OUT_OF_MEMORY
;
1250 nsROCSSPrimitiveValue
*valY
= GetROCSSPrimitiveValue();
1251 if (!valY
|| !valueList
->AppendCSSValue(valY
)) {
1254 return NS_ERROR_OUT_OF_MEMORY
;
1257 const nsStyleBackground
*bg
= GetStyleBackground();
1259 if (NS_STYLE_BG_X_POSITION_LENGTH
& bg
->mBackgroundFlags
) {
1260 valX
->SetAppUnits(bg
->mBackgroundXPosition
.mCoord
);
1262 else if (NS_STYLE_BG_X_POSITION_PERCENT
& bg
->mBackgroundFlags
) {
1263 valX
->SetPercent(bg
->mBackgroundXPosition
.mFloat
);
1266 valX
->SetPercent(0.0f
);
1269 if (NS_STYLE_BG_Y_POSITION_LENGTH
& bg
->mBackgroundFlags
) {
1270 valY
->SetAppUnits(bg
->mBackgroundYPosition
.mCoord
);
1272 else if (NS_STYLE_BG_Y_POSITION_PERCENT
& bg
->mBackgroundFlags
) {
1273 valY
->SetPercent(bg
->mBackgroundYPosition
.mFloat
);
1276 valY
->SetPercent(0.0f
);
1279 return CallQueryInterface(valueList
, aValue
);
1283 nsComputedDOMStyle::GetBackgroundRepeat(nsIDOMCSSValue
** aValue
)
1285 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1286 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1288 const nsAFlatCString
& backgroundRepeat
=
1289 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundRepeat
,
1290 nsCSSProps::kBackgroundRepeatKTable
);
1291 val
->SetIdent(backgroundRepeat
);
1293 return CallQueryInterface(val
, aValue
);
1297 nsComputedDOMStyle::GetPadding(nsIDOMCSSValue
** aValue
)
1299 // return null per spec.
1306 nsComputedDOMStyle::GetPaddingTop(nsIDOMCSSValue
** aValue
)
1308 return GetPaddingWidthFor(NS_SIDE_TOP
, aValue
);
1312 nsComputedDOMStyle::GetPaddingBottom(nsIDOMCSSValue
** aValue
)
1314 return GetPaddingWidthFor(NS_SIDE_BOTTOM
, aValue
);
1318 nsComputedDOMStyle::GetPaddingLeft(nsIDOMCSSValue
** aValue
)
1320 return GetPaddingWidthFor(NS_SIDE_LEFT
, aValue
);
1324 nsComputedDOMStyle::GetPaddingRight(nsIDOMCSSValue
** aValue
)
1326 return GetPaddingWidthFor(NS_SIDE_RIGHT
, aValue
);
1330 nsComputedDOMStyle::GetBorderCollapse(nsIDOMCSSValue
** aValue
)
1332 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1333 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1335 const nsAFlatCString
& ident
=
1336 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mBorderCollapse
,
1337 nsCSSProps::kBorderCollapseKTable
);
1338 val
->SetIdent(ident
);
1340 return CallQueryInterface(val
, aValue
);
1344 nsComputedDOMStyle::GetBorderSpacing(nsIDOMCSSValue
** aValue
)
1346 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
1347 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1349 nsROCSSPrimitiveValue
* xSpacing
= GetROCSSPrimitiveValue();
1352 return NS_ERROR_OUT_OF_MEMORY
;
1354 if (!valueList
->AppendCSSValue(xSpacing
)) {
1357 return NS_ERROR_OUT_OF_MEMORY
;
1360 nsROCSSPrimitiveValue
* ySpacing
= GetROCSSPrimitiveValue();
1363 return NS_ERROR_OUT_OF_MEMORY
;
1365 if (!valueList
->AppendCSSValue(ySpacing
)) {
1368 return NS_ERROR_OUT_OF_MEMORY
;
1371 const nsStyleTableBorder
*border
= GetStyleTableBorder();
1372 xSpacing
->SetAppUnits(border
->mBorderSpacingX
);
1373 ySpacing
->SetAppUnits(border
->mBorderSpacingY
);
1375 return CallQueryInterface(valueList
, aValue
);
1379 nsComputedDOMStyle::GetCaptionSide(nsIDOMCSSValue
** aValue
)
1381 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1382 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1384 const nsAFlatCString
& side
=
1385 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mCaptionSide
,
1386 nsCSSProps::kCaptionSideKTable
);
1387 val
->SetIdent(side
);
1389 return CallQueryInterface(val
, aValue
);
1393 nsComputedDOMStyle::GetEmptyCells(nsIDOMCSSValue
** aValue
)
1395 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1396 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1398 const nsAFlatCString
& emptyCells
=
1399 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mEmptyCells
,
1400 nsCSSProps::kEmptyCellsKTable
);
1401 val
->SetIdent(emptyCells
);
1403 return CallQueryInterface(val
, aValue
);
1407 nsComputedDOMStyle::GetTableLayout(nsIDOMCSSValue
** aValue
)
1409 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1410 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1412 const nsStyleTable
*table
= GetStyleTable();
1414 if (table
->mLayoutStrategy
!= NS_STYLE_TABLE_LAYOUT_AUTO
) {
1415 const nsAFlatCString
& tableLayout
=
1416 nsCSSProps::ValueToKeyword(table
->mLayoutStrategy
,
1417 nsCSSProps::kTableLayoutKTable
);
1418 val
->SetIdent(tableLayout
);
1420 val
->SetIdent(nsGkAtoms::_auto
);
1423 return CallQueryInterface(val
, aValue
);
1427 nsComputedDOMStyle::GetBorderStyle(nsIDOMCSSValue
** aValue
)
1429 // return null per spec.
1436 nsComputedDOMStyle::GetBorderTopStyle(nsIDOMCSSValue
** aValue
)
1438 return GetBorderStyleFor(NS_SIDE_TOP
, aValue
);
1442 nsComputedDOMStyle::GetBorderBottomStyle(nsIDOMCSSValue
** aValue
)
1444 return GetBorderStyleFor(NS_SIDE_BOTTOM
, aValue
);
1447 nsComputedDOMStyle::GetBorderLeftStyle(nsIDOMCSSValue
** aValue
)
1449 return GetBorderStyleFor(NS_SIDE_LEFT
, aValue
);
1453 nsComputedDOMStyle::GetBorderRightStyle(nsIDOMCSSValue
** aValue
)
1455 return GetBorderStyleFor(NS_SIDE_RIGHT
, aValue
);
1459 nsComputedDOMStyle::GetBorderBottomColors(nsIDOMCSSValue
** aValue
)
1461 return GetBorderColorsFor(NS_SIDE_BOTTOM
, aValue
);
1465 nsComputedDOMStyle::GetBorderLeftColors(nsIDOMCSSValue
** aValue
)
1467 return GetBorderColorsFor(NS_SIDE_LEFT
, aValue
);
1471 nsComputedDOMStyle::GetBorderRightColors(nsIDOMCSSValue
** aValue
)
1473 return GetBorderColorsFor(NS_SIDE_RIGHT
, aValue
);
1478 nsComputedDOMStyle::GetBorderTopColors(nsIDOMCSSValue
** aValue
)
1480 return GetBorderColorsFor(NS_SIDE_TOP
, aValue
);
1485 nsComputedDOMStyle::GetBorderRadiusBottomLeft(nsIDOMCSSValue
** aValue
)
1487 return GetBorderRadiusFor(NS_SIDE_LEFT
, aValue
);
1491 nsComputedDOMStyle::GetBorderRadiusBottomRight(nsIDOMCSSValue
** aValue
)
1493 return GetBorderRadiusFor(NS_SIDE_BOTTOM
, aValue
);
1497 nsComputedDOMStyle::GetBorderRadiusTopLeft(nsIDOMCSSValue
** aValue
)
1499 return GetBorderRadiusFor(NS_SIDE_TOP
, aValue
);
1503 nsComputedDOMStyle::GetBorderRadiusTopRight(nsIDOMCSSValue
** aValue
)
1505 return GetBorderRadiusFor(NS_SIDE_RIGHT
, aValue
);
1509 nsComputedDOMStyle::GetBorderWidth(nsIDOMCSSValue
** aValue
)
1511 // return null per spec.
1518 nsComputedDOMStyle::GetBorderTopWidth(nsIDOMCSSValue
** aValue
)
1520 return GetBorderWidthFor(NS_SIDE_TOP
, aValue
);
1524 nsComputedDOMStyle::GetBorderBottomWidth(nsIDOMCSSValue
** aValue
)
1526 return GetBorderWidthFor(NS_SIDE_BOTTOM
, aValue
);
1530 nsComputedDOMStyle::GetBorderLeftWidth(nsIDOMCSSValue
** aValue
)
1532 return GetBorderWidthFor(NS_SIDE_LEFT
, aValue
);
1536 nsComputedDOMStyle::GetBorderRightWidth(nsIDOMCSSValue
** aValue
)
1538 return GetBorderWidthFor(NS_SIDE_RIGHT
, aValue
);
1542 nsComputedDOMStyle::GetBorderTopColor(nsIDOMCSSValue
** aValue
)
1544 return GetBorderColorFor(NS_SIDE_TOP
, aValue
);
1548 nsComputedDOMStyle::GetBorderBottomColor(nsIDOMCSSValue
** aValue
)
1550 return GetBorderColorFor(NS_SIDE_BOTTOM
, aValue
);
1554 nsComputedDOMStyle::GetBorderLeftColor(nsIDOMCSSValue
** aValue
)
1556 return GetBorderColorFor(NS_SIDE_LEFT
, aValue
);
1560 nsComputedDOMStyle::GetBorderRightColor(nsIDOMCSSValue
** aValue
)
1562 return GetBorderColorFor(NS_SIDE_RIGHT
, aValue
);
1566 nsComputedDOMStyle::GetMarginWidth(nsIDOMCSSValue
** aValue
)
1568 // return null per spec.
1575 nsComputedDOMStyle::GetMarginTopWidth(nsIDOMCSSValue
** aValue
)
1577 return GetMarginWidthFor(NS_SIDE_TOP
, aValue
);
1581 nsComputedDOMStyle::GetMarginBottomWidth(nsIDOMCSSValue
** aValue
)
1583 return GetMarginWidthFor(NS_SIDE_BOTTOM
, aValue
);
1587 nsComputedDOMStyle::GetMarginLeftWidth(nsIDOMCSSValue
** aValue
)
1589 return GetMarginWidthFor(NS_SIDE_LEFT
, aValue
);
1593 nsComputedDOMStyle::GetMarginRightWidth(nsIDOMCSSValue
** aValue
)
1595 return GetMarginWidthFor(NS_SIDE_RIGHT
, aValue
);
1599 nsComputedDOMStyle::GetMarkerOffset(nsIDOMCSSValue
** aValue
)
1601 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1602 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1604 SetValueToCoord(val
, GetStyleContent()->mMarkerOffset
);
1606 return CallQueryInterface(val
, aValue
);
1610 nsComputedDOMStyle::GetOutline(nsIDOMCSSValue
** aValue
)
1612 // return null per spec.
1619 nsComputedDOMStyle::GetOutlineWidth(nsIDOMCSSValue
** aValue
)
1621 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1622 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1624 const nsStyleOutline
* outline
= GetStyleOutline();
1627 PRUint8 outlineStyle
= outline
->GetOutlineStyle();
1628 if (outlineStyle
== NS_STYLE_BORDER_STYLE_NONE
) {
1629 coord
.SetCoordValue(0);
1631 coord
= outline
->mOutlineWidth
;
1633 SetValueToCoord(val
, coord
, nsnull
, nsCSSProps::kBorderWidthKTable
);
1635 return CallQueryInterface(val
, aValue
);
1639 nsComputedDOMStyle::GetOutlineStyle(nsIDOMCSSValue
** aValue
)
1641 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1642 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1644 PRUint8 outlineStyle
= GetStyleOutline()->GetOutlineStyle();
1645 switch (outlineStyle
) {
1646 case NS_STYLE_BORDER_STYLE_NONE
:
1647 val
->SetIdent(nsGkAtoms::none
);
1649 case NS_STYLE_BORDER_STYLE_AUTO
:
1650 val
->SetIdent(nsGkAtoms::_auto
);
1653 const nsAFlatCString
& style
=
1654 nsCSSProps::ValueToKeyword(outlineStyle
,
1655 nsCSSProps::kOutlineStyleKTable
);
1656 val
->SetIdent(style
);
1659 return CallQueryInterface(val
, aValue
);
1663 nsComputedDOMStyle::GetOutlineOffset(nsIDOMCSSValue
** aValue
)
1665 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1666 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1668 val
->SetAppUnits(GetStyleOutline()->mOutlineOffset
);
1670 return CallQueryInterface(val
, aValue
);
1674 nsComputedDOMStyle::GetOutlineRadiusBottomLeft(nsIDOMCSSValue
** aValue
)
1676 return GetOutlineRadiusFor(NS_SIDE_LEFT
, aValue
);
1680 nsComputedDOMStyle::GetOutlineRadiusBottomRight(nsIDOMCSSValue
** aValue
)
1682 return GetOutlineRadiusFor(NS_SIDE_BOTTOM
, aValue
);
1686 nsComputedDOMStyle::GetOutlineRadiusTopLeft(nsIDOMCSSValue
** aValue
)
1688 return GetOutlineRadiusFor(NS_SIDE_TOP
, aValue
);
1692 nsComputedDOMStyle::GetOutlineRadiusTopRight(nsIDOMCSSValue
** aValue
)
1694 return GetOutlineRadiusFor(NS_SIDE_RIGHT
, aValue
);
1698 nsComputedDOMStyle::GetOutlineColor(nsIDOMCSSValue
** aValue
)
1700 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1701 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1704 #ifdef GFX_HAS_INVERT
1705 GetStyleOutline()->GetOutlineColor(color
);
1707 if (!GetStyleOutline()->GetOutlineColor(color
))
1708 color
= GetStyleColor()->mColor
;
1711 nsresult rv
= SetToRGBAColor(val
, color
);
1712 if (NS_FAILED(rv
)) {
1717 return CallQueryInterface(val
, aValue
);
1721 nsComputedDOMStyle::GetOutlineRadiusFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
1723 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1724 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1726 SetValueToCoord(val
, GetStyleOutline()->mOutlineRadius
.Get(aSide
),
1727 &nsComputedDOMStyle::GetFrameBorderRectWidth
);
1729 return CallQueryInterface(val
, aValue
);
1733 nsComputedDOMStyle::GetCSSShadowArray(nsCSSShadowArray
* aArray
,
1734 const nscolor
& aDefaultColor
,
1736 nsIDOMCSSValue
** aValue
)
1739 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1740 val
->SetIdent(nsGkAtoms::none
);
1741 return CallQueryInterface(val
, aValue
);
1744 static nscoord
nsCSSShadowItem::* const shadowValuesNoSpread
[] = {
1745 &nsCSSShadowItem::mXOffset
,
1746 &nsCSSShadowItem::mYOffset
,
1747 &nsCSSShadowItem::mRadius
1750 static nscoord
nsCSSShadowItem::* const shadowValuesWithSpread
[] = {
1751 &nsCSSShadowItem::mXOffset
,
1752 &nsCSSShadowItem::mYOffset
,
1753 &nsCSSShadowItem::mRadius
,
1754 &nsCSSShadowItem::mSpread
1757 nscoord
nsCSSShadowItem::* const * shadowValues
;
1758 PRUint32 shadowValuesLength
;
1760 shadowValues
= shadowValuesWithSpread
;
1761 shadowValuesLength
= NS_ARRAY_LENGTH(shadowValuesWithSpread
);
1763 shadowValues
= shadowValuesNoSpread
;
1764 shadowValuesLength
= NS_ARRAY_LENGTH(shadowValuesNoSpread
);
1767 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
1768 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1770 for (nsCSSShadowItem
*item
= aArray
->ShadowAt(0),
1771 *item_end
= item
+ aArray
->Length();
1772 item
< item_end
; ++item
) {
1773 nsDOMCSSValueList
*itemList
= GetROCSSValueList(PR_FALSE
);
1774 if (!itemList
|| !valueList
->AppendCSSValue(itemList
)) {
1777 return NS_ERROR_OUT_OF_MEMORY
;
1780 // Color is either the specified shadow color or the foreground color
1781 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1782 if (!val
|| !itemList
->AppendCSSValue(val
)) {
1785 return NS_ERROR_OUT_OF_MEMORY
;
1787 nscolor shadowColor
;
1788 if (item
->mHasColor
) {
1789 shadowColor
= item
->mColor
;
1791 shadowColor
= aDefaultColor
;
1793 SetToRGBAColor(val
, shadowColor
);
1795 // Set the offsets, blur radius, and spread if available
1796 for (PRUint32 i
= 0; i
< shadowValuesLength
; ++i
) {
1797 val
= GetROCSSPrimitiveValue();
1798 if (!val
|| !itemList
->AppendCSSValue(val
)) {
1801 return NS_ERROR_OUT_OF_MEMORY
;
1803 val
->SetAppUnits(item
->*(shadowValues
[i
]));
1807 return CallQueryInterface(valueList
, aValue
);
1811 nsComputedDOMStyle::GetBoxShadow(nsIDOMCSSValue
** aValue
)
1813 return GetCSSShadowArray(GetStyleBorder()->mBoxShadow
,
1814 GetStyleColor()->mColor
,
1819 nsComputedDOMStyle::GetZIndex(nsIDOMCSSValue
** aValue
)
1821 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1822 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1824 SetValueToCoord(val
, GetStylePosition()->mZIndex
);
1826 return CallQueryInterface(val
, aValue
);
1830 nsComputedDOMStyle::GetListStyleImage(nsIDOMCSSValue
** aValue
)
1832 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1833 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1835 const nsStyleList
* list
= GetStyleList();
1837 if (!list
->mListStyleImage
) {
1838 val
->SetIdent(nsGkAtoms::none
);
1840 nsCOMPtr
<nsIURI
> uri
;
1841 if (list
->mListStyleImage
) {
1842 list
->mListStyleImage
->GetURI(getter_AddRefs(uri
));
1847 return CallQueryInterface(val
, aValue
);
1851 nsComputedDOMStyle::GetListStylePosition(nsIDOMCSSValue
** aValue
)
1853 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1854 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1856 const nsAFlatCString
& style
=
1857 nsCSSProps::ValueToKeyword(GetStyleList()->mListStylePosition
,
1858 nsCSSProps::kListStylePositionKTable
);
1859 val
->SetIdent(style
);
1861 return CallQueryInterface(val
, aValue
);
1865 nsComputedDOMStyle::GetListStyleType(nsIDOMCSSValue
** aValue
)
1867 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1868 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1870 const nsStyleList
*list
= GetStyleList();
1872 if (list
->mListStyleType
== NS_STYLE_LIST_STYLE_NONE
) {
1873 val
->SetIdent(nsGkAtoms::none
);
1875 const nsAFlatCString
& style
=
1876 nsCSSProps::ValueToKeyword(list
->mListStyleType
,
1877 nsCSSProps::kListStyleKTable
);
1878 val
->SetIdent(style
);
1881 return CallQueryInterface(val
, aValue
);
1885 nsComputedDOMStyle::GetImageRegion(nsIDOMCSSValue
** aValue
)
1887 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1888 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1890 const nsStyleList
* list
= GetStyleList();
1892 nsresult rv
= NS_OK
;
1893 nsROCSSPrimitiveValue
*topVal
= nsnull
;
1894 nsROCSSPrimitiveValue
*rightVal
= nsnull
;
1895 nsROCSSPrimitiveValue
*bottomVal
= nsnull
;
1896 nsROCSSPrimitiveValue
*leftVal
= nsnull
;
1897 if (list
->mImageRegion
.width
<= 0 || list
->mImageRegion
.height
<= 0) {
1898 val
->SetIdent(nsGkAtoms::_auto
);
1900 // create the cssvalues for the sides, stick them in the rect object
1901 topVal
= GetROCSSPrimitiveValue();
1902 rightVal
= GetROCSSPrimitiveValue();
1903 bottomVal
= GetROCSSPrimitiveValue();
1904 leftVal
= GetROCSSPrimitiveValue();
1905 if (topVal
&& rightVal
&& bottomVal
&& leftVal
) {
1906 nsDOMCSSRect
* domRect
= new nsDOMCSSRect(topVal
, rightVal
,
1907 bottomVal
, leftVal
);
1909 topVal
->SetAppUnits(list
->mImageRegion
.y
);
1910 rightVal
->SetAppUnits(list
->mImageRegion
.width
+ list
->mImageRegion
.x
);
1911 bottomVal
->SetAppUnits(list
->mImageRegion
.height
+ list
->mImageRegion
.y
);
1912 leftVal
->SetAppUnits(list
->mImageRegion
.x
);
1913 val
->SetRect(domRect
);
1915 rv
= NS_ERROR_OUT_OF_MEMORY
;
1918 rv
= NS_ERROR_OUT_OF_MEMORY
;
1922 if (NS_FAILED(rv
)) {
1932 return CallQueryInterface(val
, aValue
);
1936 nsComputedDOMStyle::GetLineHeight(nsIDOMCSSValue
** aValue
)
1938 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1939 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1942 GetLineHeightCoord(lineHeight
);
1943 val
->SetAppUnits(lineHeight
);
1945 return CallQueryInterface(val
, aValue
);
1949 nsComputedDOMStyle::GetVerticalAlign(nsIDOMCSSValue
** aValue
)
1951 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1952 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1954 SetValueToCoord(val
, GetStyleTextReset()->mVerticalAlign
,
1955 &nsComputedDOMStyle::GetLineHeightCoord
,
1956 nsCSSProps::kVerticalAlignKTable
);
1958 return CallQueryInterface(val
, aValue
);
1962 nsComputedDOMStyle::GetTextAlign(nsIDOMCSSValue
** aValue
)
1964 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1965 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1967 const nsAFlatCString
& align
=
1968 nsCSSProps::ValueToKeyword(GetStyleText()->mTextAlign
,
1969 nsCSSProps::kTextAlignKTable
);
1970 val
->SetIdent(align
);
1972 return CallQueryInterface(val
, aValue
);
1976 nsComputedDOMStyle::GetTextDecoration(nsIDOMCSSValue
** aValue
)
1978 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1979 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1981 const nsStyleTextReset
* text
= GetStyleTextReset();
1983 if (NS_STYLE_TEXT_DECORATION_NONE
== text
->mTextDecoration
) {
1984 const nsAFlatCString
& decoration
=
1985 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
1986 val
->SetIdent(decoration
);
1988 nsAutoString decorationString
;
1989 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_UNDERLINE
) {
1990 const nsAFlatCString
& decoration
=
1991 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_UNDERLINE
,
1992 nsCSSProps::kTextDecorationKTable
);
1993 decorationString
.AppendWithConversion(decoration
.get());
1995 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_OVERLINE
) {
1996 if (!decorationString
.IsEmpty()) {
1997 decorationString
.Append(PRUnichar(' '));
1999 const nsAFlatCString
& decoration
=
2000 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_OVERLINE
,
2001 nsCSSProps::kTextDecorationKTable
);
2002 decorationString
.AppendWithConversion(decoration
.get());
2004 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_LINE_THROUGH
) {
2005 if (!decorationString
.IsEmpty()) {
2006 decorationString
.Append(PRUnichar(' '));
2008 const nsAFlatCString
& decoration
=
2009 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_LINE_THROUGH
,
2010 nsCSSProps::kTextDecorationKTable
);
2011 decorationString
.AppendWithConversion(decoration
.get());
2013 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_BLINK
) {
2014 if (!decorationString
.IsEmpty()) {
2015 decorationString
.Append(PRUnichar(' '));
2017 const nsAFlatCString
& decoration
=
2018 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_BLINK
,
2019 nsCSSProps::kTextDecorationKTable
);
2020 decorationString
.AppendWithConversion(decoration
.get());
2022 val
->SetString(decorationString
);
2025 return CallQueryInterface(val
, aValue
);
2029 nsComputedDOMStyle::GetTextIndent(nsIDOMCSSValue
** aValue
)
2031 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2032 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2034 SetValueToCoord(val
, GetStyleText()->mTextIndent
,
2035 &nsComputedDOMStyle::GetCBContentWidth
);
2037 return CallQueryInterface(val
, aValue
);
2041 nsComputedDOMStyle::GetTextShadow(nsIDOMCSSValue
** aValue
)
2043 return GetCSSShadowArray(GetStyleText()->mTextShadow
,
2044 GetStyleColor()->mColor
,
2049 nsComputedDOMStyle::GetTextTransform(nsIDOMCSSValue
** aValue
)
2051 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2052 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2054 const nsStyleText
*text
= GetStyleText();
2056 if (text
->mTextTransform
!= NS_STYLE_TEXT_TRANSFORM_NONE
) {
2057 const nsAFlatCString
& textTransform
=
2058 nsCSSProps::ValueToKeyword(text
->mTextTransform
,
2059 nsCSSProps::kTextTransformKTable
);
2060 val
->SetIdent(textTransform
);
2062 val
->SetIdent(nsGkAtoms::none
);
2065 return CallQueryInterface(val
, aValue
);
2069 nsComputedDOMStyle::GetLetterSpacing(nsIDOMCSSValue
** aValue
)
2071 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2072 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2074 SetValueToCoord(val
, GetStyleText()->mLetterSpacing
);
2076 return CallQueryInterface(val
, aValue
);
2080 nsComputedDOMStyle::GetWordSpacing(nsIDOMCSSValue
** aValue
)
2082 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2083 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2085 SetValueToCoord(val
, GetStyleText()->mWordSpacing
);
2087 return CallQueryInterface(val
, aValue
);
2091 nsComputedDOMStyle::GetWhiteSpace(nsIDOMCSSValue
** aValue
)
2093 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2094 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2096 const nsStyleText
*text
= GetStyleText();
2098 if (text
->mWhiteSpace
!= NS_STYLE_WHITESPACE_NORMAL
) {
2099 const nsAFlatCString
& whiteSpace
=
2100 nsCSSProps::ValueToKeyword(text
->mWhiteSpace
,
2101 nsCSSProps::kWhitespaceKTable
);
2102 val
->SetIdent(whiteSpace
);
2104 val
->SetIdent(nsGkAtoms::normal
);
2107 return CallQueryInterface(val
, aValue
);
2111 nsComputedDOMStyle::GetWordWrap(nsIDOMCSSValue
** aValue
)
2113 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2114 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2116 const nsStyleText
*text
= GetStyleText();
2118 if (text
->mWordWrap
!= NS_STYLE_WORDWRAP_NORMAL
) {
2119 const nsAFlatCString
& wordWrap
=
2120 nsCSSProps::ValueToKeyword(text
->mWordWrap
,
2121 nsCSSProps::kWordwrapKTable
);
2122 val
->SetIdent(wordWrap
);
2124 val
->SetIdent(nsGkAtoms::normal
);
2127 return CallQueryInterface(val
, aValue
);
2131 nsComputedDOMStyle::GetVisibility(nsIDOMCSSValue
** aValue
)
2133 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2134 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2136 const nsAFlatCString
& value
=
2137 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mVisible
,
2138 nsCSSProps::kVisibilityKTable
);
2139 val
->SetIdent(value
);
2141 return CallQueryInterface(val
, aValue
);
2145 nsComputedDOMStyle::GetDirection(nsIDOMCSSValue
** aValue
)
2147 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2148 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2150 const nsAFlatCString
& direction
=
2151 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mDirection
,
2152 nsCSSProps::kDirectionKTable
);
2153 val
->SetIdent(direction
);
2155 return CallQueryInterface(val
, aValue
);
2159 nsComputedDOMStyle::GetUnicodeBidi(nsIDOMCSSValue
** aValue
)
2161 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2162 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2164 const nsStyleTextReset
*text
= GetStyleTextReset();
2166 if (text
->mUnicodeBidi
!= NS_STYLE_UNICODE_BIDI_NORMAL
) {
2167 const nsAFlatCString
& bidi
=
2168 nsCSSProps::ValueToKeyword(text
->mUnicodeBidi
,
2169 nsCSSProps::kUnicodeBidiKTable
);
2170 val
->SetIdent(bidi
);
2172 val
->SetIdent(nsGkAtoms::normal
);
2175 return CallQueryInterface(val
, aValue
);
2179 nsComputedDOMStyle::GetCursor(nsIDOMCSSValue
** aValue
)
2181 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
2182 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
2184 const nsStyleUserInterface
*ui
= GetStyleUserInterface();
2186 for (nsCursorImage
*item
= ui
->mCursorArray
,
2187 *item_end
= ui
->mCursorArray
+ ui
->mCursorArrayLength
;
2188 item
< item_end
; ++item
) {
2189 nsDOMCSSValueList
*itemList
= GetROCSSValueList(PR_FALSE
);
2190 if (!itemList
|| !valueList
->AppendCSSValue(itemList
)) {
2193 return NS_ERROR_OUT_OF_MEMORY
;
2196 nsCOMPtr
<nsIURI
> uri
;
2197 item
->mImage
->GetURI(getter_AddRefs(uri
));
2199 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2200 if (!val
|| !itemList
->AppendCSSValue(val
)) {
2203 return NS_ERROR_OUT_OF_MEMORY
;
2207 if (item
->mHaveHotspot
) {
2208 nsROCSSPrimitiveValue
*valX
= GetROCSSPrimitiveValue();
2209 if (!valX
|| !itemList
->AppendCSSValue(valX
)) {
2212 return NS_ERROR_OUT_OF_MEMORY
;
2214 nsROCSSPrimitiveValue
*valY
= GetROCSSPrimitiveValue();
2215 if (!valY
|| !itemList
->AppendCSSValue(valY
)) {
2218 return NS_ERROR_OUT_OF_MEMORY
;
2221 valX
->SetNumber(item
->mHotspotX
);
2222 valY
->SetNumber(item
->mHotspotY
);
2226 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2229 return NS_ERROR_OUT_OF_MEMORY
;
2232 if (ui
->mCursor
== NS_STYLE_CURSOR_AUTO
) {
2233 val
->SetIdent(nsGkAtoms::_auto
);
2235 const nsAFlatCString
& cursor
=
2236 nsCSSProps::ValueToKeyword(ui
->mCursor
,
2237 nsCSSProps::kCursorKTable
);
2238 val
->SetIdent(cursor
);
2240 if (!valueList
->AppendCSSValue(val
)) {
2243 return NS_ERROR_OUT_OF_MEMORY
;
2246 return CallQueryInterface(valueList
, aValue
);
2250 nsComputedDOMStyle::GetAppearance(nsIDOMCSSValue
** aValue
)
2252 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2253 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2255 const nsAFlatCString
& appearanceIdent
=
2256 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mAppearance
,
2257 nsCSSProps::kAppearanceKTable
);
2258 val
->SetIdent(appearanceIdent
);
2260 return CallQueryInterface(val
, aValue
);
2265 nsComputedDOMStyle::GetBoxAlign(nsIDOMCSSValue
** aValue
)
2267 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2268 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2270 const nsAFlatCString
& boxAlignIdent
=
2271 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxAlign
,
2272 nsCSSProps::kBoxAlignKTable
);
2273 val
->SetIdent(boxAlignIdent
);
2275 return CallQueryInterface(val
, aValue
);
2279 nsComputedDOMStyle::GetBoxDirection(nsIDOMCSSValue
** aValue
)
2281 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2282 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2284 const nsAFlatCString
& boxDirectionIdent
=
2285 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxDirection
,
2286 nsCSSProps::kBoxDirectionKTable
);
2287 val
->SetIdent(boxDirectionIdent
);
2289 return CallQueryInterface(val
, aValue
);
2293 nsComputedDOMStyle::GetBoxFlex(nsIDOMCSSValue
** aValue
)
2295 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2296 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2298 val
->SetNumber(GetStyleXUL()->mBoxFlex
);
2300 return CallQueryInterface(val
, aValue
);
2304 nsComputedDOMStyle::GetBoxOrdinalGroup(nsIDOMCSSValue
** aValue
)
2306 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2307 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2309 val
->SetNumber(GetStyleXUL()->mBoxOrdinal
);
2311 return CallQueryInterface(val
, aValue
);
2315 nsComputedDOMStyle::GetBoxOrient(nsIDOMCSSValue
** aValue
)
2317 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2318 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2320 const nsAFlatCString
& boxOrientIdent
=
2321 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxOrient
,
2322 nsCSSProps::kBoxOrientKTable
);
2323 val
->SetIdent(boxOrientIdent
);
2325 return CallQueryInterface(val
, aValue
);
2329 nsComputedDOMStyle::GetBoxPack(nsIDOMCSSValue
** aValue
)
2331 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2332 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2334 const nsAFlatCString
& boxPackIdent
=
2335 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxPack
,
2336 nsCSSProps::kBoxPackKTable
);
2337 val
->SetIdent(boxPackIdent
);
2339 return CallQueryInterface(val
, aValue
);
2343 nsComputedDOMStyle::GetBoxSizing(nsIDOMCSSValue
** aValue
)
2345 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2346 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2348 const nsAFlatCString
& boxSizingIdent
=
2349 nsCSSProps::ValueToKeyword(GetStylePosition()->mBoxSizing
,
2350 nsCSSProps::kBoxSizingKTable
);
2351 val
->SetIdent(boxSizingIdent
);
2353 return CallQueryInterface(val
, aValue
);
2357 nsComputedDOMStyle::GetBorderImage(nsIDOMCSSValue
** aValue
)
2359 const nsStyleBorder
* border
= GetStyleBorder();
2362 if (!border
->GetBorderImage()) {
2363 nsROCSSPrimitiveValue
*valNone
= GetROCSSPrimitiveValue();
2364 NS_ENSURE_TRUE(valNone
, NS_ERROR_OUT_OF_MEMORY
);
2365 valNone
->SetIdent(nsGkAtoms::none
);
2366 return CallQueryInterface(valNone
, aValue
);
2369 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
2370 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
2373 nsROCSSPrimitiveValue
*valURI
= GetROCSSPrimitiveValue();
2374 if (!valURI
|| !valueList
->AppendCSSValue(valURI
)) {
2377 return NS_ERROR_OUT_OF_MEMORY
;
2379 nsCOMPtr
<nsIURI
> uri
;
2380 border
->GetBorderImage()->GetURI(getter_AddRefs(uri
));
2381 valURI
->SetURI(uri
);
2383 // four split numbers
2384 NS_FOR_CSS_SIDES(side
) {
2385 nsROCSSPrimitiveValue
*valSplit
= GetROCSSPrimitiveValue();
2386 if (!valSplit
|| !valueList
->AppendCSSValue(valSplit
)) {
2389 return NS_ERROR_OUT_OF_MEMORY
;
2391 SetValueToCoord(valSplit
, border
->mBorderImageSplit
.Get(side
), nsnull
,
2395 // copy of border-width
2396 if (border
->mHaveBorderImageWidth
) {
2397 nsROCSSPrimitiveValue
*slash
= GetROCSSPrimitiveValue();
2398 if (!slash
|| !valueList
->AppendCSSValue(slash
)) {
2401 return NS_ERROR_OUT_OF_MEMORY
;
2403 slash
->SetString(NS_LITERAL_STRING("/"));
2404 NS_FOR_CSS_SIDES(side
) {
2405 nsROCSSPrimitiveValue
*borderWidth
= GetROCSSPrimitiveValue();
2406 if (!borderWidth
|| !valueList
->AppendCSSValue(borderWidth
)) {
2409 return NS_ERROR_OUT_OF_MEMORY
;
2411 nscoord width
= GetStyleBorder()->mBorderImageWidth
.side(side
);
2412 borderWidth
->SetAppUnits(width
);
2417 nsROCSSPrimitiveValue
*keyword
= GetROCSSPrimitiveValue();
2418 if (!keyword
|| !valueList
->AppendCSSValue(keyword
)) {
2421 return NS_ERROR_OUT_OF_MEMORY
;
2423 const nsAFlatCString
& borderImageIdent
=
2424 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageHFill
,
2425 nsCSSProps::kBorderImageKTable
);
2426 keyword
->SetIdent(borderImageIdent
);
2429 nsROCSSPrimitiveValue
*keyword2
= GetROCSSPrimitiveValue();
2430 if (!keyword2
|| !valueList
->AppendCSSValue(keyword2
)) {
2433 return NS_ERROR_OUT_OF_MEMORY
;
2435 const nsAFlatCString
& borderImageIdent2
=
2436 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageVFill
,
2437 nsCSSProps::kBorderImageKTable
);
2438 keyword2
->SetIdent(borderImageIdent2
);
2440 return CallQueryInterface(valueList
, aValue
);
2444 nsComputedDOMStyle::GetFloatEdge(nsIDOMCSSValue
** aValue
)
2446 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2447 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2449 const nsAFlatCString
& floatEdgeIdent
=
2450 nsCSSProps::ValueToKeyword(GetStyleBorder()->mFloatEdge
,
2451 nsCSSProps::kFloatEdgeKTable
);
2452 val
->SetIdent(floatEdgeIdent
);
2454 return CallQueryInterface(val
, aValue
);
2458 nsComputedDOMStyle::GetForceBrokenImageIcon(nsIDOMCSSValue
** aValue
)
2460 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2461 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2463 val
->SetNumber(GetStyleUIReset()->mForceBrokenImageIcon
);
2465 return CallQueryInterface(val
, aValue
);
2469 nsComputedDOMStyle::GetIMEMode(nsIDOMCSSValue
** aValue
)
2471 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2472 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2474 const nsStyleUIReset
*uiData
= GetStyleUIReset();
2476 nsCSSKeyword keyword
;
2477 if (uiData
->mIMEMode
== NS_STYLE_IME_MODE_AUTO
) {
2478 keyword
= eCSSKeyword_auto
;
2479 } else if (uiData
->mIMEMode
== NS_STYLE_IME_MODE_NORMAL
) {
2480 keyword
= eCSSKeyword_normal
;
2482 keyword
= nsCSSProps::ValueToKeywordEnum(uiData
->mIMEMode
,
2483 nsCSSProps::kIMEModeKTable
);
2485 val
->SetIdent(nsCSSKeywords::GetStringValue(keyword
));
2487 return CallQueryInterface(val
, aValue
);
2491 nsComputedDOMStyle::GetUserFocus(nsIDOMCSSValue
** aValue
)
2493 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2494 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2496 const nsStyleUserInterface
*uiData
= GetStyleUserInterface();
2498 if (uiData
->mUserFocus
!= NS_STYLE_USER_FOCUS_NONE
) {
2499 if (uiData
->mUserFocus
== NS_STYLE_USER_FOCUS_NORMAL
) {
2500 const nsAFlatCString
& userFocusIdent
=
2501 nsCSSKeywords::GetStringValue(eCSSKeyword_normal
);
2502 val
->SetIdent(userFocusIdent
);
2504 const nsAFlatCString
& userFocusIdent
=
2505 nsCSSProps::ValueToKeyword(uiData
->mUserFocus
,
2506 nsCSSProps::kUserFocusKTable
);
2507 val
->SetIdent(userFocusIdent
);
2510 const nsAFlatCString
& userFocusIdent
=
2511 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2512 val
->SetIdent(userFocusIdent
);
2515 return CallQueryInterface(val
, aValue
);
2519 nsComputedDOMStyle::GetUserInput(nsIDOMCSSValue
** aValue
)
2521 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2522 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2524 const nsStyleUserInterface
*uiData
= GetStyleUserInterface();
2526 if (uiData
->mUserInput
!= NS_STYLE_USER_INPUT_AUTO
) {
2527 if (uiData
->mUserInput
== NS_STYLE_USER_INPUT_NONE
) {
2528 const nsAFlatCString
& userInputIdent
=
2529 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2530 val
->SetIdent(userInputIdent
);
2532 const nsAFlatCString
& userInputIdent
=
2533 nsCSSProps::ValueToKeyword(uiData
->mUserInput
,
2534 nsCSSProps::kUserInputKTable
);
2535 val
->SetIdent(userInputIdent
);
2538 const nsAFlatCString
& userInputIdent
=
2539 nsCSSKeywords::GetStringValue(eCSSKeyword_auto
);
2540 val
->SetIdent(userInputIdent
);
2543 return CallQueryInterface(val
, aValue
);
2547 nsComputedDOMStyle::GetUserModify(nsIDOMCSSValue
** aValue
)
2549 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2550 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2552 const nsAFlatCString
& userModifyIdent
=
2553 nsCSSProps::ValueToKeyword(GetStyleUserInterface()->mUserModify
,
2554 nsCSSProps::kUserModifyKTable
);
2555 val
->SetIdent(userModifyIdent
);
2557 return CallQueryInterface(val
, aValue
);
2561 nsComputedDOMStyle::GetUserSelect(nsIDOMCSSValue
** aValue
)
2563 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2564 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2566 const nsStyleUIReset
*uiData
= GetStyleUIReset();
2568 if (uiData
->mUserSelect
!= NS_STYLE_USER_SELECT_AUTO
) {
2569 if (uiData
->mUserSelect
== NS_STYLE_USER_SELECT_NONE
) {
2570 const nsAFlatCString
& userSelectIdent
=
2571 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2572 val
->SetIdent(userSelectIdent
);
2574 const nsAFlatCString
& userSelectIdent
=
2575 nsCSSProps::ValueToKeyword(uiData
->mUserSelect
,
2576 nsCSSProps::kUserSelectKTable
);
2577 val
->SetIdent(userSelectIdent
);
2580 const nsAFlatCString
& userSelectIdent
=
2581 nsCSSKeywords::GetStringValue(eCSSKeyword_auto
);
2582 val
->SetIdent(userSelectIdent
);
2585 return CallQueryInterface(val
, aValue
);
2589 nsComputedDOMStyle::GetDisplay(nsIDOMCSSValue
** aValue
)
2591 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2592 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2594 const nsStyleDisplay
*displayData
= GetStyleDisplay();
2596 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_NONE
) {
2597 val
->SetIdent(nsGkAtoms::none
);
2599 const nsAFlatCString
& display
=
2600 nsCSSProps::ValueToKeyword(displayData
->mDisplay
,
2601 nsCSSProps::kDisplayKTable
);
2602 val
->SetIdent(display
);
2605 return CallQueryInterface(val
, aValue
);
2609 nsComputedDOMStyle::GetPosition(nsIDOMCSSValue
** aValue
)
2611 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2612 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2614 const nsAFlatCString
& position
=
2615 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mPosition
,
2616 nsCSSProps::kPositionKTable
);
2617 val
->SetIdent(position
);
2619 return CallQueryInterface(val
, aValue
);
2623 nsComputedDOMStyle::GetClip(nsIDOMCSSValue
** aValue
)
2625 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2626 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2628 const nsStyleDisplay
* display
= GetStyleDisplay();
2630 nsresult rv
= NS_OK
;
2631 nsROCSSPrimitiveValue
*topVal
= nsnull
;
2632 nsROCSSPrimitiveValue
*rightVal
= nsnull
;
2633 nsROCSSPrimitiveValue
*bottomVal
= nsnull
;
2634 nsROCSSPrimitiveValue
*leftVal
= nsnull
;
2635 if (display
->mClipFlags
== NS_STYLE_CLIP_AUTO
||
2636 display
->mClipFlags
== (NS_STYLE_CLIP_TOP_AUTO
|
2637 NS_STYLE_CLIP_RIGHT_AUTO
|
2638 NS_STYLE_CLIP_BOTTOM_AUTO
|
2639 NS_STYLE_CLIP_LEFT_AUTO
)) {
2640 val
->SetIdent(nsGkAtoms::_auto
);
2642 // create the cssvalues for the sides, stick them in the rect object
2643 topVal
= GetROCSSPrimitiveValue();
2644 rightVal
= GetROCSSPrimitiveValue();
2645 bottomVal
= GetROCSSPrimitiveValue();
2646 leftVal
= GetROCSSPrimitiveValue();
2647 if (topVal
&& rightVal
&& bottomVal
&& leftVal
) {
2648 nsDOMCSSRect
* domRect
= new nsDOMCSSRect(topVal
, rightVal
,
2649 bottomVal
, leftVal
);
2651 if (display
->mClipFlags
& NS_STYLE_CLIP_TOP_AUTO
) {
2652 topVal
->SetIdent(nsGkAtoms::_auto
);
2654 topVal
->SetAppUnits(display
->mClip
.y
);
2657 if (display
->mClipFlags
& NS_STYLE_CLIP_RIGHT_AUTO
) {
2658 rightVal
->SetIdent(nsGkAtoms::_auto
);
2660 rightVal
->SetAppUnits(display
->mClip
.width
+ display
->mClip
.x
);
2663 if (display
->mClipFlags
& NS_STYLE_CLIP_BOTTOM_AUTO
) {
2664 bottomVal
->SetIdent(nsGkAtoms::_auto
);
2666 bottomVal
->SetAppUnits(display
->mClip
.height
+ display
->mClip
.y
);
2669 if (display
->mClipFlags
& NS_STYLE_CLIP_LEFT_AUTO
) {
2670 leftVal
->SetIdent(nsGkAtoms::_auto
);
2672 leftVal
->SetAppUnits(display
->mClip
.x
);
2675 val
->SetRect(domRect
);
2677 rv
= NS_ERROR_OUT_OF_MEMORY
;
2680 rv
= NS_ERROR_OUT_OF_MEMORY
;
2684 if (NS_FAILED(rv
)) {
2694 return CallQueryInterface(val
, aValue
);
2698 nsComputedDOMStyle::GetOverflow(nsIDOMCSSValue
** aValue
)
2700 const nsStyleDisplay
* display
= GetStyleDisplay();
2702 if (display
->mOverflowX
!= display
->mOverflowY
) {
2703 // No value to return. We can't express this combination of
2704 // values as a shorthand.
2709 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2710 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2712 if (display
->mOverflowX
!= NS_STYLE_OVERFLOW_AUTO
) {
2713 const nsAFlatCString
& overflow
=
2714 nsCSSProps::ValueToKeyword(display
->mOverflowX
,
2715 nsCSSProps::kOverflowKTable
);
2716 val
->SetIdent(overflow
);
2718 val
->SetIdent(nsGkAtoms::_auto
);
2721 return CallQueryInterface(val
, aValue
);
2725 nsComputedDOMStyle::GetOverflowX(nsIDOMCSSValue
** aValue
)
2727 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2728 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2730 const nsStyleDisplay
* display
= GetStyleDisplay();
2732 if (display
->mOverflowX
!= NS_STYLE_OVERFLOW_AUTO
) {
2733 const nsAFlatCString
& overflow
=
2734 nsCSSProps::ValueToKeyword(display
->mOverflowX
,
2735 nsCSSProps::kOverflowSubKTable
);
2736 val
->SetIdent(overflow
);
2738 val
->SetIdent(nsGkAtoms::_auto
);
2741 return CallQueryInterface(val
, aValue
);
2745 nsComputedDOMStyle::GetOverflowY(nsIDOMCSSValue
** aValue
)
2747 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2748 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2750 const nsStyleDisplay
* display
= GetStyleDisplay();
2752 if (display
->mOverflowY
!= NS_STYLE_OVERFLOW_AUTO
) {
2753 const nsAFlatCString
& overflow
=
2754 nsCSSProps::ValueToKeyword(display
->mOverflowY
,
2755 nsCSSProps::kOverflowSubKTable
);
2756 val
->SetIdent(overflow
);
2758 val
->SetIdent(nsGkAtoms::_auto
);
2761 return CallQueryInterface(val
, aValue
);
2765 nsComputedDOMStyle::GetPageBreakAfter(nsIDOMCSSValue
** aValue
)
2767 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2768 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2770 const nsStyleDisplay
*display
= GetStyleDisplay();
2772 if (display
->mBreakAfter
) {
2773 val
->SetIdent(nsGkAtoms::always
);
2775 val
->SetIdent(nsGkAtoms::_auto
);
2778 return CallQueryInterface(val
, aValue
);
2782 nsComputedDOMStyle::GetPageBreakBefore(nsIDOMCSSValue
** aValue
)
2784 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2785 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2787 const nsStyleDisplay
*display
= GetStyleDisplay();
2789 if (display
->mBreakBefore
) {
2790 val
->SetIdent(nsGkAtoms::always
);
2792 val
->SetIdent(nsGkAtoms::_auto
);
2795 return CallQueryInterface(val
, aValue
);
2799 nsComputedDOMStyle::GetHeight(nsIDOMCSSValue
** aValue
)
2801 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2802 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2804 PRBool calcHeight
= PR_FALSE
;
2807 calcHeight
= PR_TRUE
;
2809 const nsStyleDisplay
* displayData
= GetStyleDisplay();
2810 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_INLINE
&&
2811 !(mInnerFrame
->IsFrameOfType(nsIFrame::eReplaced
))) {
2812 calcHeight
= PR_FALSE
;
2817 FlushPendingReflows();
2819 val
->SetAppUnits(mInnerFrame
->GetContentRect().height
);
2821 const nsStylePosition
*positionData
= GetStylePosition();
2824 StyleCoordToNSCoord(positionData
->mMinHeight
,
2825 &nsComputedDOMStyle::GetCBContentHeight
, 0);
2828 StyleCoordToNSCoord(positionData
->mMaxHeight
,
2829 &nsComputedDOMStyle::GetCBContentHeight
,
2832 SetValueToCoord(val
, positionData
->mHeight
, nsnull
, nsnull
,
2833 minHeight
, maxHeight
);
2836 return CallQueryInterface(val
, aValue
);
2840 nsComputedDOMStyle::GetWidth(nsIDOMCSSValue
** aValue
)
2842 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2843 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2845 PRBool calcWidth
= PR_FALSE
;
2848 calcWidth
= PR_TRUE
;
2850 const nsStyleDisplay
*displayData
= GetStyleDisplay();
2851 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_INLINE
&&
2852 !(mInnerFrame
->IsFrameOfType(nsIFrame::eReplaced
))) {
2853 calcWidth
= PR_FALSE
;
2858 FlushPendingReflows();
2860 val
->SetAppUnits(mInnerFrame
->GetContentRect().width
);
2862 const nsStylePosition
*positionData
= GetStylePosition();
2865 StyleCoordToNSCoord(positionData
->mMinWidth
,
2866 &nsComputedDOMStyle::GetCBContentWidth
, 0);
2869 StyleCoordToNSCoord(positionData
->mMaxWidth
,
2870 &nsComputedDOMStyle::GetCBContentWidth
,
2873 SetValueToCoord(val
, positionData
->mWidth
, nsnull
,
2874 nsCSSProps::kWidthKTable
, minWidth
, maxWidth
);
2877 return CallQueryInterface(val
, aValue
);
2881 nsComputedDOMStyle::GetMaxHeight(nsIDOMCSSValue
** aValue
)
2883 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2884 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2886 SetValueToCoord(val
, GetStylePosition()->mMaxHeight
,
2887 &nsComputedDOMStyle::GetCBContentHeight
);
2889 return CallQueryInterface(val
, aValue
);
2893 nsComputedDOMStyle::GetMaxWidth(nsIDOMCSSValue
** aValue
)
2895 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2896 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2898 SetValueToCoord(val
, GetStylePosition()->mMaxWidth
,
2899 &nsComputedDOMStyle::GetCBContentWidth
,
2900 nsCSSProps::kWidthKTable
);
2902 return CallQueryInterface(val
, aValue
);
2906 nsComputedDOMStyle::GetMinHeight(nsIDOMCSSValue
** aValue
)
2908 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2909 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2911 SetValueToCoord(val
, GetStylePosition()->mMinHeight
,
2912 &nsComputedDOMStyle::GetCBContentHeight
);
2914 return CallQueryInterface(val
, aValue
);
2918 nsComputedDOMStyle::GetMinWidth(nsIDOMCSSValue
** aValue
)
2920 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2921 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2923 SetValueToCoord(val
, GetStylePosition()->mMinWidth
,
2924 &nsComputedDOMStyle::GetCBContentWidth
,
2925 nsCSSProps::kWidthKTable
);
2927 return CallQueryInterface(val
, aValue
);
2931 nsComputedDOMStyle::GetLeft(nsIDOMCSSValue
** aValue
)
2933 return GetOffsetWidthFor(NS_SIDE_LEFT
, aValue
);
2937 nsComputedDOMStyle::GetRight(nsIDOMCSSValue
** aValue
)
2939 return GetOffsetWidthFor(NS_SIDE_RIGHT
, aValue
);
2943 nsComputedDOMStyle::GetTop(nsIDOMCSSValue
** aValue
)
2945 return GetOffsetWidthFor(NS_SIDE_TOP
, aValue
);
2948 nsROCSSPrimitiveValue
*
2949 nsComputedDOMStyle::GetROCSSPrimitiveValue()
2951 nsROCSSPrimitiveValue
*primitiveValue
= new nsROCSSPrimitiveValue(mAppUnitsPerInch
);
2953 NS_ASSERTION(primitiveValue
!= 0, "ran out of memory");
2955 return primitiveValue
;
2959 nsComputedDOMStyle::GetROCSSValueList(PRBool aCommaDelimited
)
2961 nsDOMCSSValueList
*valueList
= new nsDOMCSSValueList(aCommaDelimited
,
2963 NS_ASSERTION(valueList
!= 0, "ran out of memory");
2969 nsComputedDOMStyle::GetOffsetWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
2971 const nsStyleDisplay
* display
= GetStyleDisplay();
2973 FlushPendingReflows();
2975 nsresult rv
= NS_OK
;
2976 switch (display
->mPosition
) {
2977 case NS_STYLE_POSITION_STATIC
:
2978 rv
= GetStaticOffset(aSide
, aValue
);
2980 case NS_STYLE_POSITION_RELATIVE
:
2981 rv
= GetRelativeOffset(aSide
, aValue
);
2983 case NS_STYLE_POSITION_ABSOLUTE
:
2984 case NS_STYLE_POSITION_FIXED
:
2985 rv
= GetAbsoluteOffset(aSide
, aValue
);
2988 NS_ERROR("Invalid position");
2996 nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
2998 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2999 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3001 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3003 nsMargin margin
= mOuterFrame
->GetUsedMargin();
3004 nsMargin border
= container
->GetUsedBorder();
3005 nsMargin
scrollbarSizes(0, 0, 0, 0);
3006 nsRect rect
= mOuterFrame
->GetRect();
3007 nsRect containerRect
= container
->GetRect();
3009 if (container
->GetType() == nsGkAtoms::viewportFrame
) {
3010 // For absolutely positioned frames scrollbars are taken into
3011 // account by virtue of getting a containing block that does
3012 // _not_ include the scrollbars. For fixed positioned frames,
3013 // the containing block is the viewport, which _does_ include
3014 // scrollbars. We have to do some extra work.
3015 // the first child in the default frame list is what we want
3016 nsIFrame
* scrollingChild
= container
->GetFirstChild(nsnull
);
3017 nsCOMPtr
<nsIScrollableFrame
> scrollFrame
=
3018 do_QueryInterface(scrollingChild
);
3020 scrollbarSizes
= scrollFrame
->GetActualScrollbarSizes();
3027 offset
= rect
.y
- margin
.top
- border
.top
- scrollbarSizes
.top
;
3031 offset
= containerRect
.width
- rect
.width
-
3032 rect
.x
- margin
.right
- border
.right
- scrollbarSizes
.right
;
3035 case NS_SIDE_BOTTOM
:
3036 offset
= containerRect
.height
- rect
.height
-
3037 rect
.y
- margin
.bottom
- border
.bottom
- scrollbarSizes
.bottom
;
3041 offset
= rect
.x
- margin
.left
- border
.left
- scrollbarSizes
.left
;
3045 NS_ERROR("Invalid side");
3048 val
->SetAppUnits(offset
);
3050 // XXX no frame. This property makes no sense
3051 val
->SetAppUnits(0);
3054 return CallQueryInterface(val
, aValue
);
3058 #if (NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3)
3059 #define NS_OPPOSITE_SIDE(s_) (((s_) + 2) & 3)
3061 #error "Somebody changed the side constants."
3065 nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3067 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3068 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3070 const nsStylePosition
* positionData
= GetStylePosition();
3072 nsStyleCoord coord
= positionData
->mOffset
.Get(aSide
);
3074 NS_ASSERTION(coord
.GetUnit() == eStyleUnit_Coord
||
3075 coord
.GetUnit() == eStyleUnit_Percent
||
3076 coord
.GetUnit() == eStyleUnit_Auto
,
3079 if (coord
.GetUnit() == eStyleUnit_Auto
) {
3080 coord
= positionData
->mOffset
.Get(NS_OPPOSITE_SIDE(aSide
));
3083 PercentageBaseGetter baseGetter
;
3084 if (aSide
== NS_SIDE_LEFT
|| aSide
== NS_SIDE_RIGHT
) {
3085 baseGetter
= &nsComputedDOMStyle::GetCBContentWidth
;
3087 baseGetter
= &nsComputedDOMStyle::GetCBContentHeight
;
3090 val
->SetAppUnits(sign
* StyleCoordToNSCoord(coord
, baseGetter
, 0));
3092 return CallQueryInterface(val
, aValue
);
3096 nsComputedDOMStyle::GetStaticOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3099 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3100 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3102 SetValueToCoord(val
, GetStylePosition()->mOffset
.Get(aSide
));
3104 return CallQueryInterface(val
, aValue
);
3108 nsComputedDOMStyle::FlushPendingReflows()
3110 // Flush all pending notifications so that our frames are up to date
3111 nsCOMPtr
<nsIDocument
> document
= mContent
->GetDocument();
3113 document
->FlushPendingNotifications(Flush_Layout
);
3118 nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3120 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3121 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3124 SetValueToCoord(val
, GetStylePadding()->mPadding
.Get(aSide
));
3126 FlushPendingReflows();
3128 val
->SetAppUnits(mInnerFrame
->GetUsedPadding().side(aSide
));
3131 return CallQueryInterface(val
, aValue
);
3135 nsComputedDOMStyle::GetLineHeightCoord(nscoord
& aCoord
)
3137 aCoord
= nsHTMLReflowState::CalcLineHeight(mStyleContextHolder
);
3139 // CalcLineHeight uses font->mFont.size, but we want to use
3140 // font->mSize as the font size. Adjust for that. Also adjust for
3141 // the text zoom, if any.
3142 const nsStyleFont
* font
= GetStyleFont();
3143 aCoord
= NSToCoordRound((float(aCoord
) *
3144 (float(font
->mSize
) / float(font
->mFont
.size
))) /
3145 mPresShell
->GetPresContext()->TextZoom());
3151 nsComputedDOMStyle::GetBorderColorsFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3153 const nsStyleBorder
*border
= GetStyleBorder();
3155 if (border
->mBorderColors
) {
3156 nsBorderColors
* borderColors
= border
->mBorderColors
[aSide
];
3158 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
3159 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3162 nsROCSSPrimitiveValue
*primitive
= GetROCSSPrimitiveValue();
3166 return NS_ERROR_OUT_OF_MEMORY
;
3168 nsresult rv
= SetToRGBAColor(primitive
, borderColors
->mColor
);
3169 if (NS_FAILED(rv
)) {
3175 PRBool success
= valueList
->AppendCSSValue(primitive
);
3180 return NS_ERROR_OUT_OF_MEMORY
;
3182 borderColors
= borderColors
->mNext
;
3183 } while (borderColors
);
3185 return CallQueryInterface(valueList
, aValue
);
3189 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3190 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3192 val
->SetIdent(nsGkAtoms::none
);
3194 return CallQueryInterface(val
, aValue
);
3198 nsComputedDOMStyle::GetBorderRadiusFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3200 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3201 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3203 SetValueToCoord(val
, GetStyleBorder()->mBorderRadius
.Get(aSide
),
3204 &nsComputedDOMStyle::GetFrameBorderRectWidth
);
3206 return CallQueryInterface(val
, aValue
);
3210 nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3212 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3213 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3217 FlushPendingReflows();
3218 width
= mInnerFrame
->GetUsedBorder().side(aSide
);
3220 width
= GetStyleBorder()->GetActualBorderWidth(aSide
);
3222 val
->SetAppUnits(width
);
3224 return CallQueryInterface(val
, aValue
);
3228 nsComputedDOMStyle::GetBorderColorFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3230 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3231 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3235 GetStyleBorder()->GetBorderColor(aSide
, color
, foreground
);
3237 color
= GetStyleColor()->mColor
;
3240 nsresult rv
= SetToRGBAColor(val
, color
);
3241 if (NS_FAILED(rv
)) {
3246 return CallQueryInterface(val
, aValue
);
3250 nsComputedDOMStyle::GetMarginWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3252 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3253 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3256 SetValueToCoord(val
, GetStyleMargin()->mMargin
.Get(aSide
));
3258 FlushPendingReflows();
3260 val
->SetAppUnits(mInnerFrame
->GetUsedMargin().side(aSide
));
3263 return CallQueryInterface(val
, aValue
);
3267 nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3269 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3270 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3272 PRUint8 borderStyle
= GetStyleBorder()->GetBorderStyle(aSide
);
3274 if (borderStyle
!= NS_STYLE_BORDER_STYLE_NONE
) {
3275 const nsAFlatCString
& style
=
3276 nsCSSProps::ValueToKeyword(borderStyle
,
3277 nsCSSProps::kBorderStyleKTable
);
3278 val
->SetIdent(style
);
3280 val
->SetIdent(nsGkAtoms::none
);
3283 return CallQueryInterface(val
, aValue
);
3287 nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue
* aValue
,
3288 const nsStyleCoord
& aCoord
,
3289 PercentageBaseGetter aPercentageBaseGetter
,
3290 const PRInt32 aTable
[],
3291 nscoord aMinAppUnits
,
3292 nscoord aMaxAppUnits
)
3294 NS_PRECONDITION(aValue
, "Must have a value to work with");
3296 switch (aCoord
.GetUnit()) {
3297 case eStyleUnit_Normal
:
3298 aValue
->SetIdent(nsGkAtoms::normal
);
3301 case eStyleUnit_Auto
:
3302 aValue
->SetIdent(nsGkAtoms::_auto
);
3305 case eStyleUnit_Percent
:
3307 nscoord percentageBase
;
3308 if (aPercentageBaseGetter
&&
3309 (this->*aPercentageBaseGetter
)(percentageBase
)) {
3310 nscoord val
= nscoord(aCoord
.GetPercentValue() * percentageBase
);
3311 aValue
->SetAppUnits(PR_MAX(aMinAppUnits
, PR_MIN(val
, aMaxAppUnits
)));
3313 aValue
->SetPercent(aCoord
.GetPercentValue());
3318 case eStyleUnit_Factor
:
3319 aValue
->SetNumber(aCoord
.GetFactorValue());
3322 case eStyleUnit_Coord
:
3324 nscoord val
= aCoord
.GetCoordValue();
3325 aValue
->SetAppUnits(PR_MAX(aMinAppUnits
, PR_MIN(val
, aMaxAppUnits
)));
3329 case eStyleUnit_Integer
:
3330 aValue
->SetNumber(aCoord
.GetIntValue());
3333 case eStyleUnit_Enumerated
:
3334 NS_ASSERTION(aTable
, "Must have table to handle this case");
3335 aValue
->SetIdent(nsCSSProps::ValueToKeyword(aCoord
.GetIntValue(),
3339 case eStyleUnit_None
:
3340 aValue
->SetIdent(nsGkAtoms::none
);
3344 NS_ERROR("Can't handle this unit");
3350 nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord
& aCoord
,
3351 PercentageBaseGetter aPercentageBaseGetter
,
3352 nscoord aDefaultValue
)
3354 NS_PRECONDITION(aPercentageBaseGetter
, "Must have a percentage base getter");
3355 switch (aCoord
.GetUnit()) {
3356 case eStyleUnit_Coord
:
3357 return aCoord
.GetCoordValue();
3358 case eStyleUnit_Percent
:
3360 nscoord percentageBase
;
3361 if ((this->*aPercentageBaseGetter
)(percentageBase
)) {
3362 return nscoord(aCoord
.GetPercentValue() * percentageBase
);
3365 // Fall through to returning aDefaultValue if we have no percentage base.
3370 return aDefaultValue
;
3374 nsComputedDOMStyle::GetCBContentWidth(nscoord
& aWidth
)
3380 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3385 FlushPendingReflows();
3387 aWidth
= container
->GetContentRect().width
;
3392 nsComputedDOMStyle::GetCBContentHeight(nscoord
& aHeight
)
3398 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3403 FlushPendingReflows();
3405 aHeight
= container
->GetContentRect().height
;
3410 nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord
& aWidth
)
3416 FlushPendingReflows();
3418 aWidth
= mInnerFrame
->GetSize().width
;
3423 nsComputedDOMStyle::GetFrameBoundsWidthForTransform(nscoord
& aWidth
)
3425 // We need a frame to work with.
3430 FlushPendingReflows();
3432 // Check to see that we're transformed.
3433 if (!mInnerFrame
->GetStyleDisplay()->HasTransform())
3436 aWidth
= nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame
).width
;
3441 nsComputedDOMStyle::GetFrameBoundsHeightForTransform(nscoord
& aHeight
)
3443 // We need a frame to work with.
3448 FlushPendingReflows();
3450 // Check to see that we're transformed.
3451 if (!mInnerFrame
->GetStyleDisplay()->HasTransform())
3454 aHeight
= nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame
).height
;
3461 nsComputedDOMStyle::GetSVGPaintFor(PRBool aFill
,
3462 nsIDOMCSSValue
** aValue
)
3464 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3465 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3467 const nsStyleSVG
* svg
= GetStyleSVG();
3468 const nsStyleSVGPaint
* paint
= nsnull
;
3471 paint
= &svg
->mFill
;
3473 paint
= &svg
->mStroke
;
3475 nsAutoString paintString
;
3477 switch (paint
->mType
) {
3478 case eStyleSVGPaintType_None
:
3480 val
->SetIdent(nsGkAtoms::none
);
3483 case eStyleSVGPaintType_Color
:
3485 nsresult rv
= SetToRGBAColor(val
, paint
->mPaint
.mColor
);
3486 if (NS_FAILED(rv
)) {
3492 case eStyleSVGPaintType_Server
:
3494 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
3495 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3497 if (!valueList
->AppendCSSValue(val
)) {
3500 return NS_ERROR_OUT_OF_MEMORY
;
3503 nsROCSSPrimitiveValue
* fallback
= GetROCSSPrimitiveValue();
3504 if (!fallback
|| !valueList
->AppendCSSValue(fallback
)) {
3507 return NS_ERROR_OUT_OF_MEMORY
;
3510 val
->SetURI(paint
->mPaint
.mPaintServer
);
3511 nsresult rv
= SetToRGBAColor(fallback
, paint
->mFallbackColor
);
3512 if (NS_FAILED(rv
)) {
3517 return CallQueryInterface(valueList
, aValue
);
3521 return CallQueryInterface(val
, aValue
);
3525 nsComputedDOMStyle::GetFill(nsIDOMCSSValue
** aValue
)
3527 return GetSVGPaintFor(PR_TRUE
, aValue
);
3531 nsComputedDOMStyle::GetStroke(nsIDOMCSSValue
** aValue
)
3533 return GetSVGPaintFor(PR_FALSE
, aValue
);
3537 nsComputedDOMStyle::GetMarkerEnd(nsIDOMCSSValue
** aValue
)
3539 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3540 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3542 const nsStyleSVG
* svg
= GetStyleSVG();
3544 if (svg
->mMarkerEnd
)
3545 val
->SetURI(svg
->mMarkerEnd
);
3547 val
->SetIdent(nsGkAtoms::none
);
3549 return CallQueryInterface(val
, aValue
);
3553 nsComputedDOMStyle::GetMarkerMid(nsIDOMCSSValue
** aValue
)
3555 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3556 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3558 const nsStyleSVG
* svg
= GetStyleSVG();
3560 if (svg
->mMarkerMid
)
3561 val
->SetURI(svg
->mMarkerMid
);
3563 val
->SetIdent(nsGkAtoms::none
);
3565 return CallQueryInterface(val
, aValue
);
3569 nsComputedDOMStyle::GetMarkerStart(nsIDOMCSSValue
** aValue
)
3571 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3572 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3574 const nsStyleSVG
* svg
= GetStyleSVG();
3576 if (svg
->mMarkerStart
)
3577 val
->SetURI(svg
->mMarkerStart
);
3579 val
->SetIdent(nsGkAtoms::none
);
3581 return CallQueryInterface(val
, aValue
);
3585 nsComputedDOMStyle::GetStrokeDasharray(nsIDOMCSSValue
** aValue
)
3587 const nsStyleSVG
* svg
= GetStyleSVG();
3589 if (!svg
->mStrokeDasharrayLength
|| !svg
->mStrokeDasharray
) {
3590 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3591 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3592 val
->SetIdent(nsGkAtoms::none
);
3593 return CallQueryInterface(val
, aValue
);
3596 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
3597 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3599 for (PRUint32 i
= 0; i
< svg
->mStrokeDasharrayLength
; i
++) {
3600 nsROCSSPrimitiveValue
* dash
= GetROCSSPrimitiveValue();
3601 if (!dash
|| !valueList
->AppendCSSValue(dash
)) {
3604 return NS_ERROR_OUT_OF_MEMORY
;
3607 SetValueToCoord(dash
, svg
->mStrokeDasharray
[i
]);
3610 return CallQueryInterface(valueList
, aValue
);
3614 nsComputedDOMStyle::GetStrokeDashoffset(nsIDOMCSSValue
** aValue
)
3616 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3617 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3619 SetValueToCoord(val
, GetStyleSVG()->mStrokeDashoffset
);
3621 return CallQueryInterface(val
, aValue
);
3625 nsComputedDOMStyle::GetStrokeWidth(nsIDOMCSSValue
** aValue
)
3627 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3628 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3630 SetValueToCoord(val
, GetStyleSVG()->mStrokeWidth
);
3632 return CallQueryInterface(val
, aValue
);
3636 nsComputedDOMStyle::GetFillOpacity(nsIDOMCSSValue
** aValue
)
3638 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3639 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3641 val
->SetNumber(GetStyleSVG()->mFillOpacity
);
3643 return CallQueryInterface(val
, aValue
);
3647 nsComputedDOMStyle::GetFloodOpacity(nsIDOMCSSValue
** aValue
)
3649 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3650 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3652 val
->SetNumber(GetStyleSVGReset()->mFloodOpacity
);
3654 return CallQueryInterface(val
, aValue
);
3658 nsComputedDOMStyle::GetStopOpacity(nsIDOMCSSValue
** aValue
)
3660 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3661 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3663 val
->SetNumber(GetStyleSVGReset()->mStopOpacity
);
3665 return CallQueryInterface(val
, aValue
);
3669 nsComputedDOMStyle::GetStrokeMiterlimit(nsIDOMCSSValue
** aValue
)
3671 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3672 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3674 val
->SetNumber(GetStyleSVG()->mStrokeMiterlimit
);
3676 return CallQueryInterface(val
, aValue
);
3680 nsComputedDOMStyle::GetStrokeOpacity(nsIDOMCSSValue
** aValue
)
3682 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3683 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3685 val
->SetNumber(GetStyleSVG()->mStrokeOpacity
);
3687 return CallQueryInterface(val
, aValue
);
3691 nsComputedDOMStyle::GetClipRule(nsIDOMCSSValue
** aValue
)
3693 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3694 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3696 const nsAFlatCString
& keyword
=
3697 nsCSSProps::ValueToKeyword(GetStyleSVG()->mClipRule
,
3698 nsCSSProps::kFillRuleKTable
);
3699 val
->SetIdent(keyword
);
3701 return CallQueryInterface(val
, aValue
);
3705 nsComputedDOMStyle::GetFillRule(nsIDOMCSSValue
** aValue
)
3707 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3708 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3710 const nsAFlatCString
& keyword
=
3711 nsCSSProps::ValueToKeyword(GetStyleSVG()->mFillRule
,
3712 nsCSSProps::kFillRuleKTable
);
3713 val
->SetIdent(keyword
);
3715 return CallQueryInterface(val
, aValue
);
3719 nsComputedDOMStyle::GetStrokeLinecap(nsIDOMCSSValue
** aValue
)
3721 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3722 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3724 const nsAFlatCString
& keyword
=
3725 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinecap
,
3726 nsCSSProps::kStrokeLinecapKTable
);
3727 val
->SetIdent(keyword
);
3729 return CallQueryInterface(val
, aValue
);
3733 nsComputedDOMStyle::GetStrokeLinejoin(nsIDOMCSSValue
** aValue
)
3735 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3736 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3738 const nsAFlatCString
& keyword
=
3739 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinejoin
,
3740 nsCSSProps::kStrokeLinejoinKTable
);
3741 val
->SetIdent(keyword
);
3743 return CallQueryInterface(val
, aValue
);
3747 nsComputedDOMStyle::GetTextAnchor(nsIDOMCSSValue
** aValue
)
3749 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3750 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3752 const nsAFlatCString
& keyword
=
3753 nsCSSProps::ValueToKeyword(GetStyleSVG()->mTextAnchor
,
3754 nsCSSProps::kTextAnchorKTable
);
3755 val
->SetIdent(keyword
);
3757 return CallQueryInterface(val
, aValue
);
3761 nsComputedDOMStyle::GetColorInterpolation(nsIDOMCSSValue
** aValue
)
3763 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3764 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3766 const nsStyleSVG
* svg
= GetStyleSVG();
3768 if (svg
->mColorInterpolation
!= NS_STYLE_COLOR_INTERPOLATION_AUTO
) {
3769 const nsAFlatCString
& keyword
=
3770 nsCSSProps::ValueToKeyword(svg
->mColorInterpolation
,
3771 nsCSSProps::kColorInterpolationKTable
);
3772 val
->SetIdent(keyword
);
3774 val
->SetIdent(nsGkAtoms::_auto
);
3777 return CallQueryInterface(val
, aValue
);
3781 nsComputedDOMStyle::GetColorInterpolationFilters(nsIDOMCSSValue
** aValue
)
3783 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3784 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3786 const nsStyleSVG
* svg
= GetStyleSVG();
3788 if (svg
->mColorInterpolationFilters
!= NS_STYLE_COLOR_INTERPOLATION_AUTO
) {
3789 const nsAFlatCString
& keyword
=
3790 nsCSSProps::ValueToKeyword(svg
->mColorInterpolationFilters
,
3791 nsCSSProps::kColorInterpolationKTable
);
3792 val
->SetIdent(keyword
);
3794 val
->SetIdent(nsGkAtoms::_auto
);
3797 return CallQueryInterface(val
, aValue
);
3801 nsComputedDOMStyle::GetDominantBaseline(nsIDOMCSSValue
** aValue
)
3803 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3804 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3806 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3808 if (svg
->mDominantBaseline
!= NS_STYLE_DOMINANT_BASELINE_AUTO
) {
3809 const nsAFlatCString
& keyword
=
3810 nsCSSProps::ValueToKeyword(svg
->mDominantBaseline
,
3811 nsCSSProps::kDominantBaselineKTable
);
3812 val
->SetIdent(keyword
);
3814 val
->SetIdent(nsGkAtoms::_auto
);
3817 return CallQueryInterface(val
, aValue
);
3821 nsComputedDOMStyle::GetPointerEvents(nsIDOMCSSValue
** aValue
)
3823 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3824 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3826 const nsStyleSVG
* svg
= GetStyleSVG();
3828 if (svg
->mPointerEvents
!= NS_STYLE_POINTER_EVENTS_NONE
) {
3829 const nsAFlatCString
& keyword
=
3830 nsCSSProps::ValueToKeyword(svg
->mPointerEvents
,
3831 nsCSSProps::kPointerEventsKTable
);
3832 val
->SetIdent(keyword
);
3834 val
->SetIdent(nsGkAtoms::none
);
3837 return CallQueryInterface(val
, aValue
);
3841 nsComputedDOMStyle::GetShapeRendering(nsIDOMCSSValue
** aValue
)
3843 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3844 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3846 const nsStyleSVG
* svg
= GetStyleSVG();
3848 if (svg
->mShapeRendering
!= NS_STYLE_SHAPE_RENDERING_AUTO
) {
3849 const nsAFlatCString
& keyword
=
3850 nsCSSProps::ValueToKeyword(svg
->mShapeRendering
,
3851 nsCSSProps::kShapeRenderingKTable
);
3852 val
->SetIdent(keyword
);
3854 val
->SetIdent(nsGkAtoms::_auto
);
3857 return CallQueryInterface(val
, aValue
);
3861 nsComputedDOMStyle::GetTextRendering(nsIDOMCSSValue
** aValue
)
3863 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3864 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3866 const nsStyleSVG
* svg
= GetStyleSVG();
3868 if (svg
->mTextRendering
!= NS_STYLE_TEXT_RENDERING_AUTO
) {
3869 const nsAFlatCString
& keyword
=
3870 nsCSSProps::ValueToKeyword(svg
->mTextRendering
,
3871 nsCSSProps::kTextRenderingKTable
);
3872 val
->SetIdent(keyword
);
3874 val
->SetIdent(nsGkAtoms::_auto
);
3877 return CallQueryInterface(val
, aValue
);
3881 nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue
** aValue
)
3883 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3884 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3886 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mFloodColor
);
3887 if (NS_FAILED(rv
)) {
3892 return CallQueryInterface(val
, aValue
);
3896 nsComputedDOMStyle::GetLightingColor(nsIDOMCSSValue
** aValue
)
3898 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3899 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3901 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mLightingColor
);
3902 if (NS_FAILED(rv
)) {
3907 return CallQueryInterface(val
, aValue
);
3911 nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue
** aValue
)
3913 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3914 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3916 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mStopColor
);
3917 if (NS_FAILED(rv
)) {
3922 return CallQueryInterface(val
, aValue
);
3926 nsComputedDOMStyle::GetClipPath(nsIDOMCSSValue
** aValue
)
3928 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3929 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3931 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3934 val
->SetURI(svg
->mClipPath
);
3936 val
->SetIdent(nsGkAtoms::none
);
3938 return CallQueryInterface(val
, aValue
);
3942 nsComputedDOMStyle::GetFilter(nsIDOMCSSValue
** aValue
)
3944 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3945 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3947 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3950 val
->SetURI(svg
->mFilter
);
3952 val
->SetIdent(nsGkAtoms::none
);
3954 return CallQueryInterface(val
, aValue
);
3958 nsComputedDOMStyle::GetMask(nsIDOMCSSValue
** aValue
)
3960 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3961 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3963 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3966 val
->SetURI(svg
->mMask
);
3968 val
->SetIdent(nsGkAtoms::none
);
3970 return CallQueryInterface(val
, aValue
);
3976 #define COMPUTED_STYLE_MAP_ENTRY(_prop, _method) \
3977 { eCSSProperty_##_prop, &nsComputedDOMStyle::Get##_method }
3979 const nsComputedDOMStyle::ComputedStyleMapEntry
*
3980 nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32
* aLength
)
3982 /* ******************************************************************* *\
3983 * Properties below are listed in alphabetical order. *
3984 * Please keep them that way. *
3986 * Properties commented out with // are not yet implemented *
3987 * Properties commented out with //// are shorthands and not queryable *
3988 \* ******************************************************************* */
3991 // XXX If this actually fixes the bustage, replace this with an
3995 ComputedStyleMapEntry map
[] = {
3996 /* ****************************** *\
3997 * Implementations of CSS2 styles *
3998 \* ****************************** */
4000 // COMPUTED_STYLE_MAP_ENTRY(azimuth, Azimuth),
4001 //// COMPUTED_STYLE_MAP_ENTRY(background, Background),
4002 COMPUTED_STYLE_MAP_ENTRY(background_attachment
, BackgroundAttachment
),
4003 COMPUTED_STYLE_MAP_ENTRY(background_color
, BackgroundColor
),
4004 COMPUTED_STYLE_MAP_ENTRY(background_image
, BackgroundImage
),
4005 COMPUTED_STYLE_MAP_ENTRY(background_position
, BackgroundPosition
),
4006 COMPUTED_STYLE_MAP_ENTRY(background_repeat
, BackgroundRepeat
),
4007 //// COMPUTED_STYLE_MAP_ENTRY(border, Border),
4008 //// COMPUTED_STYLE_MAP_ENTRY(border_bottom, BorderBottom),
4009 COMPUTED_STYLE_MAP_ENTRY(border_bottom_color
, BorderBottomColor
),
4010 COMPUTED_STYLE_MAP_ENTRY(border_bottom_style
, BorderBottomStyle
),
4011 COMPUTED_STYLE_MAP_ENTRY(border_bottom_width
, BorderBottomWidth
),
4012 COMPUTED_STYLE_MAP_ENTRY(border_collapse
, BorderCollapse
),
4013 //// COMPUTED_STYLE_MAP_ENTRY(border_color, BorderColor),
4014 //// COMPUTED_STYLE_MAP_ENTRY(border_left, BorderLeft),
4015 COMPUTED_STYLE_MAP_ENTRY(border_left_color
, BorderLeftColor
),
4016 COMPUTED_STYLE_MAP_ENTRY(border_left_style
, BorderLeftStyle
),
4017 COMPUTED_STYLE_MAP_ENTRY(border_left_width
, BorderLeftWidth
),
4018 //// COMPUTED_STYLE_MAP_ENTRY(border_right, BorderRight),
4019 COMPUTED_STYLE_MAP_ENTRY(border_right_color
, BorderRightColor
),
4020 COMPUTED_STYLE_MAP_ENTRY(border_right_style
, BorderRightStyle
),
4021 COMPUTED_STYLE_MAP_ENTRY(border_right_width
, BorderRightWidth
),
4022 COMPUTED_STYLE_MAP_ENTRY(border_spacing
, BorderSpacing
),
4023 //// COMPUTED_STYLE_MAP_ENTRY(border_style, BorderStyle),
4024 //// COMPUTED_STYLE_MAP_ENTRY(border_top, BorderTop),
4025 COMPUTED_STYLE_MAP_ENTRY(border_top_color
, BorderTopColor
),
4026 COMPUTED_STYLE_MAP_ENTRY(border_top_style
, BorderTopStyle
),
4027 COMPUTED_STYLE_MAP_ENTRY(border_top_width
, BorderTopWidth
),
4028 //// COMPUTED_STYLE_MAP_ENTRY(border_width, BorderWidth),
4029 COMPUTED_STYLE_MAP_ENTRY(bottom
, Bottom
),
4030 COMPUTED_STYLE_MAP_ENTRY(caption_side
, CaptionSide
),
4031 COMPUTED_STYLE_MAP_ENTRY(clear
, Clear
),
4032 COMPUTED_STYLE_MAP_ENTRY(clip
, Clip
),
4033 COMPUTED_STYLE_MAP_ENTRY(color
, Color
),
4034 COMPUTED_STYLE_MAP_ENTRY(content
, Content
),
4035 COMPUTED_STYLE_MAP_ENTRY(counter_increment
, CounterIncrement
),
4036 COMPUTED_STYLE_MAP_ENTRY(counter_reset
, CounterReset
),
4037 //// COMPUTED_STYLE_MAP_ENTRY(cue, Cue),
4038 // COMPUTED_STYLE_MAP_ENTRY(cue_after, CueAfter),
4039 // COMPUTED_STYLE_MAP_ENTRY(cue_before, CueBefore),
4040 COMPUTED_STYLE_MAP_ENTRY(cursor
, Cursor
),
4041 COMPUTED_STYLE_MAP_ENTRY(direction
, Direction
),
4042 COMPUTED_STYLE_MAP_ENTRY(display
, Display
),
4043 // COMPUTED_STYLE_MAP_ENTRY(elevation, Elevation),
4044 COMPUTED_STYLE_MAP_ENTRY(empty_cells
, EmptyCells
),
4045 COMPUTED_STYLE_MAP_ENTRY(float, CssFloat
),
4046 //// COMPUTED_STYLE_MAP_ENTRY(font, Font),
4047 COMPUTED_STYLE_MAP_ENTRY(font_family
, FontFamily
),
4048 COMPUTED_STYLE_MAP_ENTRY(font_size
, FontSize
),
4049 COMPUTED_STYLE_MAP_ENTRY(font_size_adjust
, FontSizeAdjust
),
4050 // COMPUTED_STYLE_MAP_ENTRY(font_stretch, FontStretch),
4051 COMPUTED_STYLE_MAP_ENTRY(font_style
, FontStyle
),
4052 COMPUTED_STYLE_MAP_ENTRY(font_variant
, FontVariant
),
4053 COMPUTED_STYLE_MAP_ENTRY(font_weight
, FontWeight
),
4054 COMPUTED_STYLE_MAP_ENTRY(height
, Height
),
4055 COMPUTED_STYLE_MAP_ENTRY(left
, Left
),
4056 COMPUTED_STYLE_MAP_ENTRY(letter_spacing
, LetterSpacing
),
4057 COMPUTED_STYLE_MAP_ENTRY(line_height
, LineHeight
),
4058 //// COMPUTED_STYLE_MAP_ENTRY(list_style, ListStyle),
4059 COMPUTED_STYLE_MAP_ENTRY(list_style_image
, ListStyleImage
),
4060 COMPUTED_STYLE_MAP_ENTRY(list_style_position
, ListStylePosition
),
4061 COMPUTED_STYLE_MAP_ENTRY(list_style_type
, ListStyleType
),
4062 //// COMPUTED_STYLE_MAP_ENTRY(margin, Margin),
4063 COMPUTED_STYLE_MAP_ENTRY(margin_bottom
, MarginBottomWidth
),
4064 COMPUTED_STYLE_MAP_ENTRY(margin_left
, MarginLeftWidth
),
4065 COMPUTED_STYLE_MAP_ENTRY(margin_right
, MarginRightWidth
),
4066 COMPUTED_STYLE_MAP_ENTRY(margin_top
, MarginTopWidth
),
4067 COMPUTED_STYLE_MAP_ENTRY(marker_offset
, MarkerOffset
),
4068 // COMPUTED_STYLE_MAP_ENTRY(marks, Marks),
4069 COMPUTED_STYLE_MAP_ENTRY(max_height
, MaxHeight
),
4070 COMPUTED_STYLE_MAP_ENTRY(max_width
, MaxWidth
),
4071 COMPUTED_STYLE_MAP_ENTRY(min_height
, MinHeight
),
4072 COMPUTED_STYLE_MAP_ENTRY(min_width
, MinWidth
),
4073 COMPUTED_STYLE_MAP_ENTRY(ime_mode
, IMEMode
),
4074 COMPUTED_STYLE_MAP_ENTRY(opacity
, Opacity
),
4075 // COMPUTED_STYLE_MAP_ENTRY(orphans, Orphans),
4076 //// COMPUTED_STYLE_MAP_ENTRY(outline, Outline),
4077 COMPUTED_STYLE_MAP_ENTRY(outline_color
, OutlineColor
),
4078 COMPUTED_STYLE_MAP_ENTRY(outline_style
, OutlineStyle
),
4079 COMPUTED_STYLE_MAP_ENTRY(outline_width
, OutlineWidth
),
4080 COMPUTED_STYLE_MAP_ENTRY(outline_offset
, OutlineOffset
),
4081 COMPUTED_STYLE_MAP_ENTRY(overflow
, Overflow
),
4082 COMPUTED_STYLE_MAP_ENTRY(overflow_x
, OverflowX
),
4083 COMPUTED_STYLE_MAP_ENTRY(overflow_y
, OverflowY
),
4084 //// COMPUTED_STYLE_MAP_ENTRY(padding, Padding),
4085 COMPUTED_STYLE_MAP_ENTRY(padding_bottom
, PaddingBottom
),
4086 COMPUTED_STYLE_MAP_ENTRY(padding_left
, PaddingLeft
),
4087 COMPUTED_STYLE_MAP_ENTRY(padding_right
, PaddingRight
),
4088 COMPUTED_STYLE_MAP_ENTRY(padding_top
, PaddingTop
),
4089 // COMPUTED_STYLE_MAP_ENTRY(page, Page),
4090 COMPUTED_STYLE_MAP_ENTRY(page_break_after
, PageBreakAfter
),
4091 COMPUTED_STYLE_MAP_ENTRY(page_break_before
, PageBreakBefore
),
4092 // COMPUTED_STYLE_MAP_ENTRY(page_break_inside, PageBreakInside),
4093 //// COMPUTED_STYLE_MAP_ENTRY(pause, Pause),
4094 // COMPUTED_STYLE_MAP_ENTRY(pause_after, PauseAfter),
4095 // COMPUTED_STYLE_MAP_ENTRY(pause_before, PauseBefore),
4096 // COMPUTED_STYLE_MAP_ENTRY(pitch, Pitch),
4097 // COMPUTED_STYLE_MAP_ENTRY(pitch_range, PitchRange),
4098 COMPUTED_STYLE_MAP_ENTRY(position
, Position
),
4099 COMPUTED_STYLE_MAP_ENTRY(quotes
, Quotes
),
4100 // COMPUTED_STYLE_MAP_ENTRY(richness, Richness),
4101 COMPUTED_STYLE_MAP_ENTRY(right
, Right
),
4102 //// COMPUTED_STYLE_MAP_ENTRY(size, Size),
4103 // COMPUTED_STYLE_MAP_ENTRY(speak, Speak),
4104 // COMPUTED_STYLE_MAP_ENTRY(speak_header, SpeakHeader),
4105 // COMPUTED_STYLE_MAP_ENTRY(speak_numeral, SpeakNumeral),
4106 // COMPUTED_STYLE_MAP_ENTRY(speak_punctuation, SpeakPunctuation),
4107 // COMPUTED_STYLE_MAP_ENTRY(speech_rate, SpeechRate),
4108 // COMPUTED_STYLE_MAP_ENTRY(stress, Stress),
4109 COMPUTED_STYLE_MAP_ENTRY(table_layout
, TableLayout
),
4110 COMPUTED_STYLE_MAP_ENTRY(text_align
, TextAlign
),
4111 COMPUTED_STYLE_MAP_ENTRY(text_decoration
, TextDecoration
),
4112 COMPUTED_STYLE_MAP_ENTRY(text_indent
, TextIndent
),
4113 COMPUTED_STYLE_MAP_ENTRY(text_shadow
, TextShadow
),
4114 COMPUTED_STYLE_MAP_ENTRY(text_transform
, TextTransform
),
4115 COMPUTED_STYLE_MAP_ENTRY(top
, Top
),
4116 COMPUTED_STYLE_MAP_ENTRY(unicode_bidi
, UnicodeBidi
),
4117 COMPUTED_STYLE_MAP_ENTRY(vertical_align
, VerticalAlign
),
4118 COMPUTED_STYLE_MAP_ENTRY(visibility
, Visibility
),
4119 // COMPUTED_STYLE_MAP_ENTRY(voice_family, VoiceFamily),
4120 // COMPUTED_STYLE_MAP_ENTRY(volume, Volume),
4121 COMPUTED_STYLE_MAP_ENTRY(white_space
, WhiteSpace
),
4122 // COMPUTED_STYLE_MAP_ENTRY(widows, Widows),
4123 COMPUTED_STYLE_MAP_ENTRY(width
, Width
),
4124 COMPUTED_STYLE_MAP_ENTRY(word_spacing
, WordSpacing
),
4125 COMPUTED_STYLE_MAP_ENTRY(z_index
, ZIndex
),
4127 /* ******************************* *\
4128 * Implementations of -moz- styles *
4129 \* ******************************* */
4131 COMPUTED_STYLE_MAP_ENTRY(appearance
, Appearance
),
4132 COMPUTED_STYLE_MAP_ENTRY(_moz_background_clip
, BackgroundClip
),
4133 COMPUTED_STYLE_MAP_ENTRY(_moz_background_inline_policy
, BackgroundInlinePolicy
),
4134 COMPUTED_STYLE_MAP_ENTRY(_moz_background_origin
, BackgroundOrigin
),
4135 COMPUTED_STYLE_MAP_ENTRY(binding
, Binding
),
4136 COMPUTED_STYLE_MAP_ENTRY(border_bottom_colors
, BorderBottomColors
),
4137 COMPUTED_STYLE_MAP_ENTRY(border_image
, BorderImage
),
4138 COMPUTED_STYLE_MAP_ENTRY(border_left_colors
, BorderLeftColors
),
4139 COMPUTED_STYLE_MAP_ENTRY(border_right_colors
, BorderRightColors
),
4140 COMPUTED_STYLE_MAP_ENTRY(border_top_colors
, BorderTopColors
),
4141 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomLeft
, BorderRadiusBottomLeft
),
4142 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomRight
,BorderRadiusBottomRight
),
4143 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topLeft
, BorderRadiusTopLeft
),
4144 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topRight
, BorderRadiusTopRight
),
4145 COMPUTED_STYLE_MAP_ENTRY(box_align
, BoxAlign
),
4146 COMPUTED_STYLE_MAP_ENTRY(box_direction
, BoxDirection
),
4147 COMPUTED_STYLE_MAP_ENTRY(box_flex
, BoxFlex
),
4148 COMPUTED_STYLE_MAP_ENTRY(box_ordinal_group
, BoxOrdinalGroup
),
4149 COMPUTED_STYLE_MAP_ENTRY(box_orient
, BoxOrient
),
4150 COMPUTED_STYLE_MAP_ENTRY(box_pack
, BoxPack
),
4151 COMPUTED_STYLE_MAP_ENTRY(box_shadow
, BoxShadow
),
4152 COMPUTED_STYLE_MAP_ENTRY(box_sizing
, BoxSizing
),
4153 COMPUTED_STYLE_MAP_ENTRY(_moz_column_count
, ColumnCount
),
4154 COMPUTED_STYLE_MAP_ENTRY(_moz_column_width
, ColumnWidth
),
4155 COMPUTED_STYLE_MAP_ENTRY(_moz_column_gap
, ColumnGap
),
4156 //// COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule, ColumnRule),
4157 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_color
, ColumnRuleColor
),
4158 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_width
, ColumnRuleWidth
),
4159 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_style
, ColumnRuleStyle
),
4160 COMPUTED_STYLE_MAP_ENTRY(float_edge
, FloatEdge
),
4161 COMPUTED_STYLE_MAP_ENTRY(force_broken_image_icon
, ForceBrokenImageIcon
),
4162 COMPUTED_STYLE_MAP_ENTRY(image_region
, ImageRegion
),
4163 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomLeft
, OutlineRadiusBottomLeft
),
4164 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomRight
,OutlineRadiusBottomRight
),
4165 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topLeft
, OutlineRadiusTopLeft
),
4166 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topRight
, OutlineRadiusTopRight
),
4167 COMPUTED_STYLE_MAP_ENTRY(stack_sizing
, StackSizing
),
4168 COMPUTED_STYLE_MAP_ENTRY(_moz_transform
, MozTransform
),
4169 COMPUTED_STYLE_MAP_ENTRY(_moz_transform_origin
, MozTransformOrigin
),
4170 COMPUTED_STYLE_MAP_ENTRY(user_focus
, UserFocus
),
4171 COMPUTED_STYLE_MAP_ENTRY(user_input
, UserInput
),
4172 COMPUTED_STYLE_MAP_ENTRY(user_modify
, UserModify
),
4173 COMPUTED_STYLE_MAP_ENTRY(user_select
, UserSelect
),
4174 COMPUTED_STYLE_MAP_ENTRY(word_wrap
, WordWrap
)
4178 COMPUTED_STYLE_MAP_ENTRY(clip_path
, ClipPath
),
4179 COMPUTED_STYLE_MAP_ENTRY(clip_rule
, ClipRule
),
4180 COMPUTED_STYLE_MAP_ENTRY(color_interpolation
, ColorInterpolation
),
4181 COMPUTED_STYLE_MAP_ENTRY(color_interpolation_filters
, ColorInterpolationFilters
),
4182 COMPUTED_STYLE_MAP_ENTRY(dominant_baseline
, DominantBaseline
),
4183 COMPUTED_STYLE_MAP_ENTRY(fill
, Fill
),
4184 COMPUTED_STYLE_MAP_ENTRY(fill_opacity
, FillOpacity
),
4185 COMPUTED_STYLE_MAP_ENTRY(fill_rule
, FillRule
),
4186 COMPUTED_STYLE_MAP_ENTRY(filter
, Filter
),
4187 COMPUTED_STYLE_MAP_ENTRY(flood_color
, FloodColor
),
4188 COMPUTED_STYLE_MAP_ENTRY(flood_opacity
, FloodOpacity
),
4189 COMPUTED_STYLE_MAP_ENTRY(lighting_color
, LightingColor
),
4190 COMPUTED_STYLE_MAP_ENTRY(mask
, Mask
),
4191 COMPUTED_STYLE_MAP_ENTRY(marker_end
, MarkerEnd
),
4192 COMPUTED_STYLE_MAP_ENTRY(marker_mid
, MarkerMid
),
4193 COMPUTED_STYLE_MAP_ENTRY(marker_start
, MarkerStart
),
4194 COMPUTED_STYLE_MAP_ENTRY(pointer_events
, PointerEvents
),
4195 COMPUTED_STYLE_MAP_ENTRY(shape_rendering
, ShapeRendering
),
4196 COMPUTED_STYLE_MAP_ENTRY(stop_color
, StopColor
),
4197 COMPUTED_STYLE_MAP_ENTRY(stop_opacity
, StopOpacity
),
4198 COMPUTED_STYLE_MAP_ENTRY(stroke
, Stroke
),
4199 COMPUTED_STYLE_MAP_ENTRY(stroke_dasharray
, StrokeDasharray
),
4200 COMPUTED_STYLE_MAP_ENTRY(stroke_dashoffset
, StrokeDashoffset
),
4201 COMPUTED_STYLE_MAP_ENTRY(stroke_linecap
, StrokeLinecap
),
4202 COMPUTED_STYLE_MAP_ENTRY(stroke_linejoin
, StrokeLinejoin
),
4203 COMPUTED_STYLE_MAP_ENTRY(stroke_miterlimit
, StrokeMiterlimit
),
4204 COMPUTED_STYLE_MAP_ENTRY(stroke_opacity
, StrokeOpacity
),
4205 COMPUTED_STYLE_MAP_ENTRY(stroke_width
, StrokeWidth
),
4206 COMPUTED_STYLE_MAP_ENTRY(text_anchor
, TextAnchor
),
4207 COMPUTED_STYLE_MAP_ENTRY(text_rendering
, TextRendering
)
4212 *aLength
= NS_ARRAY_LENGTH(map
);