Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / style / nsComputedDOMStyle.cpp
blob77d0a507471a484743019d253384dd3c00e60442
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
13 * License.
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.
22 * Contributor(s):
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"
56 #include "prprf.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
82 #endif
85 * This is the implementation of the readonly CSSStyleDeclaration that is
86 * returned by the getComputedStyle() function.
89 static nsComputedDOMStyle *sCachedComputedDOMStyle;
91 nsresult
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;
104 } else {
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);
113 return NS_OK;
116 static nsIFrame*
117 GetContainingBlockFor(nsIFrame* aFrame) {
118 if (!aFrame) {
119 return nsnull;
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()
135 void
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
141 // about our dtor.
142 delete reinterpret_cast<char*>(sCachedComputedDOMStyle);
143 sCachedComputedDOMStyle = nsnull;
147 NS_IMPL_CYCLE_COLLECTION_CLASS(nsComputedDOMStyle)
148 NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsComputedDOMStyle)
149 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsComputedDOMStyle)
150 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContent)
151 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
153 // QueryInterface implementation for nsComputedDOMStyle
154 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsComputedDOMStyle)
155 NS_INTERFACE_MAP_ENTRY(nsIComputedDOMStyle)
156 NS_INTERFACE_MAP_ENTRY(nsICSSDeclaration)
157 NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
158 NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMCSS2Properties, &mInner)
159 NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMNSCSS2Properties, &mInner)
160 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIComputedDOMStyle)
161 NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ComputedCSSStyleDeclaration)
162 NS_INTERFACE_MAP_END
165 static void doDestroyComputedDOMStyle(nsComputedDOMStyle *aComputedStyle)
167 if (!sCachedComputedDOMStyle) {
168 // The cache is empty, store aComputedStyle in the cache.
170 sCachedComputedDOMStyle = aComputedStyle;
171 sCachedComputedDOMStyle->~nsComputedDOMStyle();
172 } else {
173 // The cache is full, delete aComputedStyle
175 delete aComputedStyle;
179 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsComputedDOMStyle)
180 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsComputedDOMStyle,
181 doDestroyComputedDOMStyle(this))
184 NS_IMETHODIMP
185 nsComputedDOMStyle::Init(nsIDOMElement *aElement,
186 const nsAString& aPseudoElt,
187 nsIPresShell *aPresShell)
189 NS_ENSURE_ARG_POINTER(aElement);
190 NS_ENSURE_ARG_POINTER(aPresShell);
192 mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
194 mContent = do_QueryInterface(aElement);
195 if (!mContent) {
196 // This should not happen, all our elements support nsIContent!
198 return NS_ERROR_FAILURE;
201 if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty() &&
202 aPseudoElt.First() == PRUnichar(':')) {
203 // deal with two-colon forms of aPseudoElt
204 nsAString::const_iterator start, end;
205 aPseudoElt.BeginReading(start);
206 aPseudoElt.EndReading(end);
207 NS_ASSERTION(start != end, "aPseudoElt is not empty!");
208 ++start;
209 PRBool haveTwoColons = PR_TRUE;
210 if (start == end || *start != PRUnichar(':')) {
211 --start;
212 haveTwoColons = PR_FALSE;
214 mPseudo = do_GetAtom(Substring(start, end));
215 NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY);
217 // There aren't any non-CSS2 pseudo-elements with a single ':'
218 if (!haveTwoColons &&
219 !nsCSSPseudoElements::IsCSS2PseudoElement(mPseudo)) {
220 // XXXbz I'd really rather we threw an exception or something, but
221 // the DOM spec sucks.
222 mPseudo = nsnull;
226 nsPresContext *presCtx = aPresShell->GetPresContext();
227 NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
229 mAppUnitsPerInch = presCtx->AppUnitsPerInch();
231 return NS_OK;
234 NS_IMETHODIMP
235 nsComputedDOMStyle::GetPropertyValue(const nsCSSProperty aPropID,
236 nsAString& aValue)
238 // This is mostly to avoid code duplication with GetPropertyCSSValue(); if
239 // perf ever becomes an issue here (doubtful), we can look into changing
240 // this.
241 return GetPropertyValue(
242 NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(aPropID)),
243 aValue);
246 NS_IMETHODIMP
247 nsComputedDOMStyle::SetPropertyValue(const nsCSSProperty aPropID,
248 const nsAString& aValue)
250 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
254 NS_IMETHODIMP
255 nsComputedDOMStyle::GetCssText(nsAString& aCssText)
257 aCssText.Truncate();
259 return NS_OK;
263 NS_IMETHODIMP
264 nsComputedDOMStyle::SetCssText(const nsAString& aCssText)
266 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
270 NS_IMETHODIMP
271 nsComputedDOMStyle::GetLength(PRUint32* aLength)
273 NS_PRECONDITION(aLength, "Null aLength! Prepare to die!");
275 (void)GetQueryablePropertyMap(aLength);
277 return NS_OK;
281 NS_IMETHODIMP
282 nsComputedDOMStyle::GetParentRule(nsIDOMCSSRule** aParentRule)
284 NS_ENSURE_ARG_POINTER(aParentRule);
285 *aParentRule = nsnull;
287 return NS_OK;
291 NS_IMETHODIMP
292 nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
293 nsAString& aReturn)
295 nsCOMPtr<nsIDOMCSSValue> val;
297 aReturn.Truncate();
299 nsresult rv = GetPropertyCSSValue(aPropertyName, getter_AddRefs(val));
300 NS_ENSURE_SUCCESS(rv, rv);
302 if (val) {
303 rv = val->GetCssText(aReturn);
306 return rv;
310 NS_IMETHODIMP
311 nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
312 nsIDOMCSSValue** aReturn)
314 NS_ENSURE_ARG_POINTER(aReturn);
315 *aReturn = nsnull;
317 nsCOMPtr<nsIDocument> document = do_QueryReferent(mDocumentWeak);
318 NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
320 // Flush _before_ getting the presshell, since that could create a new
321 // presshell. Also note that we want to flush the style on the document
322 // we're computing style in, not on the document mContent is in -- the two
323 // may be different.
324 document->FlushPendingNotifications(Flush_Style);
326 mPresShell = document->GetPrimaryShell();
327 NS_ENSURE_TRUE(mPresShell && mPresShell->GetPresContext(),
328 NS_ERROR_NOT_AVAILABLE);
330 mOuterFrame = mPresShell->GetPrimaryFrameFor(mContent);
331 mInnerFrame = mOuterFrame;
332 if (!mOuterFrame || mPseudo) {
333 // Need to resolve a style context
334 mStyleContextHolder =
335 nsInspectorCSSUtils::GetStyleContextForContent(mContent,
336 mPseudo,
337 mPresShell);
338 NS_ENSURE_TRUE(mStyleContextHolder, NS_ERROR_OUT_OF_MEMORY);
339 } else {
340 nsIAtom* type = mOuterFrame->GetType();
341 if (type == nsGkAtoms::tableOuterFrame) {
342 // If the frame is an outer table frame then we should get the style
343 // from the inner table frame.
344 mInnerFrame = mOuterFrame->GetFirstChild(nsnull);
345 NS_ASSERTION(mInnerFrame, "Outer table must have an inner");
346 NS_ASSERTION(!mInnerFrame->GetNextSibling(),
347 "Outer table frames should have just one child, the inner "
348 "table");
351 mStyleContextHolder = mInnerFrame->GetStyleContext();
352 NS_ASSERTION(mStyleContextHolder, "Frame without style context?");
355 nsresult rv = NS_OK;
357 nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
359 PRUint32 i = 0;
360 PRUint32 length = 0;
361 const ComputedStyleMapEntry* propMap = GetQueryablePropertyMap(&length);
362 for (; i < length; ++i) {
363 if (prop == propMap[i].mProperty) {
364 // Call our pointer-to-member-function.
365 rv = (this->*(propMap[i].mGetter))(aReturn);
366 break;
370 #ifdef DEBUG_ComputedDOMStyle
371 if (i == length) {
372 NS_WARNING(PromiseFlatCString(NS_ConvertUTF16toUTF8(aPropertyName) +
373 NS_LITERAL_CSTRING(" is not queryable!")).get());
375 #endif
377 if (NS_FAILED(rv)) {
378 *aReturn = nsnull;
381 mOuterFrame = nsnull;
382 mInnerFrame = nsnull;
383 mPresShell = nsnull;
385 // Release the current style context for it should be re-resolved
386 // whenever a frame is not available.
387 mStyleContextHolder = nsnull;
389 return rv;
393 NS_IMETHODIMP
394 nsComputedDOMStyle::RemoveProperty(const nsAString& aPropertyName,
395 nsAString& aReturn)
397 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
401 NS_IMETHODIMP
402 nsComputedDOMStyle::GetPropertyPriority(const nsAString& aPropertyName,
403 nsAString& aReturn)
405 aReturn.Truncate();
407 return NS_OK;
411 NS_IMETHODIMP
412 nsComputedDOMStyle::SetProperty(const nsAString& aPropertyName,
413 const nsAString& aValue,
414 const nsAString& aPriority)
416 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
420 NS_IMETHODIMP
421 nsComputedDOMStyle::Item(PRUint32 aIndex, nsAString& aReturn)
423 aReturn.Truncate();
425 PRUint32 length = 0;
426 const ComputedStyleMapEntry* propMap = GetQueryablePropertyMap(&length);
427 if (aIndex < length) {
428 CopyASCIItoUTF16(nsCSSProps::GetStringValue(propMap[aIndex].mProperty),
429 aReturn);
432 return NS_OK;
436 // Property getters...
438 nsresult
439 nsComputedDOMStyle::GetBinding(nsIDOMCSSValue** aValue)
441 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
442 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
444 const nsStyleDisplay* display = GetStyleDisplay();
446 if (display->mBinding) {
447 val->SetURI(display->mBinding->mURI);
448 } else {
449 val->SetIdent(nsGkAtoms::none);
452 return CallQueryInterface(val, aValue);
455 nsresult
456 nsComputedDOMStyle::GetClear(nsIDOMCSSValue** aValue)
458 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
459 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
461 const nsStyleDisplay *display = GetStyleDisplay();
463 if (display->mBreakType != NS_STYLE_CLEAR_NONE) {
464 const nsAFlatCString& clear =
465 nsCSSProps::ValueToKeyword(display->mBreakType,
466 nsCSSProps::kClearKTable);
467 val->SetIdent(clear);
468 } else {
469 val->SetIdent(nsGkAtoms::none);
472 return CallQueryInterface(val, aValue);
475 nsresult
476 nsComputedDOMStyle::GetCssFloat(nsIDOMCSSValue** aValue)
478 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
479 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
481 const nsStyleDisplay* display = GetStyleDisplay();
483 if (display->mFloats != NS_STYLE_FLOAT_NONE) {
484 const nsAFlatCString& cssFloat =
485 nsCSSProps::ValueToKeyword(display->mFloats,
486 nsCSSProps::kFloatKTable);
487 val->SetIdent(cssFloat);
488 } else {
489 val->SetIdent(nsGkAtoms::none);
492 return CallQueryInterface(val, aValue);
495 nsresult
496 nsComputedDOMStyle::GetBottom(nsIDOMCSSValue** aValue)
498 return GetOffsetWidthFor(NS_SIDE_BOTTOM, aValue);
501 nsresult
502 nsComputedDOMStyle::GetStackSizing(nsIDOMCSSValue** aValue)
504 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
505 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
507 val->SetIdent(GetStyleXUL()->mStretchStack ? nsGkAtoms::stretch_to_fit :
508 nsGkAtoms::ignore);
510 return CallQueryInterface(val, aValue);
513 nsresult
514 nsComputedDOMStyle::SetToRGBAColor(nsROCSSPrimitiveValue* aValue,
515 nscolor aColor)
517 if (NS_GET_A(aColor) == 0) {
518 aValue->SetIdent(nsGkAtoms::transparent);
519 return NS_OK;
522 nsROCSSPrimitiveValue *red = GetROCSSPrimitiveValue();
523 nsROCSSPrimitiveValue *green = GetROCSSPrimitiveValue();
524 nsROCSSPrimitiveValue *blue = GetROCSSPrimitiveValue();
525 nsROCSSPrimitiveValue *alpha = GetROCSSPrimitiveValue();
527 if (red && green && blue && alpha) {
528 PRUint8 a = NS_GET_A(aColor);
529 nsDOMCSSRGBColor *rgbColor =
530 new nsDOMCSSRGBColor(red, green, blue, alpha, a < 255);
532 if (rgbColor) {
533 red->SetNumber(NS_GET_R(aColor));
534 green->SetNumber(NS_GET_G(aColor));
535 blue->SetNumber(NS_GET_B(aColor));
536 alpha->SetNumber(nsStyleUtil::ColorComponentToFloat(a));
538 aValue->SetColor(rgbColor);
539 return NS_OK;
543 delete red;
544 delete green;
545 delete blue;
546 delete alpha;
548 return NS_ERROR_OUT_OF_MEMORY;
551 nsresult
552 nsComputedDOMStyle::GetColor(nsIDOMCSSValue** aValue)
554 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
555 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
557 const nsStyleColor* color = GetStyleColor();
559 nsresult rv = SetToRGBAColor(val, color->mColor);
560 if (NS_FAILED(rv)) {
561 delete val;
562 return rv;
565 return CallQueryInterface(val, aValue);
568 nsresult
569 nsComputedDOMStyle::GetOpacity(nsIDOMCSSValue** aValue)
571 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
572 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
574 val->SetNumber(GetStyleDisplay()->mOpacity);
576 return CallQueryInterface(val, aValue);
579 nsresult
580 nsComputedDOMStyle::GetColumnCount(nsIDOMCSSValue** aValue)
582 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
583 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
585 const nsStyleColumn* column = GetStyleColumn();
587 if (column->mColumnCount == NS_STYLE_COLUMN_COUNT_AUTO) {
588 val->SetIdent(nsGkAtoms::_auto);
589 } else {
590 val->SetNumber(column->mColumnCount);
593 return CallQueryInterface(val, aValue);
596 nsresult
597 nsComputedDOMStyle::GetColumnWidth(nsIDOMCSSValue** aValue)
599 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
600 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
602 // XXX fix the auto case. When we actually have a column frame, I think
603 // we should return the computed column width.
604 SetValueToCoord(val, GetStyleColumn()->mColumnWidth);
606 return CallQueryInterface(val, aValue);
609 nsresult
610 nsComputedDOMStyle::GetColumnGap(nsIDOMCSSValue** aValue)
612 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
613 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
615 const nsStyleColumn* column = GetStyleColumn();
616 if (column->mColumnGap.GetUnit() == eStyleUnit_Normal) {
617 val->SetAppUnits(GetStyleFont()->mFont.size);
618 } else {
619 SetValueToCoord(val, GetStyleColumn()->mColumnGap);
622 return CallQueryInterface(val, aValue);
625 nsresult
626 nsComputedDOMStyle::GetColumnRuleWidth(nsIDOMCSSValue** aValue)
628 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
629 if (!val)
630 return NS_ERROR_OUT_OF_MEMORY;
632 SetValueToCoord(val, GetStyleColumn()->GetComputedColumnRuleWidth());
633 return CallQueryInterface(val, aValue);
636 nsresult
637 nsComputedDOMStyle::GetColumnRuleStyle(nsIDOMCSSValue** aValue)
639 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
640 if (!val)
641 return NS_ERROR_OUT_OF_MEMORY;
643 const nsStyleColumn* column = GetStyleColumn();
644 if (column->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_NONE) {
645 val->SetIdent(nsGkAtoms::none);
646 } else {
647 const nsAFlatCString& style =
648 nsCSSProps::ValueToKeyword(column->mColumnRuleStyle,
649 nsCSSProps::kBorderStyleKTable);
650 val->SetIdent(style);
652 return CallQueryInterface(val, aValue);
655 nsresult
656 nsComputedDOMStyle::GetColumnRuleColor(nsIDOMCSSValue** aValue)
658 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
659 if (!val)
660 return NS_ERROR_OUT_OF_MEMORY;
662 const nsStyleColumn* column = GetStyleColumn();
663 nscolor ruleColor;
664 if (column->mColumnRuleColorIsForeground) {
665 ruleColor = GetStyleColor()->mColor;
666 } else {
667 ruleColor = column->mColumnRuleColor;
670 SetToRGBAColor(val, ruleColor);
671 return CallQueryInterface(val, aValue);
674 nsresult
675 nsComputedDOMStyle::GetContent(nsIDOMCSSValue** aValue)
677 const nsStyleContent *content = GetStyleContent();
679 if (content->ContentCount() == 0) {
680 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
681 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
682 val->SetIdent(nsGkAtoms::none);
683 return CallQueryInterface(val, aValue);
686 if (content->ContentCount() == 1 &&
687 content->ContentAt(0).mType == eStyleContentType_AltContent) {
688 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
689 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
690 val->SetIdent(eCSSKeyword__moz_alt_content);
691 return CallQueryInterface(val, aValue);
694 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
695 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
697 for (PRUint32 i = 0, i_end = content->ContentCount(); i < i_end; ++i) {
698 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
699 if (!val || !valueList->AppendCSSValue(val)) {
700 delete valueList;
701 delete val;
702 return NS_ERROR_OUT_OF_MEMORY;
705 const nsStyleContentData &data = content->ContentAt(i);
706 switch (data.mType) {
707 case eStyleContentType_String:
709 nsString str;
710 nsStyleUtil::EscapeCSSString(nsDependentString(data.mContent.mString),
711 str);
712 str.Insert(PRUnichar('"'), 0);
713 str.Append(PRUnichar('"'));
714 val->SetString(str);
716 break;
717 case eStyleContentType_Image:
719 nsCOMPtr<nsIURI> uri;
720 if (data.mContent.mImage) {
721 data.mContent.mImage->GetURI(getter_AddRefs(uri));
723 val->SetURI(uri);
725 break;
726 case eStyleContentType_Attr:
727 val->SetString(nsDependentString(data.mContent.mString),
728 nsIDOMCSSPrimitiveValue::CSS_ATTR);
729 break;
730 case eStyleContentType_Counter:
731 case eStyleContentType_Counters:
733 /* FIXME: counters should really use an object */
734 nsAutoString str;
735 if (data.mType == eStyleContentType_Counter) {
736 str.AppendLiteral("counter(");
738 else {
739 str.AppendLiteral("counters(");
741 // WRITE ME
742 nsCSSValue::Array *a = data.mContent.mCounters;
744 str.Append(a->Item(0).GetStringBufferValue());
745 PRInt32 typeItem = 1;
746 if (data.mType == eStyleContentType_Counters) {
747 typeItem = 2;
748 str.AppendLiteral(", \"");
749 nsString itemstr;
750 nsStyleUtil::EscapeCSSString(
751 nsDependentString(a->Item(1).GetStringBufferValue()), itemstr);
752 str.Append(itemstr);
753 str.Append(PRUnichar('"'));
755 PRInt32 type = a->Item(typeItem).GetIntValue();
756 if (type != NS_STYLE_LIST_STYLE_DECIMAL) {
757 str.AppendLiteral(", ");
758 str.AppendInt(type);
761 str.Append(PRUnichar(')'));
762 val->SetString(str, nsIDOMCSSPrimitiveValue::CSS_COUNTER);
764 break;
765 case eStyleContentType_OpenQuote:
766 val->SetIdent(eCSSKeyword_open_quote);
767 break;
768 case eStyleContentType_CloseQuote:
769 val->SetIdent(eCSSKeyword_close_quote);
770 break;
771 case eStyleContentType_NoOpenQuote:
772 val->SetIdent(eCSSKeyword_no_open_quote);
773 break;
774 case eStyleContentType_NoCloseQuote:
775 val->SetIdent(eCSSKeyword_no_close_quote);
776 break;
777 case eStyleContentType_AltContent:
778 default:
779 NS_NOTREACHED("unexpected type");
780 break;
784 return CallQueryInterface(valueList, aValue);
787 nsresult
788 nsComputedDOMStyle::GetCounterIncrement(nsIDOMCSSValue** aValue)
790 const nsStyleContent *content = GetStyleContent();
792 if (content->CounterIncrementCount() == 0) {
793 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
794 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
795 val->SetIdent(nsGkAtoms::none);
796 return CallQueryInterface(val, aValue);
799 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
800 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
802 for (PRUint32 i = 0, i_end = content->CounterIncrementCount(); i < i_end; ++i) {
803 nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
804 if (!name || !valueList->AppendCSSValue(name)) {
805 delete valueList;
806 delete name;
807 return NS_ERROR_OUT_OF_MEMORY;
810 nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
811 if (!value || !valueList->AppendCSSValue(value)) {
812 delete valueList;
813 delete value;
814 return NS_ERROR_OUT_OF_MEMORY;
817 const nsStyleCounterData *data = content->GetCounterIncrementAt(i);
818 name->SetString(data->mCounter);
819 value->SetNumber(data->mValue); // XXX This should really be integer
822 return CallQueryInterface(valueList, aValue);
825 /* Convert the stored representation into a list of two values and then hand
826 * it back.
828 nsresult nsComputedDOMStyle::GetMozTransformOrigin(nsIDOMCSSValue **aValue)
830 /* We need to build up a list of two values. We'll call them
831 * width and height.
833 nsAutoPtr<nsROCSSPrimitiveValue> width(GetROCSSPrimitiveValue());
834 nsAutoPtr<nsROCSSPrimitiveValue> height(GetROCSSPrimitiveValue());
835 if (!width || !height)
836 return NS_ERROR_OUT_OF_MEMORY;
838 /* Now, get the values. */
839 const nsStyleDisplay* display = GetStyleDisplay();
840 SetValueToCoord(width, display->mTransformOrigin[0],
841 &nsComputedDOMStyle::GetFrameBoundsWidthForTransform);
842 SetValueToCoord(height, display->mTransformOrigin[1],
843 &nsComputedDOMStyle::GetFrameBoundsHeightForTransform);
845 /* Store things as a value list, fail if we can't get one. */
846 nsAutoPtr<nsDOMCSSValueList> valueList(GetROCSSValueList(PR_FALSE));
847 if (!valueList)
848 return NS_ERROR_OUT_OF_MEMORY;
850 /* Chain on width and height, fail if we can't. */
851 if (!valueList->AppendCSSValue(width))
852 return NS_ERROR_OUT_OF_MEMORY;
853 width.forget();
854 if (!valueList->AppendCSSValue(height))
855 return NS_ERROR_OUT_OF_MEMORY;
856 height.forget();
858 /* Release the pointer and call query interface! We're done. */
859 return CallQueryInterface(valueList.forget(), aValue);
862 /* If the property is "none", hand back "none" wrapped in a value.
863 * Otherwise, compute the aggregate transform matrix and hands it back in a
864 * "matrix" wrapper.
866 nsresult nsComputedDOMStyle::GetMozTransform(nsIDOMCSSValue **aValue)
868 static const PRInt32 NUM_FLOATS = 4;
870 /* First, get the display data. We'll need it. */
871 const nsStyleDisplay* display = GetStyleDisplay();
873 /* If the "no transforms" flag is set, then we should construct a
874 * single-element entry and hand it back.
876 if (!display->mTransformPresent) {
877 nsROCSSPrimitiveValue *val(GetROCSSPrimitiveValue());
878 if (!val)
879 return NS_ERROR_OUT_OF_MEMORY;
881 /* Set it to "none." */
882 val->SetIdent(eCSSKeyword_none);
883 return CallQueryInterface(val, aValue);
886 /* Otherwise, we need to compute the current value of the transform matrix,
887 * store it in a string, and hand it back to the caller.
889 nsAutoString resultString(NS_LITERAL_STRING("matrix("));
891 /* Now, we need to convert the matrix into a string. We'll start by taking
892 * the first four entries and converting them directly to floating-point
893 * values.
895 for (PRInt32 index = 0; index < NUM_FLOATS; ++index) {
896 resultString.AppendFloat(display->mTransform.GetMainMatrixEntry(index));
897 resultString.Append(NS_LITERAL_STRING(", "));
900 /* Use the inner frame for width and height. If we fail, assume zero.
901 * TODO: There is no good way for us to represent the case where there's no
902 * frame, which is problematic. The reason is that when we have percentage
903 * transforms, there are a total of four stored matrix entries that influence
904 * the transform based on the size of the element. However, this poses a
905 * problem, because only two of these values can be explicitly referenced
906 * using the named transforms. Until a real solution is found, we'll just
907 * use this approach.
909 nsRect bounds =
910 (mInnerFrame ? nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame) :
911 nsRect(0, 0, 0, 0));
913 /* Now, compute the dX and dY components by adding the stored coord value
914 * (in CSS pixels) to the translate values.
917 float deltaX = nsPresContext::AppUnitsToFloatCSSPixels
918 (display->mTransform.GetXTranslation(bounds));
919 float deltaY = nsPresContext::AppUnitsToFloatCSSPixels
920 (display->mTransform.GetYTranslation(bounds));
923 /* Append these values! */
924 resultString.AppendFloat(deltaX);
925 resultString.Append(NS_LITERAL_STRING("px, "));
926 resultString.AppendFloat(deltaY);
927 resultString.Append(NS_LITERAL_STRING("px)"));
929 /* Create a value to hold our result. */
930 nsROCSSPrimitiveValue* rv(GetROCSSPrimitiveValue());
932 if (!rv)
933 return NS_ERROR_OUT_OF_MEMORY;
935 rv->SetString(resultString);
936 return CallQueryInterface(rv, aValue);
939 nsresult
940 nsComputedDOMStyle::GetCounterReset(nsIDOMCSSValue** aValue)
942 const nsStyleContent *content = GetStyleContent();
944 if (content->CounterResetCount() == 0) {
945 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
946 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
947 val->SetIdent(nsGkAtoms::none);
948 return CallQueryInterface(val, aValue);
951 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
952 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
954 for (PRUint32 i = 0, i_end = content->CounterResetCount(); i < i_end; ++i) {
955 nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
956 if (!name || !valueList->AppendCSSValue(name)) {
957 delete valueList;
958 delete name;
959 return NS_ERROR_OUT_OF_MEMORY;
962 nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
963 if (!value || !valueList->AppendCSSValue(value)) {
964 delete valueList;
965 delete value;
966 return NS_ERROR_OUT_OF_MEMORY;
969 const nsStyleCounterData *data = content->GetCounterResetAt(i);
970 name->SetString(data->mCounter);
971 value->SetNumber(data->mValue); // XXX This should really be integer
974 return CallQueryInterface(valueList, aValue);
977 nsresult
978 nsComputedDOMStyle::GetQuotes(nsIDOMCSSValue** aValue)
980 const nsStyleQuotes *quotes = GetStyleQuotes();
982 if (quotes->QuotesCount() == 0) {
983 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
984 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
985 val->SetIdent(nsGkAtoms::none);
986 return CallQueryInterface(val, aValue);
989 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
990 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
992 for (PRUint32 i = 0, i_end = quotes->QuotesCount(); i < i_end; ++i) {
993 nsROCSSPrimitiveValue* openVal = GetROCSSPrimitiveValue();
994 if (!openVal || !valueList->AppendCSSValue(openVal)) {
995 delete valueList;
996 delete openVal;
997 return NS_ERROR_OUT_OF_MEMORY;
1000 nsROCSSPrimitiveValue* closeVal = GetROCSSPrimitiveValue();
1001 if (!closeVal || !valueList->AppendCSSValue(closeVal)) {
1002 delete valueList;
1003 delete closeVal;
1004 return NS_ERROR_OUT_OF_MEMORY;
1007 nsString s;
1008 nsStyleUtil::EscapeCSSString(*quotes->OpenQuoteAt(i), s);
1009 s.Insert(PRUnichar('"'), 0);
1010 s.Append(PRUnichar('"'));
1011 openVal->SetString(s);
1012 nsStyleUtil::EscapeCSSString(*quotes->CloseQuoteAt(i), s);
1013 s.Insert(PRUnichar('"'), 0);
1014 s.Append(PRUnichar('"'));
1015 closeVal->SetString(s);
1018 return CallQueryInterface(valueList, aValue);
1021 nsresult
1022 nsComputedDOMStyle::GetFontFamily(nsIDOMCSSValue** aValue)
1024 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1025 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1027 const nsStyleFont* font = GetStyleFont();
1029 nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocumentWeak);
1030 NS_ASSERTION(doc, "document is required");
1031 nsIPresShell* presShell = doc->GetPrimaryShell();
1032 NS_ASSERTION(presShell, "pres shell is required");
1033 nsPresContext *presContext = presShell->GetPresContext();
1034 NS_ASSERTION(presContext, "pres context is required");
1036 const nsString& fontName = font->mFont.name;
1037 if (font->mGenericID == kGenericFont_NONE && !font->mFont.systemFont) {
1038 const nsFont* defaultFont =
1039 presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID);
1041 PRInt32 lendiff = fontName.Length() - defaultFont->name.Length();
1042 if (lendiff > 0) {
1043 val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
1044 } else {
1045 val->SetString(fontName);
1047 } else {
1048 val->SetString(fontName);
1051 return CallQueryInterface(val, aValue);
1054 nsresult
1055 nsComputedDOMStyle::GetFontSize(nsIDOMCSSValue** aValue)
1057 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1058 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1060 // Note: GetStyleFont()->mSize is the 'computed size';
1061 // GetStyleFont()->mFont.size is the 'actual size'
1062 val->SetAppUnits(GetStyleFont()->mSize);
1064 return CallQueryInterface(val, aValue);
1067 nsresult
1068 nsComputedDOMStyle::GetFontSizeAdjust(nsIDOMCSSValue** aValue)
1070 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1071 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1073 const nsStyleFont *font = GetStyleFont();
1075 if (font->mFont.sizeAdjust) {
1076 val->SetNumber(font->mFont.sizeAdjust);
1077 } else {
1078 val->SetIdent(nsGkAtoms::none);
1081 return CallQueryInterface(val, aValue);
1084 nsresult
1085 nsComputedDOMStyle::GetFontStyle(nsIDOMCSSValue** aValue)
1087 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1088 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1090 const nsStyleFont* font = GetStyleFont();
1092 if (font->mFont.style != NS_STYLE_FONT_STYLE_NORMAL) {
1093 const nsAFlatCString& style=
1094 nsCSSProps::ValueToKeyword(font->mFont.style,
1095 nsCSSProps::kFontStyleKTable);
1096 val->SetIdent(style);
1097 } else {
1098 val->SetIdent(nsGkAtoms::normal);
1101 return CallQueryInterface(val, aValue);
1104 nsresult
1105 nsComputedDOMStyle::GetFontWeight(nsIDOMCSSValue** aValue)
1107 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1108 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1110 const nsStyleFont* font = GetStyleFont();
1112 const nsAFlatCString& str_weight=
1113 nsCSSProps::ValueToKeyword(font->mFont.weight,
1114 nsCSSProps::kFontWeightKTable);
1115 if (!str_weight.IsEmpty()) {
1116 val->SetIdent(str_weight);
1117 } else {
1118 val->SetNumber(font->mFont.weight);
1121 return CallQueryInterface(val, aValue);
1124 nsresult
1125 nsComputedDOMStyle::GetFontVariant(nsIDOMCSSValue** aValue)
1127 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1128 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1130 const nsStyleFont* font = GetStyleFont();
1132 if (font->mFont.variant != NS_STYLE_FONT_VARIANT_NORMAL) {
1133 const nsAFlatCString& variant=
1134 nsCSSProps::ValueToKeyword(font->mFont.variant,
1135 nsCSSProps::kFontVariantKTable);
1136 val->SetIdent(variant);
1137 } else {
1138 val->SetIdent(nsGkAtoms::normal);
1141 return CallQueryInterface(val, aValue);
1144 nsresult
1145 nsComputedDOMStyle::GetBackgroundAttachment(nsIDOMCSSValue** aValue)
1147 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1148 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1150 const nsStyleBackground *background = GetStyleBackground();
1152 const nsAFlatCString& backgroundAttachment =
1153 nsCSSProps::ValueToKeyword(background->mBackgroundAttachment,
1154 nsCSSProps::kBackgroundAttachmentKTable);
1155 val->SetIdent(backgroundAttachment);
1157 return CallQueryInterface(val, aValue);
1160 nsresult
1161 nsComputedDOMStyle::GetBackgroundClip(nsIDOMCSSValue** aValue)
1163 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1164 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1166 const nsAFlatCString& backgroundClip =
1167 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundClip,
1168 nsCSSProps::kBackgroundClipKTable);
1170 val->SetIdent(backgroundClip);
1172 return CallQueryInterface(val, aValue);
1175 nsresult
1176 nsComputedDOMStyle::GetBackgroundColor(nsIDOMCSSValue** aValue)
1178 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1179 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1181 const nsStyleBackground* color = GetStyleBackground();
1182 nsresult rv = SetToRGBAColor(val, color->mBackgroundColor);
1183 if (NS_FAILED(rv)) {
1184 delete val;
1185 return rv;
1188 return CallQueryInterface(val, aValue);
1191 nsresult
1192 nsComputedDOMStyle::GetBackgroundImage(nsIDOMCSSValue** aValue)
1194 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1195 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1197 const nsStyleBackground* color = GetStyleBackground();
1199 if (color->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) {
1200 val->SetIdent(nsGkAtoms::none);
1201 } else {
1202 nsCOMPtr<nsIURI> uri;
1203 if (color->mBackgroundImage) {
1204 color->mBackgroundImage->GetURI(getter_AddRefs(uri));
1206 val->SetURI(uri);
1209 return CallQueryInterface(val, aValue);
1212 nsresult
1213 nsComputedDOMStyle::GetBackgroundInlinePolicy(nsIDOMCSSValue** aValue)
1215 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1216 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1218 const nsAFlatCString& backgroundPolicy =
1219 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundInlinePolicy,
1220 nsCSSProps::kBackgroundInlinePolicyKTable);
1222 val->SetIdent(backgroundPolicy);
1224 return CallQueryInterface(val, aValue);
1227 nsresult
1228 nsComputedDOMStyle::GetBackgroundOrigin(nsIDOMCSSValue** aValue)
1230 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1231 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1233 const nsAFlatCString& backgroundOrigin =
1234 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundOrigin,
1235 nsCSSProps::kBackgroundOriginKTable);
1237 val->SetIdent(backgroundOrigin);
1239 return CallQueryInterface(val, aValue);
1242 nsresult
1243 nsComputedDOMStyle::GetBackgroundPosition(nsIDOMCSSValue** aValue)
1245 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
1246 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
1248 nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
1249 if (!valX || !valueList->AppendCSSValue(valX)) {
1250 delete valueList;
1251 delete valX;
1252 return NS_ERROR_OUT_OF_MEMORY;
1255 nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
1256 if (!valY || !valueList->AppendCSSValue(valY)) {
1257 delete valueList;
1258 delete valY;
1259 return NS_ERROR_OUT_OF_MEMORY;
1262 const nsStyleBackground *bg = GetStyleBackground();
1264 if (NS_STYLE_BG_X_POSITION_LENGTH & bg->mBackgroundFlags) {
1265 valX->SetAppUnits(bg->mBackgroundXPosition.mCoord);
1267 else if (NS_STYLE_BG_X_POSITION_PERCENT & bg->mBackgroundFlags) {
1268 valX->SetPercent(bg->mBackgroundXPosition.mFloat);
1270 else {
1271 valX->SetPercent(0.0f);
1274 if (NS_STYLE_BG_Y_POSITION_LENGTH & bg->mBackgroundFlags) {
1275 valY->SetAppUnits(bg->mBackgroundYPosition.mCoord);
1277 else if (NS_STYLE_BG_Y_POSITION_PERCENT & bg->mBackgroundFlags) {
1278 valY->SetPercent(bg->mBackgroundYPosition.mFloat);
1280 else {
1281 valY->SetPercent(0.0f);
1284 return CallQueryInterface(valueList, aValue);
1287 nsresult
1288 nsComputedDOMStyle::GetBackgroundRepeat(nsIDOMCSSValue** aValue)
1290 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1291 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1293 const nsAFlatCString& backgroundRepeat =
1294 nsCSSProps::ValueToKeyword(GetStyleBackground()->mBackgroundRepeat,
1295 nsCSSProps::kBackgroundRepeatKTable);
1296 val->SetIdent(backgroundRepeat);
1298 return CallQueryInterface(val, aValue);
1301 nsresult
1302 nsComputedDOMStyle::GetPadding(nsIDOMCSSValue** aValue)
1304 // return null per spec.
1305 aValue = nsnull;
1307 return NS_OK;
1310 nsresult
1311 nsComputedDOMStyle::GetPaddingTop(nsIDOMCSSValue** aValue)
1313 return GetPaddingWidthFor(NS_SIDE_TOP, aValue);
1316 nsresult
1317 nsComputedDOMStyle::GetPaddingBottom(nsIDOMCSSValue** aValue)
1319 return GetPaddingWidthFor(NS_SIDE_BOTTOM, aValue);
1322 nsresult
1323 nsComputedDOMStyle::GetPaddingLeft(nsIDOMCSSValue** aValue)
1325 return GetPaddingWidthFor(NS_SIDE_LEFT, aValue);
1328 nsresult
1329 nsComputedDOMStyle::GetPaddingRight(nsIDOMCSSValue** aValue)
1331 return GetPaddingWidthFor(NS_SIDE_RIGHT, aValue);
1334 nsresult
1335 nsComputedDOMStyle::GetBorderCollapse(nsIDOMCSSValue** aValue)
1337 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1338 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1340 const nsAFlatCString& ident=
1341 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mBorderCollapse,
1342 nsCSSProps::kBorderCollapseKTable);
1343 val->SetIdent(ident);
1345 return CallQueryInterface(val, aValue);
1348 nsresult
1349 nsComputedDOMStyle::GetBorderSpacing(nsIDOMCSSValue** aValue)
1351 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
1352 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
1354 nsROCSSPrimitiveValue* xSpacing = GetROCSSPrimitiveValue();
1355 if (!xSpacing) {
1356 delete valueList;
1357 return NS_ERROR_OUT_OF_MEMORY;
1359 if (!valueList->AppendCSSValue(xSpacing)) {
1360 delete valueList;
1361 delete xSpacing;
1362 return NS_ERROR_OUT_OF_MEMORY;
1365 nsROCSSPrimitiveValue* ySpacing = GetROCSSPrimitiveValue();
1366 if (!ySpacing) {
1367 delete valueList;
1368 return NS_ERROR_OUT_OF_MEMORY;
1370 if (!valueList->AppendCSSValue(ySpacing)) {
1371 delete valueList;
1372 delete ySpacing;
1373 return NS_ERROR_OUT_OF_MEMORY;
1376 const nsStyleTableBorder *border = GetStyleTableBorder();
1377 xSpacing->SetAppUnits(border->mBorderSpacingX);
1378 ySpacing->SetAppUnits(border->mBorderSpacingY);
1380 return CallQueryInterface(valueList, aValue);
1383 nsresult
1384 nsComputedDOMStyle::GetCaptionSide(nsIDOMCSSValue** aValue)
1386 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1387 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1389 const nsAFlatCString& side =
1390 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mCaptionSide,
1391 nsCSSProps::kCaptionSideKTable);
1392 val->SetIdent(side);
1394 return CallQueryInterface(val, aValue);
1397 nsresult
1398 nsComputedDOMStyle::GetEmptyCells(nsIDOMCSSValue** aValue)
1400 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1401 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1403 const nsAFlatCString& emptyCells =
1404 nsCSSProps::ValueToKeyword(GetStyleTableBorder()->mEmptyCells,
1405 nsCSSProps::kEmptyCellsKTable);
1406 val->SetIdent(emptyCells);
1408 return CallQueryInterface(val, aValue);
1411 nsresult
1412 nsComputedDOMStyle::GetTableLayout(nsIDOMCSSValue** aValue)
1414 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1415 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1417 const nsStyleTable *table = GetStyleTable();
1419 if (table->mLayoutStrategy != NS_STYLE_TABLE_LAYOUT_AUTO) {
1420 const nsAFlatCString& tableLayout =
1421 nsCSSProps::ValueToKeyword(table->mLayoutStrategy,
1422 nsCSSProps::kTableLayoutKTable);
1423 val->SetIdent(tableLayout);
1424 } else {
1425 val->SetIdent(nsGkAtoms::_auto);
1428 return CallQueryInterface(val, aValue);
1431 nsresult
1432 nsComputedDOMStyle::GetBorderStyle(nsIDOMCSSValue** aValue)
1434 // return null per spec.
1435 aValue = nsnull;
1437 return NS_OK;
1440 nsresult
1441 nsComputedDOMStyle::GetBorderTopStyle(nsIDOMCSSValue** aValue)
1443 return GetBorderStyleFor(NS_SIDE_TOP, aValue);
1446 nsresult
1447 nsComputedDOMStyle::GetBorderBottomStyle(nsIDOMCSSValue** aValue)
1449 return GetBorderStyleFor(NS_SIDE_BOTTOM, aValue);
1451 nsresult
1452 nsComputedDOMStyle::GetBorderLeftStyle(nsIDOMCSSValue** aValue)
1454 return GetBorderStyleFor(NS_SIDE_LEFT, aValue);
1457 nsresult
1458 nsComputedDOMStyle::GetBorderRightStyle(nsIDOMCSSValue** aValue)
1460 return GetBorderStyleFor(NS_SIDE_RIGHT, aValue);
1463 nsresult
1464 nsComputedDOMStyle::GetBorderBottomColors(nsIDOMCSSValue** aValue)
1466 return GetBorderColorsFor(NS_SIDE_BOTTOM, aValue);
1469 nsresult
1470 nsComputedDOMStyle::GetBorderLeftColors(nsIDOMCSSValue** aValue)
1472 return GetBorderColorsFor(NS_SIDE_LEFT, aValue);
1475 nsresult
1476 nsComputedDOMStyle::GetBorderRightColors(nsIDOMCSSValue** aValue)
1478 return GetBorderColorsFor(NS_SIDE_RIGHT, aValue);
1482 nsresult
1483 nsComputedDOMStyle::GetBorderTopColors(nsIDOMCSSValue** aValue)
1485 return GetBorderColorsFor(NS_SIDE_TOP, aValue);
1488 nsresult
1489 nsComputedDOMStyle::GetBorderRadiusBottomLeft(nsIDOMCSSValue** aValue)
1491 return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
1492 NS_CORNER_BOTTOM_LEFT, aValue);
1495 nsresult
1496 nsComputedDOMStyle::GetBorderRadiusBottomRight(nsIDOMCSSValue** aValue)
1498 return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
1499 NS_CORNER_BOTTOM_RIGHT, aValue);
1502 nsresult
1503 nsComputedDOMStyle::GetBorderRadiusTopLeft(nsIDOMCSSValue** aValue)
1505 return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
1506 NS_CORNER_TOP_LEFT, aValue);
1509 nsresult
1510 nsComputedDOMStyle::GetBorderRadiusTopRight(nsIDOMCSSValue** aValue)
1512 return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
1513 NS_CORNER_TOP_RIGHT, aValue);
1516 nsresult
1517 nsComputedDOMStyle::GetBorderWidth(nsIDOMCSSValue** aValue)
1519 // return null per spec.
1520 aValue = nsnull;
1522 return NS_OK;
1525 nsresult
1526 nsComputedDOMStyle::GetBorderTopWidth(nsIDOMCSSValue** aValue)
1528 return GetBorderWidthFor(NS_SIDE_TOP, aValue);
1531 nsresult
1532 nsComputedDOMStyle::GetBorderBottomWidth(nsIDOMCSSValue** aValue)
1534 return GetBorderWidthFor(NS_SIDE_BOTTOM, aValue);
1537 nsresult
1538 nsComputedDOMStyle::GetBorderLeftWidth(nsIDOMCSSValue** aValue)
1540 return GetBorderWidthFor(NS_SIDE_LEFT, aValue);
1543 nsresult
1544 nsComputedDOMStyle::GetBorderRightWidth(nsIDOMCSSValue** aValue)
1546 return GetBorderWidthFor(NS_SIDE_RIGHT, aValue);
1549 nsresult
1550 nsComputedDOMStyle::GetBorderTopColor(nsIDOMCSSValue** aValue)
1552 return GetBorderColorFor(NS_SIDE_TOP, aValue);
1555 nsresult
1556 nsComputedDOMStyle::GetBorderBottomColor(nsIDOMCSSValue** aValue)
1558 return GetBorderColorFor(NS_SIDE_BOTTOM, aValue);
1561 nsresult
1562 nsComputedDOMStyle::GetBorderLeftColor(nsIDOMCSSValue** aValue)
1564 return GetBorderColorFor(NS_SIDE_LEFT, aValue);
1567 nsresult
1568 nsComputedDOMStyle::GetBorderRightColor(nsIDOMCSSValue** aValue)
1570 return GetBorderColorFor(NS_SIDE_RIGHT, aValue);
1573 nsresult
1574 nsComputedDOMStyle::GetMarginWidth(nsIDOMCSSValue** aValue)
1576 // return null per spec.
1577 aValue = nsnull;
1579 return NS_OK;
1582 nsresult
1583 nsComputedDOMStyle::GetMarginTopWidth(nsIDOMCSSValue** aValue)
1585 return GetMarginWidthFor(NS_SIDE_TOP, aValue);
1588 nsresult
1589 nsComputedDOMStyle::GetMarginBottomWidth(nsIDOMCSSValue** aValue)
1591 return GetMarginWidthFor(NS_SIDE_BOTTOM, aValue);
1594 nsresult
1595 nsComputedDOMStyle::GetMarginLeftWidth(nsIDOMCSSValue** aValue)
1597 return GetMarginWidthFor(NS_SIDE_LEFT, aValue);
1600 nsresult
1601 nsComputedDOMStyle::GetMarginRightWidth(nsIDOMCSSValue** aValue)
1603 return GetMarginWidthFor(NS_SIDE_RIGHT, aValue);
1606 nsresult
1607 nsComputedDOMStyle::GetMarkerOffset(nsIDOMCSSValue** aValue)
1609 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1610 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1612 SetValueToCoord(val, GetStyleContent()->mMarkerOffset);
1614 return CallQueryInterface(val, aValue);
1617 nsresult
1618 nsComputedDOMStyle::GetOutline(nsIDOMCSSValue** aValue)
1620 // return null per spec.
1621 aValue = nsnull;
1623 return NS_OK;
1626 nsresult
1627 nsComputedDOMStyle::GetOutlineWidth(nsIDOMCSSValue** aValue)
1629 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1630 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1632 const nsStyleOutline* outline = GetStyleOutline();
1634 nsStyleCoord coord;
1635 PRUint8 outlineStyle = outline->GetOutlineStyle();
1636 if (outlineStyle == NS_STYLE_BORDER_STYLE_NONE) {
1637 coord.SetCoordValue(0);
1638 } else {
1639 coord = outline->mOutlineWidth;
1641 SetValueToCoord(val, coord, nsnull, nsCSSProps::kBorderWidthKTable);
1643 return CallQueryInterface(val, aValue);
1646 nsresult
1647 nsComputedDOMStyle::GetOutlineStyle(nsIDOMCSSValue** aValue)
1649 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1650 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1652 PRUint8 outlineStyle = GetStyleOutline()->GetOutlineStyle();
1653 switch (outlineStyle) {
1654 case NS_STYLE_BORDER_STYLE_NONE:
1655 val->SetIdent(nsGkAtoms::none);
1656 break;
1657 case NS_STYLE_BORDER_STYLE_AUTO:
1658 val->SetIdent(nsGkAtoms::_auto);
1659 break;
1660 default:
1661 const nsAFlatCString& style =
1662 nsCSSProps::ValueToKeyword(outlineStyle,
1663 nsCSSProps::kOutlineStyleKTable);
1664 val->SetIdent(style);
1667 return CallQueryInterface(val, aValue);
1670 nsresult
1671 nsComputedDOMStyle::GetOutlineOffset(nsIDOMCSSValue** aValue)
1673 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1674 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1676 val->SetAppUnits(GetStyleOutline()->mOutlineOffset);
1678 return CallQueryInterface(val, aValue);
1681 nsresult
1682 nsComputedDOMStyle::GetOutlineRadiusBottomLeft(nsIDOMCSSValue** aValue)
1684 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
1685 NS_CORNER_BOTTOM_LEFT, aValue);
1688 nsresult
1689 nsComputedDOMStyle::GetOutlineRadiusBottomRight(nsIDOMCSSValue** aValue)
1691 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
1692 NS_CORNER_BOTTOM_RIGHT, aValue);
1695 nsresult
1696 nsComputedDOMStyle::GetOutlineRadiusTopLeft(nsIDOMCSSValue** aValue)
1698 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
1699 NS_CORNER_TOP_LEFT, aValue);
1702 nsresult
1703 nsComputedDOMStyle::GetOutlineRadiusTopRight(nsIDOMCSSValue** aValue)
1705 return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
1706 NS_CORNER_TOP_RIGHT, aValue);
1709 nsresult
1710 nsComputedDOMStyle::GetOutlineColor(nsIDOMCSSValue** aValue)
1712 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1713 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1715 nscolor color;
1716 #ifdef GFX_HAS_INVERT
1717 GetStyleOutline()->GetOutlineColor(color);
1718 #else
1719 if (!GetStyleOutline()->GetOutlineColor(color))
1720 color = GetStyleColor()->mColor;
1721 #endif
1723 nsresult rv = SetToRGBAColor(val, color);
1724 if (NS_FAILED(rv)) {
1725 delete val;
1726 return rv;
1729 return CallQueryInterface(val, aValue);
1732 nsresult
1733 nsComputedDOMStyle::GetEllipseRadii(const nsStyleCorners& aRadius,
1734 PRUint8 aFullCorner,
1735 nsIDOMCSSValue** aValue)
1737 const nsStyleCoord& radiusX
1738 = aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, PR_FALSE));
1739 const nsStyleCoord& radiusY
1740 = aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, PR_TRUE));
1742 // for compatibility, return a single value if X and Y are equal
1743 if (radiusX == radiusY) {
1744 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1745 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1747 SetValueToCoord(val, radiusX,
1748 &nsComputedDOMStyle::GetFrameBorderRectWidth);
1750 return CallQueryInterface(val, aValue);
1751 } else {
1752 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
1753 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
1755 nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
1756 if (!valX || !valueList->AppendCSSValue(valX)) {
1757 delete valX;
1758 delete valueList;
1759 return NS_ERROR_OUT_OF_MEMORY;
1762 nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
1763 if (!valY || !valueList->AppendCSSValue(valY)) {
1764 delete valY;
1765 // valX deleted by valueList destructor
1766 delete valueList;
1767 return NS_ERROR_OUT_OF_MEMORY;
1770 SetValueToCoord(valX, radiusX,
1771 &nsComputedDOMStyle::GetFrameBorderRectWidth);
1772 SetValueToCoord(valY, radiusY,
1773 &nsComputedDOMStyle::GetFrameBorderRectWidth);
1775 return CallQueryInterface(valueList, aValue);
1779 nsresult
1780 nsComputedDOMStyle::GetCSSShadowArray(nsCSSShadowArray* aArray,
1781 const nscolor& aDefaultColor,
1782 PRBool aUsesSpread,
1783 nsIDOMCSSValue** aValue)
1785 if (!aArray) {
1786 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1787 val->SetIdent(nsGkAtoms::none);
1788 return CallQueryInterface(val, aValue);
1791 static nscoord nsCSSShadowItem::* const shadowValuesNoSpread[] = {
1792 &nsCSSShadowItem::mXOffset,
1793 &nsCSSShadowItem::mYOffset,
1794 &nsCSSShadowItem::mRadius
1797 static nscoord nsCSSShadowItem::* const shadowValuesWithSpread[] = {
1798 &nsCSSShadowItem::mXOffset,
1799 &nsCSSShadowItem::mYOffset,
1800 &nsCSSShadowItem::mRadius,
1801 &nsCSSShadowItem::mSpread
1804 nscoord nsCSSShadowItem::* const * shadowValues;
1805 PRUint32 shadowValuesLength;
1806 if (aUsesSpread) {
1807 shadowValues = shadowValuesWithSpread;
1808 shadowValuesLength = NS_ARRAY_LENGTH(shadowValuesWithSpread);
1809 } else {
1810 shadowValues = shadowValuesNoSpread;
1811 shadowValuesLength = NS_ARRAY_LENGTH(shadowValuesNoSpread);
1814 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
1815 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
1817 for (nsCSSShadowItem *item = aArray->ShadowAt(0),
1818 *item_end = item + aArray->Length();
1819 item < item_end; ++item) {
1820 nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
1821 if (!itemList || !valueList->AppendCSSValue(itemList)) {
1822 delete itemList;
1823 delete valueList;
1824 return NS_ERROR_OUT_OF_MEMORY;
1827 // Color is either the specified shadow color or the foreground color
1828 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1829 if (!val || !itemList->AppendCSSValue(val)) {
1830 delete val;
1831 delete valueList;
1832 return NS_ERROR_OUT_OF_MEMORY;
1834 nscolor shadowColor;
1835 if (item->mHasColor) {
1836 shadowColor = item->mColor;
1837 } else {
1838 shadowColor = aDefaultColor;
1840 SetToRGBAColor(val, shadowColor);
1842 // Set the offsets, blur radius, and spread if available
1843 for (PRUint32 i = 0; i < shadowValuesLength; ++i) {
1844 val = GetROCSSPrimitiveValue();
1845 if (!val || !itemList->AppendCSSValue(val)) {
1846 delete val;
1847 delete valueList;
1848 return NS_ERROR_OUT_OF_MEMORY;
1850 val->SetAppUnits(item->*(shadowValues[i]));
1854 return CallQueryInterface(valueList, aValue);
1857 nsresult
1858 nsComputedDOMStyle::GetBoxShadow(nsIDOMCSSValue** aValue)
1860 return GetCSSShadowArray(GetStyleBorder()->mBoxShadow,
1861 GetStyleColor()->mColor,
1862 PR_TRUE, aValue);
1865 nsresult
1866 nsComputedDOMStyle::GetZIndex(nsIDOMCSSValue** aValue)
1868 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1869 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1871 SetValueToCoord(val, GetStylePosition()->mZIndex);
1873 return CallQueryInterface(val, aValue);
1876 nsresult
1877 nsComputedDOMStyle::GetListStyleImage(nsIDOMCSSValue** aValue)
1879 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
1880 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1882 const nsStyleList* list = GetStyleList();
1884 if (!list->mListStyleImage) {
1885 val->SetIdent(nsGkAtoms::none);
1886 } else {
1887 nsCOMPtr<nsIURI> uri;
1888 if (list->mListStyleImage) {
1889 list->mListStyleImage->GetURI(getter_AddRefs(uri));
1891 val->SetURI(uri);
1894 return CallQueryInterface(val, aValue);
1897 nsresult
1898 nsComputedDOMStyle::GetListStylePosition(nsIDOMCSSValue** aValue)
1900 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1901 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1903 const nsAFlatCString& style =
1904 nsCSSProps::ValueToKeyword(GetStyleList()->mListStylePosition,
1905 nsCSSProps::kListStylePositionKTable);
1906 val->SetIdent(style);
1908 return CallQueryInterface(val, aValue);
1911 nsresult
1912 nsComputedDOMStyle::GetListStyleType(nsIDOMCSSValue** aValue)
1914 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1915 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1917 const nsStyleList *list = GetStyleList();
1919 if (list->mListStyleType == NS_STYLE_LIST_STYLE_NONE) {
1920 val->SetIdent(nsGkAtoms::none);
1921 } else {
1922 const nsAFlatCString& style =
1923 nsCSSProps::ValueToKeyword(list->mListStyleType,
1924 nsCSSProps::kListStyleKTable);
1925 val->SetIdent(style);
1928 return CallQueryInterface(val, aValue);
1931 nsresult
1932 nsComputedDOMStyle::GetImageRegion(nsIDOMCSSValue** aValue)
1934 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1935 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1937 const nsStyleList* list = GetStyleList();
1939 nsresult rv = NS_OK;
1940 nsROCSSPrimitiveValue *topVal = nsnull;
1941 nsROCSSPrimitiveValue *rightVal = nsnull;
1942 nsROCSSPrimitiveValue *bottomVal = nsnull;
1943 nsROCSSPrimitiveValue *leftVal = nsnull;
1944 if (list->mImageRegion.width <= 0 || list->mImageRegion.height <= 0) {
1945 val->SetIdent(nsGkAtoms::_auto);
1946 } else {
1947 // create the cssvalues for the sides, stick them in the rect object
1948 topVal = GetROCSSPrimitiveValue();
1949 rightVal = GetROCSSPrimitiveValue();
1950 bottomVal = GetROCSSPrimitiveValue();
1951 leftVal = GetROCSSPrimitiveValue();
1952 if (topVal && rightVal && bottomVal && leftVal) {
1953 nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
1954 bottomVal, leftVal);
1955 if (domRect) {
1956 topVal->SetAppUnits(list->mImageRegion.y);
1957 rightVal->SetAppUnits(list->mImageRegion.width + list->mImageRegion.x);
1958 bottomVal->SetAppUnits(list->mImageRegion.height + list->mImageRegion.y);
1959 leftVal->SetAppUnits(list->mImageRegion.x);
1960 val->SetRect(domRect);
1961 } else {
1962 rv = NS_ERROR_OUT_OF_MEMORY;
1964 } else {
1965 rv = NS_ERROR_OUT_OF_MEMORY;
1969 if (NS_FAILED(rv)) {
1970 delete topVal;
1971 delete rightVal;
1972 delete bottomVal;
1973 delete leftVal;
1974 delete val;
1976 return rv;
1979 return CallQueryInterface(val, aValue);
1982 nsresult
1983 nsComputedDOMStyle::GetLineHeight(nsIDOMCSSValue** aValue)
1985 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1986 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
1988 nscoord lineHeight;
1989 GetLineHeightCoord(lineHeight);
1990 val->SetAppUnits(lineHeight);
1992 return CallQueryInterface(val, aValue);
1995 nsresult
1996 nsComputedDOMStyle::GetVerticalAlign(nsIDOMCSSValue** aValue)
1998 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
1999 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2001 SetValueToCoord(val, GetStyleTextReset()->mVerticalAlign,
2002 &nsComputedDOMStyle::GetLineHeightCoord,
2003 nsCSSProps::kVerticalAlignKTable);
2005 return CallQueryInterface(val, aValue);
2008 nsresult
2009 nsComputedDOMStyle::GetTextAlign(nsIDOMCSSValue** aValue)
2011 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2012 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2014 const nsAFlatCString& align=
2015 nsCSSProps::ValueToKeyword(GetStyleText()->mTextAlign,
2016 nsCSSProps::kTextAlignKTable);
2017 val->SetIdent(align);
2019 return CallQueryInterface(val, aValue);
2022 nsresult
2023 nsComputedDOMStyle::GetTextDecoration(nsIDOMCSSValue** aValue)
2025 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2026 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2028 const nsStyleTextReset* text = GetStyleTextReset();
2030 if (NS_STYLE_TEXT_DECORATION_NONE == text->mTextDecoration) {
2031 const nsAFlatCString& decoration=
2032 nsCSSKeywords::GetStringValue(eCSSKeyword_none);
2033 val->SetIdent(decoration);
2034 } else {
2035 nsAutoString decorationString;
2036 if (text->mTextDecoration & NS_STYLE_TEXT_DECORATION_UNDERLINE) {
2037 const nsAFlatCString& decoration=
2038 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_UNDERLINE,
2039 nsCSSProps::kTextDecorationKTable);
2040 decorationString.AppendWithConversion(decoration.get());
2042 if (text->mTextDecoration & NS_STYLE_TEXT_DECORATION_OVERLINE) {
2043 if (!decorationString.IsEmpty()) {
2044 decorationString.Append(PRUnichar(' '));
2046 const nsAFlatCString& decoration=
2047 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_OVERLINE,
2048 nsCSSProps::kTextDecorationKTable);
2049 decorationString.AppendWithConversion(decoration.get());
2051 if (text->mTextDecoration & NS_STYLE_TEXT_DECORATION_LINE_THROUGH) {
2052 if (!decorationString.IsEmpty()) {
2053 decorationString.Append(PRUnichar(' '));
2055 const nsAFlatCString& decoration=
2056 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
2057 nsCSSProps::kTextDecorationKTable);
2058 decorationString.AppendWithConversion(decoration.get());
2060 if (text->mTextDecoration & NS_STYLE_TEXT_DECORATION_BLINK) {
2061 if (!decorationString.IsEmpty()) {
2062 decorationString.Append(PRUnichar(' '));
2064 const nsAFlatCString& decoration=
2065 nsCSSProps::ValueToKeyword(NS_STYLE_TEXT_DECORATION_BLINK,
2066 nsCSSProps::kTextDecorationKTable);
2067 decorationString.AppendWithConversion(decoration.get());
2069 val->SetString(decorationString);
2072 return CallQueryInterface(val, aValue);
2075 nsresult
2076 nsComputedDOMStyle::GetTextIndent(nsIDOMCSSValue** aValue)
2078 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2079 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2081 SetValueToCoord(val, GetStyleText()->mTextIndent,
2082 &nsComputedDOMStyle::GetCBContentWidth);
2084 return CallQueryInterface(val, aValue);
2087 nsresult
2088 nsComputedDOMStyle::GetTextShadow(nsIDOMCSSValue** aValue)
2090 return GetCSSShadowArray(GetStyleText()->mTextShadow,
2091 GetStyleColor()->mColor,
2092 PR_FALSE, aValue);
2095 nsresult
2096 nsComputedDOMStyle::GetTextTransform(nsIDOMCSSValue** aValue)
2098 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2099 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2101 const nsStyleText *text = GetStyleText();
2103 if (text->mTextTransform != NS_STYLE_TEXT_TRANSFORM_NONE) {
2104 const nsAFlatCString& textTransform =
2105 nsCSSProps::ValueToKeyword(text->mTextTransform,
2106 nsCSSProps::kTextTransformKTable);
2107 val->SetIdent(textTransform);
2108 } else {
2109 val->SetIdent(nsGkAtoms::none);
2112 return CallQueryInterface(val, aValue);
2115 nsresult
2116 nsComputedDOMStyle::GetLetterSpacing(nsIDOMCSSValue** aValue)
2118 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2119 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2121 SetValueToCoord(val, GetStyleText()->mLetterSpacing);
2123 return CallQueryInterface(val, aValue);
2126 nsresult
2127 nsComputedDOMStyle::GetWordSpacing(nsIDOMCSSValue** aValue)
2129 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2130 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2132 SetValueToCoord(val, GetStyleText()->mWordSpacing);
2134 return CallQueryInterface(val, aValue);
2137 nsresult
2138 nsComputedDOMStyle::GetWhiteSpace(nsIDOMCSSValue** aValue)
2140 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2141 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2143 const nsStyleText *text = GetStyleText();
2145 if (text->mWhiteSpace != NS_STYLE_WHITESPACE_NORMAL) {
2146 const nsAFlatCString& whiteSpace =
2147 nsCSSProps::ValueToKeyword(text->mWhiteSpace,
2148 nsCSSProps::kWhitespaceKTable);
2149 val->SetIdent(whiteSpace);
2150 } else {
2151 val->SetIdent(nsGkAtoms::normal);
2154 return CallQueryInterface(val, aValue);
2157 nsresult
2158 nsComputedDOMStyle::GetWindowShadow(nsIDOMCSSValue** aValue)
2160 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2161 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2163 const nsStyleUIReset *uiData = GetStyleUIReset();
2165 if (uiData->mWindowShadow != NS_STYLE_WINDOW_SHADOW_NONE) {
2166 const nsAFlatCString& windowShadow =
2167 nsCSSProps::ValueToKeyword(uiData->mWindowShadow,
2168 nsCSSProps::kWindowShadowKTable);
2169 val->SetIdent(windowShadow);
2170 } else {
2171 val->SetIdent(nsGkAtoms::none);
2174 return CallQueryInterface(val, aValue);
2178 nsresult
2179 nsComputedDOMStyle::GetWordWrap(nsIDOMCSSValue** aValue)
2181 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2182 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2184 const nsStyleText *text = GetStyleText();
2186 if (text->mWordWrap != NS_STYLE_WORDWRAP_NORMAL) {
2187 const nsAFlatCString& wordWrap =
2188 nsCSSProps::ValueToKeyword(text->mWordWrap,
2189 nsCSSProps::kWordwrapKTable);
2190 val->SetIdent(wordWrap);
2191 } else {
2192 val->SetIdent(nsGkAtoms::normal);
2195 return CallQueryInterface(val, aValue);
2198 nsresult
2199 nsComputedDOMStyle::GetVisibility(nsIDOMCSSValue** aValue)
2201 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2202 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2204 const nsAFlatCString& value=
2205 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mVisible,
2206 nsCSSProps::kVisibilityKTable);
2207 val->SetIdent(value);
2209 return CallQueryInterface(val, aValue);
2212 nsresult
2213 nsComputedDOMStyle::GetDirection(nsIDOMCSSValue** aValue)
2215 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2216 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2218 const nsAFlatCString & direction =
2219 nsCSSProps::ValueToKeyword(GetStyleVisibility()->mDirection,
2220 nsCSSProps::kDirectionKTable);
2221 val->SetIdent(direction);
2223 return CallQueryInterface(val, aValue);
2226 nsresult
2227 nsComputedDOMStyle::GetUnicodeBidi(nsIDOMCSSValue** aValue)
2229 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2230 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2232 const nsStyleTextReset *text = GetStyleTextReset();
2234 if (text->mUnicodeBidi != NS_STYLE_UNICODE_BIDI_NORMAL) {
2235 const nsAFlatCString& bidi =
2236 nsCSSProps::ValueToKeyword(text->mUnicodeBidi,
2237 nsCSSProps::kUnicodeBidiKTable);
2238 val->SetIdent(bidi);
2239 } else {
2240 val->SetIdent(nsGkAtoms::normal);
2243 return CallQueryInterface(val, aValue);
2246 nsresult
2247 nsComputedDOMStyle::GetCursor(nsIDOMCSSValue** aValue)
2249 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
2250 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
2252 const nsStyleUserInterface *ui = GetStyleUserInterface();
2254 for (nsCursorImage *item = ui->mCursorArray,
2255 *item_end = ui->mCursorArray + ui->mCursorArrayLength;
2256 item < item_end; ++item) {
2257 nsDOMCSSValueList *itemList = GetROCSSValueList(PR_FALSE);
2258 if (!itemList || !valueList->AppendCSSValue(itemList)) {
2259 delete itemList;
2260 delete valueList;
2261 return NS_ERROR_OUT_OF_MEMORY;
2264 nsCOMPtr<nsIURI> uri;
2265 item->mImage->GetURI(getter_AddRefs(uri));
2267 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2268 if (!val || !itemList->AppendCSSValue(val)) {
2269 delete val;
2270 delete valueList;
2271 return NS_ERROR_OUT_OF_MEMORY;
2273 val->SetURI(uri);
2275 if (item->mHaveHotspot) {
2276 nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
2277 if (!valX || !itemList->AppendCSSValue(valX)) {
2278 delete valX;
2279 delete valueList;
2280 return NS_ERROR_OUT_OF_MEMORY;
2282 nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
2283 if (!valY || !itemList->AppendCSSValue(valY)) {
2284 delete valY;
2285 delete valueList;
2286 return NS_ERROR_OUT_OF_MEMORY;
2289 valX->SetNumber(item->mHotspotX);
2290 valY->SetNumber(item->mHotspotY);
2294 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2295 if (!val) {
2296 delete valueList;
2297 return NS_ERROR_OUT_OF_MEMORY;
2300 if (ui->mCursor == NS_STYLE_CURSOR_AUTO) {
2301 val->SetIdent(nsGkAtoms::_auto);
2302 } else {
2303 const nsAFlatCString& cursor =
2304 nsCSSProps::ValueToKeyword(ui->mCursor,
2305 nsCSSProps::kCursorKTable);
2306 val->SetIdent(cursor);
2308 if (!valueList->AppendCSSValue(val)) {
2309 delete valueList;
2310 delete val;
2311 return NS_ERROR_OUT_OF_MEMORY;
2314 return CallQueryInterface(valueList, aValue);
2317 nsresult
2318 nsComputedDOMStyle::GetAppearance(nsIDOMCSSValue** aValue)
2320 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2321 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2323 const nsAFlatCString& appearanceIdent =
2324 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mAppearance,
2325 nsCSSProps::kAppearanceKTable);
2326 val->SetIdent(appearanceIdent);
2328 return CallQueryInterface(val, aValue);
2332 nsresult
2333 nsComputedDOMStyle::GetBoxAlign(nsIDOMCSSValue** aValue)
2335 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2336 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2338 const nsAFlatCString& boxAlignIdent =
2339 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxAlign,
2340 nsCSSProps::kBoxAlignKTable);
2341 val->SetIdent(boxAlignIdent);
2343 return CallQueryInterface(val, aValue);
2346 nsresult
2347 nsComputedDOMStyle::GetBoxDirection(nsIDOMCSSValue** aValue)
2349 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2350 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2352 const nsAFlatCString& boxDirectionIdent =
2353 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxDirection,
2354 nsCSSProps::kBoxDirectionKTable);
2355 val->SetIdent(boxDirectionIdent);
2357 return CallQueryInterface(val, aValue);
2360 nsresult
2361 nsComputedDOMStyle::GetBoxFlex(nsIDOMCSSValue** aValue)
2363 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2364 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2366 val->SetNumber(GetStyleXUL()->mBoxFlex);
2368 return CallQueryInterface(val, aValue);
2371 nsresult
2372 nsComputedDOMStyle::GetBoxOrdinalGroup(nsIDOMCSSValue** aValue)
2374 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2375 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2377 val->SetNumber(GetStyleXUL()->mBoxOrdinal);
2379 return CallQueryInterface(val, aValue);
2382 nsresult
2383 nsComputedDOMStyle::GetBoxOrient(nsIDOMCSSValue** aValue)
2385 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2386 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2388 const nsAFlatCString& boxOrientIdent =
2389 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxOrient,
2390 nsCSSProps::kBoxOrientKTable);
2391 val->SetIdent(boxOrientIdent);
2393 return CallQueryInterface(val, aValue);
2396 nsresult
2397 nsComputedDOMStyle::GetBoxPack(nsIDOMCSSValue** aValue)
2399 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2400 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2402 const nsAFlatCString& boxPackIdent =
2403 nsCSSProps::ValueToKeyword(GetStyleXUL()->mBoxPack,
2404 nsCSSProps::kBoxPackKTable);
2405 val->SetIdent(boxPackIdent);
2407 return CallQueryInterface(val, aValue);
2410 nsresult
2411 nsComputedDOMStyle::GetBoxSizing(nsIDOMCSSValue** aValue)
2413 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2414 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2416 const nsAFlatCString& boxSizingIdent =
2417 nsCSSProps::ValueToKeyword(GetStylePosition()->mBoxSizing,
2418 nsCSSProps::kBoxSizingKTable);
2419 val->SetIdent(boxSizingIdent);
2421 return CallQueryInterface(val, aValue);
2424 nsresult
2425 nsComputedDOMStyle::GetBorderImage(nsIDOMCSSValue** aValue)
2427 const nsStyleBorder* border = GetStyleBorder();
2429 // none
2430 if (!border->GetBorderImage()) {
2431 nsROCSSPrimitiveValue *valNone = GetROCSSPrimitiveValue();
2432 NS_ENSURE_TRUE(valNone, NS_ERROR_OUT_OF_MEMORY);
2433 valNone->SetIdent(nsGkAtoms::none);
2434 return CallQueryInterface(valNone, aValue);
2437 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
2438 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
2440 // uri
2441 nsROCSSPrimitiveValue *valURI = GetROCSSPrimitiveValue();
2442 if (!valURI || !valueList->AppendCSSValue(valURI)) {
2443 delete valURI;
2444 delete valueList;
2445 return NS_ERROR_OUT_OF_MEMORY;
2447 nsCOMPtr<nsIURI> uri;
2448 border->GetBorderImage()->GetURI(getter_AddRefs(uri));
2449 valURI->SetURI(uri);
2451 // four split numbers
2452 NS_FOR_CSS_SIDES(side) {
2453 nsROCSSPrimitiveValue *valSplit = GetROCSSPrimitiveValue();
2454 if (!valSplit || !valueList->AppendCSSValue(valSplit)) {
2455 delete valSplit;
2456 delete valueList;
2457 return NS_ERROR_OUT_OF_MEMORY;
2459 SetValueToCoord(valSplit, border->mBorderImageSplit.Get(side), nsnull,
2460 nsnull);
2463 // copy of border-width
2464 if (border->mHaveBorderImageWidth) {
2465 nsROCSSPrimitiveValue *slash = GetROCSSPrimitiveValue();
2466 if (!slash || !valueList->AppendCSSValue(slash)) {
2467 delete slash;
2468 delete valueList;
2469 return NS_ERROR_OUT_OF_MEMORY;
2471 slash->SetString(NS_LITERAL_STRING("/"));
2472 NS_FOR_CSS_SIDES(side) {
2473 nsROCSSPrimitiveValue *borderWidth = GetROCSSPrimitiveValue();
2474 if (!borderWidth || !valueList->AppendCSSValue(borderWidth)) {
2475 delete borderWidth;
2476 delete valueList;
2477 return NS_ERROR_OUT_OF_MEMORY;
2479 nscoord width = GetStyleBorder()->mBorderImageWidth.side(side);
2480 borderWidth->SetAppUnits(width);
2484 // first keyword
2485 nsROCSSPrimitiveValue *keyword = GetROCSSPrimitiveValue();
2486 if (!keyword || !valueList->AppendCSSValue(keyword)) {
2487 delete keyword;
2488 delete valueList;
2489 return NS_ERROR_OUT_OF_MEMORY;
2491 const nsAFlatCString& borderImageIdent =
2492 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageHFill,
2493 nsCSSProps::kBorderImageKTable);
2494 keyword->SetIdent(borderImageIdent);
2496 // second keyword
2497 nsROCSSPrimitiveValue *keyword2 = GetROCSSPrimitiveValue();
2498 if (!keyword2 || !valueList->AppendCSSValue(keyword2)) {
2499 delete keyword2;
2500 delete valueList;
2501 return NS_ERROR_OUT_OF_MEMORY;
2503 const nsAFlatCString& borderImageIdent2 =
2504 nsCSSProps::ValueToKeyword(GetStyleBorder()->mBorderImageVFill,
2505 nsCSSProps::kBorderImageKTable);
2506 keyword2->SetIdent(borderImageIdent2);
2508 return CallQueryInterface(valueList, aValue);
2511 nsresult
2512 nsComputedDOMStyle::GetFloatEdge(nsIDOMCSSValue** aValue)
2514 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2515 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2517 const nsAFlatCString& floatEdgeIdent =
2518 nsCSSProps::ValueToKeyword(GetStyleBorder()->mFloatEdge,
2519 nsCSSProps::kFloatEdgeKTable);
2520 val->SetIdent(floatEdgeIdent);
2522 return CallQueryInterface(val, aValue);
2525 nsresult
2526 nsComputedDOMStyle::GetForceBrokenImageIcon(nsIDOMCSSValue** aValue)
2528 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2529 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2531 val->SetNumber(GetStyleUIReset()->mForceBrokenImageIcon);
2533 return CallQueryInterface(val, aValue);
2536 nsresult
2537 nsComputedDOMStyle::GetIMEMode(nsIDOMCSSValue** aValue)
2539 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2540 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2542 const nsStyleUIReset *uiData = GetStyleUIReset();
2544 nsCSSKeyword keyword;
2545 if (uiData->mIMEMode == NS_STYLE_IME_MODE_AUTO) {
2546 keyword = eCSSKeyword_auto;
2547 } else if (uiData->mIMEMode == NS_STYLE_IME_MODE_NORMAL) {
2548 keyword = eCSSKeyword_normal;
2549 } else {
2550 keyword = nsCSSProps::ValueToKeywordEnum(uiData->mIMEMode,
2551 nsCSSProps::kIMEModeKTable);
2553 val->SetIdent(nsCSSKeywords::GetStringValue(keyword));
2555 return CallQueryInterface(val, aValue);
2558 nsresult
2559 nsComputedDOMStyle::GetUserFocus(nsIDOMCSSValue** aValue)
2561 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2562 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2564 const nsStyleUserInterface *uiData = GetStyleUserInterface();
2566 if (uiData->mUserFocus != NS_STYLE_USER_FOCUS_NONE) {
2567 if (uiData->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL) {
2568 const nsAFlatCString& userFocusIdent =
2569 nsCSSKeywords::GetStringValue(eCSSKeyword_normal);
2570 val->SetIdent(userFocusIdent);
2571 } else {
2572 const nsAFlatCString& userFocusIdent =
2573 nsCSSProps::ValueToKeyword(uiData->mUserFocus,
2574 nsCSSProps::kUserFocusKTable);
2575 val->SetIdent(userFocusIdent);
2577 } else {
2578 const nsAFlatCString& userFocusIdent =
2579 nsCSSKeywords::GetStringValue(eCSSKeyword_none);
2580 val->SetIdent(userFocusIdent);
2583 return CallQueryInterface(val, aValue);
2586 nsresult
2587 nsComputedDOMStyle::GetUserInput(nsIDOMCSSValue** aValue)
2589 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2590 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2592 const nsStyleUserInterface *uiData = GetStyleUserInterface();
2594 if (uiData->mUserInput != NS_STYLE_USER_INPUT_AUTO) {
2595 if (uiData->mUserInput == NS_STYLE_USER_INPUT_NONE) {
2596 const nsAFlatCString& userInputIdent =
2597 nsCSSKeywords::GetStringValue(eCSSKeyword_none);
2598 val->SetIdent(userInputIdent);
2599 } else {
2600 const nsAFlatCString& userInputIdent =
2601 nsCSSProps::ValueToKeyword(uiData->mUserInput,
2602 nsCSSProps::kUserInputKTable);
2603 val->SetIdent(userInputIdent);
2605 } else {
2606 const nsAFlatCString& userInputIdent =
2607 nsCSSKeywords::GetStringValue(eCSSKeyword_auto);
2608 val->SetIdent(userInputIdent);
2611 return CallQueryInterface(val, aValue);
2614 nsresult
2615 nsComputedDOMStyle::GetUserModify(nsIDOMCSSValue** aValue)
2617 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2618 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2620 const nsAFlatCString& userModifyIdent =
2621 nsCSSProps::ValueToKeyword(GetStyleUserInterface()->mUserModify,
2622 nsCSSProps::kUserModifyKTable);
2623 val->SetIdent(userModifyIdent);
2625 return CallQueryInterface(val, aValue);
2628 nsresult
2629 nsComputedDOMStyle::GetUserSelect(nsIDOMCSSValue** aValue)
2631 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2632 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2634 const nsStyleUIReset *uiData = GetStyleUIReset();
2636 if (uiData->mUserSelect != NS_STYLE_USER_SELECT_AUTO) {
2637 if (uiData->mUserSelect == NS_STYLE_USER_SELECT_NONE) {
2638 const nsAFlatCString& userSelectIdent =
2639 nsCSSKeywords::GetStringValue(eCSSKeyword_none);
2640 val->SetIdent(userSelectIdent);
2641 } else {
2642 const nsAFlatCString& userSelectIdent =
2643 nsCSSProps::ValueToKeyword(uiData->mUserSelect,
2644 nsCSSProps::kUserSelectKTable);
2645 val->SetIdent(userSelectIdent);
2647 } else {
2648 const nsAFlatCString& userSelectIdent =
2649 nsCSSKeywords::GetStringValue(eCSSKeyword_auto);
2650 val->SetIdent(userSelectIdent);
2653 return CallQueryInterface(val, aValue);
2656 nsresult
2657 nsComputedDOMStyle::GetDisplay(nsIDOMCSSValue** aValue)
2659 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2660 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2662 const nsStyleDisplay *displayData = GetStyleDisplay();
2664 if (displayData->mDisplay == NS_STYLE_DISPLAY_NONE) {
2665 val->SetIdent(nsGkAtoms::none);
2666 } else {
2667 const nsAFlatCString& display =
2668 nsCSSProps::ValueToKeyword(displayData->mDisplay,
2669 nsCSSProps::kDisplayKTable);
2670 val->SetIdent(display);
2673 return CallQueryInterface(val, aValue);
2676 nsresult
2677 nsComputedDOMStyle::GetPosition(nsIDOMCSSValue** aValue)
2679 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2680 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2682 const nsAFlatCString& position =
2683 nsCSSProps::ValueToKeyword(GetStyleDisplay()->mPosition,
2684 nsCSSProps::kPositionKTable);
2685 val->SetIdent(position);
2687 return CallQueryInterface(val, aValue);
2690 nsresult
2691 nsComputedDOMStyle::GetClip(nsIDOMCSSValue** aValue)
2693 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2694 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2696 const nsStyleDisplay* display = GetStyleDisplay();
2698 nsresult rv = NS_OK;
2699 nsROCSSPrimitiveValue *topVal = nsnull;
2700 nsROCSSPrimitiveValue *rightVal = nsnull;
2701 nsROCSSPrimitiveValue *bottomVal = nsnull;
2702 nsROCSSPrimitiveValue *leftVal = nsnull;
2703 if (display->mClipFlags == NS_STYLE_CLIP_AUTO ||
2704 display->mClipFlags == (NS_STYLE_CLIP_TOP_AUTO |
2705 NS_STYLE_CLIP_RIGHT_AUTO |
2706 NS_STYLE_CLIP_BOTTOM_AUTO |
2707 NS_STYLE_CLIP_LEFT_AUTO)) {
2708 val->SetIdent(nsGkAtoms::_auto);
2709 } else {
2710 // create the cssvalues for the sides, stick them in the rect object
2711 topVal = GetROCSSPrimitiveValue();
2712 rightVal = GetROCSSPrimitiveValue();
2713 bottomVal = GetROCSSPrimitiveValue();
2714 leftVal = GetROCSSPrimitiveValue();
2715 if (topVal && rightVal && bottomVal && leftVal) {
2716 nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
2717 bottomVal, leftVal);
2718 if (domRect) {
2719 if (display->mClipFlags & NS_STYLE_CLIP_TOP_AUTO) {
2720 topVal->SetIdent(nsGkAtoms::_auto);
2721 } else {
2722 topVal->SetAppUnits(display->mClip.y);
2725 if (display->mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO) {
2726 rightVal->SetIdent(nsGkAtoms::_auto);
2727 } else {
2728 rightVal->SetAppUnits(display->mClip.width + display->mClip.x);
2731 if (display->mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO) {
2732 bottomVal->SetIdent(nsGkAtoms::_auto);
2733 } else {
2734 bottomVal->SetAppUnits(display->mClip.height + display->mClip.y);
2737 if (display->mClipFlags & NS_STYLE_CLIP_LEFT_AUTO) {
2738 leftVal->SetIdent(nsGkAtoms::_auto);
2739 } else {
2740 leftVal->SetAppUnits(display->mClip.x);
2743 val->SetRect(domRect);
2744 } else {
2745 rv = NS_ERROR_OUT_OF_MEMORY;
2747 } else {
2748 rv = NS_ERROR_OUT_OF_MEMORY;
2752 if (NS_FAILED(rv)) {
2753 delete topVal;
2754 delete rightVal;
2755 delete bottomVal;
2756 delete leftVal;
2757 delete val;
2759 return rv;
2762 return CallQueryInterface(val, aValue);
2765 nsresult
2766 nsComputedDOMStyle::GetOverflow(nsIDOMCSSValue** aValue)
2768 const nsStyleDisplay* display = GetStyleDisplay();
2770 if (display->mOverflowX != display->mOverflowY) {
2771 // No value to return. We can't express this combination of
2772 // values as a shorthand.
2773 *aValue = nsnull;
2774 return NS_OK;
2777 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2778 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2780 if (display->mOverflowX != NS_STYLE_OVERFLOW_AUTO) {
2781 const nsAFlatCString& overflow =
2782 nsCSSProps::ValueToKeyword(display->mOverflowX,
2783 nsCSSProps::kOverflowKTable);
2784 val->SetIdent(overflow);
2785 } else {
2786 val->SetIdent(nsGkAtoms::_auto);
2789 return CallQueryInterface(val, aValue);
2792 nsresult
2793 nsComputedDOMStyle::GetOverflowX(nsIDOMCSSValue** aValue)
2795 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2796 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2798 const nsStyleDisplay* display = GetStyleDisplay();
2800 if (display->mOverflowX != NS_STYLE_OVERFLOW_AUTO) {
2801 const nsAFlatCString& overflow =
2802 nsCSSProps::ValueToKeyword(display->mOverflowX,
2803 nsCSSProps::kOverflowSubKTable);
2804 val->SetIdent(overflow);
2805 } else {
2806 val->SetIdent(nsGkAtoms::_auto);
2809 return CallQueryInterface(val, aValue);
2812 nsresult
2813 nsComputedDOMStyle::GetOverflowY(nsIDOMCSSValue** aValue)
2815 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
2816 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2818 const nsStyleDisplay* display = GetStyleDisplay();
2820 if (display->mOverflowY != NS_STYLE_OVERFLOW_AUTO) {
2821 const nsAFlatCString& overflow =
2822 nsCSSProps::ValueToKeyword(display->mOverflowY,
2823 nsCSSProps::kOverflowSubKTable);
2824 val->SetIdent(overflow);
2825 } else {
2826 val->SetIdent(nsGkAtoms::_auto);
2829 return CallQueryInterface(val, aValue);
2832 nsresult
2833 nsComputedDOMStyle::GetPageBreakAfter(nsIDOMCSSValue** aValue)
2835 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2836 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2838 const nsStyleDisplay *display = GetStyleDisplay();
2840 if (display->mBreakAfter) {
2841 val->SetIdent(nsGkAtoms::always);
2842 } else {
2843 val->SetIdent(nsGkAtoms::_auto);
2846 return CallQueryInterface(val, aValue);
2849 nsresult
2850 nsComputedDOMStyle::GetPageBreakBefore(nsIDOMCSSValue** aValue)
2852 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2853 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2855 const nsStyleDisplay *display = GetStyleDisplay();
2857 if (display->mBreakBefore) {
2858 val->SetIdent(nsGkAtoms::always);
2859 } else {
2860 val->SetIdent(nsGkAtoms::_auto);
2863 return CallQueryInterface(val, aValue);
2866 nsresult
2867 nsComputedDOMStyle::GetHeight(nsIDOMCSSValue** aValue)
2869 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2870 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2872 PRBool calcHeight = PR_FALSE;
2874 if (mInnerFrame) {
2875 calcHeight = PR_TRUE;
2877 const nsStyleDisplay* displayData = GetStyleDisplay();
2878 if (displayData->mDisplay == NS_STYLE_DISPLAY_INLINE &&
2879 !(mInnerFrame->IsFrameOfType(nsIFrame::eReplaced))) {
2880 calcHeight = PR_FALSE;
2884 if (calcHeight) {
2885 FlushPendingReflows();
2887 val->SetAppUnits(mInnerFrame->GetContentRect().height);
2888 } else {
2889 const nsStylePosition *positionData = GetStylePosition();
2891 nscoord minHeight =
2892 StyleCoordToNSCoord(positionData->mMinHeight,
2893 &nsComputedDOMStyle::GetCBContentHeight, 0);
2895 nscoord maxHeight =
2896 StyleCoordToNSCoord(positionData->mMaxHeight,
2897 &nsComputedDOMStyle::GetCBContentHeight,
2898 nscoord_MAX);
2900 SetValueToCoord(val, positionData->mHeight, nsnull, nsnull,
2901 minHeight, maxHeight);
2904 return CallQueryInterface(val, aValue);
2907 nsresult
2908 nsComputedDOMStyle::GetWidth(nsIDOMCSSValue** aValue)
2910 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2911 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2913 PRBool calcWidth = PR_FALSE;
2915 if (mInnerFrame) {
2916 calcWidth = PR_TRUE;
2918 const nsStyleDisplay *displayData = GetStyleDisplay();
2919 if (displayData->mDisplay == NS_STYLE_DISPLAY_INLINE &&
2920 !(mInnerFrame->IsFrameOfType(nsIFrame::eReplaced))) {
2921 calcWidth = PR_FALSE;
2925 if (calcWidth) {
2926 FlushPendingReflows();
2928 val->SetAppUnits(mInnerFrame->GetContentRect().width);
2929 } else {
2930 const nsStylePosition *positionData = GetStylePosition();
2932 nscoord minWidth =
2933 StyleCoordToNSCoord(positionData->mMinWidth,
2934 &nsComputedDOMStyle::GetCBContentWidth, 0);
2936 nscoord maxWidth =
2937 StyleCoordToNSCoord(positionData->mMaxWidth,
2938 &nsComputedDOMStyle::GetCBContentWidth,
2939 nscoord_MAX);
2941 SetValueToCoord(val, positionData->mWidth, nsnull,
2942 nsCSSProps::kWidthKTable, minWidth, maxWidth);
2945 return CallQueryInterface(val, aValue);
2948 nsresult
2949 nsComputedDOMStyle::GetMaxHeight(nsIDOMCSSValue** aValue)
2951 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2952 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2954 SetValueToCoord(val, GetStylePosition()->mMaxHeight,
2955 &nsComputedDOMStyle::GetCBContentHeight);
2957 return CallQueryInterface(val, aValue);
2960 nsresult
2961 nsComputedDOMStyle::GetMaxWidth(nsIDOMCSSValue** aValue)
2963 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2964 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2966 SetValueToCoord(val, GetStylePosition()->mMaxWidth,
2967 &nsComputedDOMStyle::GetCBContentWidth,
2968 nsCSSProps::kWidthKTable);
2970 return CallQueryInterface(val, aValue);
2973 nsresult
2974 nsComputedDOMStyle::GetMinHeight(nsIDOMCSSValue** aValue)
2976 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2977 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2979 SetValueToCoord(val, GetStylePosition()->mMinHeight,
2980 &nsComputedDOMStyle::GetCBContentHeight);
2982 return CallQueryInterface(val, aValue);
2985 nsresult
2986 nsComputedDOMStyle::GetMinWidth(nsIDOMCSSValue** aValue)
2988 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
2989 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
2991 SetValueToCoord(val, GetStylePosition()->mMinWidth,
2992 &nsComputedDOMStyle::GetCBContentWidth,
2993 nsCSSProps::kWidthKTable);
2995 return CallQueryInterface(val, aValue);
2998 nsresult
2999 nsComputedDOMStyle::GetLeft(nsIDOMCSSValue** aValue)
3001 return GetOffsetWidthFor(NS_SIDE_LEFT, aValue);
3004 nsresult
3005 nsComputedDOMStyle::GetRight(nsIDOMCSSValue** aValue)
3007 return GetOffsetWidthFor(NS_SIDE_RIGHT, aValue);
3010 nsresult
3011 nsComputedDOMStyle::GetTop(nsIDOMCSSValue** aValue)
3013 return GetOffsetWidthFor(NS_SIDE_TOP, aValue);
3016 nsROCSSPrimitiveValue*
3017 nsComputedDOMStyle::GetROCSSPrimitiveValue()
3019 nsROCSSPrimitiveValue *primitiveValue = new nsROCSSPrimitiveValue(mAppUnitsPerInch);
3021 NS_ASSERTION(primitiveValue != 0, "ran out of memory");
3023 return primitiveValue;
3026 nsDOMCSSValueList*
3027 nsComputedDOMStyle::GetROCSSValueList(PRBool aCommaDelimited)
3029 nsDOMCSSValueList *valueList = new nsDOMCSSValueList(aCommaDelimited,
3030 PR_TRUE);
3031 NS_ASSERTION(valueList != 0, "ran out of memory");
3033 return valueList;
3036 nsresult
3037 nsComputedDOMStyle::GetOffsetWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3039 const nsStyleDisplay* display = GetStyleDisplay();
3041 FlushPendingReflows();
3043 nsresult rv = NS_OK;
3044 switch (display->mPosition) {
3045 case NS_STYLE_POSITION_STATIC:
3046 rv = GetStaticOffset(aSide, aValue);
3047 break;
3048 case NS_STYLE_POSITION_RELATIVE:
3049 rv = GetRelativeOffset(aSide, aValue);
3050 break;
3051 case NS_STYLE_POSITION_ABSOLUTE:
3052 case NS_STYLE_POSITION_FIXED:
3053 rv = GetAbsoluteOffset(aSide, aValue);
3054 break;
3055 default:
3056 NS_ERROR("Invalid position");
3057 break;
3060 return rv;
3063 nsresult
3064 nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
3066 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3067 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3069 nsIFrame* container = GetContainingBlockFor(mOuterFrame);
3070 if (container) {
3071 nsMargin margin = mOuterFrame->GetUsedMargin();
3072 nsMargin border = container->GetUsedBorder();
3073 nsMargin scrollbarSizes(0, 0, 0, 0);
3074 nsRect rect = mOuterFrame->GetRect();
3075 nsRect containerRect = container->GetRect();
3077 if (container->GetType() == nsGkAtoms::viewportFrame) {
3078 // For absolutely positioned frames scrollbars are taken into
3079 // account by virtue of getting a containing block that does
3080 // _not_ include the scrollbars. For fixed positioned frames,
3081 // the containing block is the viewport, which _does_ include
3082 // scrollbars. We have to do some extra work.
3083 // the first child in the default frame list is what we want
3084 nsIFrame* scrollingChild = container->GetFirstChild(nsnull);
3085 nsCOMPtr<nsIScrollableFrame> scrollFrame =
3086 do_QueryInterface(scrollingChild);
3087 if (scrollFrame) {
3088 scrollbarSizes = scrollFrame->GetActualScrollbarSizes();
3092 nscoord offset = 0;
3093 switch (aSide) {
3094 case NS_SIDE_TOP:
3095 offset = rect.y - margin.top - border.top - scrollbarSizes.top;
3097 break;
3098 case NS_SIDE_RIGHT:
3099 offset = containerRect.width - rect.width -
3100 rect.x - margin.right - border.right - scrollbarSizes.right;
3102 break;
3103 case NS_SIDE_BOTTOM:
3104 offset = containerRect.height - rect.height -
3105 rect.y - margin.bottom - border.bottom - scrollbarSizes.bottom;
3107 break;
3108 case NS_SIDE_LEFT:
3109 offset = rect.x - margin.left - border.left - scrollbarSizes.left;
3111 break;
3112 default:
3113 NS_ERROR("Invalid side");
3114 break;
3116 val->SetAppUnits(offset);
3117 } else {
3118 // XXX no frame. This property makes no sense
3119 val->SetAppUnits(0);
3122 return CallQueryInterface(val, aValue);
3126 #if (NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3)
3127 #define NS_OPPOSITE_SIDE(s_) (((s_) + 2) & 3)
3128 #else
3129 #error "Somebody changed the side constants."
3130 #endif
3132 nsresult
3133 nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
3135 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3136 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3138 const nsStylePosition* positionData = GetStylePosition();
3139 PRInt32 sign = 1;
3140 nsStyleCoord coord = positionData->mOffset.Get(aSide);
3142 NS_ASSERTION(coord.GetUnit() == eStyleUnit_Coord ||
3143 coord.GetUnit() == eStyleUnit_Percent ||
3144 coord.GetUnit() == eStyleUnit_Auto,
3145 "Unexpected unit");
3147 if (coord.GetUnit() == eStyleUnit_Auto) {
3148 coord = positionData->mOffset.Get(NS_OPPOSITE_SIDE(aSide));
3149 sign = -1;
3151 PercentageBaseGetter baseGetter;
3152 if (aSide == NS_SIDE_LEFT || aSide == NS_SIDE_RIGHT) {
3153 baseGetter = &nsComputedDOMStyle::GetCBContentWidth;
3154 } else {
3155 baseGetter = &nsComputedDOMStyle::GetCBContentHeight;
3158 val->SetAppUnits(sign * StyleCoordToNSCoord(coord, baseGetter, 0));
3160 return CallQueryInterface(val, aValue);
3163 nsresult
3164 nsComputedDOMStyle::GetStaticOffset(PRUint8 aSide, nsIDOMCSSValue** aValue)
3167 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3168 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3170 SetValueToCoord(val, GetStylePosition()->mOffset.Get(aSide));
3172 return CallQueryInterface(val, aValue);
3175 void
3176 nsComputedDOMStyle::FlushPendingReflows()
3178 // Flush all pending notifications so that our frames are up to date
3179 nsCOMPtr<nsIDocument> document = mContent->GetDocument();
3180 if (document) {
3181 document->FlushPendingNotifications(Flush_Layout);
3185 nsresult
3186 nsComputedDOMStyle::GetPaddingWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3188 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3189 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3191 if (!mInnerFrame) {
3192 SetValueToCoord(val, GetStylePadding()->mPadding.Get(aSide));
3193 } else {
3194 FlushPendingReflows();
3196 val->SetAppUnits(mInnerFrame->GetUsedPadding().side(aSide));
3199 return CallQueryInterface(val, aValue);
3202 PRBool
3203 nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
3205 aCoord = nsHTMLReflowState::CalcLineHeight(mStyleContextHolder);
3207 // CalcLineHeight uses font->mFont.size, but we want to use
3208 // font->mSize as the font size. Adjust for that. Also adjust for
3209 // the text zoom, if any.
3210 const nsStyleFont* font = GetStyleFont();
3211 aCoord = NSToCoordRound((float(aCoord) *
3212 (float(font->mSize) / float(font->mFont.size))) /
3213 mPresShell->GetPresContext()->TextZoom());
3215 return PR_TRUE;
3218 nsresult
3219 nsComputedDOMStyle::GetBorderColorsFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3221 const nsStyleBorder *border = GetStyleBorder();
3223 if (border->mBorderColors) {
3224 nsBorderColors* borderColors = border->mBorderColors[aSide];
3225 if (borderColors) {
3226 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
3227 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
3229 do {
3230 nsROCSSPrimitiveValue *primitive = GetROCSSPrimitiveValue();
3231 if (!primitive) {
3232 delete valueList;
3234 return NS_ERROR_OUT_OF_MEMORY;
3236 nsresult rv = SetToRGBAColor(primitive, borderColors->mColor);
3237 if (NS_FAILED(rv)) {
3238 delete valueList;
3239 delete primitive;
3240 return rv;
3243 PRBool success = valueList->AppendCSSValue(primitive);
3244 if (!success) {
3245 delete valueList;
3246 delete primitive;
3248 return NS_ERROR_OUT_OF_MEMORY;
3250 borderColors = borderColors->mNext;
3251 } while (borderColors);
3253 return CallQueryInterface(valueList, aValue);
3257 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3258 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3260 val->SetIdent(nsGkAtoms::none);
3262 return CallQueryInterface(val, aValue);
3265 nsresult
3266 nsComputedDOMStyle::GetBorderWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3268 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3269 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3271 nscoord width;
3272 if (mInnerFrame) {
3273 FlushPendingReflows();
3274 width = mInnerFrame->GetUsedBorder().side(aSide);
3275 } else {
3276 width = GetStyleBorder()->GetActualBorderWidth(aSide);
3278 val->SetAppUnits(width);
3280 return CallQueryInterface(val, aValue);
3283 nsresult
3284 nsComputedDOMStyle::GetBorderColorFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3286 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3287 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3289 nscolor color;
3290 PRBool foreground;
3291 GetStyleBorder()->GetBorderColor(aSide, color, foreground);
3292 if (foreground) {
3293 color = GetStyleColor()->mColor;
3296 nsresult rv = SetToRGBAColor(val, color);
3297 if (NS_FAILED(rv)) {
3298 delete val;
3299 return rv;
3302 return CallQueryInterface(val, aValue);
3305 nsresult
3306 nsComputedDOMStyle::GetMarginWidthFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3308 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3309 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3311 if (!mInnerFrame) {
3312 SetValueToCoord(val, GetStyleMargin()->mMargin.Get(aSide));
3313 } else {
3314 FlushPendingReflows();
3316 val->SetAppUnits(mInnerFrame->GetUsedMargin().side(aSide));
3319 return CallQueryInterface(val, aValue);
3322 nsresult
3323 nsComputedDOMStyle::GetBorderStyleFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
3325 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3326 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3328 PRUint8 borderStyle = GetStyleBorder()->GetBorderStyle(aSide);
3330 if (borderStyle != NS_STYLE_BORDER_STYLE_NONE) {
3331 const nsAFlatCString& style=
3332 nsCSSProps::ValueToKeyword(borderStyle,
3333 nsCSSProps::kBorderStyleKTable);
3334 val->SetIdent(style);
3335 } else {
3336 val->SetIdent(nsGkAtoms::none);
3339 return CallQueryInterface(val, aValue);
3342 void
3343 nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
3344 const nsStyleCoord& aCoord,
3345 PercentageBaseGetter aPercentageBaseGetter,
3346 const PRInt32 aTable[],
3347 nscoord aMinAppUnits,
3348 nscoord aMaxAppUnits)
3350 NS_PRECONDITION(aValue, "Must have a value to work with");
3352 switch (aCoord.GetUnit()) {
3353 case eStyleUnit_Normal:
3354 aValue->SetIdent(nsGkAtoms::normal);
3355 break;
3357 case eStyleUnit_Auto:
3358 aValue->SetIdent(nsGkAtoms::_auto);
3359 break;
3361 case eStyleUnit_Percent:
3363 nscoord percentageBase;
3364 if (aPercentageBaseGetter &&
3365 (this->*aPercentageBaseGetter)(percentageBase)) {
3366 nscoord val = nscoord(aCoord.GetPercentValue() * percentageBase);
3367 aValue->SetAppUnits(PR_MAX(aMinAppUnits, PR_MIN(val, aMaxAppUnits)));
3368 } else {
3369 aValue->SetPercent(aCoord.GetPercentValue());
3372 break;
3374 case eStyleUnit_Factor:
3375 aValue->SetNumber(aCoord.GetFactorValue());
3376 break;
3378 case eStyleUnit_Coord:
3380 nscoord val = aCoord.GetCoordValue();
3381 aValue->SetAppUnits(PR_MAX(aMinAppUnits, PR_MIN(val, aMaxAppUnits)));
3383 break;
3385 case eStyleUnit_Integer:
3386 aValue->SetNumber(aCoord.GetIntValue());
3387 break;
3389 case eStyleUnit_Enumerated:
3390 NS_ASSERTION(aTable, "Must have table to handle this case");
3391 aValue->SetIdent(nsCSSProps::ValueToKeyword(aCoord.GetIntValue(),
3392 aTable));
3393 break;
3395 case eStyleUnit_None:
3396 aValue->SetIdent(nsGkAtoms::none);
3397 break;
3399 default:
3400 NS_ERROR("Can't handle this unit");
3401 break;
3405 nscoord
3406 nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord& aCoord,
3407 PercentageBaseGetter aPercentageBaseGetter,
3408 nscoord aDefaultValue)
3410 NS_PRECONDITION(aPercentageBaseGetter, "Must have a percentage base getter");
3411 switch (aCoord.GetUnit()) {
3412 case eStyleUnit_Coord:
3413 return aCoord.GetCoordValue();
3414 case eStyleUnit_Percent:
3416 nscoord percentageBase;
3417 if ((this->*aPercentageBaseGetter)(percentageBase)) {
3418 return nscoord(aCoord.GetPercentValue() * percentageBase);
3421 // Fall through to returning aDefaultValue if we have no percentage base.
3422 default:
3423 break;
3426 return aDefaultValue;
3429 PRBool
3430 nsComputedDOMStyle::GetCBContentWidth(nscoord& aWidth)
3432 if (!mOuterFrame) {
3433 return PR_FALSE;
3436 nsIFrame* container = GetContainingBlockFor(mOuterFrame);
3437 if (!container) {
3438 return PR_FALSE;
3441 FlushPendingReflows();
3443 aWidth = container->GetContentRect().width;
3444 return PR_TRUE;
3447 PRBool
3448 nsComputedDOMStyle::GetCBContentHeight(nscoord& aHeight)
3450 if (!mOuterFrame) {
3451 return PR_FALSE;
3454 nsIFrame* container = GetContainingBlockFor(mOuterFrame);
3455 if (!container) {
3456 return PR_FALSE;
3459 FlushPendingReflows();
3461 aHeight = container->GetContentRect().height;
3462 return PR_TRUE;
3465 PRBool
3466 nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord& aWidth)
3468 if (!mInnerFrame) {
3469 return PR_FALSE;
3472 FlushPendingReflows();
3474 aWidth = mInnerFrame->GetSize().width;
3475 return PR_TRUE;
3478 PRBool
3479 nsComputedDOMStyle::GetFrameBoundsWidthForTransform(nscoord& aWidth)
3481 // We need a frame to work with.
3482 if (!mInnerFrame) {
3483 return PR_FALSE;
3486 FlushPendingReflows();
3488 // Check to see that we're transformed.
3489 if (!mInnerFrame->GetStyleDisplay()->HasTransform())
3490 return PR_FALSE;
3492 aWidth = nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame).width;
3493 return PR_TRUE;
3496 PRBool
3497 nsComputedDOMStyle::GetFrameBoundsHeightForTransform(nscoord& aHeight)
3499 // We need a frame to work with.
3500 if (!mInnerFrame) {
3501 return PR_FALSE;
3504 FlushPendingReflows();
3506 // Check to see that we're transformed.
3507 if (!mInnerFrame->GetStyleDisplay()->HasTransform())
3508 return PR_FALSE;
3510 aHeight = nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame).height;
3511 return PR_TRUE;
3514 #ifdef MOZ_SVG
3516 nsresult
3517 nsComputedDOMStyle::GetSVGPaintFor(PRBool aFill,
3518 nsIDOMCSSValue** aValue)
3520 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3521 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3523 const nsStyleSVG* svg = GetStyleSVG();
3524 const nsStyleSVGPaint* paint = nsnull;
3526 if (aFill)
3527 paint = &svg->mFill;
3528 else
3529 paint = &svg->mStroke;
3531 nsAutoString paintString;
3533 switch (paint->mType) {
3534 case eStyleSVGPaintType_None:
3536 val->SetIdent(nsGkAtoms::none);
3537 break;
3539 case eStyleSVGPaintType_Color:
3541 nsresult rv = SetToRGBAColor(val, paint->mPaint.mColor);
3542 if (NS_FAILED(rv)) {
3543 delete val;
3544 return rv;
3546 break;
3548 case eStyleSVGPaintType_Server:
3550 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE);
3551 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
3553 if (!valueList->AppendCSSValue(val)) {
3554 delete valueList;
3555 delete val;
3556 return NS_ERROR_OUT_OF_MEMORY;
3559 nsROCSSPrimitiveValue* fallback = GetROCSSPrimitiveValue();
3560 if (!fallback || !valueList->AppendCSSValue(fallback)) {
3561 delete valueList;
3562 delete fallback;
3563 return NS_ERROR_OUT_OF_MEMORY;
3566 val->SetURI(paint->mPaint.mPaintServer);
3567 nsresult rv = SetToRGBAColor(fallback, paint->mFallbackColor);
3568 if (NS_FAILED(rv)) {
3569 delete valueList;
3570 return rv;
3573 return CallQueryInterface(valueList, aValue);
3577 return CallQueryInterface(val, aValue);
3580 nsresult
3581 nsComputedDOMStyle::GetFill(nsIDOMCSSValue** aValue)
3583 return GetSVGPaintFor(PR_TRUE, aValue);
3586 nsresult
3587 nsComputedDOMStyle::GetStroke(nsIDOMCSSValue** aValue)
3589 return GetSVGPaintFor(PR_FALSE, aValue);
3592 nsresult
3593 nsComputedDOMStyle::GetMarkerEnd(nsIDOMCSSValue** aValue)
3595 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3596 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3598 const nsStyleSVG* svg = GetStyleSVG();
3600 if (svg->mMarkerEnd)
3601 val->SetURI(svg->mMarkerEnd);
3602 else
3603 val->SetIdent(nsGkAtoms::none);
3605 return CallQueryInterface(val, aValue);
3608 nsresult
3609 nsComputedDOMStyle::GetMarkerMid(nsIDOMCSSValue** aValue)
3611 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3612 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3614 const nsStyleSVG* svg = GetStyleSVG();
3616 if (svg->mMarkerMid)
3617 val->SetURI(svg->mMarkerMid);
3618 else
3619 val->SetIdent(nsGkAtoms::none);
3621 return CallQueryInterface(val, aValue);
3624 nsresult
3625 nsComputedDOMStyle::GetMarkerStart(nsIDOMCSSValue** aValue)
3627 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3628 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3630 const nsStyleSVG* svg = GetStyleSVG();
3632 if (svg->mMarkerStart)
3633 val->SetURI(svg->mMarkerStart);
3634 else
3635 val->SetIdent(nsGkAtoms::none);
3637 return CallQueryInterface(val, aValue);
3640 nsresult
3641 nsComputedDOMStyle::GetStrokeDasharray(nsIDOMCSSValue** aValue)
3643 const nsStyleSVG* svg = GetStyleSVG();
3645 if (!svg->mStrokeDasharrayLength || !svg->mStrokeDasharray) {
3646 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3647 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3648 val->SetIdent(nsGkAtoms::none);
3649 return CallQueryInterface(val, aValue);
3652 nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE);
3653 NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY);
3655 for (PRUint32 i = 0; i < svg->mStrokeDasharrayLength; i++) {
3656 nsROCSSPrimitiveValue* dash = GetROCSSPrimitiveValue();
3657 if (!dash || !valueList->AppendCSSValue(dash)) {
3658 delete valueList;
3659 delete dash;
3660 return NS_ERROR_OUT_OF_MEMORY;
3663 SetValueToCoord(dash, svg->mStrokeDasharray[i]);
3666 return CallQueryInterface(valueList, aValue);
3669 nsresult
3670 nsComputedDOMStyle::GetStrokeDashoffset(nsIDOMCSSValue** aValue)
3672 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3673 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3675 SetValueToCoord(val, GetStyleSVG()->mStrokeDashoffset);
3677 return CallQueryInterface(val, aValue);
3680 nsresult
3681 nsComputedDOMStyle::GetStrokeWidth(nsIDOMCSSValue** aValue)
3683 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3684 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3686 SetValueToCoord(val, GetStyleSVG()->mStrokeWidth);
3688 return CallQueryInterface(val, aValue);
3691 nsresult
3692 nsComputedDOMStyle::GetFillOpacity(nsIDOMCSSValue** aValue)
3694 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3695 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3697 val->SetNumber(GetStyleSVG()->mFillOpacity);
3699 return CallQueryInterface(val, aValue);
3702 nsresult
3703 nsComputedDOMStyle::GetFloodOpacity(nsIDOMCSSValue** aValue)
3705 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3706 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3708 val->SetNumber(GetStyleSVGReset()->mFloodOpacity);
3710 return CallQueryInterface(val, aValue);
3713 nsresult
3714 nsComputedDOMStyle::GetStopOpacity(nsIDOMCSSValue** aValue)
3716 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3717 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3719 val->SetNumber(GetStyleSVGReset()->mStopOpacity);
3721 return CallQueryInterface(val, aValue);
3724 nsresult
3725 nsComputedDOMStyle::GetStrokeMiterlimit(nsIDOMCSSValue** aValue)
3727 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3728 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3730 val->SetNumber(GetStyleSVG()->mStrokeMiterlimit);
3732 return CallQueryInterface(val, aValue);
3735 nsresult
3736 nsComputedDOMStyle::GetStrokeOpacity(nsIDOMCSSValue** aValue)
3738 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3739 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3741 val->SetNumber(GetStyleSVG()->mStrokeOpacity);
3743 return CallQueryInterface(val, aValue);
3746 nsresult
3747 nsComputedDOMStyle::GetClipRule(nsIDOMCSSValue** aValue)
3749 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3750 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3752 const nsAFlatCString& keyword =
3753 nsCSSProps::ValueToKeyword(GetStyleSVG()->mClipRule,
3754 nsCSSProps::kFillRuleKTable);
3755 val->SetIdent(keyword);
3757 return CallQueryInterface(val, aValue);
3760 nsresult
3761 nsComputedDOMStyle::GetFillRule(nsIDOMCSSValue** aValue)
3763 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3764 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3766 const nsAFlatCString& keyword =
3767 nsCSSProps::ValueToKeyword(GetStyleSVG()->mFillRule,
3768 nsCSSProps::kFillRuleKTable);
3769 val->SetIdent(keyword);
3771 return CallQueryInterface(val, aValue);
3774 nsresult
3775 nsComputedDOMStyle::GetStrokeLinecap(nsIDOMCSSValue** aValue)
3777 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3778 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3780 const nsAFlatCString& keyword =
3781 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinecap,
3782 nsCSSProps::kStrokeLinecapKTable);
3783 val->SetIdent(keyword);
3785 return CallQueryInterface(val, aValue);
3788 nsresult
3789 nsComputedDOMStyle::GetStrokeLinejoin(nsIDOMCSSValue** aValue)
3791 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3792 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3794 const nsAFlatCString& keyword =
3795 nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinejoin,
3796 nsCSSProps::kStrokeLinejoinKTable);
3797 val->SetIdent(keyword);
3799 return CallQueryInterface(val, aValue);
3802 nsresult
3803 nsComputedDOMStyle::GetTextAnchor(nsIDOMCSSValue** aValue)
3805 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3806 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3808 const nsAFlatCString& keyword =
3809 nsCSSProps::ValueToKeyword(GetStyleSVG()->mTextAnchor,
3810 nsCSSProps::kTextAnchorKTable);
3811 val->SetIdent(keyword);
3813 return CallQueryInterface(val, aValue);
3816 nsresult
3817 nsComputedDOMStyle::GetColorInterpolation(nsIDOMCSSValue** aValue)
3819 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3820 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3822 const nsStyleSVG* svg = GetStyleSVG();
3824 if (svg->mColorInterpolation != NS_STYLE_COLOR_INTERPOLATION_AUTO) {
3825 const nsAFlatCString& keyword =
3826 nsCSSProps::ValueToKeyword(svg->mColorInterpolation,
3827 nsCSSProps::kColorInterpolationKTable);
3828 val->SetIdent(keyword);
3829 } else {
3830 val->SetIdent(nsGkAtoms::_auto);
3833 return CallQueryInterface(val, aValue);
3836 nsresult
3837 nsComputedDOMStyle::GetColorInterpolationFilters(nsIDOMCSSValue** aValue)
3839 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3840 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3842 const nsStyleSVG* svg = GetStyleSVG();
3844 if (svg->mColorInterpolationFilters != NS_STYLE_COLOR_INTERPOLATION_AUTO) {
3845 const nsAFlatCString& keyword =
3846 nsCSSProps::ValueToKeyword(svg->mColorInterpolationFilters,
3847 nsCSSProps::kColorInterpolationKTable);
3848 val->SetIdent(keyword);
3849 } else {
3850 val->SetIdent(nsGkAtoms::_auto);
3853 return CallQueryInterface(val, aValue);
3856 nsresult
3857 nsComputedDOMStyle::GetDominantBaseline(nsIDOMCSSValue** aValue)
3859 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3860 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3862 const nsStyleSVGReset* svg = GetStyleSVGReset();
3864 if (svg->mDominantBaseline != NS_STYLE_DOMINANT_BASELINE_AUTO) {
3865 const nsAFlatCString& keyword =
3866 nsCSSProps::ValueToKeyword(svg->mDominantBaseline,
3867 nsCSSProps::kDominantBaselineKTable);
3868 val->SetIdent(keyword);
3869 } else {
3870 val->SetIdent(nsGkAtoms::_auto);
3873 return CallQueryInterface(val, aValue);
3876 nsresult
3877 nsComputedDOMStyle::GetPointerEvents(nsIDOMCSSValue** aValue)
3879 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3880 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3882 const nsStyleSVG* svg = GetStyleSVG();
3884 if (svg->mPointerEvents != NS_STYLE_POINTER_EVENTS_NONE) {
3885 const nsAFlatCString& keyword =
3886 nsCSSProps::ValueToKeyword(svg->mPointerEvents,
3887 nsCSSProps::kPointerEventsKTable);
3888 val->SetIdent(keyword);
3889 } else {
3890 val->SetIdent(nsGkAtoms::none);
3893 return CallQueryInterface(val, aValue);
3896 nsresult
3897 nsComputedDOMStyle::GetShapeRendering(nsIDOMCSSValue** aValue)
3899 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3900 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3902 const nsStyleSVG* svg = GetStyleSVG();
3904 if (svg->mShapeRendering != NS_STYLE_SHAPE_RENDERING_AUTO) {
3905 const nsAFlatCString& keyword =
3906 nsCSSProps::ValueToKeyword(svg->mShapeRendering,
3907 nsCSSProps::kShapeRenderingKTable);
3908 val->SetIdent(keyword);
3909 } else {
3910 val->SetIdent(nsGkAtoms::_auto);
3913 return CallQueryInterface(val, aValue);
3916 nsresult
3917 nsComputedDOMStyle::GetTextRendering(nsIDOMCSSValue** aValue)
3919 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3920 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3922 const nsStyleSVG* svg = GetStyleSVG();
3924 if (svg->mTextRendering != NS_STYLE_TEXT_RENDERING_AUTO) {
3925 const nsAFlatCString& keyword =
3926 nsCSSProps::ValueToKeyword(svg->mTextRendering,
3927 nsCSSProps::kTextRenderingKTable);
3928 val->SetIdent(keyword);
3929 } else {
3930 val->SetIdent(nsGkAtoms::_auto);
3933 return CallQueryInterface(val, aValue);
3936 nsresult
3937 nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue** aValue)
3939 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3940 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3942 nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mFloodColor);
3943 if (NS_FAILED(rv)) {
3944 delete val;
3945 return rv;
3948 return CallQueryInterface(val, aValue);
3951 nsresult
3952 nsComputedDOMStyle::GetLightingColor(nsIDOMCSSValue** aValue)
3954 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3955 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3957 nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mLightingColor);
3958 if (NS_FAILED(rv)) {
3959 delete val;
3960 return rv;
3963 return CallQueryInterface(val, aValue);
3966 nsresult
3967 nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue** aValue)
3969 nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
3970 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3972 nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mStopColor);
3973 if (NS_FAILED(rv)) {
3974 delete val;
3975 return rv;
3978 return CallQueryInterface(val, aValue);
3981 nsresult
3982 nsComputedDOMStyle::GetClipPath(nsIDOMCSSValue** aValue)
3984 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
3985 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
3987 const nsStyleSVGReset* svg = GetStyleSVGReset();
3989 if (svg->mClipPath)
3990 val->SetURI(svg->mClipPath);
3991 else
3992 val->SetIdent(nsGkAtoms::none);
3994 return CallQueryInterface(val, aValue);
3997 nsresult
3998 nsComputedDOMStyle::GetFilter(nsIDOMCSSValue** aValue)
4000 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
4001 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
4003 const nsStyleSVGReset* svg = GetStyleSVGReset();
4005 if (svg->mFilter)
4006 val->SetURI(svg->mFilter);
4007 else
4008 val->SetIdent(nsGkAtoms::none);
4010 return CallQueryInterface(val, aValue);
4013 nsresult
4014 nsComputedDOMStyle::GetMask(nsIDOMCSSValue** aValue)
4016 nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
4017 NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
4019 const nsStyleSVGReset* svg = GetStyleSVGReset();
4021 if (svg->mMask)
4022 val->SetURI(svg->mMask);
4023 else
4024 val->SetIdent(nsGkAtoms::none);
4026 return CallQueryInterface(val, aValue);
4029 #endif // MOZ_SVG
4032 #define COMPUTED_STYLE_MAP_ENTRY(_prop, _method) \
4033 { eCSSProperty_##_prop, &nsComputedDOMStyle::Get##_method }
4035 const nsComputedDOMStyle::ComputedStyleMapEntry*
4036 nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
4038 /* ******************************************************************* *\
4039 * Properties below are listed in alphabetical order. *
4040 * Please keep them that way. *
4042 * Properties commented out with // are not yet implemented *
4043 * Properties commented out with //// are shorthands and not queryable *
4044 \* ******************************************************************* */
4045 static
4046 #ifndef XP_MACOSX
4047 // XXX If this actually fixes the bustage, replace this with an
4048 // autoconf test.
4049 const
4050 #endif
4051 ComputedStyleMapEntry map[] = {
4052 /* ****************************** *\
4053 * Implementations of CSS2 styles *
4054 \* ****************************** */
4056 // COMPUTED_STYLE_MAP_ENTRY(azimuth, Azimuth),
4057 //// COMPUTED_STYLE_MAP_ENTRY(background, Background),
4058 COMPUTED_STYLE_MAP_ENTRY(background_attachment, BackgroundAttachment),
4059 COMPUTED_STYLE_MAP_ENTRY(background_color, BackgroundColor),
4060 COMPUTED_STYLE_MAP_ENTRY(background_image, BackgroundImage),
4061 COMPUTED_STYLE_MAP_ENTRY(background_position, BackgroundPosition),
4062 COMPUTED_STYLE_MAP_ENTRY(background_repeat, BackgroundRepeat),
4063 //// COMPUTED_STYLE_MAP_ENTRY(border, Border),
4064 //// COMPUTED_STYLE_MAP_ENTRY(border_bottom, BorderBottom),
4065 COMPUTED_STYLE_MAP_ENTRY(border_bottom_color, BorderBottomColor),
4066 COMPUTED_STYLE_MAP_ENTRY(border_bottom_style, BorderBottomStyle),
4067 COMPUTED_STYLE_MAP_ENTRY(border_bottom_width, BorderBottomWidth),
4068 COMPUTED_STYLE_MAP_ENTRY(border_collapse, BorderCollapse),
4069 //// COMPUTED_STYLE_MAP_ENTRY(border_color, BorderColor),
4070 //// COMPUTED_STYLE_MAP_ENTRY(border_left, BorderLeft),
4071 COMPUTED_STYLE_MAP_ENTRY(border_left_color, BorderLeftColor),
4072 COMPUTED_STYLE_MAP_ENTRY(border_left_style, BorderLeftStyle),
4073 COMPUTED_STYLE_MAP_ENTRY(border_left_width, BorderLeftWidth),
4074 //// COMPUTED_STYLE_MAP_ENTRY(border_right, BorderRight),
4075 COMPUTED_STYLE_MAP_ENTRY(border_right_color, BorderRightColor),
4076 COMPUTED_STYLE_MAP_ENTRY(border_right_style, BorderRightStyle),
4077 COMPUTED_STYLE_MAP_ENTRY(border_right_width, BorderRightWidth),
4078 COMPUTED_STYLE_MAP_ENTRY(border_spacing, BorderSpacing),
4079 //// COMPUTED_STYLE_MAP_ENTRY(border_style, BorderStyle),
4080 //// COMPUTED_STYLE_MAP_ENTRY(border_top, BorderTop),
4081 COMPUTED_STYLE_MAP_ENTRY(border_top_color, BorderTopColor),
4082 COMPUTED_STYLE_MAP_ENTRY(border_top_style, BorderTopStyle),
4083 COMPUTED_STYLE_MAP_ENTRY(border_top_width, BorderTopWidth),
4084 //// COMPUTED_STYLE_MAP_ENTRY(border_width, BorderWidth),
4085 COMPUTED_STYLE_MAP_ENTRY(bottom, Bottom),
4086 COMPUTED_STYLE_MAP_ENTRY(caption_side, CaptionSide),
4087 COMPUTED_STYLE_MAP_ENTRY(clear, Clear),
4088 COMPUTED_STYLE_MAP_ENTRY(clip, Clip),
4089 COMPUTED_STYLE_MAP_ENTRY(color, Color),
4090 COMPUTED_STYLE_MAP_ENTRY(content, Content),
4091 COMPUTED_STYLE_MAP_ENTRY(counter_increment, CounterIncrement),
4092 COMPUTED_STYLE_MAP_ENTRY(counter_reset, CounterReset),
4093 //// COMPUTED_STYLE_MAP_ENTRY(cue, Cue),
4094 // COMPUTED_STYLE_MAP_ENTRY(cue_after, CueAfter),
4095 // COMPUTED_STYLE_MAP_ENTRY(cue_before, CueBefore),
4096 COMPUTED_STYLE_MAP_ENTRY(cursor, Cursor),
4097 COMPUTED_STYLE_MAP_ENTRY(direction, Direction),
4098 COMPUTED_STYLE_MAP_ENTRY(display, Display),
4099 // COMPUTED_STYLE_MAP_ENTRY(elevation, Elevation),
4100 COMPUTED_STYLE_MAP_ENTRY(empty_cells, EmptyCells),
4101 COMPUTED_STYLE_MAP_ENTRY(float, CssFloat),
4102 //// COMPUTED_STYLE_MAP_ENTRY(font, Font),
4103 COMPUTED_STYLE_MAP_ENTRY(font_family, FontFamily),
4104 COMPUTED_STYLE_MAP_ENTRY(font_size, FontSize),
4105 COMPUTED_STYLE_MAP_ENTRY(font_size_adjust, FontSizeAdjust),
4106 // COMPUTED_STYLE_MAP_ENTRY(font_stretch, FontStretch),
4107 COMPUTED_STYLE_MAP_ENTRY(font_style, FontStyle),
4108 COMPUTED_STYLE_MAP_ENTRY(font_variant, FontVariant),
4109 COMPUTED_STYLE_MAP_ENTRY(font_weight, FontWeight),
4110 COMPUTED_STYLE_MAP_ENTRY(height, Height),
4111 COMPUTED_STYLE_MAP_ENTRY(left, Left),
4112 COMPUTED_STYLE_MAP_ENTRY(letter_spacing, LetterSpacing),
4113 COMPUTED_STYLE_MAP_ENTRY(line_height, LineHeight),
4114 //// COMPUTED_STYLE_MAP_ENTRY(list_style, ListStyle),
4115 COMPUTED_STYLE_MAP_ENTRY(list_style_image, ListStyleImage),
4116 COMPUTED_STYLE_MAP_ENTRY(list_style_position, ListStylePosition),
4117 COMPUTED_STYLE_MAP_ENTRY(list_style_type, ListStyleType),
4118 //// COMPUTED_STYLE_MAP_ENTRY(margin, Margin),
4119 COMPUTED_STYLE_MAP_ENTRY(margin_bottom, MarginBottomWidth),
4120 COMPUTED_STYLE_MAP_ENTRY(margin_left, MarginLeftWidth),
4121 COMPUTED_STYLE_MAP_ENTRY(margin_right, MarginRightWidth),
4122 COMPUTED_STYLE_MAP_ENTRY(margin_top, MarginTopWidth),
4123 COMPUTED_STYLE_MAP_ENTRY(marker_offset, MarkerOffset),
4124 // COMPUTED_STYLE_MAP_ENTRY(marks, Marks),
4125 COMPUTED_STYLE_MAP_ENTRY(max_height, MaxHeight),
4126 COMPUTED_STYLE_MAP_ENTRY(max_width, MaxWidth),
4127 COMPUTED_STYLE_MAP_ENTRY(min_height, MinHeight),
4128 COMPUTED_STYLE_MAP_ENTRY(min_width, MinWidth),
4129 COMPUTED_STYLE_MAP_ENTRY(ime_mode, IMEMode),
4130 COMPUTED_STYLE_MAP_ENTRY(opacity, Opacity),
4131 // COMPUTED_STYLE_MAP_ENTRY(orphans, Orphans),
4132 //// COMPUTED_STYLE_MAP_ENTRY(outline, Outline),
4133 COMPUTED_STYLE_MAP_ENTRY(outline_color, OutlineColor),
4134 COMPUTED_STYLE_MAP_ENTRY(outline_style, OutlineStyle),
4135 COMPUTED_STYLE_MAP_ENTRY(outline_width, OutlineWidth),
4136 COMPUTED_STYLE_MAP_ENTRY(outline_offset, OutlineOffset),
4137 COMPUTED_STYLE_MAP_ENTRY(overflow, Overflow),
4138 COMPUTED_STYLE_MAP_ENTRY(overflow_x, OverflowX),
4139 COMPUTED_STYLE_MAP_ENTRY(overflow_y, OverflowY),
4140 //// COMPUTED_STYLE_MAP_ENTRY(padding, Padding),
4141 COMPUTED_STYLE_MAP_ENTRY(padding_bottom, PaddingBottom),
4142 COMPUTED_STYLE_MAP_ENTRY(padding_left, PaddingLeft),
4143 COMPUTED_STYLE_MAP_ENTRY(padding_right, PaddingRight),
4144 COMPUTED_STYLE_MAP_ENTRY(padding_top, PaddingTop),
4145 // COMPUTED_STYLE_MAP_ENTRY(page, Page),
4146 COMPUTED_STYLE_MAP_ENTRY(page_break_after, PageBreakAfter),
4147 COMPUTED_STYLE_MAP_ENTRY(page_break_before, PageBreakBefore),
4148 // COMPUTED_STYLE_MAP_ENTRY(page_break_inside, PageBreakInside),
4149 //// COMPUTED_STYLE_MAP_ENTRY(pause, Pause),
4150 // COMPUTED_STYLE_MAP_ENTRY(pause_after, PauseAfter),
4151 // COMPUTED_STYLE_MAP_ENTRY(pause_before, PauseBefore),
4152 // COMPUTED_STYLE_MAP_ENTRY(pitch, Pitch),
4153 // COMPUTED_STYLE_MAP_ENTRY(pitch_range, PitchRange),
4154 COMPUTED_STYLE_MAP_ENTRY(position, Position),
4155 COMPUTED_STYLE_MAP_ENTRY(quotes, Quotes),
4156 // COMPUTED_STYLE_MAP_ENTRY(richness, Richness),
4157 COMPUTED_STYLE_MAP_ENTRY(right, Right),
4158 //// COMPUTED_STYLE_MAP_ENTRY(size, Size),
4159 // COMPUTED_STYLE_MAP_ENTRY(speak, Speak),
4160 // COMPUTED_STYLE_MAP_ENTRY(speak_header, SpeakHeader),
4161 // COMPUTED_STYLE_MAP_ENTRY(speak_numeral, SpeakNumeral),
4162 // COMPUTED_STYLE_MAP_ENTRY(speak_punctuation, SpeakPunctuation),
4163 // COMPUTED_STYLE_MAP_ENTRY(speech_rate, SpeechRate),
4164 // COMPUTED_STYLE_MAP_ENTRY(stress, Stress),
4165 COMPUTED_STYLE_MAP_ENTRY(table_layout, TableLayout),
4166 COMPUTED_STYLE_MAP_ENTRY(text_align, TextAlign),
4167 COMPUTED_STYLE_MAP_ENTRY(text_decoration, TextDecoration),
4168 COMPUTED_STYLE_MAP_ENTRY(text_indent, TextIndent),
4169 COMPUTED_STYLE_MAP_ENTRY(text_shadow, TextShadow),
4170 COMPUTED_STYLE_MAP_ENTRY(text_transform, TextTransform),
4171 COMPUTED_STYLE_MAP_ENTRY(top, Top),
4172 COMPUTED_STYLE_MAP_ENTRY(unicode_bidi, UnicodeBidi),
4173 COMPUTED_STYLE_MAP_ENTRY(vertical_align, VerticalAlign),
4174 COMPUTED_STYLE_MAP_ENTRY(visibility, Visibility),
4175 // COMPUTED_STYLE_MAP_ENTRY(voice_family, VoiceFamily),
4176 // COMPUTED_STYLE_MAP_ENTRY(volume, Volume),
4177 COMPUTED_STYLE_MAP_ENTRY(white_space, WhiteSpace),
4178 // COMPUTED_STYLE_MAP_ENTRY(widows, Widows),
4179 COMPUTED_STYLE_MAP_ENTRY(width, Width),
4180 COMPUTED_STYLE_MAP_ENTRY(word_spacing, WordSpacing),
4181 COMPUTED_STYLE_MAP_ENTRY(z_index, ZIndex),
4183 /* ******************************* *\
4184 * Implementations of -moz- styles *
4185 \* ******************************* */
4187 COMPUTED_STYLE_MAP_ENTRY(appearance, Appearance),
4188 COMPUTED_STYLE_MAP_ENTRY(_moz_background_clip, BackgroundClip),
4189 COMPUTED_STYLE_MAP_ENTRY(_moz_background_inline_policy, BackgroundInlinePolicy),
4190 COMPUTED_STYLE_MAP_ENTRY(_moz_background_origin, BackgroundOrigin),
4191 COMPUTED_STYLE_MAP_ENTRY(binding, Binding),
4192 COMPUTED_STYLE_MAP_ENTRY(border_bottom_colors, BorderBottomColors),
4193 COMPUTED_STYLE_MAP_ENTRY(border_image, BorderImage),
4194 COMPUTED_STYLE_MAP_ENTRY(border_left_colors, BorderLeftColors),
4195 COMPUTED_STYLE_MAP_ENTRY(border_right_colors, BorderRightColors),
4196 COMPUTED_STYLE_MAP_ENTRY(border_top_colors, BorderTopColors),
4197 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomLeft, BorderRadiusBottomLeft),
4198 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_bottomRight,BorderRadiusBottomRight),
4199 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topLeft, BorderRadiusTopLeft),
4200 COMPUTED_STYLE_MAP_ENTRY(_moz_border_radius_topRight, BorderRadiusTopRight),
4201 COMPUTED_STYLE_MAP_ENTRY(box_align, BoxAlign),
4202 COMPUTED_STYLE_MAP_ENTRY(box_direction, BoxDirection),
4203 COMPUTED_STYLE_MAP_ENTRY(box_flex, BoxFlex),
4204 COMPUTED_STYLE_MAP_ENTRY(box_ordinal_group, BoxOrdinalGroup),
4205 COMPUTED_STYLE_MAP_ENTRY(box_orient, BoxOrient),
4206 COMPUTED_STYLE_MAP_ENTRY(box_pack, BoxPack),
4207 COMPUTED_STYLE_MAP_ENTRY(box_shadow, BoxShadow),
4208 COMPUTED_STYLE_MAP_ENTRY(box_sizing, BoxSizing),
4209 COMPUTED_STYLE_MAP_ENTRY(_moz_column_count, ColumnCount),
4210 COMPUTED_STYLE_MAP_ENTRY(_moz_column_width, ColumnWidth),
4211 COMPUTED_STYLE_MAP_ENTRY(_moz_column_gap, ColumnGap),
4212 //// COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule, ColumnRule),
4213 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_color, ColumnRuleColor),
4214 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_width, ColumnRuleWidth),
4215 COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_style, ColumnRuleStyle),
4216 COMPUTED_STYLE_MAP_ENTRY(float_edge, FloatEdge),
4217 COMPUTED_STYLE_MAP_ENTRY(force_broken_image_icon, ForceBrokenImageIcon),
4218 COMPUTED_STYLE_MAP_ENTRY(image_region, ImageRegion),
4219 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomLeft, OutlineRadiusBottomLeft),
4220 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_bottomRight,OutlineRadiusBottomRight),
4221 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topLeft, OutlineRadiusTopLeft),
4222 COMPUTED_STYLE_MAP_ENTRY(_moz_outline_radius_topRight, OutlineRadiusTopRight),
4223 COMPUTED_STYLE_MAP_ENTRY(stack_sizing, StackSizing),
4224 COMPUTED_STYLE_MAP_ENTRY(_moz_transform, MozTransform),
4225 COMPUTED_STYLE_MAP_ENTRY(_moz_transform_origin, MozTransformOrigin),
4226 COMPUTED_STYLE_MAP_ENTRY(user_focus, UserFocus),
4227 COMPUTED_STYLE_MAP_ENTRY(user_input, UserInput),
4228 COMPUTED_STYLE_MAP_ENTRY(user_modify, UserModify),
4229 COMPUTED_STYLE_MAP_ENTRY(user_select, UserSelect),
4230 COMPUTED_STYLE_MAP_ENTRY(_moz_window_shadow, WindowShadow),
4231 COMPUTED_STYLE_MAP_ENTRY(word_wrap, WordWrap)
4233 #ifdef MOZ_SVG
4235 COMPUTED_STYLE_MAP_ENTRY(clip_path, ClipPath),
4236 COMPUTED_STYLE_MAP_ENTRY(clip_rule, ClipRule),
4237 COMPUTED_STYLE_MAP_ENTRY(color_interpolation, ColorInterpolation),
4238 COMPUTED_STYLE_MAP_ENTRY(color_interpolation_filters, ColorInterpolationFilters),
4239 COMPUTED_STYLE_MAP_ENTRY(dominant_baseline, DominantBaseline),
4240 COMPUTED_STYLE_MAP_ENTRY(fill, Fill),
4241 COMPUTED_STYLE_MAP_ENTRY(fill_opacity, FillOpacity),
4242 COMPUTED_STYLE_MAP_ENTRY(fill_rule, FillRule),
4243 COMPUTED_STYLE_MAP_ENTRY(filter, Filter),
4244 COMPUTED_STYLE_MAP_ENTRY(flood_color, FloodColor),
4245 COMPUTED_STYLE_MAP_ENTRY(flood_opacity, FloodOpacity),
4246 COMPUTED_STYLE_MAP_ENTRY(lighting_color, LightingColor),
4247 COMPUTED_STYLE_MAP_ENTRY(mask, Mask),
4248 COMPUTED_STYLE_MAP_ENTRY(marker_end, MarkerEnd),
4249 COMPUTED_STYLE_MAP_ENTRY(marker_mid, MarkerMid),
4250 COMPUTED_STYLE_MAP_ENTRY(marker_start, MarkerStart),
4251 COMPUTED_STYLE_MAP_ENTRY(pointer_events, PointerEvents),
4252 COMPUTED_STYLE_MAP_ENTRY(shape_rendering, ShapeRendering),
4253 COMPUTED_STYLE_MAP_ENTRY(stop_color, StopColor),
4254 COMPUTED_STYLE_MAP_ENTRY(stop_opacity, StopOpacity),
4255 COMPUTED_STYLE_MAP_ENTRY(stroke, Stroke),
4256 COMPUTED_STYLE_MAP_ENTRY(stroke_dasharray, StrokeDasharray),
4257 COMPUTED_STYLE_MAP_ENTRY(stroke_dashoffset, StrokeDashoffset),
4258 COMPUTED_STYLE_MAP_ENTRY(stroke_linecap, StrokeLinecap),
4259 COMPUTED_STYLE_MAP_ENTRY(stroke_linejoin, StrokeLinejoin),
4260 COMPUTED_STYLE_MAP_ENTRY(stroke_miterlimit, StrokeMiterlimit),
4261 COMPUTED_STYLE_MAP_ENTRY(stroke_opacity, StrokeOpacity),
4262 COMPUTED_STYLE_MAP_ENTRY(stroke_width, StrokeWidth),
4263 COMPUTED_STYLE_MAP_ENTRY(text_anchor, TextAnchor),
4264 COMPUTED_STYLE_MAP_ENTRY(text_rendering, TextRendering)
4265 #endif
4269 *aLength = NS_ARRAY_LENGTH(map);
4271 return map;