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 if (font
->mGenericID
== kGenericFont_NONE
&& !font
->mFont
.systemFont
) {
1032 const nsFont
* defaultFont
=
1033 presContext
->GetDefaultFont(kPresContext_DefaultVariableFont_ID
);
1035 PRInt32 lendiff
= fontName
.Length() - defaultFont
->name
.Length();
1037 val
->SetString(Substring(fontName
, 0, lendiff
-1)); // -1 removes comma
1039 val
->SetString(fontName
);
1042 val
->SetString(fontName
);
1045 return CallQueryInterface(val
, aValue
);
1049 nsComputedDOMStyle::GetFontSize(nsIDOMCSSValue
** aValue
)
1051 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1052 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1054 // Note: GetStyleFont()->mSize is the 'computed size';
1055 // GetStyleFont()->mFont.size is the 'actual size'
1056 val
->SetAppUnits(GetStyleFont()->mSize
);
1058 return CallQueryInterface(val
, aValue
);
1062 nsComputedDOMStyle::GetFontSizeAdjust(nsIDOMCSSValue
** aValue
)
1064 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1065 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1067 const nsStyleFont
*font
= GetStyleFont();
1069 if (font
->mFont
.sizeAdjust
) {
1070 val
->SetNumber(font
->mFont
.sizeAdjust
);
1072 val
->SetIdent(nsGkAtoms::none
);
1075 return CallQueryInterface(val
, aValue
);
1079 nsComputedDOMStyle::GetFontStyle(nsIDOMCSSValue
** aValue
)
1081 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1082 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1084 const nsStyleFont
* font
= GetStyleFont();
1086 if (font
->mFont
.style
!= NS_STYLE_FONT_STYLE_NORMAL
) {
1087 const nsAFlatCString
& style
=
1088 nsCSSProps::ValueToKeyword(font
->mFont
.style
,
1089 nsCSSProps::kFontStyleKTable
);
1090 val
->SetIdent(style
);
1092 val
->SetIdent(nsGkAtoms::normal
);
1095 return CallQueryInterface(val
, aValue
);
1099 nsComputedDOMStyle::GetFontWeight(nsIDOMCSSValue
** aValue
)
1101 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1102 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1104 const nsStyleFont
* font
= GetStyleFont();
1106 const nsAFlatCString
& str_weight
=
1107 nsCSSProps::ValueToKeyword(font
->mFont
.weight
,
1108 nsCSSProps::kFontWeightKTable
);
1109 if (!str_weight
.IsEmpty()) {
1110 val
->SetIdent(str_weight
);
1112 val
->SetNumber(font
->mFont
.weight
);
1115 return CallQueryInterface(val
, aValue
);
1119 nsComputedDOMStyle::GetFontVariant(nsIDOMCSSValue
** aValue
)
1121 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1122 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1124 const nsStyleFont
* font
= GetStyleFont();
1126 if (font
->mFont
.variant
!= NS_STYLE_FONT_VARIANT_NORMAL
) {
1127 const nsAFlatCString
& variant
=
1128 nsCSSProps::ValueToKeyword(font
->mFont
.variant
,
1129 nsCSSProps::kFontVariantKTable
);
1130 val
->SetIdent(variant
);
1132 val
->SetIdent(nsGkAtoms::normal
);
1135 return CallQueryInterface(val
, aValue
);
1139 nsComputedDOMStyle::GetBackgroundAttachment(nsIDOMCSSValue
** aValue
)
1141 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1142 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1144 const nsStyleBackground
*background
= GetStyleBackground();
1146 const nsAFlatCString
& backgroundAttachment
=
1147 nsCSSProps::ValueToKeyword(background
->mBackgroundAttachment
,
1148 nsCSSProps::kBackgroundAttachmentKTable
);
1149 val
->SetIdent(backgroundAttachment
);
1151 return CallQueryInterface(val
, aValue
);
1155 nsComputedDOMStyle::GetBackgroundClip(nsIDOMCSSValue
** aValue
)
1157 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1158 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1160 const nsAFlatCString
& backgroundClip
=
1161 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundClip
,
1162 nsCSSProps::kBackgroundClipKTable
);
1164 val
->SetIdent(backgroundClip
);
1166 return CallQueryInterface(val
, aValue
);
1170 nsComputedDOMStyle::GetBackgroundColor(nsIDOMCSSValue
** aValue
)
1172 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1173 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1175 const nsStyleBackground
* color
= GetStyleBackground();
1176 nsresult rv
= SetToRGBAColor(val
, color
->mBackgroundColor
);
1177 if (NS_FAILED(rv
)) {
1182 return CallQueryInterface(val
, aValue
);
1186 nsComputedDOMStyle::GetBackgroundImage(nsIDOMCSSValue
** aValue
)
1188 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1189 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1191 const nsStyleBackground
* color
= GetStyleBackground();
1193 if (color
->mBackgroundFlags
& NS_STYLE_BG_IMAGE_NONE
) {
1194 val
->SetIdent(nsGkAtoms::none
);
1196 nsCOMPtr
<nsIURI
> uri
;
1197 if (color
->mBackgroundImage
) {
1198 color
->mBackgroundImage
->GetURI(getter_AddRefs(uri
));
1203 return CallQueryInterface(val
, aValue
);
1207 nsComputedDOMStyle::GetBackgroundInlinePolicy(nsIDOMCSSValue
** aValue
)
1209 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1210 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1212 const nsAFlatCString
& backgroundPolicy
=
1213 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundInlinePolicy
,
1214 nsCSSProps::kBackgroundInlinePolicyKTable
);
1216 val
->SetIdent(backgroundPolicy
);
1218 return CallQueryInterface(val
, aValue
);
1222 nsComputedDOMStyle::GetBackgroundOrigin(nsIDOMCSSValue
** aValue
)
1224 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1225 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1227 const nsAFlatCString
& backgroundOrigin
=
1228 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundOrigin
,
1229 nsCSSProps::kBackgroundOriginKTable
);
1231 val
->SetIdent(backgroundOrigin
);
1233 return CallQueryInterface(val
, aValue
);
1237 nsComputedDOMStyle::GetBackgroundPosition(nsIDOMCSSValue
** aValue
)
1239 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
1240 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1242 nsROCSSPrimitiveValue
*valX
= GetROCSSPrimitiveValue();
1243 if (!valX
|| !valueList
->AppendCSSValue(valX
)) {
1246 return NS_ERROR_OUT_OF_MEMORY
;
1249 nsROCSSPrimitiveValue
*valY
= GetROCSSPrimitiveValue();
1250 if (!valY
|| !valueList
->AppendCSSValue(valY
)) {
1253 return NS_ERROR_OUT_OF_MEMORY
;
1256 const nsStyleBackground
*bg
= GetStyleBackground();
1258 if (NS_STYLE_BG_X_POSITION_LENGTH
& bg
->mBackgroundFlags
) {
1259 valX
->SetAppUnits(bg
->mBackgroundXPosition
.mCoord
);
1261 else if (NS_STYLE_BG_X_POSITION_PERCENT
& bg
->mBackgroundFlags
) {
1262 valX
->SetPercent(bg
->mBackgroundXPosition
.mFloat
);
1265 valX
->SetPercent(0.0f
);
1268 if (NS_STYLE_BG_Y_POSITION_LENGTH
& bg
->mBackgroundFlags
) {
1269 valY
->SetAppUnits(bg
->mBackgroundYPosition
.mCoord
);
1271 else if (NS_STYLE_BG_Y_POSITION_PERCENT
& bg
->mBackgroundFlags
) {
1272 valY
->SetPercent(bg
->mBackgroundYPosition
.mFloat
);
1275 valY
->SetPercent(0.0f
);
1278 return CallQueryInterface(valueList
, aValue
);
1282 nsComputedDOMStyle::GetBackgroundRepeat(nsIDOMCSSValue
** aValue
)
1284 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1285 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1287 const nsAFlatCString
& backgroundRepeat
=
1288 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundRepeat
,
1289 nsCSSProps::kBackgroundRepeatKTable
);
1290 val
->SetIdent(backgroundRepeat
);
1292 return CallQueryInterface(val
, aValue
);
1296 nsComputedDOMStyle::GetPadding(nsIDOMCSSValue
** aValue
)
1298 // return null per spec.
1305 nsComputedDOMStyle::GetPaddingTop(nsIDOMCSSValue
** aValue
)
1307 return GetPaddingWidthFor(NS_SIDE_TOP
, aValue
);
1311 nsComputedDOMStyle::GetPaddingBottom(nsIDOMCSSValue
** aValue
)
1313 return GetPaddingWidthFor(NS_SIDE_BOTTOM
, aValue
);
1317 nsComputedDOMStyle::GetPaddingLeft(nsIDOMCSSValue
** aValue
)
1319 return GetPaddingWidthFor(NS_SIDE_LEFT
, aValue
);
1323 nsComputedDOMStyle::GetPaddingRight(nsIDOMCSSValue
** aValue
)
1325 return GetPaddingWidthFor(NS_SIDE_RIGHT
, aValue
);
1329 nsComputedDOMStyle::GetBorderCollapse(nsIDOMCSSValue
** aValue
)
1331 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1332 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1334 const nsAFlatCString
& ident
=
1335 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mBorderCollapse
,
1336 nsCSSProps::kBorderCollapseKTable
);
1337 val
->SetIdent(ident
);
1339 return CallQueryInterface(val
, aValue
);
1343 nsComputedDOMStyle::GetBorderSpacing(nsIDOMCSSValue
** aValue
)
1345 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
1346 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1348 nsROCSSPrimitiveValue
* xSpacing
= GetROCSSPrimitiveValue();
1351 return NS_ERROR_OUT_OF_MEMORY
;
1353 if (!valueList
->AppendCSSValue(xSpacing
)) {
1356 return NS_ERROR_OUT_OF_MEMORY
;
1359 nsROCSSPrimitiveValue
* ySpacing
= GetROCSSPrimitiveValue();
1362 return NS_ERROR_OUT_OF_MEMORY
;
1364 if (!valueList
->AppendCSSValue(ySpacing
)) {
1367 return NS_ERROR_OUT_OF_MEMORY
;
1370 const nsStyleTableBorder
*border
= GetStyleTableBorder();
1371 xSpacing
->SetAppUnits(border
->mBorderSpacingX
);
1372 ySpacing
->SetAppUnits(border
->mBorderSpacingY
);
1374 return CallQueryInterface(valueList
, aValue
);
1378 nsComputedDOMStyle::GetCaptionSide(nsIDOMCSSValue
** aValue
)
1380 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1381 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1383 const nsAFlatCString
& side
=
1384 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mCaptionSide
,
1385 nsCSSProps::kCaptionSideKTable
);
1386 val
->SetIdent(side
);
1388 return CallQueryInterface(val
, aValue
);
1392 nsComputedDOMStyle::GetEmptyCells(nsIDOMCSSValue
** aValue
)
1394 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1395 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1397 const nsAFlatCString
& emptyCells
=
1398 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mEmptyCells
,
1399 nsCSSProps::kEmptyCellsKTable
);
1400 val
->SetIdent(emptyCells
);
1402 return CallQueryInterface(val
, aValue
);
1406 nsComputedDOMStyle::GetTableLayout(nsIDOMCSSValue
** aValue
)
1408 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1409 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1411 const nsStyleTable
*table
= GetStyleTable();
1413 if (table
->mLayoutStrategy
!= NS_STYLE_TABLE_LAYOUT_AUTO
) {
1414 const nsAFlatCString
& tableLayout
=
1415 nsCSSProps::ValueToKeyword(table
->mLayoutStrategy
,
1416 nsCSSProps::kTableLayoutKTable
);
1417 val
->SetIdent(tableLayout
);
1419 val
->SetIdent(nsGkAtoms::_auto
);
1422 return CallQueryInterface(val
, aValue
);
1426 nsComputedDOMStyle::GetBorderStyle(nsIDOMCSSValue
** aValue
)
1428 // return null per spec.
1435 nsComputedDOMStyle::GetBorderTopStyle(nsIDOMCSSValue
** aValue
)
1437 return GetBorderStyleFor(NS_SIDE_TOP
, aValue
);
1441 nsComputedDOMStyle::GetBorderBottomStyle(nsIDOMCSSValue
** aValue
)
1443 return GetBorderStyleFor(NS_SIDE_BOTTOM
, aValue
);
1446 nsComputedDOMStyle::GetBorderLeftStyle(nsIDOMCSSValue
** aValue
)
1448 return GetBorderStyleFor(NS_SIDE_LEFT
, aValue
);
1452 nsComputedDOMStyle::GetBorderRightStyle(nsIDOMCSSValue
** aValue
)
1454 return GetBorderStyleFor(NS_SIDE_RIGHT
, aValue
);
1458 nsComputedDOMStyle::GetBorderBottomColors(nsIDOMCSSValue
** aValue
)
1460 return GetBorderColorsFor(NS_SIDE_BOTTOM
, aValue
);
1464 nsComputedDOMStyle::GetBorderLeftColors(nsIDOMCSSValue
** aValue
)
1466 return GetBorderColorsFor(NS_SIDE_LEFT
, aValue
);
1470 nsComputedDOMStyle::GetBorderRightColors(nsIDOMCSSValue
** aValue
)
1472 return GetBorderColorsFor(NS_SIDE_RIGHT
, aValue
);
1477 nsComputedDOMStyle::GetBorderTopColors(nsIDOMCSSValue
** aValue
)
1479 return GetBorderColorsFor(NS_SIDE_TOP
, aValue
);
1483 nsComputedDOMStyle::GetBorderRadiusBottomLeft(nsIDOMCSSValue
** aValue
)
1485 return GetEllipseRadii(GetStyleBorder()->mBorderRadius
,
1486 NS_CORNER_BOTTOM_LEFT
, aValue
);
1490 nsComputedDOMStyle::GetBorderRadiusBottomRight(nsIDOMCSSValue
** aValue
)
1492 return GetEllipseRadii(GetStyleBorder()->mBorderRadius
,
1493 NS_CORNER_BOTTOM_RIGHT
, aValue
);
1497 nsComputedDOMStyle::GetBorderRadiusTopLeft(nsIDOMCSSValue
** aValue
)
1499 return GetEllipseRadii(GetStyleBorder()->mBorderRadius
,
1500 NS_CORNER_TOP_LEFT
, aValue
);
1504 nsComputedDOMStyle::GetBorderRadiusTopRight(nsIDOMCSSValue
** aValue
)
1506 return GetEllipseRadii(GetStyleBorder()->mBorderRadius
,
1507 NS_CORNER_TOP_RIGHT
, aValue
);
1511 nsComputedDOMStyle::GetBorderWidth(nsIDOMCSSValue
** aValue
)
1513 // return null per spec.
1520 nsComputedDOMStyle::GetBorderTopWidth(nsIDOMCSSValue
** aValue
)
1522 return GetBorderWidthFor(NS_SIDE_TOP
, aValue
);
1526 nsComputedDOMStyle::GetBorderBottomWidth(nsIDOMCSSValue
** aValue
)
1528 return GetBorderWidthFor(NS_SIDE_BOTTOM
, aValue
);
1532 nsComputedDOMStyle::GetBorderLeftWidth(nsIDOMCSSValue
** aValue
)
1534 return GetBorderWidthFor(NS_SIDE_LEFT
, aValue
);
1538 nsComputedDOMStyle::GetBorderRightWidth(nsIDOMCSSValue
** aValue
)
1540 return GetBorderWidthFor(NS_SIDE_RIGHT
, aValue
);
1544 nsComputedDOMStyle::GetBorderTopColor(nsIDOMCSSValue
** aValue
)
1546 return GetBorderColorFor(NS_SIDE_TOP
, aValue
);
1550 nsComputedDOMStyle::GetBorderBottomColor(nsIDOMCSSValue
** aValue
)
1552 return GetBorderColorFor(NS_SIDE_BOTTOM
, aValue
);
1556 nsComputedDOMStyle::GetBorderLeftColor(nsIDOMCSSValue
** aValue
)
1558 return GetBorderColorFor(NS_SIDE_LEFT
, aValue
);
1562 nsComputedDOMStyle::GetBorderRightColor(nsIDOMCSSValue
** aValue
)
1564 return GetBorderColorFor(NS_SIDE_RIGHT
, aValue
);
1568 nsComputedDOMStyle::GetMarginWidth(nsIDOMCSSValue
** aValue
)
1570 // return null per spec.
1577 nsComputedDOMStyle::GetMarginTopWidth(nsIDOMCSSValue
** aValue
)
1579 return GetMarginWidthFor(NS_SIDE_TOP
, aValue
);
1583 nsComputedDOMStyle::GetMarginBottomWidth(nsIDOMCSSValue
** aValue
)
1585 return GetMarginWidthFor(NS_SIDE_BOTTOM
, aValue
);
1589 nsComputedDOMStyle::GetMarginLeftWidth(nsIDOMCSSValue
** aValue
)
1591 return GetMarginWidthFor(NS_SIDE_LEFT
, aValue
);
1595 nsComputedDOMStyle::GetMarginRightWidth(nsIDOMCSSValue
** aValue
)
1597 return GetMarginWidthFor(NS_SIDE_RIGHT
, aValue
);
1601 nsComputedDOMStyle::GetMarkerOffset(nsIDOMCSSValue
** aValue
)
1603 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1604 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1606 SetValueToCoord(val
, GetStyleContent()->mMarkerOffset
);
1608 return CallQueryInterface(val
, aValue
);
1612 nsComputedDOMStyle::GetOutline(nsIDOMCSSValue
** aValue
)
1614 // return null per spec.
1621 nsComputedDOMStyle::GetOutlineWidth(nsIDOMCSSValue
** aValue
)
1623 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1624 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1626 const nsStyleOutline
* outline
= GetStyleOutline();
1629 PRUint8 outlineStyle
= outline
->GetOutlineStyle();
1630 if (outlineStyle
== NS_STYLE_BORDER_STYLE_NONE
) {
1631 coord
.SetCoordValue(0);
1633 coord
= outline
->mOutlineWidth
;
1635 SetValueToCoord(val
, coord
, nsnull
, nsCSSProps::kBorderWidthKTable
);
1637 return CallQueryInterface(val
, aValue
);
1641 nsComputedDOMStyle::GetOutlineStyle(nsIDOMCSSValue
** aValue
)
1643 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1644 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1646 PRUint8 outlineStyle
= GetStyleOutline()->GetOutlineStyle();
1647 switch (outlineStyle
) {
1648 case NS_STYLE_BORDER_STYLE_NONE
:
1649 val
->SetIdent(nsGkAtoms::none
);
1651 case NS_STYLE_BORDER_STYLE_AUTO
:
1652 val
->SetIdent(nsGkAtoms::_auto
);
1655 const nsAFlatCString
& style
=
1656 nsCSSProps::ValueToKeyword(outlineStyle
,
1657 nsCSSProps::kOutlineStyleKTable
);
1658 val
->SetIdent(style
);
1661 return CallQueryInterface(val
, aValue
);
1665 nsComputedDOMStyle::GetOutlineOffset(nsIDOMCSSValue
** aValue
)
1667 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1668 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1670 val
->SetAppUnits(GetStyleOutline()->mOutlineOffset
);
1672 return CallQueryInterface(val
, aValue
);
1676 nsComputedDOMStyle::GetOutlineRadiusBottomLeft(nsIDOMCSSValue
** aValue
)
1678 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius
,
1679 NS_CORNER_BOTTOM_LEFT
, aValue
);
1683 nsComputedDOMStyle::GetOutlineRadiusBottomRight(nsIDOMCSSValue
** aValue
)
1685 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius
,
1686 NS_CORNER_BOTTOM_RIGHT
, aValue
);
1690 nsComputedDOMStyle::GetOutlineRadiusTopLeft(nsIDOMCSSValue
** aValue
)
1692 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius
,
1693 NS_CORNER_TOP_LEFT
, aValue
);
1697 nsComputedDOMStyle::GetOutlineRadiusTopRight(nsIDOMCSSValue
** aValue
)
1699 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius
,
1700 NS_CORNER_TOP_RIGHT
, aValue
);
1704 nsComputedDOMStyle::GetOutlineColor(nsIDOMCSSValue
** aValue
)
1706 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1707 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1710 #ifdef GFX_HAS_INVERT
1711 GetStyleOutline()->GetOutlineColor(color
);
1713 if (!GetStyleOutline()->GetOutlineColor(color
))
1714 color
= GetStyleColor()->mColor
;
1717 nsresult rv
= SetToRGBAColor(val
, color
);
1718 if (NS_FAILED(rv
)) {
1723 return CallQueryInterface(val
, aValue
);
1727 nsComputedDOMStyle::GetEllipseRadii(const nsStyleCorners
& aRadius
,
1728 PRUint8 aFullCorner
,
1729 nsIDOMCSSValue
** aValue
)
1731 const nsStyleCoord
& radiusX
1732 = aRadius
.Get(NS_FULL_TO_HALF_CORNER(aFullCorner
, PR_FALSE
));
1733 const nsStyleCoord
& radiusY
1734 = aRadius
.Get(NS_FULL_TO_HALF_CORNER(aFullCorner
, PR_TRUE
));
1736 // for compatibility, return a single value if X and Y are equal
1737 if (radiusX
== radiusY
) {
1738 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1739 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1741 SetValueToCoord(val
, radiusX
,
1742 &nsComputedDOMStyle::GetFrameBorderRectWidth
);
1744 return CallQueryInterface(val
, aValue
);
1746 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
1747 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1749 nsROCSSPrimitiveValue
*valX
= GetROCSSPrimitiveValue();
1750 if (!valX
|| !valueList
->AppendCSSValue(valX
)) {
1753 return NS_ERROR_OUT_OF_MEMORY
;
1756 nsROCSSPrimitiveValue
*valY
= GetROCSSPrimitiveValue();
1757 if (!valY
|| !valueList
->AppendCSSValue(valY
)) {
1759 // valX deleted by valueList destructor
1761 return NS_ERROR_OUT_OF_MEMORY
;
1764 SetValueToCoord(valX
, radiusX
,
1765 &nsComputedDOMStyle::GetFrameBorderRectWidth
);
1766 SetValueToCoord(valY
, radiusY
,
1767 &nsComputedDOMStyle::GetFrameBorderRectWidth
);
1769 return CallQueryInterface(valueList
, aValue
);
1774 nsComputedDOMStyle::GetCSSShadowArray(nsCSSShadowArray
* aArray
,
1775 const nscolor
& aDefaultColor
,
1777 nsIDOMCSSValue
** aValue
)
1780 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1781 val
->SetIdent(nsGkAtoms::none
);
1782 return CallQueryInterface(val
, aValue
);
1785 static nscoord
nsCSSShadowItem::* const shadowValuesNoSpread
[] = {
1786 &nsCSSShadowItem::mXOffset
,
1787 &nsCSSShadowItem::mYOffset
,
1788 &nsCSSShadowItem::mRadius
1791 static nscoord
nsCSSShadowItem::* const shadowValuesWithSpread
[] = {
1792 &nsCSSShadowItem::mXOffset
,
1793 &nsCSSShadowItem::mYOffset
,
1794 &nsCSSShadowItem::mRadius
,
1795 &nsCSSShadowItem::mSpread
1798 nscoord
nsCSSShadowItem::* const * shadowValues
;
1799 PRUint32 shadowValuesLength
;
1801 shadowValues
= shadowValuesWithSpread
;
1802 shadowValuesLength
= NS_ARRAY_LENGTH(shadowValuesWithSpread
);
1804 shadowValues
= shadowValuesNoSpread
;
1805 shadowValuesLength
= NS_ARRAY_LENGTH(shadowValuesNoSpread
);
1808 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
1809 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
1811 for (nsCSSShadowItem
*item
= aArray
->ShadowAt(0),
1812 *item_end
= item
+ aArray
->Length();
1813 item
< item_end
; ++item
) {
1814 nsDOMCSSValueList
*itemList
= GetROCSSValueList(PR_FALSE
);
1815 if (!itemList
|| !valueList
->AppendCSSValue(itemList
)) {
1818 return NS_ERROR_OUT_OF_MEMORY
;
1821 // Color is either the specified shadow color or the foreground color
1822 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1823 if (!val
|| !itemList
->AppendCSSValue(val
)) {
1826 return NS_ERROR_OUT_OF_MEMORY
;
1828 nscolor shadowColor
;
1829 if (item
->mHasColor
) {
1830 shadowColor
= item
->mColor
;
1832 shadowColor
= aDefaultColor
;
1834 SetToRGBAColor(val
, shadowColor
);
1836 // Set the offsets, blur radius, and spread if available
1837 for (PRUint32 i
= 0; i
< shadowValuesLength
; ++i
) {
1838 val
= GetROCSSPrimitiveValue();
1839 if (!val
|| !itemList
->AppendCSSValue(val
)) {
1842 return NS_ERROR_OUT_OF_MEMORY
;
1844 val
->SetAppUnits(item
->*(shadowValues
[i
]));
1848 return CallQueryInterface(valueList
, aValue
);
1852 nsComputedDOMStyle::GetBoxShadow(nsIDOMCSSValue
** aValue
)
1854 return GetCSSShadowArray(GetStyleBorder()->mBoxShadow
,
1855 GetStyleColor()->mColor
,
1860 nsComputedDOMStyle::GetZIndex(nsIDOMCSSValue
** aValue
)
1862 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1863 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1865 SetValueToCoord(val
, GetStylePosition()->mZIndex
);
1867 return CallQueryInterface(val
, aValue
);
1871 nsComputedDOMStyle::GetListStyleImage(nsIDOMCSSValue
** aValue
)
1873 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
1874 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1876 const nsStyleList
* list
= GetStyleList();
1878 if (!list
->mListStyleImage
) {
1879 val
->SetIdent(nsGkAtoms::none
);
1881 nsCOMPtr
<nsIURI
> uri
;
1882 if (list
->mListStyleImage
) {
1883 list
->mListStyleImage
->GetURI(getter_AddRefs(uri
));
1888 return CallQueryInterface(val
, aValue
);
1892 nsComputedDOMStyle::GetListStylePosition(nsIDOMCSSValue
** aValue
)
1894 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1895 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1897 const nsAFlatCString
& style
=
1898 nsCSSProps::ValueToKeyword(GetStyleList()->mListStylePosition
,
1899 nsCSSProps::kListStylePositionKTable
);
1900 val
->SetIdent(style
);
1902 return CallQueryInterface(val
, aValue
);
1906 nsComputedDOMStyle::GetListStyleType(nsIDOMCSSValue
** aValue
)
1908 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1909 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1911 const nsStyleList
*list
= GetStyleList();
1913 if (list
->mListStyleType
== NS_STYLE_LIST_STYLE_NONE
) {
1914 val
->SetIdent(nsGkAtoms::none
);
1916 const nsAFlatCString
& style
=
1917 nsCSSProps::ValueToKeyword(list
->mListStyleType
,
1918 nsCSSProps::kListStyleKTable
);
1919 val
->SetIdent(style
);
1922 return CallQueryInterface(val
, aValue
);
1926 nsComputedDOMStyle::GetImageRegion(nsIDOMCSSValue
** aValue
)
1928 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1929 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1931 const nsStyleList
* list
= GetStyleList();
1933 nsresult rv
= NS_OK
;
1934 nsROCSSPrimitiveValue
*topVal
= nsnull
;
1935 nsROCSSPrimitiveValue
*rightVal
= nsnull
;
1936 nsROCSSPrimitiveValue
*bottomVal
= nsnull
;
1937 nsROCSSPrimitiveValue
*leftVal
= nsnull
;
1938 if (list
->mImageRegion
.width
<= 0 || list
->mImageRegion
.height
<= 0) {
1939 val
->SetIdent(nsGkAtoms::_auto
);
1941 // create the cssvalues for the sides, stick them in the rect object
1942 topVal
= GetROCSSPrimitiveValue();
1943 rightVal
= GetROCSSPrimitiveValue();
1944 bottomVal
= GetROCSSPrimitiveValue();
1945 leftVal
= GetROCSSPrimitiveValue();
1946 if (topVal
&& rightVal
&& bottomVal
&& leftVal
) {
1947 nsDOMCSSRect
* domRect
= new nsDOMCSSRect(topVal
, rightVal
,
1948 bottomVal
, leftVal
);
1950 topVal
->SetAppUnits(list
->mImageRegion
.y
);
1951 rightVal
->SetAppUnits(list
->mImageRegion
.width
+ list
->mImageRegion
.x
);
1952 bottomVal
->SetAppUnits(list
->mImageRegion
.height
+ list
->mImageRegion
.y
);
1953 leftVal
->SetAppUnits(list
->mImageRegion
.x
);
1954 val
->SetRect(domRect
);
1956 rv
= NS_ERROR_OUT_OF_MEMORY
;
1959 rv
= NS_ERROR_OUT_OF_MEMORY
;
1963 if (NS_FAILED(rv
)) {
1973 return CallQueryInterface(val
, aValue
);
1977 nsComputedDOMStyle::GetLineHeight(nsIDOMCSSValue
** aValue
)
1979 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1980 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1983 GetLineHeightCoord(lineHeight
);
1984 val
->SetAppUnits(lineHeight
);
1986 return CallQueryInterface(val
, aValue
);
1990 nsComputedDOMStyle::GetVerticalAlign(nsIDOMCSSValue
** aValue
)
1992 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
1993 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
1995 SetValueToCoord(val
, GetStyleTextReset()->mVerticalAlign
,
1996 &nsComputedDOMStyle::GetLineHeightCoord
,
1997 nsCSSProps::kVerticalAlignKTable
);
1999 return CallQueryInterface(val
, aValue
);
2003 nsComputedDOMStyle::GetTextAlign(nsIDOMCSSValue
** aValue
)
2005 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2006 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2008 const nsAFlatCString
& align
=
2009 nsCSSProps::ValueToKeyword(GetStyleText()->mTextAlign
,
2010 nsCSSProps::kTextAlignKTable
);
2011 val
->SetIdent(align
);
2013 return CallQueryInterface(val
, aValue
);
2017 nsComputedDOMStyle::GetTextDecoration(nsIDOMCSSValue
** aValue
)
2019 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2020 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2022 const nsStyleTextReset
* text
= GetStyleTextReset();
2024 if (NS_STYLE_TEXT_DECORATION_NONE
== text
->mTextDecoration
) {
2025 const nsAFlatCString
& decoration
=
2026 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2027 val
->SetIdent(decoration
);
2029 nsAutoString decorationString
;
2030 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_UNDERLINE
) {
2031 const nsAFlatCString
& decoration
=
2032 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_UNDERLINE
,
2033 nsCSSProps::kTextDecorationKTable
);
2034 decorationString
.AppendWithConversion(decoration
.get());
2036 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_OVERLINE
) {
2037 if (!decorationString
.IsEmpty()) {
2038 decorationString
.Append(PRUnichar(' '));
2040 const nsAFlatCString
& decoration
=
2041 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_OVERLINE
,
2042 nsCSSProps::kTextDecorationKTable
);
2043 decorationString
.AppendWithConversion(decoration
.get());
2045 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_LINE_THROUGH
) {
2046 if (!decorationString
.IsEmpty()) {
2047 decorationString
.Append(PRUnichar(' '));
2049 const nsAFlatCString
& decoration
=
2050 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_LINE_THROUGH
,
2051 nsCSSProps::kTextDecorationKTable
);
2052 decorationString
.AppendWithConversion(decoration
.get());
2054 if (text
->mTextDecoration
& NS_STYLE_TEXT_DECORATION_BLINK
) {
2055 if (!decorationString
.IsEmpty()) {
2056 decorationString
.Append(PRUnichar(' '));
2058 const nsAFlatCString
& decoration
=
2059 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_BLINK
,
2060 nsCSSProps::kTextDecorationKTable
);
2061 decorationString
.AppendWithConversion(decoration
.get());
2063 val
->SetString(decorationString
);
2066 return CallQueryInterface(val
, aValue
);
2070 nsComputedDOMStyle::GetTextIndent(nsIDOMCSSValue
** aValue
)
2072 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2073 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2075 SetValueToCoord(val
, GetStyleText()->mTextIndent
,
2076 &nsComputedDOMStyle::GetCBContentWidth
);
2078 return CallQueryInterface(val
, aValue
);
2082 nsComputedDOMStyle::GetTextShadow(nsIDOMCSSValue
** aValue
)
2084 return GetCSSShadowArray(GetStyleText()->mTextShadow
,
2085 GetStyleColor()->mColor
,
2090 nsComputedDOMStyle::GetTextTransform(nsIDOMCSSValue
** aValue
)
2092 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2093 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2095 const nsStyleText
*text
= GetStyleText();
2097 if (text
->mTextTransform
!= NS_STYLE_TEXT_TRANSFORM_NONE
) {
2098 const nsAFlatCString
& textTransform
=
2099 nsCSSProps::ValueToKeyword(text
->mTextTransform
,
2100 nsCSSProps::kTextTransformKTable
);
2101 val
->SetIdent(textTransform
);
2103 val
->SetIdent(nsGkAtoms::none
);
2106 return CallQueryInterface(val
, aValue
);
2110 nsComputedDOMStyle::GetLetterSpacing(nsIDOMCSSValue
** aValue
)
2112 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2113 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2115 SetValueToCoord(val
, GetStyleText()->mLetterSpacing
);
2117 return CallQueryInterface(val
, aValue
);
2121 nsComputedDOMStyle::GetWordSpacing(nsIDOMCSSValue
** aValue
)
2123 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2124 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2126 SetValueToCoord(val
, GetStyleText()->mWordSpacing
);
2128 return CallQueryInterface(val
, aValue
);
2132 nsComputedDOMStyle::GetWhiteSpace(nsIDOMCSSValue
** aValue
)
2134 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2135 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2137 const nsStyleText
*text
= GetStyleText();
2139 if (text
->mWhiteSpace
!= NS_STYLE_WHITESPACE_NORMAL
) {
2140 const nsAFlatCString
& whiteSpace
=
2141 nsCSSProps::ValueToKeyword(text
->mWhiteSpace
,
2142 nsCSSProps::kWhitespaceKTable
);
2143 val
->SetIdent(whiteSpace
);
2145 val
->SetIdent(nsGkAtoms::normal
);
2148 return CallQueryInterface(val
, aValue
);
2152 nsComputedDOMStyle::GetWindowShadow(nsIDOMCSSValue
** aValue
)
2154 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2155 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2157 const nsStyleUIReset
*uiData
= GetStyleUIReset();
2159 if (uiData
->mWindowShadow
!= NS_STYLE_WINDOW_SHADOW_NONE
) {
2160 const nsAFlatCString
& windowShadow
=
2161 nsCSSProps::ValueToKeyword(uiData
->mWindowShadow
,
2162 nsCSSProps::kWindowShadowKTable
);
2163 val
->SetIdent(windowShadow
);
2165 val
->SetIdent(nsGkAtoms::none
);
2168 return CallQueryInterface(val
, aValue
);
2173 nsComputedDOMStyle::GetWordWrap(nsIDOMCSSValue
** aValue
)
2175 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2176 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2178 const nsStyleText
*text
= GetStyleText();
2180 if (text
->mWordWrap
!= NS_STYLE_WORDWRAP_NORMAL
) {
2181 const nsAFlatCString
& wordWrap
=
2182 nsCSSProps::ValueToKeyword(text
->mWordWrap
,
2183 nsCSSProps::kWordwrapKTable
);
2184 val
->SetIdent(wordWrap
);
2186 val
->SetIdent(nsGkAtoms::normal
);
2189 return CallQueryInterface(val
, aValue
);
2193 nsComputedDOMStyle::GetVisibility(nsIDOMCSSValue
** aValue
)
2195 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2196 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2198 const nsAFlatCString
& value
=
2199 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mVisible
,
2200 nsCSSProps::kVisibilityKTable
);
2201 val
->SetIdent(value
);
2203 return CallQueryInterface(val
, aValue
);
2207 nsComputedDOMStyle::GetDirection(nsIDOMCSSValue
** aValue
)
2209 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2210 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2212 const nsAFlatCString
& direction
=
2213 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mDirection
,
2214 nsCSSProps::kDirectionKTable
);
2215 val
->SetIdent(direction
);
2217 return CallQueryInterface(val
, aValue
);
2221 nsComputedDOMStyle::GetUnicodeBidi(nsIDOMCSSValue
** aValue
)
2223 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2224 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2226 const nsStyleTextReset
*text
= GetStyleTextReset();
2228 if (text
->mUnicodeBidi
!= NS_STYLE_UNICODE_BIDI_NORMAL
) {
2229 const nsAFlatCString
& bidi
=
2230 nsCSSProps::ValueToKeyword(text
->mUnicodeBidi
,
2231 nsCSSProps::kUnicodeBidiKTable
);
2232 val
->SetIdent(bidi
);
2234 val
->SetIdent(nsGkAtoms::normal
);
2237 return CallQueryInterface(val
, aValue
);
2241 nsComputedDOMStyle::GetCursor(nsIDOMCSSValue
** aValue
)
2243 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
2244 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
2246 const nsStyleUserInterface
*ui
= GetStyleUserInterface();
2248 for (nsCursorImage
*item
= ui
->mCursorArray
,
2249 *item_end
= ui
->mCursorArray
+ ui
->mCursorArrayLength
;
2250 item
< item_end
; ++item
) {
2251 nsDOMCSSValueList
*itemList
= GetROCSSValueList(PR_FALSE
);
2252 if (!itemList
|| !valueList
->AppendCSSValue(itemList
)) {
2255 return NS_ERROR_OUT_OF_MEMORY
;
2258 nsCOMPtr
<nsIURI
> uri
;
2259 item
->mImage
->GetURI(getter_AddRefs(uri
));
2261 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2262 if (!val
|| !itemList
->AppendCSSValue(val
)) {
2265 return NS_ERROR_OUT_OF_MEMORY
;
2269 if (item
->mHaveHotspot
) {
2270 nsROCSSPrimitiveValue
*valX
= GetROCSSPrimitiveValue();
2271 if (!valX
|| !itemList
->AppendCSSValue(valX
)) {
2274 return NS_ERROR_OUT_OF_MEMORY
;
2276 nsROCSSPrimitiveValue
*valY
= GetROCSSPrimitiveValue();
2277 if (!valY
|| !itemList
->AppendCSSValue(valY
)) {
2280 return NS_ERROR_OUT_OF_MEMORY
;
2283 valX
->SetNumber(item
->mHotspotX
);
2284 valY
->SetNumber(item
->mHotspotY
);
2288 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2291 return NS_ERROR_OUT_OF_MEMORY
;
2294 if (ui
->mCursor
== NS_STYLE_CURSOR_AUTO
) {
2295 val
->SetIdent(nsGkAtoms::_auto
);
2297 const nsAFlatCString
& cursor
=
2298 nsCSSProps::ValueToKeyword(ui
->mCursor
,
2299 nsCSSProps::kCursorKTable
);
2300 val
->SetIdent(cursor
);
2302 if (!valueList
->AppendCSSValue(val
)) {
2305 return NS_ERROR_OUT_OF_MEMORY
;
2308 return CallQueryInterface(valueList
, aValue
);
2312 nsComputedDOMStyle::GetAppearance(nsIDOMCSSValue
** aValue
)
2314 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2315 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2317 const nsAFlatCString
& appearanceIdent
=
2318 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mAppearance
,
2319 nsCSSProps::kAppearanceKTable
);
2320 val
->SetIdent(appearanceIdent
);
2322 return CallQueryInterface(val
, aValue
);
2327 nsComputedDOMStyle::GetBoxAlign(nsIDOMCSSValue
** aValue
)
2329 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2330 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2332 const nsAFlatCString
& boxAlignIdent
=
2333 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxAlign
,
2334 nsCSSProps::kBoxAlignKTable
);
2335 val
->SetIdent(boxAlignIdent
);
2337 return CallQueryInterface(val
, aValue
);
2341 nsComputedDOMStyle::GetBoxDirection(nsIDOMCSSValue
** aValue
)
2343 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2344 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2346 const nsAFlatCString
& boxDirectionIdent
=
2347 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxDirection
,
2348 nsCSSProps::kBoxDirectionKTable
);
2349 val
->SetIdent(boxDirectionIdent
);
2351 return CallQueryInterface(val
, aValue
);
2355 nsComputedDOMStyle::GetBoxFlex(nsIDOMCSSValue
** aValue
)
2357 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2358 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2360 val
->SetNumber(GetStyleXUL()->mBoxFlex
);
2362 return CallQueryInterface(val
, aValue
);
2366 nsComputedDOMStyle::GetBoxOrdinalGroup(nsIDOMCSSValue
** aValue
)
2368 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2369 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2371 val
->SetNumber(GetStyleXUL()->mBoxOrdinal
);
2373 return CallQueryInterface(val
, aValue
);
2377 nsComputedDOMStyle::GetBoxOrient(nsIDOMCSSValue
** aValue
)
2379 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2380 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2382 const nsAFlatCString
& boxOrientIdent
=
2383 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxOrient
,
2384 nsCSSProps::kBoxOrientKTable
);
2385 val
->SetIdent(boxOrientIdent
);
2387 return CallQueryInterface(val
, aValue
);
2391 nsComputedDOMStyle::GetBoxPack(nsIDOMCSSValue
** aValue
)
2393 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2394 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2396 const nsAFlatCString
& boxPackIdent
=
2397 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxPack
,
2398 nsCSSProps::kBoxPackKTable
);
2399 val
->SetIdent(boxPackIdent
);
2401 return CallQueryInterface(val
, aValue
);
2405 nsComputedDOMStyle::GetBoxSizing(nsIDOMCSSValue
** aValue
)
2407 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2408 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2410 const nsAFlatCString
& boxSizingIdent
=
2411 nsCSSProps::ValueToKeyword(GetStylePosition()->mBoxSizing
,
2412 nsCSSProps::kBoxSizingKTable
);
2413 val
->SetIdent(boxSizingIdent
);
2415 return CallQueryInterface(val
, aValue
);
2419 nsComputedDOMStyle::GetBorderImage(nsIDOMCSSValue
** aValue
)
2421 const nsStyleBorder
* border
= GetStyleBorder();
2424 if (!border
->GetBorderImage()) {
2425 nsROCSSPrimitiveValue
*valNone
= GetROCSSPrimitiveValue();
2426 NS_ENSURE_TRUE(valNone
, NS_ERROR_OUT_OF_MEMORY
);
2427 valNone
->SetIdent(nsGkAtoms::none
);
2428 return CallQueryInterface(valNone
, aValue
);
2431 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
2432 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
2435 nsROCSSPrimitiveValue
*valURI
= GetROCSSPrimitiveValue();
2436 if (!valURI
|| !valueList
->AppendCSSValue(valURI
)) {
2439 return NS_ERROR_OUT_OF_MEMORY
;
2441 nsCOMPtr
<nsIURI
> uri
;
2442 border
->GetBorderImage()->GetURI(getter_AddRefs(uri
));
2443 valURI
->SetURI(uri
);
2445 // four split numbers
2446 NS_FOR_CSS_SIDES(side
) {
2447 nsROCSSPrimitiveValue
*valSplit
= GetROCSSPrimitiveValue();
2448 if (!valSplit
|| !valueList
->AppendCSSValue(valSplit
)) {
2451 return NS_ERROR_OUT_OF_MEMORY
;
2453 SetValueToCoord(valSplit
, border
->mBorderImageSplit
.Get(side
), nsnull
,
2457 // copy of border-width
2458 if (border
->mHaveBorderImageWidth
) {
2459 nsROCSSPrimitiveValue
*slash
= GetROCSSPrimitiveValue();
2460 if (!slash
|| !valueList
->AppendCSSValue(slash
)) {
2463 return NS_ERROR_OUT_OF_MEMORY
;
2465 slash
->SetString(NS_LITERAL_STRING("/"));
2466 NS_FOR_CSS_SIDES(side
) {
2467 nsROCSSPrimitiveValue
*borderWidth
= GetROCSSPrimitiveValue();
2468 if (!borderWidth
|| !valueList
->AppendCSSValue(borderWidth
)) {
2471 return NS_ERROR_OUT_OF_MEMORY
;
2473 nscoord width
= GetStyleBorder()->mBorderImageWidth
.side(side
);
2474 borderWidth
->SetAppUnits(width
);
2479 nsROCSSPrimitiveValue
*keyword
= GetROCSSPrimitiveValue();
2480 if (!keyword
|| !valueList
->AppendCSSValue(keyword
)) {
2483 return NS_ERROR_OUT_OF_MEMORY
;
2485 const nsAFlatCString
& borderImageIdent
=
2486 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageHFill
,
2487 nsCSSProps::kBorderImageKTable
);
2488 keyword
->SetIdent(borderImageIdent
);
2491 nsROCSSPrimitiveValue
*keyword2
= GetROCSSPrimitiveValue();
2492 if (!keyword2
|| !valueList
->AppendCSSValue(keyword2
)) {
2495 return NS_ERROR_OUT_OF_MEMORY
;
2497 const nsAFlatCString
& borderImageIdent2
=
2498 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageVFill
,
2499 nsCSSProps::kBorderImageKTable
);
2500 keyword2
->SetIdent(borderImageIdent2
);
2502 return CallQueryInterface(valueList
, aValue
);
2506 nsComputedDOMStyle::GetFloatEdge(nsIDOMCSSValue
** aValue
)
2508 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2509 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2511 const nsAFlatCString
& floatEdgeIdent
=
2512 nsCSSProps::ValueToKeyword(GetStyleBorder()->mFloatEdge
,
2513 nsCSSProps::kFloatEdgeKTable
);
2514 val
->SetIdent(floatEdgeIdent
);
2516 return CallQueryInterface(val
, aValue
);
2520 nsComputedDOMStyle::GetForceBrokenImageIcon(nsIDOMCSSValue
** aValue
)
2522 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2523 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2525 val
->SetNumber(GetStyleUIReset()->mForceBrokenImageIcon
);
2527 return CallQueryInterface(val
, aValue
);
2531 nsComputedDOMStyle::GetIMEMode(nsIDOMCSSValue
** aValue
)
2533 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2534 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2536 const nsStyleUIReset
*uiData
= GetStyleUIReset();
2538 nsCSSKeyword keyword
;
2539 if (uiData
->mIMEMode
== NS_STYLE_IME_MODE_AUTO
) {
2540 keyword
= eCSSKeyword_auto
;
2541 } else if (uiData
->mIMEMode
== NS_STYLE_IME_MODE_NORMAL
) {
2542 keyword
= eCSSKeyword_normal
;
2544 keyword
= nsCSSProps::ValueToKeywordEnum(uiData
->mIMEMode
,
2545 nsCSSProps::kIMEModeKTable
);
2547 val
->SetIdent(nsCSSKeywords::GetStringValue(keyword
));
2549 return CallQueryInterface(val
, aValue
);
2553 nsComputedDOMStyle::GetUserFocus(nsIDOMCSSValue
** aValue
)
2555 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2556 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2558 const nsStyleUserInterface
*uiData
= GetStyleUserInterface();
2560 if (uiData
->mUserFocus
!= NS_STYLE_USER_FOCUS_NONE
) {
2561 if (uiData
->mUserFocus
== NS_STYLE_USER_FOCUS_NORMAL
) {
2562 const nsAFlatCString
& userFocusIdent
=
2563 nsCSSKeywords::GetStringValue(eCSSKeyword_normal
);
2564 val
->SetIdent(userFocusIdent
);
2566 const nsAFlatCString
& userFocusIdent
=
2567 nsCSSProps::ValueToKeyword(uiData
->mUserFocus
,
2568 nsCSSProps::kUserFocusKTable
);
2569 val
->SetIdent(userFocusIdent
);
2572 const nsAFlatCString
& userFocusIdent
=
2573 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2574 val
->SetIdent(userFocusIdent
);
2577 return CallQueryInterface(val
, aValue
);
2581 nsComputedDOMStyle::GetUserInput(nsIDOMCSSValue
** aValue
)
2583 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2584 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2586 const nsStyleUserInterface
*uiData
= GetStyleUserInterface();
2588 if (uiData
->mUserInput
!= NS_STYLE_USER_INPUT_AUTO
) {
2589 if (uiData
->mUserInput
== NS_STYLE_USER_INPUT_NONE
) {
2590 const nsAFlatCString
& userInputIdent
=
2591 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2592 val
->SetIdent(userInputIdent
);
2594 const nsAFlatCString
& userInputIdent
=
2595 nsCSSProps::ValueToKeyword(uiData
->mUserInput
,
2596 nsCSSProps::kUserInputKTable
);
2597 val
->SetIdent(userInputIdent
);
2600 const nsAFlatCString
& userInputIdent
=
2601 nsCSSKeywords::GetStringValue(eCSSKeyword_auto
);
2602 val
->SetIdent(userInputIdent
);
2605 return CallQueryInterface(val
, aValue
);
2609 nsComputedDOMStyle::GetUserModify(nsIDOMCSSValue
** aValue
)
2611 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2612 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2614 const nsAFlatCString
& userModifyIdent
=
2615 nsCSSProps::ValueToKeyword(GetStyleUserInterface()->mUserModify
,
2616 nsCSSProps::kUserModifyKTable
);
2617 val
->SetIdent(userModifyIdent
);
2619 return CallQueryInterface(val
, aValue
);
2623 nsComputedDOMStyle::GetUserSelect(nsIDOMCSSValue
** aValue
)
2625 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2626 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2628 const nsStyleUIReset
*uiData
= GetStyleUIReset();
2630 if (uiData
->mUserSelect
!= NS_STYLE_USER_SELECT_AUTO
) {
2631 if (uiData
->mUserSelect
== NS_STYLE_USER_SELECT_NONE
) {
2632 const nsAFlatCString
& userSelectIdent
=
2633 nsCSSKeywords::GetStringValue(eCSSKeyword_none
);
2634 val
->SetIdent(userSelectIdent
);
2636 const nsAFlatCString
& userSelectIdent
=
2637 nsCSSProps::ValueToKeyword(uiData
->mUserSelect
,
2638 nsCSSProps::kUserSelectKTable
);
2639 val
->SetIdent(userSelectIdent
);
2642 const nsAFlatCString
& userSelectIdent
=
2643 nsCSSKeywords::GetStringValue(eCSSKeyword_auto
);
2644 val
->SetIdent(userSelectIdent
);
2647 return CallQueryInterface(val
, aValue
);
2651 nsComputedDOMStyle::GetDisplay(nsIDOMCSSValue
** aValue
)
2653 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2654 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2656 const nsStyleDisplay
*displayData
= GetStyleDisplay();
2658 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_NONE
) {
2659 val
->SetIdent(nsGkAtoms::none
);
2661 const nsAFlatCString
& display
=
2662 nsCSSProps::ValueToKeyword(displayData
->mDisplay
,
2663 nsCSSProps::kDisplayKTable
);
2664 val
->SetIdent(display
);
2667 return CallQueryInterface(val
, aValue
);
2671 nsComputedDOMStyle::GetPosition(nsIDOMCSSValue
** aValue
)
2673 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2674 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2676 const nsAFlatCString
& position
=
2677 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mPosition
,
2678 nsCSSProps::kPositionKTable
);
2679 val
->SetIdent(position
);
2681 return CallQueryInterface(val
, aValue
);
2685 nsComputedDOMStyle::GetClip(nsIDOMCSSValue
** aValue
)
2687 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2688 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2690 const nsStyleDisplay
* display
= GetStyleDisplay();
2692 nsresult rv
= NS_OK
;
2693 nsROCSSPrimitiveValue
*topVal
= nsnull
;
2694 nsROCSSPrimitiveValue
*rightVal
= nsnull
;
2695 nsROCSSPrimitiveValue
*bottomVal
= nsnull
;
2696 nsROCSSPrimitiveValue
*leftVal
= nsnull
;
2697 if (display
->mClipFlags
== NS_STYLE_CLIP_AUTO
||
2698 display
->mClipFlags
== (NS_STYLE_CLIP_TOP_AUTO
|
2699 NS_STYLE_CLIP_RIGHT_AUTO
|
2700 NS_STYLE_CLIP_BOTTOM_AUTO
|
2701 NS_STYLE_CLIP_LEFT_AUTO
)) {
2702 val
->SetIdent(nsGkAtoms::_auto
);
2704 // create the cssvalues for the sides, stick them in the rect object
2705 topVal
= GetROCSSPrimitiveValue();
2706 rightVal
= GetROCSSPrimitiveValue();
2707 bottomVal
= GetROCSSPrimitiveValue();
2708 leftVal
= GetROCSSPrimitiveValue();
2709 if (topVal
&& rightVal
&& bottomVal
&& leftVal
) {
2710 nsDOMCSSRect
* domRect
= new nsDOMCSSRect(topVal
, rightVal
,
2711 bottomVal
, leftVal
);
2713 if (display
->mClipFlags
& NS_STYLE_CLIP_TOP_AUTO
) {
2714 topVal
->SetIdent(nsGkAtoms::_auto
);
2716 topVal
->SetAppUnits(display
->mClip
.y
);
2719 if (display
->mClipFlags
& NS_STYLE_CLIP_RIGHT_AUTO
) {
2720 rightVal
->SetIdent(nsGkAtoms::_auto
);
2722 rightVal
->SetAppUnits(display
->mClip
.width
+ display
->mClip
.x
);
2725 if (display
->mClipFlags
& NS_STYLE_CLIP_BOTTOM_AUTO
) {
2726 bottomVal
->SetIdent(nsGkAtoms::_auto
);
2728 bottomVal
->SetAppUnits(display
->mClip
.height
+ display
->mClip
.y
);
2731 if (display
->mClipFlags
& NS_STYLE_CLIP_LEFT_AUTO
) {
2732 leftVal
->SetIdent(nsGkAtoms::_auto
);
2734 leftVal
->SetAppUnits(display
->mClip
.x
);
2737 val
->SetRect(domRect
);
2739 rv
= NS_ERROR_OUT_OF_MEMORY
;
2742 rv
= NS_ERROR_OUT_OF_MEMORY
;
2746 if (NS_FAILED(rv
)) {
2756 return CallQueryInterface(val
, aValue
);
2760 nsComputedDOMStyle::GetOverflow(nsIDOMCSSValue
** aValue
)
2762 const nsStyleDisplay
* display
= GetStyleDisplay();
2764 if (display
->mOverflowX
!= display
->mOverflowY
) {
2765 // No value to return. We can't express this combination of
2766 // values as a shorthand.
2771 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2772 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2774 if (display
->mOverflowX
!= NS_STYLE_OVERFLOW_AUTO
) {
2775 const nsAFlatCString
& overflow
=
2776 nsCSSProps::ValueToKeyword(display
->mOverflowX
,
2777 nsCSSProps::kOverflowKTable
);
2778 val
->SetIdent(overflow
);
2780 val
->SetIdent(nsGkAtoms::_auto
);
2783 return CallQueryInterface(val
, aValue
);
2787 nsComputedDOMStyle::GetOverflowX(nsIDOMCSSValue
** aValue
)
2789 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2790 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2792 const nsStyleDisplay
* display
= GetStyleDisplay();
2794 if (display
->mOverflowX
!= NS_STYLE_OVERFLOW_AUTO
) {
2795 const nsAFlatCString
& overflow
=
2796 nsCSSProps::ValueToKeyword(display
->mOverflowX
,
2797 nsCSSProps::kOverflowSubKTable
);
2798 val
->SetIdent(overflow
);
2800 val
->SetIdent(nsGkAtoms::_auto
);
2803 return CallQueryInterface(val
, aValue
);
2807 nsComputedDOMStyle::GetOverflowY(nsIDOMCSSValue
** aValue
)
2809 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
2810 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2812 const nsStyleDisplay
* display
= GetStyleDisplay();
2814 if (display
->mOverflowY
!= NS_STYLE_OVERFLOW_AUTO
) {
2815 const nsAFlatCString
& overflow
=
2816 nsCSSProps::ValueToKeyword(display
->mOverflowY
,
2817 nsCSSProps::kOverflowSubKTable
);
2818 val
->SetIdent(overflow
);
2820 val
->SetIdent(nsGkAtoms::_auto
);
2823 return CallQueryInterface(val
, aValue
);
2827 nsComputedDOMStyle::GetPageBreakAfter(nsIDOMCSSValue
** aValue
)
2829 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2830 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2832 const nsStyleDisplay
*display
= GetStyleDisplay();
2834 if (display
->mBreakAfter
) {
2835 val
->SetIdent(nsGkAtoms::always
);
2837 val
->SetIdent(nsGkAtoms::_auto
);
2840 return CallQueryInterface(val
, aValue
);
2844 nsComputedDOMStyle::GetPageBreakBefore(nsIDOMCSSValue
** aValue
)
2846 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2847 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2849 const nsStyleDisplay
*display
= GetStyleDisplay();
2851 if (display
->mBreakBefore
) {
2852 val
->SetIdent(nsGkAtoms::always
);
2854 val
->SetIdent(nsGkAtoms::_auto
);
2857 return CallQueryInterface(val
, aValue
);
2861 nsComputedDOMStyle::GetHeight(nsIDOMCSSValue
** aValue
)
2863 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2864 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2866 PRBool calcHeight
= PR_FALSE
;
2869 calcHeight
= PR_TRUE
;
2871 const nsStyleDisplay
* displayData
= GetStyleDisplay();
2872 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_INLINE
&&
2873 !(mInnerFrame
->IsFrameOfType(nsIFrame::eReplaced
))) {
2874 calcHeight
= PR_FALSE
;
2879 FlushPendingReflows();
2881 val
->SetAppUnits(mInnerFrame
->GetContentRect().height
);
2883 const nsStylePosition
*positionData
= GetStylePosition();
2886 StyleCoordToNSCoord(positionData
->mMinHeight
,
2887 &nsComputedDOMStyle::GetCBContentHeight
, 0);
2890 StyleCoordToNSCoord(positionData
->mMaxHeight
,
2891 &nsComputedDOMStyle::GetCBContentHeight
,
2894 SetValueToCoord(val
, positionData
->mHeight
, nsnull
, nsnull
,
2895 minHeight
, maxHeight
);
2898 return CallQueryInterface(val
, aValue
);
2902 nsComputedDOMStyle::GetWidth(nsIDOMCSSValue
** aValue
)
2904 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2905 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2907 PRBool calcWidth
= PR_FALSE
;
2910 calcWidth
= PR_TRUE
;
2912 const nsStyleDisplay
*displayData
= GetStyleDisplay();
2913 if (displayData
->mDisplay
== NS_STYLE_DISPLAY_INLINE
&&
2914 !(mInnerFrame
->IsFrameOfType(nsIFrame::eReplaced
))) {
2915 calcWidth
= PR_FALSE
;
2920 FlushPendingReflows();
2922 val
->SetAppUnits(mInnerFrame
->GetContentRect().width
);
2924 const nsStylePosition
*positionData
= GetStylePosition();
2927 StyleCoordToNSCoord(positionData
->mMinWidth
,
2928 &nsComputedDOMStyle::GetCBContentWidth
, 0);
2931 StyleCoordToNSCoord(positionData
->mMaxWidth
,
2932 &nsComputedDOMStyle::GetCBContentWidth
,
2935 SetValueToCoord(val
, positionData
->mWidth
, nsnull
,
2936 nsCSSProps::kWidthKTable
, minWidth
, maxWidth
);
2939 return CallQueryInterface(val
, aValue
);
2943 nsComputedDOMStyle::GetMaxHeight(nsIDOMCSSValue
** aValue
)
2945 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2946 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2948 SetValueToCoord(val
, GetStylePosition()->mMaxHeight
,
2949 &nsComputedDOMStyle::GetCBContentHeight
);
2951 return CallQueryInterface(val
, aValue
);
2955 nsComputedDOMStyle::GetMaxWidth(nsIDOMCSSValue
** aValue
)
2957 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2958 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2960 SetValueToCoord(val
, GetStylePosition()->mMaxWidth
,
2961 &nsComputedDOMStyle::GetCBContentWidth
,
2962 nsCSSProps::kWidthKTable
);
2964 return CallQueryInterface(val
, aValue
);
2968 nsComputedDOMStyle::GetMinHeight(nsIDOMCSSValue
** aValue
)
2970 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2971 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2973 SetValueToCoord(val
, GetStylePosition()->mMinHeight
,
2974 &nsComputedDOMStyle::GetCBContentHeight
);
2976 return CallQueryInterface(val
, aValue
);
2980 nsComputedDOMStyle::GetMinWidth(nsIDOMCSSValue
** aValue
)
2982 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
2983 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
2985 SetValueToCoord(val
, GetStylePosition()->mMinWidth
,
2986 &nsComputedDOMStyle::GetCBContentWidth
,
2987 nsCSSProps::kWidthKTable
);
2989 return CallQueryInterface(val
, aValue
);
2993 nsComputedDOMStyle::GetLeft(nsIDOMCSSValue
** aValue
)
2995 return GetOffsetWidthFor(NS_SIDE_LEFT
, aValue
);
2999 nsComputedDOMStyle::GetRight(nsIDOMCSSValue
** aValue
)
3001 return GetOffsetWidthFor(NS_SIDE_RIGHT
, aValue
);
3005 nsComputedDOMStyle::GetTop(nsIDOMCSSValue
** aValue
)
3007 return GetOffsetWidthFor(NS_SIDE_TOP
, aValue
);
3010 nsROCSSPrimitiveValue
*
3011 nsComputedDOMStyle::GetROCSSPrimitiveValue()
3013 nsROCSSPrimitiveValue
*primitiveValue
= new nsROCSSPrimitiveValue(mAppUnitsPerInch
);
3015 NS_ASSERTION(primitiveValue
!= 0, "ran out of memory");
3017 return primitiveValue
;
3021 nsComputedDOMStyle::GetROCSSValueList(PRBool aCommaDelimited
)
3023 nsDOMCSSValueList
*valueList
= new nsDOMCSSValueList(aCommaDelimited
,
3025 NS_ASSERTION(valueList
!= 0, "ran out of memory");
3031 nsComputedDOMStyle::GetOffsetWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3033 const nsStyleDisplay
* display
= GetStyleDisplay();
3035 FlushPendingReflows();
3037 nsresult rv
= NS_OK
;
3038 switch (display
->mPosition
) {
3039 case NS_STYLE_POSITION_STATIC
:
3040 rv
= GetStaticOffset(aSide
, aValue
);
3042 case NS_STYLE_POSITION_RELATIVE
:
3043 rv
= GetRelativeOffset(aSide
, aValue
);
3045 case NS_STYLE_POSITION_ABSOLUTE
:
3046 case NS_STYLE_POSITION_FIXED
:
3047 rv
= GetAbsoluteOffset(aSide
, aValue
);
3050 NS_ERROR("Invalid position");
3058 nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3060 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3061 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3063 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3065 nsMargin margin
= mOuterFrame
->GetUsedMargin();
3066 nsMargin border
= container
->GetUsedBorder();
3067 nsMargin
scrollbarSizes(0, 0, 0, 0);
3068 nsRect rect
= mOuterFrame
->GetRect();
3069 nsRect containerRect
= container
->GetRect();
3071 if (container
->GetType() == nsGkAtoms::viewportFrame
) {
3072 // For absolutely positioned frames scrollbars are taken into
3073 // account by virtue of getting a containing block that does
3074 // _not_ include the scrollbars. For fixed positioned frames,
3075 // the containing block is the viewport, which _does_ include
3076 // scrollbars. We have to do some extra work.
3077 // the first child in the default frame list is what we want
3078 nsIFrame
* scrollingChild
= container
->GetFirstChild(nsnull
);
3079 nsCOMPtr
<nsIScrollableFrame
> scrollFrame
=
3080 do_QueryInterface(scrollingChild
);
3082 scrollbarSizes
= scrollFrame
->GetActualScrollbarSizes();
3089 offset
= rect
.y
- margin
.top
- border
.top
- scrollbarSizes
.top
;
3093 offset
= containerRect
.width
- rect
.width
-
3094 rect
.x
- margin
.right
- border
.right
- scrollbarSizes
.right
;
3097 case NS_SIDE_BOTTOM
:
3098 offset
= containerRect
.height
- rect
.height
-
3099 rect
.y
- margin
.bottom
- border
.bottom
- scrollbarSizes
.bottom
;
3103 offset
= rect
.x
- margin
.left
- border
.left
- scrollbarSizes
.left
;
3107 NS_ERROR("Invalid side");
3110 val
->SetAppUnits(offset
);
3112 // XXX no frame. This property makes no sense
3113 val
->SetAppUnits(0);
3116 return CallQueryInterface(val
, aValue
);
3120 #if (NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3)
3121 #define NS_OPPOSITE_SIDE(s_) (((s_) + 2) & 3)
3123 #error "Somebody changed the side constants."
3127 nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3129 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3130 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3132 const nsStylePosition
* positionData
= GetStylePosition();
3134 nsStyleCoord coord
= positionData
->mOffset
.Get(aSide
);
3136 NS_ASSERTION(coord
.GetUnit() == eStyleUnit_Coord
||
3137 coord
.GetUnit() == eStyleUnit_Percent
||
3138 coord
.GetUnit() == eStyleUnit_Auto
,
3141 if (coord
.GetUnit() == eStyleUnit_Auto
) {
3142 coord
= positionData
->mOffset
.Get(NS_OPPOSITE_SIDE(aSide
));
3145 PercentageBaseGetter baseGetter
;
3146 if (aSide
== NS_SIDE_LEFT
|| aSide
== NS_SIDE_RIGHT
) {
3147 baseGetter
= &nsComputedDOMStyle::GetCBContentWidth
;
3149 baseGetter
= &nsComputedDOMStyle::GetCBContentHeight
;
3152 val
->SetAppUnits(sign
* StyleCoordToNSCoord(coord
, baseGetter
, 0));
3154 return CallQueryInterface(val
, aValue
);
3158 nsComputedDOMStyle::GetStaticOffset(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3161 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3162 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3164 SetValueToCoord(val
, GetStylePosition()->mOffset
.Get(aSide
));
3166 return CallQueryInterface(val
, aValue
);
3170 nsComputedDOMStyle::FlushPendingReflows()
3172 // Flush all pending notifications so that our frames are up to date
3173 nsCOMPtr
<nsIDocument
> document
= mContent
->GetDocument();
3175 document
->FlushPendingNotifications(Flush_Layout
);
3180 nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3182 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3183 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3186 SetValueToCoord(val
, GetStylePadding()->mPadding
.Get(aSide
));
3188 FlushPendingReflows();
3190 val
->SetAppUnits(mInnerFrame
->GetUsedPadding().side(aSide
));
3193 return CallQueryInterface(val
, aValue
);
3197 nsComputedDOMStyle::GetLineHeightCoord(nscoord
& aCoord
)
3199 aCoord
= nsHTMLReflowState::CalcLineHeight(mStyleContextHolder
);
3201 // CalcLineHeight uses font->mFont.size, but we want to use
3202 // font->mSize as the font size. Adjust for that. Also adjust for
3203 // the text zoom, if any.
3204 const nsStyleFont
* font
= GetStyleFont();
3205 aCoord
= NSToCoordRound((float(aCoord
) *
3206 (float(font
->mSize
) / float(font
->mFont
.size
))) /
3207 mPresShell
->GetPresContext()->TextZoom());
3213 nsComputedDOMStyle::GetBorderColorsFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3215 const nsStyleBorder
*border
= GetStyleBorder();
3217 if (border
->mBorderColors
) {
3218 nsBorderColors
* borderColors
= border
->mBorderColors
[aSide
];
3220 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
3221 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3224 nsROCSSPrimitiveValue
*primitive
= GetROCSSPrimitiveValue();
3228 return NS_ERROR_OUT_OF_MEMORY
;
3230 nsresult rv
= SetToRGBAColor(primitive
, borderColors
->mColor
);
3231 if (NS_FAILED(rv
)) {
3237 PRBool success
= valueList
->AppendCSSValue(primitive
);
3242 return NS_ERROR_OUT_OF_MEMORY
;
3244 borderColors
= borderColors
->mNext
;
3245 } while (borderColors
);
3247 return CallQueryInterface(valueList
, aValue
);
3251 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3252 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3254 val
->SetIdent(nsGkAtoms::none
);
3256 return CallQueryInterface(val
, aValue
);
3260 nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3262 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3263 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3267 FlushPendingReflows();
3268 width
= mInnerFrame
->GetUsedBorder().side(aSide
);
3270 width
= GetStyleBorder()->GetActualBorderWidth(aSide
);
3272 val
->SetAppUnits(width
);
3274 return CallQueryInterface(val
, aValue
);
3278 nsComputedDOMStyle::GetBorderColorFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3280 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3281 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3285 GetStyleBorder()->GetBorderColor(aSide
, color
, foreground
);
3287 color
= GetStyleColor()->mColor
;
3290 nsresult rv
= SetToRGBAColor(val
, color
);
3291 if (NS_FAILED(rv
)) {
3296 return CallQueryInterface(val
, aValue
);
3300 nsComputedDOMStyle::GetMarginWidthFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3302 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3303 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3306 SetValueToCoord(val
, GetStyleMargin()->mMargin
.Get(aSide
));
3308 FlushPendingReflows();
3310 val
->SetAppUnits(mInnerFrame
->GetUsedMargin().side(aSide
));
3313 return CallQueryInterface(val
, aValue
);
3317 nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide
, nsIDOMCSSValue
** aValue
)
3319 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3320 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3322 PRUint8 borderStyle
= GetStyleBorder()->GetBorderStyle(aSide
);
3324 if (borderStyle
!= NS_STYLE_BORDER_STYLE_NONE
) {
3325 const nsAFlatCString
& style
=
3326 nsCSSProps::ValueToKeyword(borderStyle
,
3327 nsCSSProps::kBorderStyleKTable
);
3328 val
->SetIdent(style
);
3330 val
->SetIdent(nsGkAtoms::none
);
3333 return CallQueryInterface(val
, aValue
);
3337 nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue
* aValue
,
3338 const nsStyleCoord
& aCoord
,
3339 PercentageBaseGetter aPercentageBaseGetter
,
3340 const PRInt32 aTable
[],
3341 nscoord aMinAppUnits
,
3342 nscoord aMaxAppUnits
)
3344 NS_PRECONDITION(aValue
, "Must have a value to work with");
3346 switch (aCoord
.GetUnit()) {
3347 case eStyleUnit_Normal
:
3348 aValue
->SetIdent(nsGkAtoms::normal
);
3351 case eStyleUnit_Auto
:
3352 aValue
->SetIdent(nsGkAtoms::_auto
);
3355 case eStyleUnit_Percent
:
3357 nscoord percentageBase
;
3358 if (aPercentageBaseGetter
&&
3359 (this->*aPercentageBaseGetter
)(percentageBase
)) {
3360 nscoord val
= nscoord(aCoord
.GetPercentValue() * percentageBase
);
3361 aValue
->SetAppUnits(PR_MAX(aMinAppUnits
, PR_MIN(val
, aMaxAppUnits
)));
3363 aValue
->SetPercent(aCoord
.GetPercentValue());
3368 case eStyleUnit_Factor
:
3369 aValue
->SetNumber(aCoord
.GetFactorValue());
3372 case eStyleUnit_Coord
:
3374 nscoord val
= aCoord
.GetCoordValue();
3375 aValue
->SetAppUnits(PR_MAX(aMinAppUnits
, PR_MIN(val
, aMaxAppUnits
)));
3379 case eStyleUnit_Integer
:
3380 aValue
->SetNumber(aCoord
.GetIntValue());
3383 case eStyleUnit_Enumerated
:
3384 NS_ASSERTION(aTable
, "Must have table to handle this case");
3385 aValue
->SetIdent(nsCSSProps::ValueToKeyword(aCoord
.GetIntValue(),
3389 case eStyleUnit_None
:
3390 aValue
->SetIdent(nsGkAtoms::none
);
3394 NS_ERROR("Can't handle this unit");
3400 nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord
& aCoord
,
3401 PercentageBaseGetter aPercentageBaseGetter
,
3402 nscoord aDefaultValue
)
3404 NS_PRECONDITION(aPercentageBaseGetter
, "Must have a percentage base getter");
3405 switch (aCoord
.GetUnit()) {
3406 case eStyleUnit_Coord
:
3407 return aCoord
.GetCoordValue();
3408 case eStyleUnit_Percent
:
3410 nscoord percentageBase
;
3411 if ((this->*aPercentageBaseGetter
)(percentageBase
)) {
3412 return nscoord(aCoord
.GetPercentValue() * percentageBase
);
3415 // Fall through to returning aDefaultValue if we have no percentage base.
3420 return aDefaultValue
;
3424 nsComputedDOMStyle::GetCBContentWidth(nscoord
& aWidth
)
3430 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3435 FlushPendingReflows();
3437 aWidth
= container
->GetContentRect().width
;
3442 nsComputedDOMStyle::GetCBContentHeight(nscoord
& aHeight
)
3448 nsIFrame
* container
= GetContainingBlockFor(mOuterFrame
);
3453 FlushPendingReflows();
3455 aHeight
= container
->GetContentRect().height
;
3460 nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord
& aWidth
)
3466 FlushPendingReflows();
3468 aWidth
= mInnerFrame
->GetSize().width
;
3473 nsComputedDOMStyle::GetFrameBoundsWidthForTransform(nscoord
& aWidth
)
3475 // We need a frame to work with.
3480 FlushPendingReflows();
3482 // Check to see that we're transformed.
3483 if (!mInnerFrame
->GetStyleDisplay()->HasTransform())
3486 aWidth
= nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame
).width
;
3491 nsComputedDOMStyle::GetFrameBoundsHeightForTransform(nscoord
& aHeight
)
3493 // We need a frame to work with.
3498 FlushPendingReflows();
3500 // Check to see that we're transformed.
3501 if (!mInnerFrame
->GetStyleDisplay()->HasTransform())
3504 aHeight
= nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame
).height
;
3511 nsComputedDOMStyle::GetSVGPaintFor(PRBool aFill
,
3512 nsIDOMCSSValue
** aValue
)
3514 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3515 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3517 const nsStyleSVG
* svg
= GetStyleSVG();
3518 const nsStyleSVGPaint
* paint
= nsnull
;
3521 paint
= &svg
->mFill
;
3523 paint
= &svg
->mStroke
;
3525 nsAutoString paintString
;
3527 switch (paint
->mType
) {
3528 case eStyleSVGPaintType_None
:
3530 val
->SetIdent(nsGkAtoms::none
);
3533 case eStyleSVGPaintType_Color
:
3535 nsresult rv
= SetToRGBAColor(val
, paint
->mPaint
.mColor
);
3536 if (NS_FAILED(rv
)) {
3542 case eStyleSVGPaintType_Server
:
3544 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_FALSE
);
3545 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3547 if (!valueList
->AppendCSSValue(val
)) {
3550 return NS_ERROR_OUT_OF_MEMORY
;
3553 nsROCSSPrimitiveValue
* fallback
= GetROCSSPrimitiveValue();
3554 if (!fallback
|| !valueList
->AppendCSSValue(fallback
)) {
3557 return NS_ERROR_OUT_OF_MEMORY
;
3560 val
->SetURI(paint
->mPaint
.mPaintServer
);
3561 nsresult rv
= SetToRGBAColor(fallback
, paint
->mFallbackColor
);
3562 if (NS_FAILED(rv
)) {
3567 return CallQueryInterface(valueList
, aValue
);
3571 return CallQueryInterface(val
, aValue
);
3575 nsComputedDOMStyle::GetFill(nsIDOMCSSValue
** aValue
)
3577 return GetSVGPaintFor(PR_TRUE
, aValue
);
3581 nsComputedDOMStyle::GetStroke(nsIDOMCSSValue
** aValue
)
3583 return GetSVGPaintFor(PR_FALSE
, aValue
);
3587 nsComputedDOMStyle::GetMarkerEnd(nsIDOMCSSValue
** aValue
)
3589 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3590 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3592 const nsStyleSVG
* svg
= GetStyleSVG();
3594 if (svg
->mMarkerEnd
)
3595 val
->SetURI(svg
->mMarkerEnd
);
3597 val
->SetIdent(nsGkAtoms::none
);
3599 return CallQueryInterface(val
, aValue
);
3603 nsComputedDOMStyle::GetMarkerMid(nsIDOMCSSValue
** aValue
)
3605 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3606 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3608 const nsStyleSVG
* svg
= GetStyleSVG();
3610 if (svg
->mMarkerMid
)
3611 val
->SetURI(svg
->mMarkerMid
);
3613 val
->SetIdent(nsGkAtoms::none
);
3615 return CallQueryInterface(val
, aValue
);
3619 nsComputedDOMStyle::GetMarkerStart(nsIDOMCSSValue
** aValue
)
3621 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3622 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3624 const nsStyleSVG
* svg
= GetStyleSVG();
3626 if (svg
->mMarkerStart
)
3627 val
->SetURI(svg
->mMarkerStart
);
3629 val
->SetIdent(nsGkAtoms::none
);
3631 return CallQueryInterface(val
, aValue
);
3635 nsComputedDOMStyle::GetStrokeDasharray(nsIDOMCSSValue
** aValue
)
3637 const nsStyleSVG
* svg
= GetStyleSVG();
3639 if (!svg
->mStrokeDasharrayLength
|| !svg
->mStrokeDasharray
) {
3640 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3641 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3642 val
->SetIdent(nsGkAtoms::none
);
3643 return CallQueryInterface(val
, aValue
);
3646 nsDOMCSSValueList
*valueList
= GetROCSSValueList(PR_TRUE
);
3647 NS_ENSURE_TRUE(valueList
, NS_ERROR_OUT_OF_MEMORY
);
3649 for (PRUint32 i
= 0; i
< svg
->mStrokeDasharrayLength
; i
++) {
3650 nsROCSSPrimitiveValue
* dash
= GetROCSSPrimitiveValue();
3651 if (!dash
|| !valueList
->AppendCSSValue(dash
)) {
3654 return NS_ERROR_OUT_OF_MEMORY
;
3657 SetValueToCoord(dash
, svg
->mStrokeDasharray
[i
]);
3660 return CallQueryInterface(valueList
, aValue
);
3664 nsComputedDOMStyle::GetStrokeDashoffset(nsIDOMCSSValue
** aValue
)
3666 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3667 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3669 SetValueToCoord(val
, GetStyleSVG()->mStrokeDashoffset
);
3671 return CallQueryInterface(val
, aValue
);
3675 nsComputedDOMStyle::GetStrokeWidth(nsIDOMCSSValue
** aValue
)
3677 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3678 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3680 SetValueToCoord(val
, GetStyleSVG()->mStrokeWidth
);
3682 return CallQueryInterface(val
, aValue
);
3686 nsComputedDOMStyle::GetFillOpacity(nsIDOMCSSValue
** aValue
)
3688 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3689 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3691 val
->SetNumber(GetStyleSVG()->mFillOpacity
);
3693 return CallQueryInterface(val
, aValue
);
3697 nsComputedDOMStyle::GetFloodOpacity(nsIDOMCSSValue
** aValue
)
3699 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3700 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3702 val
->SetNumber(GetStyleSVGReset()->mFloodOpacity
);
3704 return CallQueryInterface(val
, aValue
);
3708 nsComputedDOMStyle::GetStopOpacity(nsIDOMCSSValue
** aValue
)
3710 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3711 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3713 val
->SetNumber(GetStyleSVGReset()->mStopOpacity
);
3715 return CallQueryInterface(val
, aValue
);
3719 nsComputedDOMStyle::GetStrokeMiterlimit(nsIDOMCSSValue
** aValue
)
3721 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3722 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3724 val
->SetNumber(GetStyleSVG()->mStrokeMiterlimit
);
3726 return CallQueryInterface(val
, aValue
);
3730 nsComputedDOMStyle::GetStrokeOpacity(nsIDOMCSSValue
** aValue
)
3732 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3733 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3735 val
->SetNumber(GetStyleSVG()->mStrokeOpacity
);
3737 return CallQueryInterface(val
, aValue
);
3741 nsComputedDOMStyle::GetClipRule(nsIDOMCSSValue
** aValue
)
3743 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3744 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3746 const nsAFlatCString
& keyword
=
3747 nsCSSProps::ValueToKeyword(GetStyleSVG()->mClipRule
,
3748 nsCSSProps::kFillRuleKTable
);
3749 val
->SetIdent(keyword
);
3751 return CallQueryInterface(val
, aValue
);
3755 nsComputedDOMStyle::GetFillRule(nsIDOMCSSValue
** aValue
)
3757 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3758 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3760 const nsAFlatCString
& keyword
=
3761 nsCSSProps::ValueToKeyword(GetStyleSVG()->mFillRule
,
3762 nsCSSProps::kFillRuleKTable
);
3763 val
->SetIdent(keyword
);
3765 return CallQueryInterface(val
, aValue
);
3769 nsComputedDOMStyle::GetStrokeLinecap(nsIDOMCSSValue
** aValue
)
3771 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3772 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3774 const nsAFlatCString
& keyword
=
3775 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinecap
,
3776 nsCSSProps::kStrokeLinecapKTable
);
3777 val
->SetIdent(keyword
);
3779 return CallQueryInterface(val
, aValue
);
3783 nsComputedDOMStyle::GetStrokeLinejoin(nsIDOMCSSValue
** aValue
)
3785 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3786 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3788 const nsAFlatCString
& keyword
=
3789 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinejoin
,
3790 nsCSSProps::kStrokeLinejoinKTable
);
3791 val
->SetIdent(keyword
);
3793 return CallQueryInterface(val
, aValue
);
3797 nsComputedDOMStyle::GetTextAnchor(nsIDOMCSSValue
** aValue
)
3799 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3800 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3802 const nsAFlatCString
& keyword
=
3803 nsCSSProps::ValueToKeyword(GetStyleSVG()->mTextAnchor
,
3804 nsCSSProps::kTextAnchorKTable
);
3805 val
->SetIdent(keyword
);
3807 return CallQueryInterface(val
, aValue
);
3811 nsComputedDOMStyle::GetColorInterpolation(nsIDOMCSSValue
** aValue
)
3813 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3814 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3816 const nsStyleSVG
* svg
= GetStyleSVG();
3818 if (svg
->mColorInterpolation
!= NS_STYLE_COLOR_INTERPOLATION_AUTO
) {
3819 const nsAFlatCString
& keyword
=
3820 nsCSSProps::ValueToKeyword(svg
->mColorInterpolation
,
3821 nsCSSProps::kColorInterpolationKTable
);
3822 val
->SetIdent(keyword
);
3824 val
->SetIdent(nsGkAtoms::_auto
);
3827 return CallQueryInterface(val
, aValue
);
3831 nsComputedDOMStyle::GetColorInterpolationFilters(nsIDOMCSSValue
** aValue
)
3833 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3834 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3836 const nsStyleSVG
* svg
= GetStyleSVG();
3838 if (svg
->mColorInterpolationFilters
!= NS_STYLE_COLOR_INTERPOLATION_AUTO
) {
3839 const nsAFlatCString
& keyword
=
3840 nsCSSProps::ValueToKeyword(svg
->mColorInterpolationFilters
,
3841 nsCSSProps::kColorInterpolationKTable
);
3842 val
->SetIdent(keyword
);
3844 val
->SetIdent(nsGkAtoms::_auto
);
3847 return CallQueryInterface(val
, aValue
);
3851 nsComputedDOMStyle::GetDominantBaseline(nsIDOMCSSValue
** aValue
)
3853 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3854 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3856 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3858 if (svg
->mDominantBaseline
!= NS_STYLE_DOMINANT_BASELINE_AUTO
) {
3859 const nsAFlatCString
& keyword
=
3860 nsCSSProps::ValueToKeyword(svg
->mDominantBaseline
,
3861 nsCSSProps::kDominantBaselineKTable
);
3862 val
->SetIdent(keyword
);
3864 val
->SetIdent(nsGkAtoms::_auto
);
3867 return CallQueryInterface(val
, aValue
);
3871 nsComputedDOMStyle::GetPointerEvents(nsIDOMCSSValue
** aValue
)
3873 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3874 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3876 const nsStyleSVG
* svg
= GetStyleSVG();
3878 if (svg
->mPointerEvents
!= NS_STYLE_POINTER_EVENTS_NONE
) {
3879 const nsAFlatCString
& keyword
=
3880 nsCSSProps::ValueToKeyword(svg
->mPointerEvents
,
3881 nsCSSProps::kPointerEventsKTable
);
3882 val
->SetIdent(keyword
);
3884 val
->SetIdent(nsGkAtoms::none
);
3887 return CallQueryInterface(val
, aValue
);
3891 nsComputedDOMStyle::GetShapeRendering(nsIDOMCSSValue
** aValue
)
3893 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3894 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3896 const nsStyleSVG
* svg
= GetStyleSVG();
3898 if (svg
->mShapeRendering
!= NS_STYLE_SHAPE_RENDERING_AUTO
) {
3899 const nsAFlatCString
& keyword
=
3900 nsCSSProps::ValueToKeyword(svg
->mShapeRendering
,
3901 nsCSSProps::kShapeRenderingKTable
);
3902 val
->SetIdent(keyword
);
3904 val
->SetIdent(nsGkAtoms::_auto
);
3907 return CallQueryInterface(val
, aValue
);
3911 nsComputedDOMStyle::GetTextRendering(nsIDOMCSSValue
** aValue
)
3913 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3914 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3916 const nsStyleSVG
* svg
= GetStyleSVG();
3918 if (svg
->mTextRendering
!= NS_STYLE_TEXT_RENDERING_AUTO
) {
3919 const nsAFlatCString
& keyword
=
3920 nsCSSProps::ValueToKeyword(svg
->mTextRendering
,
3921 nsCSSProps::kTextRenderingKTable
);
3922 val
->SetIdent(keyword
);
3924 val
->SetIdent(nsGkAtoms::_auto
);
3927 return CallQueryInterface(val
, aValue
);
3931 nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue
** aValue
)
3933 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3934 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3936 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mFloodColor
);
3937 if (NS_FAILED(rv
)) {
3942 return CallQueryInterface(val
, aValue
);
3946 nsComputedDOMStyle::GetLightingColor(nsIDOMCSSValue
** aValue
)
3948 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3949 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3951 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mLightingColor
);
3952 if (NS_FAILED(rv
)) {
3957 return CallQueryInterface(val
, aValue
);
3961 nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue
** aValue
)
3963 nsROCSSPrimitiveValue
*val
= GetROCSSPrimitiveValue();
3964 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3966 nsresult rv
= SetToRGBAColor(val
, GetStyleSVGReset()->mStopColor
);
3967 if (NS_FAILED(rv
)) {
3972 return CallQueryInterface(val
, aValue
);
3976 nsComputedDOMStyle::GetClipPath(nsIDOMCSSValue
** aValue
)
3978 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3979 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3981 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
3984 val
->SetURI(svg
->mClipPath
);
3986 val
->SetIdent(nsGkAtoms::none
);
3988 return CallQueryInterface(val
, aValue
);
3992 nsComputedDOMStyle::GetFilter(nsIDOMCSSValue
** aValue
)
3994 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
3995 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
3997 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
4000 val
->SetURI(svg
->mFilter
);
4002 val
->SetIdent(nsGkAtoms::none
);
4004 return CallQueryInterface(val
, aValue
);
4008 nsComputedDOMStyle::GetMask(nsIDOMCSSValue
** aValue
)
4010 nsROCSSPrimitiveValue
* val
= GetROCSSPrimitiveValue();
4011 NS_ENSURE_TRUE(val
, NS_ERROR_OUT_OF_MEMORY
);
4013 const nsStyleSVGReset
* svg
= GetStyleSVGReset();
4016 val
->SetURI(svg
->mMask
);
4018 val
->SetIdent(nsGkAtoms::none
);
4020 return CallQueryInterface(val
, aValue
);
4026 #define COMPUTED_STYLE_MAP_ENTRY(_prop, _method) \
4027 { eCSSProperty_##_prop, &nsComputedDOMStyle::Get##_method }
4029 const nsComputedDOMStyle::ComputedStyleMapEntry
*
4030 nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32
* aLength
)
4032 /* ******************************************************************* *\
4033 * Properties below are listed in alphabetical order. *
4034 * Please keep them that way. *
4036 * Properties commented out with // are not yet implemented *
4037 * Properties commented out with //// are shorthands and not queryable *
4038 \* ******************************************************************* */
4041 // XXX If this actually fixes the bustage, replace this with an
4045 ComputedStyleMapEntry map
[] = {
4046 /* ****************************** *\
4047 * Implementations of CSS2 styles *
4048 \* ****************************** */
4050 // COMPUTED_STYLE_MAP_ENTRY(azimuth, Azimuth),
4051 //// COMPUTED_STYLE_MAP_ENTRY(background, Background),
4052 COMPUTED_STYLE_MAP_ENTRY(background_attachment
, BackgroundAttachment
),
4053 COMPUTED_STYLE_MAP_ENTRY(background_color
, BackgroundColor
),
4054 COMPUTED_STYLE_MAP_ENTRY(background_image
, BackgroundImage
),
4055 COMPUTED_STYLE_MAP_ENTRY(background_position
, BackgroundPosition
),
4056 COMPUTED_STYLE_MAP_ENTRY(background_repeat
, BackgroundRepeat
),
4057 //// COMPUTED_STYLE_MAP_ENTRY(border, Border),
4058 //// COMPUTED_STYLE_MAP_ENTRY(border_bottom, BorderBottom),
4059 COMPUTED_STYLE_MAP_ENTRY(border_bottom_color
, BorderBottomColor
),
4060 COMPUTED_STYLE_MAP_ENTRY(border_bottom_style
, BorderBottomStyle
),
4061 COMPUTED_STYLE_MAP_ENTRY(border_bottom_width
, BorderBottomWidth
),
4062 COMPUTED_STYLE_MAP_ENTRY(border_collapse
, BorderCollapse
),
4063 //// COMPUTED_STYLE_MAP_ENTRY(border_color, BorderColor),
4064 //// COMPUTED_STYLE_MAP_ENTRY(border_left, BorderLeft),
4065 COMPUTED_STYLE_MAP_ENTRY(border_left_color
, BorderLeftColor
),
4066 COMPUTED_STYLE_MAP_ENTRY(border_left_style
, BorderLeftStyle
),
4067 COMPUTED_STYLE_MAP_ENTRY(border_left_width
, BorderLeftWidth
),
4068 //// COMPUTED_STYLE_MAP_ENTRY(border_right, BorderRight),
4069 COMPUTED_STYLE_MAP_ENTRY(border_right_color
, BorderRightColor
),
4070 COMPUTED_STYLE_MAP_ENTRY(border_right_style
, BorderRightStyle
),
4071 COMPUTED_STYLE_MAP_ENTRY(border_right_width
, BorderRightWidth
),
4072 COMPUTED_STYLE_MAP_ENTRY(border_spacing
, BorderSpacing
),
4073 //// COMPUTED_STYLE_MAP_ENTRY(border_style, BorderStyle),
4074 //// COMPUTED_STYLE_MAP_ENTRY(border_top, BorderTop),
4075 COMPUTED_STYLE_MAP_ENTRY(border_top_color
, BorderTopColor
),
4076 COMPUTED_STYLE_MAP_ENTRY(border_top_style
, BorderTopStyle
),
4077 COMPUTED_STYLE_MAP_ENTRY(border_top_width
, BorderTopWidth
),
4078 //// COMPUTED_STYLE_MAP_ENTRY(border_width, BorderWidth),
4079 COMPUTED_STYLE_MAP_ENTRY(bottom
, Bottom
),
4080 COMPUTED_STYLE_MAP_ENTRY(caption_side
, CaptionSide
),
4081 COMPUTED_STYLE_MAP_ENTRY(clear
, Clear
),
4082 COMPUTED_STYLE_MAP_ENTRY(clip
, Clip
),
4083 COMPUTED_STYLE_MAP_ENTRY(color
, Color
),
4084 COMPUTED_STYLE_MAP_ENTRY(content
, Content
),
4085 COMPUTED_STYLE_MAP_ENTRY(counter_increment
, CounterIncrement
),
4086 COMPUTED_STYLE_MAP_ENTRY(counter_reset
, CounterReset
),
4087 //// COMPUTED_STYLE_MAP_ENTRY(cue, Cue),
4088 // COMPUTED_STYLE_MAP_ENTRY(cue_after, CueAfter),
4089 // COMPUTED_STYLE_MAP_ENTRY(cue_before, CueBefore),
4090 COMPUTED_STYLE_MAP_ENTRY(cursor
, Cursor
),
4091 COMPUTED_STYLE_MAP_ENTRY(direction
, Direction
),
4092 COMPUTED_STYLE_MAP_ENTRY(display
, Display
),
4093 // COMPUTED_STYLE_MAP_ENTRY(elevation, Elevation),
4094 COMPUTED_STYLE_MAP_ENTRY(empty_cells
, EmptyCells
),
4095 COMPUTED_STYLE_MAP_ENTRY(float, CssFloat
),
4096 //// COMPUTED_STYLE_MAP_ENTRY(font, Font),
4097 COMPUTED_STYLE_MAP_ENTRY(font_family
, FontFamily
),
4098 COMPUTED_STYLE_MAP_ENTRY(font_size
, FontSize
),
4099 COMPUTED_STYLE_MAP_ENTRY(font_size_adjust
, FontSizeAdjust
),
4100 // COMPUTED_STYLE_MAP_ENTRY(font_stretch, FontStretch),
4101 COMPUTED_STYLE_MAP_ENTRY(font_style
, FontStyle
),
4102 COMPUTED_STYLE_MAP_ENTRY(font_variant
, FontVariant
),
4103 COMPUTED_STYLE_MAP_ENTRY(font_weight
, FontWeight
),
4104 COMPUTED_STYLE_MAP_ENTRY(height
, Height
),
4105 COMPUTED_STYLE_MAP_ENTRY(left
, Left
),
4106 COMPUTED_STYLE_MAP_ENTRY(letter_spacing
, LetterSpacing
),
4107 COMPUTED_STYLE_MAP_ENTRY(line_height
, LineHeight
),
4108 //// COMPUTED_STYLE_MAP_ENTRY(list_style, ListStyle),
4109 COMPUTED_STYLE_MAP_ENTRY(list_style_image
, ListStyleImage
),
4110 COMPUTED_STYLE_MAP_ENTRY(list_style_position
, ListStylePosition
),
4111 COMPUTED_STYLE_MAP_ENTRY(list_style_type
, ListStyleType
),
4112 //// COMPUTED_STYLE_MAP_ENTRY(margin, Margin),
4113 COMPUTED_STYLE_MAP_ENTRY(margin_bottom
, MarginBottomWidth
),
4114 COMPUTED_STYLE_MAP_ENTRY(margin_left
, MarginLeftWidth
),
4115 COMPUTED_STYLE_MAP_ENTRY(margin_right
, MarginRightWidth
),
4116 COMPUTED_STYLE_MAP_ENTRY(margin_top
, MarginTopWidth
),
4117 COMPUTED_STYLE_MAP_ENTRY(marker_offset
, MarkerOffset
),
4118 // COMPUTED_STYLE_MAP_ENTRY(marks, Marks),
4119 COMPUTED_STYLE_MAP_ENTRY(max_height
, MaxHeight
),
4120 COMPUTED_STYLE_MAP_ENTRY(max_width
, MaxWidth
),
4121 COMPUTED_STYLE_MAP_ENTRY(min_height
, MinHeight
),
4122 COMPUTED_STYLE_MAP_ENTRY(min_width
, MinWidth
),
4123 COMPUTED_STYLE_MAP_ENTRY(ime_mode
, IMEMode
),
4124 COMPUTED_STYLE_MAP_ENTRY(opacity
, Opacity
),
4125 // COMPUTED_STYLE_MAP_ENTRY(orphans, Orphans),
4126 //// COMPUTED_STYLE_MAP_ENTRY(outline, Outline),
4127 COMPUTED_STYLE_MAP_ENTRY(outline_color
, OutlineColor
),
4128 COMPUTED_STYLE_MAP_ENTRY(outline_style
, OutlineStyle
),
4129 COMPUTED_STYLE_MAP_ENTRY(outline_width
, OutlineWidth
),
4130 COMPUTED_STYLE_MAP_ENTRY(outline_offset
, OutlineOffset
),
4131 COMPUTED_STYLE_MAP_ENTRY(overflow
, Overflow
),
4132 COMPUTED_STYLE_MAP_ENTRY(overflow_x
, OverflowX
),
4133 COMPUTED_STYLE_MAP_ENTRY(overflow_y
, OverflowY
),
4134 //// COMPUTED_STYLE_MAP_ENTRY(padding, Padding),
4135 COMPUTED_STYLE_MAP_ENTRY(padding_bottom
, PaddingBottom
),
4136 COMPUTED_STYLE_MAP_ENTRY(padding_left
, PaddingLeft
),
4137 COMPUTED_STYLE_MAP_ENTRY(padding_right
, PaddingRight
),
4138 COMPUTED_STYLE_MAP_ENTRY(padding_top
, PaddingTop
),
4139 // COMPUTED_STYLE_MAP_ENTRY(page, Page),
4140 COMPUTED_STYLE_MAP_ENTRY(page_break_after
, PageBreakAfter
),
4141 COMPUTED_STYLE_MAP_ENTRY(page_break_before
, PageBreakBefore
),
4142 // COMPUTED_STYLE_MAP_ENTRY(page_break_inside, PageBreakInside),
4143 //// COMPUTED_STYLE_MAP_ENTRY(pause, Pause),
4144 // COMPUTED_STYLE_MAP_ENTRY(pause_after, PauseAfter),
4145 // COMPUTED_STYLE_MAP_ENTRY(pause_before, PauseBefore),
4146 // COMPUTED_STYLE_MAP_ENTRY(pitch, Pitch),
4147 // COMPUTED_STYLE_MAP_ENTRY(pitch_range, PitchRange),
4148 COMPUTED_STYLE_MAP_ENTRY(position
, Position
),
4149 COMPUTED_STYLE_MAP_ENTRY(quotes
, Quotes
),
4150 // COMPUTED_STYLE_MAP_ENTRY(richness, Richness),
4151 COMPUTED_STYLE_MAP_ENTRY(right
, Right
),
4152 //// COMPUTED_STYLE_MAP_ENTRY(size, Size),
4153 // COMPUTED_STYLE_MAP_ENTRY(speak, Speak),
4154 // COMPUTED_STYLE_MAP_ENTRY(speak_header, SpeakHeader),
4155 // COMPUTED_STYLE_MAP_ENTRY(speak_numeral, SpeakNumeral),
4156 // COMPUTED_STYLE_MAP_ENTRY(speak_punctuation, SpeakPunctuation),
4157 // COMPUTED_STYLE_MAP_ENTRY(speech_rate, SpeechRate),
4158 // COMPUTED_STYLE_MAP_ENTRY(stress, Stress),
4159 COMPUTED_STYLE_MAP_ENTRY(table_layout
, TableLayout
),
4160 COMPUTED_STYLE_MAP_ENTRY(text_align
, TextAlign
),
4161 COMPUTED_STYLE_MAP_ENTRY(text_decoration
, TextDecoration
),
4162 COMPUTED_STYLE_MAP_ENTRY(text_indent
, TextIndent
),
4163 COMPUTED_STYLE_MAP_ENTRY(text_shadow
, TextShadow
),
4164 COMPUTED_STYLE_MAP_ENTRY(text_transform
, TextTransform
),
4165 COMPUTED_STYLE_MAP_ENTRY(top
, Top
),
4166 COMPUTED_STYLE_MAP_ENTRY(unicode_bidi
, UnicodeBidi
),
4167 COMPUTED_STYLE_MAP_ENTRY(vertical_align
, VerticalAlign
),
4168 COMPUTED_STYLE_MAP_ENTRY(visibility
, Visibility
),
4169 // COMPUTED_STYLE_MAP_ENTRY(voice_family, VoiceFamily),
4170 // COMPUTED_STYLE_MAP_ENTRY(volume, Volume),
4171 COMPUTED_STYLE_MAP_ENTRY(white_space
, WhiteSpace
),
4172 // COMPUTED_STYLE_MAP_ENTRY(widows, Widows),
4173 COMPUTED_STYLE_MAP_ENTRY(width
, Width
),
4174 COMPUTED_STYLE_MAP_ENTRY(word_spacing
, WordSpacing
),
4175 COMPUTED_STYLE_MAP_ENTRY(z_index
, ZIndex
),
4177 /* ******************************* *\
4178 * Implementations of -moz- styles *
4179 \* ******************************* */
4181 COMPUTED_STYLE_MAP_ENTRY(appearance
, Appearance
),
4182 COMPUTED_STYLE_MAP_ENTRY(_moz_background_clip
, BackgroundClip
),
4183 COMPUTED_STYLE_MAP_ENTRY(_moz_background_inline_policy
, BackgroundInlinePolicy
),
4184 COMPUTED_STYLE_MAP_ENTRY(_moz_background_origin
, BackgroundOrigin
),
4185 COMPUTED_STYLE_MAP_ENTRY(binding
, Binding
),
4186 COMPUTED_STYLE_MAP_ENTRY(border_bottom_colors
, BorderBottomColors
),
4187 COMPUTED_STYLE_MAP_ENTRY(border_image
, BorderImage
),
4188 COMPUTED_STYLE_MAP_ENTRY(border_left_colors
, BorderLeftColors
),
4189 COMPUTED_STYLE_MAP_ENTRY(border_right_colors
, BorderRightColors
),
4190 COMPUTED_STYLE_MAP_ENTRY(border_top_colors
, BorderTopColors
),
4191 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomLeft
, BorderRadiusBottomLeft
),
4192 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomRight
,BorderRadiusBottomRight
),
4193 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topLeft
, BorderRadiusTopLeft
),
4194 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topRight
, BorderRadiusTopRight
),
4195 COMPUTED_STYLE_MAP_ENTRY(box_align
, BoxAlign
),
4196 COMPUTED_STYLE_MAP_ENTRY(box_direction
, BoxDirection
),
4197 COMPUTED_STYLE_MAP_ENTRY(box_flex
, BoxFlex
),
4198 COMPUTED_STYLE_MAP_ENTRY(box_ordinal_group
, BoxOrdinalGroup
),
4199 COMPUTED_STYLE_MAP_ENTRY(box_orient
, BoxOrient
),
4200 COMPUTED_STYLE_MAP_ENTRY(box_pack
, BoxPack
),
4201 COMPUTED_STYLE_MAP_ENTRY(box_shadow
, BoxShadow
),
4202 COMPUTED_STYLE_MAP_ENTRY(box_sizing
, BoxSizing
),
4203 COMPUTED_STYLE_MAP_ENTRY(_moz_column_count
, ColumnCount
),
4204 COMPUTED_STYLE_MAP_ENTRY(_moz_column_width
, ColumnWidth
),
4205 COMPUTED_STYLE_MAP_ENTRY(_moz_column_gap
, ColumnGap
),
4206 //// COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule, ColumnRule),
4207 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_color
, ColumnRuleColor
),
4208 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_width
, ColumnRuleWidth
),
4209 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_style
, ColumnRuleStyle
),
4210 COMPUTED_STYLE_MAP_ENTRY(float_edge
, FloatEdge
),
4211 COMPUTED_STYLE_MAP_ENTRY(force_broken_image_icon
, ForceBrokenImageIcon
),
4212 COMPUTED_STYLE_MAP_ENTRY(image_region
, ImageRegion
),
4213 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomLeft
, OutlineRadiusBottomLeft
),
4214 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomRight
,OutlineRadiusBottomRight
),
4215 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topLeft
, OutlineRadiusTopLeft
),
4216 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topRight
, OutlineRadiusTopRight
),
4217 COMPUTED_STYLE_MAP_ENTRY(stack_sizing
, StackSizing
),
4218 COMPUTED_STYLE_MAP_ENTRY(_moz_transform
, MozTransform
),
4219 COMPUTED_STYLE_MAP_ENTRY(_moz_transform_origin
, MozTransformOrigin
),
4220 COMPUTED_STYLE_MAP_ENTRY(user_focus
, UserFocus
),
4221 COMPUTED_STYLE_MAP_ENTRY(user_input
, UserInput
),
4222 COMPUTED_STYLE_MAP_ENTRY(user_modify
, UserModify
),
4223 COMPUTED_STYLE_MAP_ENTRY(user_select
, UserSelect
),
4224 COMPUTED_STYLE_MAP_ENTRY(_moz_window_shadow
, WindowShadow
),
4225 COMPUTED_STYLE_MAP_ENTRY(word_wrap
, WordWrap
)
4229 COMPUTED_STYLE_MAP_ENTRY(clip_path
, ClipPath
),
4230 COMPUTED_STYLE_MAP_ENTRY(clip_rule
, ClipRule
),
4231 COMPUTED_STYLE_MAP_ENTRY(color_interpolation
, ColorInterpolation
),
4232 COMPUTED_STYLE_MAP_ENTRY(color_interpolation_filters
, ColorInterpolationFilters
),
4233 COMPUTED_STYLE_MAP_ENTRY(dominant_baseline
, DominantBaseline
),
4234 COMPUTED_STYLE_MAP_ENTRY(fill
, Fill
),
4235 COMPUTED_STYLE_MAP_ENTRY(fill_opacity
, FillOpacity
),
4236 COMPUTED_STYLE_MAP_ENTRY(fill_rule
, FillRule
),
4237 COMPUTED_STYLE_MAP_ENTRY(filter
, Filter
),
4238 COMPUTED_STYLE_MAP_ENTRY(flood_color
, FloodColor
),
4239 COMPUTED_STYLE_MAP_ENTRY(flood_opacity
, FloodOpacity
),
4240 COMPUTED_STYLE_MAP_ENTRY(lighting_color
, LightingColor
),
4241 COMPUTED_STYLE_MAP_ENTRY(mask
, Mask
),
4242 COMPUTED_STYLE_MAP_ENTRY(marker_end
, MarkerEnd
),
4243 COMPUTED_STYLE_MAP_ENTRY(marker_mid
, MarkerMid
),
4244 COMPUTED_STYLE_MAP_ENTRY(marker_start
, MarkerStart
),
4245 COMPUTED_STYLE_MAP_ENTRY(pointer_events
, PointerEvents
),
4246 COMPUTED_STYLE_MAP_ENTRY(shape_rendering
, ShapeRendering
),
4247 COMPUTED_STYLE_MAP_ENTRY(stop_color
, StopColor
),
4248 COMPUTED_STYLE_MAP_ENTRY(stop_opacity
, StopOpacity
),
4249 COMPUTED_STYLE_MAP_ENTRY(stroke
, Stroke
),
4250 COMPUTED_STYLE_MAP_ENTRY(stroke_dasharray
, StrokeDasharray
),
4251 COMPUTED_STYLE_MAP_ENTRY(stroke_dashoffset
, StrokeDashoffset
),
4252 COMPUTED_STYLE_MAP_ENTRY(stroke_linecap
, StrokeLinecap
),
4253 COMPUTED_STYLE_MAP_ENTRY(stroke_linejoin
, StrokeLinejoin
),
4254 COMPUTED_STYLE_MAP_ENTRY(stroke_miterlimit
, StrokeMiterlimit
),
4255 COMPUTED_STYLE_MAP_ENTRY(stroke_opacity
, StrokeOpacity
),
4256 COMPUTED_STYLE_MAP_ENTRY(stroke_width
, StrokeWidth
),
4257 COMPUTED_STYLE_MAP_ENTRY(text_anchor
, TextAnchor
),
4258 COMPUTED_STYLE_MAP_ENTRY(text_rendering
, TextRendering
)
4263 *aLength
= NS_ARRAY_LENGTH(map
);