LCOV - code coverage report
Current view: directory - layout/style - nsComputedDOMStyle.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 2113 6 0.3 %
Date: 2012-04-21 Functions: 274 3 1.1 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim:set tw=78 expandtab softtabstop=2 ts=2 sw=2: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Daniel Glazman <glazman@netscape.com>
      25                 :  *   Boris Zbarsky <bzbarsky@mit.edu>
      26                 :  *   Christopher A. Aillon <christopher@aillon.com>
      27                 :  *   Mats Palmgren <matspal@gmail.com>
      28                 :  *   Christian Biesinger <cbiesinger@web.de>
      29                 :  *   Michael Ventnor <m.ventnor@gmail.com>
      30                 :  *   Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
      31                 :  *   L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
      32                 :  *
      33                 :  * Alternatively, the contents of this file may be used under the terms of
      34                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      35                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      36                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      37                 :  * of those above. If you wish to allow use of your version of this file only
      38                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      39                 :  * use your version of this file under the terms of the MPL, indicate your
      40                 :  * decision by deleting the provisions above and replace them with the notice
      41                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      42                 :  * the provisions above, a recipient may use your version of this file under
      43                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      44                 :  *
      45                 :  * ***** END LICENSE BLOCK ***** */
      46                 : 
      47                 : /* DOM object returned from element.getComputedStyle() */
      48                 : 
      49                 : #include "mozilla/Util.h"
      50                 : 
      51                 : #include "nsComputedDOMStyle.h"
      52                 : 
      53                 : #include "nsDOMError.h"
      54                 : #include "nsDOMString.h"
      55                 : #include "nsIDOMCSS2Properties.h"
      56                 : #include "nsIDOMElement.h"
      57                 : #include "nsIDOMCSSPrimitiveValue.h"
      58                 : #include "nsStyleContext.h"
      59                 : #include "nsIScrollableFrame.h"
      60                 : #include "nsContentUtils.h"
      61                 : #include "prprf.h"
      62                 : 
      63                 : #include "nsCSSProps.h"
      64                 : #include "nsCSSKeywords.h"
      65                 : #include "nsDOMCSSRect.h"
      66                 : #include "nsGkAtoms.h"
      67                 : #include "nsHTMLReflowState.h"
      68                 : #include "nsThemeConstants.h"
      69                 : #include "nsStyleUtil.h"
      70                 : #include "nsStyleStructInlines.h"
      71                 : 
      72                 : #include "nsPresContext.h"
      73                 : #include "nsIDocument.h"
      74                 : 
      75                 : #include "nsCSSPseudoElements.h"
      76                 : #include "nsStyleSet.h"
      77                 : #include "imgIRequest.h"
      78                 : #include "nsLayoutUtils.h"
      79                 : #include "nsFrameManager.h"
      80                 : #include "prlog.h"
      81                 : #include "nsCSSKeywords.h"
      82                 : #include "nsStyleCoord.h"
      83                 : #include "nsDisplayList.h"
      84                 : #include "nsDOMCSSDeclaration.h"
      85                 : #include "mozilla/dom/Element.h"
      86                 : #include "nsGenericElement.h"
      87                 : #include "CSSCalc.h"
      88                 : 
      89                 : using namespace mozilla;
      90                 : using namespace mozilla::dom;
      91                 : 
      92                 : #if defined(DEBUG_bzbarsky) || defined(DEBUG_caillon)
      93                 : #define DEBUG_ComputedDOMStyle
      94                 : #endif
      95                 : 
      96                 : /*
      97                 :  * This is the implementation of the readonly CSSStyleDeclaration that is
      98                 :  * returned by the getComputedStyle() function.
      99                 :  */
     100                 : 
     101                 : static nsComputedDOMStyle *sCachedComputedDOMStyle;
     102                 : 
     103                 : nsresult
     104               0 : NS_NewComputedDOMStyle(nsIDOMElement *aElement, const nsAString &aPseudoElt,
     105                 :                        nsIPresShell *aPresShell,
     106                 :                        nsComputedDOMStyle **aComputedStyle)
     107                 : {
     108               0 :   nsRefPtr<nsComputedDOMStyle> computedStyle;
     109               0 :   if (sCachedComputedDOMStyle) {
     110                 :     // There's an unused nsComputedDOMStyle cached, use it.
     111                 :     // But before we use it, re-initialize the object.
     112                 : 
     113                 :     // Oh yeah baby, placement new!
     114               0 :     computedStyle = new (sCachedComputedDOMStyle) nsComputedDOMStyle();
     115                 : 
     116               0 :     sCachedComputedDOMStyle = nsnull;
     117                 :   } else {
     118                 :     // No nsComputedDOMStyle cached, create a new one.
     119                 : 
     120               0 :     computedStyle = new nsComputedDOMStyle();
     121               0 :     NS_ENSURE_TRUE(computedStyle, NS_ERROR_OUT_OF_MEMORY);
     122                 :   }
     123                 : 
     124               0 :   nsresult rv = computedStyle->Init(aElement, aPseudoElt, aPresShell);
     125               0 :   NS_ENSURE_SUCCESS(rv, rv);
     126                 : 
     127               0 :   *aComputedStyle = nsnull;
     128               0 :   computedStyle.swap(*aComputedStyle);
     129                 : 
     130               0 :   return NS_OK;
     131                 : }
     132                 : 
     133                 : static nsIFrame*
     134               0 : GetContainingBlockFor(nsIFrame* aFrame) {
     135               0 :   if (!aFrame) {
     136               0 :     return nsnull;
     137                 :   }
     138               0 :   return aFrame->GetContainingBlock();
     139                 : }
     140                 : 
     141               0 : nsComputedDOMStyle::nsComputedDOMStyle()
     142                 :   : mDocumentWeak(nsnull), mOuterFrame(nsnull),
     143                 :     mInnerFrame(nsnull), mPresShell(nsnull),
     144               0 :     mExposeVisitedStyle(false)
     145                 : {
     146               0 : }
     147                 : 
     148                 : 
     149               0 : nsComputedDOMStyle::~nsComputedDOMStyle()
     150                 : {
     151               0 : }
     152                 : 
     153                 : void
     154            1364 : nsComputedDOMStyle::Shutdown()
     155                 : {
     156                 :   // We want to de-allocate without calling the dtor since we
     157                 :   // already did that manually in doDestroyComputedDOMStyle(),
     158                 :   // so cast our cached object to something that doesn't know
     159                 :   // about our dtor.
     160            1364 :   delete reinterpret_cast<char*>(sCachedComputedDOMStyle);
     161            1364 :   sCachedComputedDOMStyle = nsnull;
     162            1364 : }
     163                 : 
     164                 : 
     165                 : // If nsComputedDOMStyle is changed so that any additional fields are
     166                 : // traversed by the cycle collector (for instance, if wrapper cache
     167                 : // handling is changed) then CAN_SKIP must be updated.
     168            1396 : NS_IMPL_CYCLE_COLLECTION_1(nsComputedDOMStyle, mContent)
     169                 : 
     170                 : // nsComputedDOMStyle has only one cycle collected field, so if
     171                 : // mContent is going to be skipped, the style isn't part of a garbage
     172                 : // cycle.
     173               0 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsComputedDOMStyle)
     174               0 :   return !tmp->mContent || nsGenericElement::CanSkip(tmp->mContent, true);
     175                 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
     176                 : 
     177               0 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsComputedDOMStyle)
     178               0 :   return !tmp->mContent || nsGenericElement::CanSkipInCC(tmp->mContent);
     179                 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
     180                 : 
     181                 : // CanSkipThis returns false to avoid problems with incomplete unlinking.
     182               0 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsComputedDOMStyle)
     183               0 : NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
     184                 : 
     185                 : // QueryInterface implementation for nsComputedDOMStyle
     186               0 : NS_INTERFACE_MAP_BEGIN(nsComputedDOMStyle)
     187               0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
     188               0 :   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsComputedDOMStyle)
     189               0 : NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
     190                 : 
     191                 : 
     192               0 : static void doDestroyComputedDOMStyle(nsComputedDOMStyle *aComputedStyle)
     193                 : {
     194               0 :   if (!sCachedComputedDOMStyle) {
     195                 :     // The cache is empty, store aComputedStyle in the cache.
     196                 : 
     197               0 :     sCachedComputedDOMStyle = aComputedStyle;
     198               0 :     sCachedComputedDOMStyle->~nsComputedDOMStyle();
     199                 :   } else {
     200                 :     // The cache is full, delete aComputedStyle
     201                 : 
     202               0 :     delete aComputedStyle;
     203                 :   }
     204               0 : }
     205                 : 
     206               0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(nsComputedDOMStyle)
     207               0 : NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsComputedDOMStyle,
     208                 :                                               doDestroyComputedDOMStyle(this))
     209                 : 
     210                 : 
     211                 : NS_IMETHODIMP
     212               0 : nsComputedDOMStyle::Init(nsIDOMElement *aElement,
     213                 :                          const nsAString& aPseudoElt,
     214                 :                          nsIPresShell *aPresShell)
     215                 : {
     216               0 :   NS_ENSURE_ARG_POINTER(aElement);
     217               0 :   NS_ENSURE_ARG_POINTER(aPresShell);
     218                 : 
     219               0 :   mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
     220                 : 
     221               0 :   mContent = do_QueryInterface(aElement);
     222               0 :   if (!mContent) {
     223                 :     // This should not happen, all our elements support nsIContent!
     224                 : 
     225               0 :     return NS_ERROR_FAILURE;
     226                 :   }
     227                 : 
     228               0 :   if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty() &&
     229               0 :       aPseudoElt.First() == PRUnichar(':')) {
     230                 :     // deal with two-colon forms of aPseudoElt
     231               0 :     nsAString::const_iterator start, end;
     232               0 :     aPseudoElt.BeginReading(start);
     233               0 :     aPseudoElt.EndReading(end);
     234               0 :     NS_ASSERTION(start != end, "aPseudoElt is not empty!");
     235               0 :     ++start;
     236               0 :     bool haveTwoColons = true;
     237               0 :     if (start == end || *start != PRUnichar(':')) {
     238               0 :       --start;
     239               0 :       haveTwoColons = false;
     240                 :     }
     241               0 :     mPseudo = do_GetAtom(Substring(start, end));
     242               0 :     NS_ENSURE_TRUE(mPseudo, NS_ERROR_OUT_OF_MEMORY);
     243                 : 
     244                 :     // There aren't any non-CSS2 pseudo-elements with a single ':'
     245               0 :     if (!haveTwoColons &&
     246               0 :         !nsCSSPseudoElements::IsCSS2PseudoElement(mPseudo)) {
     247                 :       // XXXbz I'd really rather we threw an exception or something, but
     248                 :       // the DOM spec sucks.
     249               0 :       mPseudo = nsnull;
     250                 :     }
     251                 :   }
     252                 : 
     253               0 :   nsPresContext *presCtx = aPresShell->GetPresContext();
     254               0 :   NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
     255                 : 
     256               0 :   return NS_OK;
     257                 : }
     258                 : 
     259                 : NS_IMETHODIMP
     260               0 : nsComputedDOMStyle::GetPropertyValue(const nsCSSProperty aPropID,
     261                 :                                      nsAString& aValue)
     262                 : {
     263                 :   // This is mostly to avoid code duplication with GetPropertyCSSValue(); if
     264                 :   // perf ever becomes an issue here (doubtful), we can look into changing
     265                 :   // this.
     266                 :   return GetPropertyValue(
     267               0 :     NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(aPropID)),
     268               0 :     aValue);
     269                 : }
     270                 : 
     271                 : NS_IMETHODIMP
     272               0 : nsComputedDOMStyle::SetPropertyValue(const nsCSSProperty aPropID,
     273                 :                                      const nsAString& aValue)
     274                 : {
     275               0 :   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     276                 : }
     277                 : 
     278                 : 
     279                 : NS_IMETHODIMP
     280               0 : nsComputedDOMStyle::GetCssText(nsAString& aCssText)
     281                 : {
     282               0 :   aCssText.Truncate();
     283                 : 
     284               0 :   return NS_OK;
     285                 : }
     286                 : 
     287                 : 
     288                 : NS_IMETHODIMP
     289               0 : nsComputedDOMStyle::SetCssText(const nsAString& aCssText)
     290                 : {
     291               0 :   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     292                 : }
     293                 : 
     294                 : 
     295                 : NS_IMETHODIMP
     296               0 : nsComputedDOMStyle::GetLength(PRUint32* aLength)
     297                 : {
     298               0 :   NS_PRECONDITION(aLength, "Null aLength!  Prepare to die!");
     299                 : 
     300               0 :   (void)GetQueryablePropertyMap(aLength);
     301                 : 
     302               0 :   return NS_OK;
     303                 : }
     304                 : 
     305                 : 
     306                 : NS_IMETHODIMP
     307               0 : nsComputedDOMStyle::GetParentRule(nsIDOMCSSRule** aParentRule)
     308                 : {
     309               0 :   *aParentRule = nsnull;
     310                 : 
     311               0 :   return NS_OK;
     312                 : }
     313                 : 
     314                 : 
     315                 : NS_IMETHODIMP
     316               0 : nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
     317                 :                                      nsAString& aReturn)
     318                 : {
     319               0 :   nsCOMPtr<nsIDOMCSSValue> val;
     320                 : 
     321               0 :   aReturn.Truncate();
     322                 : 
     323               0 :   nsresult rv = GetPropertyCSSValue(aPropertyName, getter_AddRefs(val));
     324               0 :   NS_ENSURE_SUCCESS(rv, rv);
     325                 : 
     326               0 :   if (val) {
     327               0 :     rv = val->GetCssText(aReturn);
     328                 :   }
     329                 : 
     330               0 :   return rv;
     331                 : }
     332                 : 
     333                 : /* static */
     334                 : already_AddRefed<nsStyleContext>
     335               0 : nsComputedDOMStyle::GetStyleContextForElement(Element* aElement,
     336                 :                                               nsIAtom* aPseudo,
     337                 :                                               nsIPresShell* aPresShell)
     338                 : {
     339                 :   // If the content has a pres shell, we must use it.  Otherwise we'd
     340                 :   // potentially mix rule trees by using the wrong pres shell's style
     341                 :   // set.  Using the pres shell from the content also means that any
     342                 :   // content that's actually *in* a document will get the style from the
     343                 :   // correct document.
     344               0 :   nsIPresShell *presShell = GetPresShellForContent(aElement);
     345               0 :   if (!presShell) {
     346               0 :     presShell = aPresShell;
     347               0 :     if (!presShell)
     348               0 :       return nsnull;
     349                 :   }
     350                 : 
     351               0 :   presShell->FlushPendingNotifications(Flush_Style);
     352                 : 
     353               0 :   return GetStyleContextForElementNoFlush(aElement, aPseudo, presShell);
     354                 : }
     355                 : 
     356                 : /* static */
     357                 : already_AddRefed<nsStyleContext>
     358               0 : nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement,
     359                 :                                                      nsIAtom* aPseudo,
     360                 :                                                      nsIPresShell* aPresShell)
     361                 : {
     362               0 :   NS_ABORT_IF_FALSE(aElement, "NULL element");
     363                 :   // If the content has a pres shell, we must use it.  Otherwise we'd
     364                 :   // potentially mix rule trees by using the wrong pres shell's style
     365                 :   // set.  Using the pres shell from the content also means that any
     366                 :   // content that's actually *in* a document will get the style from the
     367                 :   // correct document.
     368               0 :   nsIPresShell *presShell = GetPresShellForContent(aElement);
     369               0 :   if (!presShell) {
     370               0 :     presShell = aPresShell;
     371               0 :     if (!presShell)
     372               0 :       return nsnull;
     373                 :   }
     374                 : 
     375               0 :   if (!aPseudo) {
     376               0 :     nsIFrame* frame = aElement->GetPrimaryFrame();
     377               0 :     if (frame) {
     378                 :       nsStyleContext* result =
     379               0 :         nsLayoutUtils::GetStyleFrame(frame)->GetStyleContext();
     380                 :       // Don't use the style context if it was influenced by
     381                 :       // pseudo-elements, since then it's not the primary style
     382                 :       // for this element.
     383               0 :       if (!result->HasPseudoElementData()) {
     384                 :         // this function returns an addrefed style context
     385               0 :         result->AddRef();
     386               0 :         return result;
     387                 :       }
     388                 :     }
     389                 :   }
     390                 : 
     391                 :   // No frame has been created or we have a pseudo, so resolve the
     392                 :   // style ourselves
     393               0 :   nsRefPtr<nsStyleContext> parentContext;
     394               0 :   nsIContent* parent = aPseudo ? aElement : aElement->GetParent();
     395                 :   // Don't resolve parent context for document fragments.
     396               0 :   if (parent && parent->IsElement())
     397                 :     parentContext = GetStyleContextForElementNoFlush(parent->AsElement(),
     398               0 :                                                      nsnull, presShell);
     399                 : 
     400               0 :   nsPresContext *presContext = presShell->GetPresContext();
     401               0 :   if (!presContext)
     402               0 :     return nsnull;
     403                 : 
     404               0 :   nsStyleSet *styleSet = presShell->StyleSet();
     405                 : 
     406               0 :   if (aPseudo) {
     407               0 :     nsCSSPseudoElements::Type type = nsCSSPseudoElements::GetPseudoType(aPseudo);
     408               0 :     if (type >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
     409               0 :       return nsnull;
     410                 :     }
     411               0 :     return styleSet->ResolvePseudoElementStyle(aElement, type, parentContext);
     412                 :   }
     413                 : 
     414               0 :   return styleSet->ResolveStyleFor(aElement, parentContext);
     415                 : }
     416                 : 
     417                 : /* static */
     418                 : nsIPresShell*
     419               0 : nsComputedDOMStyle::GetPresShellForContent(nsIContent* aContent)
     420                 : {
     421               0 :   nsIDocument* currentDoc = aContent->GetCurrentDoc();
     422               0 :   if (!currentDoc)
     423               0 :     return nsnull;
     424                 : 
     425               0 :   return currentDoc->GetShell();
     426                 : }
     427                 : 
     428                 : // nsDOMCSSDeclaration abstract methods which should never be called
     429                 : // on a nsComputedDOMStyle object, but must be defined to avoid
     430                 : // compile errors.
     431                 : css::Declaration*
     432               0 : nsComputedDOMStyle::GetCSSDeclaration(bool)
     433                 : {
     434               0 :   NS_RUNTIMEABORT("called nsComputedDOMStyle::GetCSSDeclaration");
     435               0 :   return nsnull;
     436                 : }
     437                 : 
     438                 : nsresult
     439               0 : nsComputedDOMStyle::SetCSSDeclaration(css::Declaration*)
     440                 : {
     441               0 :   NS_RUNTIMEABORT("called nsComputedDOMStyle::SetCSSDeclaration");
     442               0 :   return NS_ERROR_FAILURE;
     443                 : }
     444                 : 
     445                 : nsIDocument*
     446               0 : nsComputedDOMStyle::DocToUpdate()
     447                 : {
     448               0 :   NS_RUNTIMEABORT("called nsComputedDOMStyle::DocToUpdate");
     449               0 :   return nsnull;
     450                 : }
     451                 : 
     452                 : void
     453               0 : nsComputedDOMStyle::GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv)
     454                 : {
     455               0 :   NS_RUNTIMEABORT("called nsComputedDOMStyle::GetCSSParsingEnvironment");
     456                 :   // Just in case NS_RUNTIMEABORT ever stops killing us for some reason
     457               0 :   aCSSParseEnv.mPrincipal = nsnull;
     458               0 : }
     459                 : 
     460                 : NS_IMETHODIMP
     461               0 : nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName,
     462                 :                                         nsIDOMCSSValue** aReturn)
     463                 : {
     464               0 :   NS_ASSERTION(!mStyleContextHolder, "bad state");
     465                 : 
     466               0 :   *aReturn = nsnull;
     467                 : 
     468               0 :   nsCOMPtr<nsIDocument> document = do_QueryReferent(mDocumentWeak);
     469               0 :   NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
     470               0 :   document->FlushPendingLinkUpdates();
     471                 : 
     472               0 :   nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
     473                 : 
     474               0 :   const ComputedStyleMapEntry* propEntry = nsnull;
     475                 :   {
     476               0 :     PRUint32 length = 0;
     477               0 :     const ComputedStyleMapEntry* propMap = GetQueryablePropertyMap(&length);
     478               0 :     for (PRUint32 i = 0; i < length; ++i) {
     479               0 :       if (prop == propMap[i].mProperty) {
     480               0 :         propEntry = &propMap[i];
     481               0 :         break;
     482                 :       }
     483                 :     }
     484                 :   }
     485               0 :   if (!propEntry) {
     486                 : #ifdef DEBUG_ComputedDOMStyle
     487                 :     NS_WARNING(PromiseFlatCString(NS_ConvertUTF16toUTF8(aPropertyName) +
     488                 :                                   NS_LITERAL_CSTRING(" is not queryable!")).get());
     489                 : #endif
     490                 : 
     491                 :     // NOTE:  For branches, we should flush here for compatibility!
     492               0 :     return NS_OK;
     493                 :   }
     494                 : 
     495                 :   // Flush _before_ getting the presshell, since that could create a new
     496                 :   // presshell.  Also note that we want to flush the style on the document
     497                 :   // we're computing style in, not on the document mContent is in -- the two
     498                 :   // may be different.
     499               0 :   document->FlushPendingNotifications(
     500               0 :     propEntry->mNeedsLayoutFlush ? Flush_Layout : Flush_Style);
     501                 : #ifdef DEBUG
     502               0 :   mFlushedPendingReflows = propEntry->mNeedsLayoutFlush;
     503                 : #endif
     504                 : 
     505               0 :   mPresShell = document->GetShell();
     506               0 :   NS_ENSURE_TRUE(mPresShell && mPresShell->GetPresContext(),
     507                 :                  NS_ERROR_NOT_AVAILABLE);
     508                 : 
     509               0 :   if (!mPseudo) {
     510               0 :     mOuterFrame = mContent->GetPrimaryFrame();
     511               0 :     mInnerFrame = mOuterFrame;
     512               0 :     if (mOuterFrame) {
     513               0 :       nsIAtom* type = mOuterFrame->GetType();
     514               0 :       if (type == nsGkAtoms::tableOuterFrame) {
     515                 :         // If the frame is an outer table frame then we should get the style
     516                 :         // from the inner table frame.
     517               0 :         mInnerFrame = mOuterFrame->GetFirstPrincipalChild();
     518               0 :         NS_ASSERTION(mInnerFrame, "Outer table must have an inner");
     519               0 :         NS_ASSERTION(!mInnerFrame->GetNextSibling(),
     520                 :                      "Outer table frames should have just one child, "
     521                 :                      "the inner table");
     522                 :       }
     523                 : 
     524               0 :       mStyleContextHolder = mInnerFrame->GetStyleContext();
     525               0 :       NS_ASSERTION(mStyleContextHolder, "Frame without style context?");
     526                 :     }
     527                 :   }
     528                 : 
     529               0 :   if (!mStyleContextHolder || mStyleContextHolder->HasPseudoElementData()) {
     530                 : #ifdef DEBUG
     531               0 :     if (mStyleContextHolder) {
     532                 :       // We want to check that going through this path because of
     533                 :       // HasPseudoElementData is rare, because it slows us down a good
     534                 :       // bit.  So check that we're really inside something associated
     535                 :       // with a pseudo-element that contains elements.
     536               0 :       nsStyleContext *topWithPseudoElementData = mStyleContextHolder;
     537               0 :       while (topWithPseudoElementData->GetParent()->HasPseudoElementData()) {
     538               0 :         topWithPseudoElementData = topWithPseudoElementData->GetParent();
     539                 :       }
     540               0 :       NS_ASSERTION(nsCSSPseudoElements::PseudoElementContainsElements(
     541                 :                      topWithPseudoElementData->GetPseudo()),
     542                 :                    "we should be in a pseudo-element that is expected to "
     543                 :                    "contain elements");
     544                 :     }
     545                 : #endif
     546                 :     // Need to resolve a style context
     547                 :     mStyleContextHolder =
     548               0 :       nsComputedDOMStyle::GetStyleContextForElement(mContent->AsElement(),
     549                 :                                                     mPseudo,
     550               0 :                                                     mPresShell);
     551               0 :     NS_ENSURE_TRUE(mStyleContextHolder, NS_ERROR_OUT_OF_MEMORY);
     552               0 :     NS_ASSERTION(mPseudo || !mStyleContextHolder->HasPseudoElementData(),
     553                 :                  "should not have pseudo-element data");
     554                 :   }
     555                 : 
     556                 :   // mExposeVisitedStyle is set to true only by testing APIs that
     557                 :   // require UniversalXPConnect.
     558               0 :   NS_ABORT_IF_FALSE(!mExposeVisitedStyle ||
     559                 :                     nsContentUtils::CallerHasUniversalXPConnect(),
     560                 :                     "mExposeVisitedStyle set incorrectly");
     561               0 :   if (mExposeVisitedStyle && mStyleContextHolder->RelevantLinkVisited()) {
     562               0 :     nsStyleContext *styleIfVisited = mStyleContextHolder->GetStyleIfVisited();
     563               0 :     if (styleIfVisited) {
     564               0 :       mStyleContextHolder = styleIfVisited;
     565                 :     }
     566                 :   }
     567                 : 
     568                 :   // Call our pointer-to-member-function.
     569               0 :   *aReturn = (this->*(propEntry->mGetter))();
     570               0 :   NS_IF_ADDREF(*aReturn); // property getter gives us an object with refcount of 0
     571                 : 
     572               0 :   mOuterFrame = nsnull;
     573               0 :   mInnerFrame = nsnull;
     574               0 :   mPresShell = nsnull;
     575                 : 
     576                 :   // Release the current style context for it should be re-resolved
     577                 :   // whenever a frame is not available.
     578               0 :   mStyleContextHolder = nsnull;
     579                 : 
     580               0 :   return NS_OK;
     581                 : }
     582                 : 
     583                 : 
     584                 : NS_IMETHODIMP
     585               0 : nsComputedDOMStyle::RemoveProperty(const nsAString& aPropertyName,
     586                 :                                    nsAString& aReturn)
     587                 : {
     588               0 :   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     589                 : }
     590                 : 
     591                 : 
     592                 : NS_IMETHODIMP
     593               0 : nsComputedDOMStyle::GetPropertyPriority(const nsAString& aPropertyName,
     594                 :                                         nsAString& aReturn)
     595                 : {
     596               0 :   aReturn.Truncate();
     597                 : 
     598               0 :   return NS_OK;
     599                 : }
     600                 : 
     601                 : 
     602                 : NS_IMETHODIMP
     603               0 : nsComputedDOMStyle::SetProperty(const nsAString& aPropertyName,
     604                 :                                 const nsAString& aValue,
     605                 :                                 const nsAString& aPriority)
     606                 : {
     607               0 :   return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     608                 : }
     609                 : 
     610                 : 
     611                 : NS_IMETHODIMP
     612               0 : nsComputedDOMStyle::Item(PRUint32 aIndex, nsAString& aReturn)
     613                 : {
     614               0 :   aReturn.Truncate();
     615                 : 
     616               0 :   PRUint32 length = 0;
     617               0 :   const ComputedStyleMapEntry* propMap = GetQueryablePropertyMap(&length);
     618               0 :   if (aIndex < length) {
     619               0 :     CopyASCIItoUTF16(nsCSSProps::GetStringValue(propMap[aIndex].mProperty),
     620               0 :                     aReturn);
     621                 :   }
     622                 : 
     623               0 :   return NS_OK;
     624                 : }
     625                 : 
     626                 : 
     627                 : // Property getters...
     628                 : 
     629                 : nsIDOMCSSValue*
     630               0 : nsComputedDOMStyle::DoGetBinding()
     631                 : {
     632               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     633                 : 
     634               0 :   const nsStyleDisplay* display = GetStyleDisplay();
     635                 : 
     636               0 :   if (display->mBinding) {
     637               0 :     val->SetURI(display->mBinding->GetURI());
     638                 :   } else {
     639               0 :     val->SetIdent(eCSSKeyword_none);
     640                 :   }
     641                 : 
     642               0 :   return val;
     643                 : }
     644                 : 
     645                 : nsIDOMCSSValue*
     646               0 : nsComputedDOMStyle::DoGetClear()
     647                 : {
     648               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     649               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mBreakType,
     650               0 :                                                nsCSSProps::kClearKTable));
     651               0 :   return val;
     652                 : }
     653                 : 
     654                 : nsIDOMCSSValue*
     655               0 : nsComputedDOMStyle::DoGetCssFloat()
     656                 : {
     657               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
     658               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mFloats,
     659               0 :                                                nsCSSProps::kFloatKTable));
     660               0 :   return val;
     661                 : }
     662                 : 
     663                 : nsIDOMCSSValue*
     664               0 : nsComputedDOMStyle::DoGetBottom()
     665                 : {
     666               0 :   return GetOffsetWidthFor(NS_SIDE_BOTTOM);
     667                 : }
     668                 : 
     669                 : nsIDOMCSSValue*
     670               0 : nsComputedDOMStyle::DoGetStackSizing()
     671                 : {
     672               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     673               0 :   val->SetIdent(GetStyleXUL()->mStretchStack ? eCSSKeyword_stretch_to_fit :
     674               0 :                 eCSSKeyword_ignore);
     675               0 :   return val;
     676                 : }
     677                 : 
     678                 : void
     679               0 : nsComputedDOMStyle::SetToRGBAColor(nsROCSSPrimitiveValue* aValue,
     680                 :                                    nscolor aColor)
     681                 : {
     682               0 :   if (NS_GET_A(aColor) == 0) {
     683               0 :     aValue->SetIdent(eCSSKeyword_transparent);
     684               0 :     return;
     685                 :   }
     686                 : 
     687               0 :   nsROCSSPrimitiveValue *red   = GetROCSSPrimitiveValue();
     688               0 :   nsROCSSPrimitiveValue *green = GetROCSSPrimitiveValue();
     689               0 :   nsROCSSPrimitiveValue *blue  = GetROCSSPrimitiveValue();
     690               0 :   nsROCSSPrimitiveValue *alpha  = GetROCSSPrimitiveValue();
     691                 : 
     692               0 :   PRUint8 a = NS_GET_A(aColor);
     693                 :   nsDOMCSSRGBColor *rgbColor =
     694               0 :     new nsDOMCSSRGBColor(red, green, blue, alpha, a < 255);
     695                 : 
     696               0 :   red->SetNumber(NS_GET_R(aColor));
     697               0 :   green->SetNumber(NS_GET_G(aColor));
     698               0 :   blue->SetNumber(NS_GET_B(aColor));
     699               0 :   alpha->SetNumber(nsStyleUtil::ColorComponentToFloat(a));
     700                 : 
     701               0 :   aValue->SetColor(rgbColor);
     702                 : }
     703                 : 
     704                 : nsIDOMCSSValue*
     705               0 : nsComputedDOMStyle::DoGetColor()
     706                 : {
     707               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     708               0 :   SetToRGBAColor(val, GetStyleColor()->mColor);
     709               0 :   return val;
     710                 : }
     711                 : 
     712                 : nsIDOMCSSValue*
     713               0 : nsComputedDOMStyle::DoGetOpacity()
     714                 : {
     715               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     716               0 :   val->SetNumber(GetStyleDisplay()->mOpacity);
     717               0 :   return val;
     718                 : }
     719                 : 
     720                 : nsIDOMCSSValue*
     721               0 : nsComputedDOMStyle::DoGetColumnCount()
     722                 : {
     723               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     724                 : 
     725               0 :   const nsStyleColumn* column = GetStyleColumn();
     726                 : 
     727               0 :   if (column->mColumnCount == NS_STYLE_COLUMN_COUNT_AUTO) {
     728               0 :     val->SetIdent(eCSSKeyword_auto);
     729                 :   } else {
     730               0 :     val->SetNumber(column->mColumnCount);
     731                 :   }
     732                 : 
     733               0 :   return val;
     734                 : }
     735                 : 
     736                 : nsIDOMCSSValue*
     737               0 : nsComputedDOMStyle::DoGetColumnWidth()
     738                 : {
     739               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     740                 : 
     741                 :   // XXX fix the auto case. When we actually have a column frame, I think
     742                 :   // we should return the computed column width.
     743               0 :   SetValueToCoord(val, GetStyleColumn()->mColumnWidth, true);
     744               0 :   return val;
     745                 : }
     746                 : 
     747                 : nsIDOMCSSValue*
     748               0 : nsComputedDOMStyle::DoGetColumnGap()
     749                 : {
     750               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     751                 : 
     752               0 :   const nsStyleColumn* column = GetStyleColumn();
     753               0 :   if (column->mColumnGap.GetUnit() == eStyleUnit_Normal) {
     754               0 :     val->SetAppUnits(GetStyleFont()->mFont.size);
     755                 :   } else {
     756               0 :     SetValueToCoord(val, GetStyleColumn()->mColumnGap, true);
     757                 :   }
     758                 : 
     759               0 :   return val;
     760                 : }
     761                 : 
     762                 : nsIDOMCSSValue*
     763               0 : nsComputedDOMStyle::DoGetColumnFill()
     764                 : {
     765               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     766                 :   val->SetIdent(
     767               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleColumn()->mColumnFill,
     768               0 :                                    nsCSSProps::kColumnFillKTable));
     769               0 :   return val;
     770                 : }
     771                 : 
     772                 : nsIDOMCSSValue*
     773               0 : nsComputedDOMStyle::DoGetColumnRuleWidth()
     774                 : {
     775               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     776               0 :   val->SetAppUnits(GetStyleColumn()->GetComputedColumnRuleWidth());
     777               0 :   return val;
     778                 : }
     779                 : 
     780                 : nsIDOMCSSValue*
     781               0 : nsComputedDOMStyle::DoGetColumnRuleStyle()
     782                 : {
     783               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     784                 :   val->SetIdent(
     785               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleColumn()->mColumnRuleStyle,
     786               0 :                                    nsCSSProps::kBorderStyleKTable));
     787               0 :   return val;
     788                 : }
     789                 : 
     790                 : nsIDOMCSSValue*
     791               0 : nsComputedDOMStyle::DoGetColumnRuleColor()
     792                 : {
     793               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     794                 : 
     795               0 :   const nsStyleColumn* column = GetStyleColumn();
     796                 :   nscolor ruleColor;
     797               0 :   if (column->mColumnRuleColorIsForeground) {
     798               0 :     ruleColor = GetStyleColor()->mColor;
     799                 :   } else {
     800               0 :     ruleColor = column->mColumnRuleColor;
     801                 :   }
     802                 : 
     803               0 :   SetToRGBAColor(val, ruleColor);
     804               0 :   return val;
     805                 : }
     806                 : 
     807                 : nsIDOMCSSValue*
     808               0 : nsComputedDOMStyle::DoGetContent()
     809                 : {
     810               0 :   const nsStyleContent *content = GetStyleContent();
     811                 : 
     812               0 :   if (content->ContentCount() == 0) {
     813               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     814               0 :     val->SetIdent(eCSSKeyword_none);
     815               0 :     return val;
     816                 :   }
     817                 : 
     818               0 :   if (content->ContentCount() == 1 &&
     819               0 :       content->ContentAt(0).mType == eStyleContentType_AltContent) {
     820               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     821               0 :     val->SetIdent(eCSSKeyword__moz_alt_content);
     822               0 :     return val;
     823                 :   }
     824                 : 
     825               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
     826                 : 
     827               0 :   for (PRUint32 i = 0, i_end = content->ContentCount(); i < i_end; ++i) {
     828               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
     829               0 :     valueList->AppendCSSValue(val);
     830                 : 
     831               0 :     const nsStyleContentData &data = content->ContentAt(i);
     832               0 :     switch (data.mType) {
     833                 :       case eStyleContentType_String:
     834                 :         {
     835               0 :           nsString str;
     836                 :           nsStyleUtil::AppendEscapedCSSString(
     837               0 :             nsDependentString(data.mContent.mString), str);
     838               0 :           val->SetString(str);
     839                 :         }
     840               0 :         break;
     841                 :       case eStyleContentType_Image:
     842                 :         {
     843               0 :           nsCOMPtr<nsIURI> uri;
     844               0 :           if (data.mContent.mImage) {
     845               0 :             data.mContent.mImage->GetURI(getter_AddRefs(uri));
     846                 :           }
     847               0 :           val->SetURI(uri);
     848                 :         }
     849               0 :         break;
     850                 :       case eStyleContentType_Attr:
     851                 :         {
     852               0 :           nsAutoString str;
     853                 :           nsStyleUtil::AppendEscapedCSSIdent(
     854               0 :             nsDependentString(data.mContent.mString), str);
     855               0 :           val->SetString(str, nsIDOMCSSPrimitiveValue::CSS_ATTR);
     856                 :         }
     857               0 :         break;
     858                 :       case eStyleContentType_Counter:
     859                 :       case eStyleContentType_Counters:
     860                 :         {
     861                 :           /* FIXME: counters should really use an object */
     862               0 :           nsAutoString str;
     863               0 :           if (data.mType == eStyleContentType_Counter) {
     864               0 :             str.AppendLiteral("counter(");
     865                 :           }
     866                 :           else {
     867               0 :             str.AppendLiteral("counters(");
     868                 :           }
     869                 :           // WRITE ME
     870               0 :           nsCSSValue::Array *a = data.mContent.mCounters;
     871                 : 
     872                 :           nsStyleUtil::AppendEscapedCSSIdent(
     873               0 :             nsDependentString(a->Item(0).GetStringBufferValue()), str);
     874               0 :           PRInt32 typeItem = 1;
     875               0 :           if (data.mType == eStyleContentType_Counters) {
     876               0 :             typeItem = 2;
     877               0 :             str.AppendLiteral(", ");
     878                 :             nsStyleUtil::AppendEscapedCSSString(
     879               0 :               nsDependentString(a->Item(1).GetStringBufferValue()), str);
     880                 :           }
     881               0 :           NS_ABORT_IF_FALSE(eCSSUnit_None != a->Item(typeItem).GetUnit(),
     882                 :                             "'none' should be handled  as enumerated value");
     883               0 :           PRInt32 type = a->Item(typeItem).GetIntValue();
     884               0 :           if (type != NS_STYLE_LIST_STYLE_DECIMAL) {
     885               0 :             str.AppendLiteral(", ");
     886                 :             AppendASCIItoUTF16(
     887               0 :               nsCSSProps::ValueToKeyword(type, nsCSSProps::kListStyleKTable),
     888               0 :               str);
     889                 :           }
     890                 : 
     891               0 :           str.Append(PRUnichar(')'));
     892               0 :           val->SetString(str, nsIDOMCSSPrimitiveValue::CSS_COUNTER);
     893                 :         }
     894               0 :         break;
     895                 :       case eStyleContentType_OpenQuote:
     896               0 :         val->SetIdent(eCSSKeyword_open_quote);
     897               0 :         break;
     898                 :       case eStyleContentType_CloseQuote:
     899               0 :         val->SetIdent(eCSSKeyword_close_quote);
     900               0 :         break;
     901                 :       case eStyleContentType_NoOpenQuote:
     902               0 :         val->SetIdent(eCSSKeyword_no_open_quote);
     903               0 :         break;
     904                 :       case eStyleContentType_NoCloseQuote:
     905               0 :         val->SetIdent(eCSSKeyword_no_close_quote);
     906               0 :         break;
     907                 :       case eStyleContentType_AltContent:
     908                 :       default:
     909               0 :         NS_NOTREACHED("unexpected type");
     910               0 :         break;
     911                 :     }
     912                 :   }
     913                 : 
     914               0 :   return valueList;
     915                 : }
     916                 : 
     917                 : nsIDOMCSSValue*
     918               0 : nsComputedDOMStyle::DoGetCounterIncrement()
     919                 : {
     920               0 :   const nsStyleContent *content = GetStyleContent();
     921                 : 
     922               0 :   if (content->CounterIncrementCount() == 0) {
     923               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
     924               0 :     val->SetIdent(eCSSKeyword_none);
     925               0 :     return val;
     926                 :   }
     927                 : 
     928               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
     929                 : 
     930               0 :   for (PRUint32 i = 0, i_end = content->CounterIncrementCount(); i < i_end; ++i) {
     931               0 :     nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
     932               0 :     valueList->AppendCSSValue(name);
     933                 : 
     934               0 :     nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
     935               0 :     valueList->AppendCSSValue(value);
     936                 : 
     937               0 :     const nsStyleCounterData *data = content->GetCounterIncrementAt(i);
     938               0 :     nsAutoString escaped;
     939               0 :     nsStyleUtil::AppendEscapedCSSIdent(data->mCounter, escaped);
     940               0 :     name->SetString(escaped);
     941               0 :     value->SetNumber(data->mValue); // XXX This should really be integer
     942                 :   }
     943                 : 
     944               0 :   return valueList;
     945                 : }
     946                 : 
     947                 : /* Convert the stored representation into a list of two values and then hand
     948                 :  * it back.
     949                 :  */
     950                 : nsIDOMCSSValue*
     951               0 : nsComputedDOMStyle::DoGetMozTransformOrigin()
     952                 : {
     953                 :   /* We need to build up a list of two values.  We'll call them
     954                 :    * width and height.
     955                 :    */
     956                 : 
     957                 :   /* Store things as a value list */
     958               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
     959                 : 
     960                 :   /* Now, get the values. */
     961               0 :   const nsStyleDisplay* display = GetStyleDisplay();
     962                 : 
     963               0 :   nsROCSSPrimitiveValue* width = GetROCSSPrimitiveValue();
     964                 :   SetValueToCoord(width, display->mTransformOrigin[0], false,
     965               0 :                   &nsComputedDOMStyle::GetFrameBoundsWidthForTransform);
     966               0 :   valueList->AppendCSSValue(width);
     967                 : 
     968               0 :   nsROCSSPrimitiveValue* height = GetROCSSPrimitiveValue();
     969                 :   SetValueToCoord(height, display->mTransformOrigin[1], false,
     970               0 :                   &nsComputedDOMStyle::GetFrameBoundsHeightForTransform);
     971               0 :   valueList->AppendCSSValue(height);
     972                 : 
     973               0 :   if (display->mTransformOrigin[2].GetUnit() != eStyleUnit_Coord ||
     974               0 :       display->mTransformOrigin[2].GetCoordValue() != 0) {
     975               0 :     nsROCSSPrimitiveValue* depth = GetROCSSPrimitiveValue();
     976                 :     SetValueToCoord(depth, display->mTransformOrigin[2], false,
     977               0 :                     nsnull);
     978               0 :     valueList->AppendCSSValue(depth);
     979                 :   }
     980                 : 
     981               0 :   return valueList;
     982                 : }
     983                 : 
     984                 : /* Convert the stored representation into a list of two values and then hand
     985                 :  * it back.
     986                 :  */
     987                 : nsIDOMCSSValue*
     988               0 : nsComputedDOMStyle::DoGetMozPerspectiveOrigin()
     989                 : {
     990                 :   /* We need to build up a list of two values.  We'll call them
     991                 :    * width and height.
     992                 :    */
     993                 : 
     994                 :   /* Store things as a value list */
     995               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
     996                 : 
     997                 :   /* Now, get the values. */
     998               0 :   const nsStyleDisplay* display = GetStyleDisplay();
     999                 : 
    1000               0 :   nsROCSSPrimitiveValue* width = GetROCSSPrimitiveValue();
    1001                 :   SetValueToCoord(width, display->mPerspectiveOrigin[0], false,
    1002               0 :                   &nsComputedDOMStyle::GetFrameBoundsWidthForTransform);
    1003               0 :   valueList->AppendCSSValue(width);
    1004                 : 
    1005               0 :   nsROCSSPrimitiveValue* height = GetROCSSPrimitiveValue();
    1006                 :   SetValueToCoord(height, display->mPerspectiveOrigin[1], false,
    1007               0 :                   &nsComputedDOMStyle::GetFrameBoundsHeightForTransform);
    1008               0 :   valueList->AppendCSSValue(height);
    1009                 : 
    1010               0 :   return valueList;
    1011                 : }
    1012                 : 
    1013                 : nsIDOMCSSValue*
    1014               0 : nsComputedDOMStyle::DoGetMozPerspective()
    1015                 : {
    1016               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1017               0 :     if (GetStyleDisplay()->mChildPerspective.GetUnit() == eStyleUnit_Coord &&
    1018               0 :         GetStyleDisplay()->mChildPerspective.GetCoordValue() == 0.0) {
    1019               0 :         val->SetIdent(eCSSKeyword_none);
    1020                 :     } else {
    1021               0 :         SetValueToCoord(val, GetStyleDisplay()->mChildPerspective, false);
    1022                 :     }
    1023               0 :     return val;
    1024                 : }
    1025                 : 
    1026                 : nsIDOMCSSValue*
    1027               0 : nsComputedDOMStyle::DoGetMozBackfaceVisibility()
    1028                 : {
    1029               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1030                 :     val->SetIdent(
    1031               0 :         nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mBackfaceVisibility,
    1032               0 :                                        nsCSSProps::kBackfaceVisibilityKTable));
    1033               0 :     return val;
    1034                 : }
    1035                 : 
    1036                 : nsIDOMCSSValue*
    1037               0 : nsComputedDOMStyle::DoGetMozTransformStyle()
    1038                 : {
    1039               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1040                 :     val->SetIdent(
    1041               0 :         nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mTransformStyle,
    1042               0 :                                        nsCSSProps::kTransformStyleKTable));
    1043               0 :     return val;
    1044                 : }
    1045                 : 
    1046                 : /* If the property is "none", hand back "none" wrapped in a value.
    1047                 :  * Otherwise, compute the aggregate transform matrix and hands it back in a
    1048                 :  * "matrix" wrapper.
    1049                 :  */
    1050                 : nsIDOMCSSValue*
    1051               0 : nsComputedDOMStyle::DoGetMozTransform()
    1052                 : {
    1053                 :   /* First, get the display data.  We'll need it. */
    1054               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    1055                 : 
    1056                 :   /* If the "no transforms" flag is set, then we should construct a
    1057                 :    * single-element entry and hand it back.
    1058                 :    */
    1059               0 :   if (!display->HasTransform()) {
    1060               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1061                 : 
    1062                 :     /* Set it to "none." */
    1063               0 :     val->SetIdent(eCSSKeyword_none);
    1064               0 :     return val;
    1065                 :   }
    1066                 : 
    1067                 :   /* Otherwise, we need to compute the current value of the transform matrix,
    1068                 :    * store it in a string, and hand it back to the caller.
    1069                 :    */
    1070                 : 
    1071                 :   /* Use the inner frame for width and height.  If we fail, assume zero.
    1072                 :    * TODO: There is no good way for us to represent the case where there's no
    1073                 :    * frame, which is problematic.  The reason is that when we have percentage
    1074                 :    * transforms, there are a total of four stored matrix entries that influence
    1075                 :    * the transform based on the size of the element.  However, this poses a
    1076                 :    * problem, because only two of these values can be explicitly referenced
    1077                 :    * using the named transforms.  Until a real solution is found, we'll just
    1078                 :    * use this approach.
    1079                 :    */
    1080                 :   nsRect bounds =
    1081                 :     (mInnerFrame ? nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame) :
    1082               0 :      nsRect(0, 0, 0, 0));
    1083                 : 
    1084                 :    bool dummy;
    1085                 :    gfx3DMatrix matrix =
    1086                 :      nsStyleTransformMatrix::ReadTransforms(display->mSpecifiedTransform,
    1087                 :                                             mStyleContextHolder,
    1088                 :                                             mStyleContextHolder->PresContext(),
    1089                 :                                             dummy,
    1090                 :                                             bounds,
    1091               0 :                                             float(nsDeviceContext::AppUnitsPerCSSPixel()));
    1092                 : 
    1093               0 :   bool is3D = !matrix.Is2D();
    1094                 : 
    1095               0 :   nsAutoString resultString(NS_LITERAL_STRING("matrix"));
    1096               0 :   if (is3D) {
    1097               0 :     resultString.Append(NS_LITERAL_STRING("3d"));
    1098                 :   }
    1099                 : 
    1100               0 :   resultString.Append(NS_LITERAL_STRING("("));
    1101               0 :   resultString.AppendFloat(matrix._11);
    1102               0 :   resultString.Append(NS_LITERAL_STRING(", "));
    1103               0 :   resultString.AppendFloat(matrix._12);
    1104               0 :   resultString.Append(NS_LITERAL_STRING(", "));
    1105               0 :   if (is3D) {
    1106               0 :     resultString.AppendFloat(matrix._13);
    1107               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1108               0 :     resultString.AppendFloat(matrix._14);
    1109               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1110                 :   }
    1111               0 :   resultString.AppendFloat(matrix._21);
    1112               0 :   resultString.Append(NS_LITERAL_STRING(", "));
    1113               0 :   resultString.AppendFloat(matrix._22);
    1114               0 :   resultString.Append(NS_LITERAL_STRING(", "));
    1115               0 :   if (is3D) {
    1116               0 :     resultString.AppendFloat(matrix._23);
    1117               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1118               0 :     resultString.AppendFloat(matrix._24);
    1119               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1120               0 :     resultString.AppendFloat(matrix._31);
    1121               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1122               0 :     resultString.AppendFloat(matrix._32);
    1123               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1124               0 :     resultString.AppendFloat(matrix._33);
    1125               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1126               0 :     resultString.AppendFloat(matrix._34);
    1127               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1128                 :   }
    1129               0 :   resultString.AppendFloat(matrix._41);
    1130               0 :   resultString.Append(NS_LITERAL_STRING(", "));
    1131               0 :   resultString.AppendFloat(matrix._42);
    1132               0 :   if (is3D) {
    1133               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1134               0 :     resultString.AppendFloat(matrix._43);
    1135               0 :     resultString.Append(NS_LITERAL_STRING(", "));
    1136               0 :     resultString.AppendFloat(matrix._44);
    1137                 :   }
    1138               0 :   resultString.Append(NS_LITERAL_STRING(")"));
    1139                 : 
    1140                 :   /* Create a value to hold our result. */
    1141               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1142                 : 
    1143               0 :   val->SetString(resultString);
    1144               0 :   return val;
    1145                 : }
    1146                 : 
    1147                 : nsIDOMCSSValue*
    1148               0 : nsComputedDOMStyle::DoGetCounterReset()
    1149                 : {
    1150               0 :   const nsStyleContent *content = GetStyleContent();
    1151                 : 
    1152               0 :   if (content->CounterResetCount() == 0) {
    1153               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1154               0 :     val->SetIdent(eCSSKeyword_none);
    1155               0 :     return val;
    1156                 :   }
    1157                 : 
    1158               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    1159                 : 
    1160               0 :   for (PRUint32 i = 0, i_end = content->CounterResetCount(); i < i_end; ++i) {
    1161               0 :     nsROCSSPrimitiveValue* name = GetROCSSPrimitiveValue();
    1162               0 :     valueList->AppendCSSValue(name);
    1163                 : 
    1164               0 :     nsROCSSPrimitiveValue* value = GetROCSSPrimitiveValue();
    1165               0 :     valueList->AppendCSSValue(value);
    1166                 : 
    1167               0 :     const nsStyleCounterData *data = content->GetCounterResetAt(i);
    1168               0 :     nsAutoString escaped;
    1169               0 :     nsStyleUtil::AppendEscapedCSSIdent(data->mCounter, escaped);
    1170               0 :     name->SetString(escaped);
    1171               0 :     value->SetNumber(data->mValue); // XXX This should really be integer
    1172                 :   }
    1173                 : 
    1174               0 :   return valueList;
    1175                 : }
    1176                 : 
    1177                 : nsIDOMCSSValue*
    1178               0 : nsComputedDOMStyle::DoGetQuotes()
    1179                 : {
    1180               0 :   const nsStyleQuotes *quotes = GetStyleQuotes();
    1181                 : 
    1182               0 :   if (quotes->QuotesCount() == 0) {
    1183               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1184               0 :     val->SetIdent(eCSSKeyword_none);
    1185               0 :     return val;
    1186                 :   }
    1187                 : 
    1188               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    1189                 : 
    1190               0 :   for (PRUint32 i = 0, i_end = quotes->QuotesCount(); i < i_end; ++i) {
    1191               0 :     nsROCSSPrimitiveValue* openVal = GetROCSSPrimitiveValue();
    1192               0 :     valueList->AppendCSSValue(openVal);
    1193                 : 
    1194               0 :     nsROCSSPrimitiveValue* closeVal = GetROCSSPrimitiveValue();
    1195               0 :     valueList->AppendCSSValue(closeVal);
    1196                 : 
    1197               0 :     nsString s;
    1198               0 :     nsStyleUtil::AppendEscapedCSSString(*quotes->OpenQuoteAt(i), s);
    1199               0 :     openVal->SetString(s);
    1200               0 :     s.Truncate();
    1201               0 :     nsStyleUtil::AppendEscapedCSSString(*quotes->CloseQuoteAt(i), s);
    1202               0 :     closeVal->SetString(s);
    1203                 :   }
    1204                 : 
    1205               0 :   return valueList;
    1206                 : }
    1207                 : 
    1208                 : nsIDOMCSSValue*
    1209               0 : nsComputedDOMStyle::DoGetFontFamily()
    1210                 : {
    1211               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1212                 : 
    1213               0 :   const nsStyleFont* font = GetStyleFont();
    1214                 : 
    1215               0 :   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocumentWeak);
    1216               0 :   NS_ASSERTION(doc, "document is required");
    1217               0 :   nsIPresShell* presShell = doc->GetShell();
    1218               0 :   NS_ASSERTION(presShell, "pres shell is required");
    1219               0 :   nsPresContext *presContext = presShell->GetPresContext();
    1220               0 :   NS_ASSERTION(presContext, "pres context is required");
    1221                 : 
    1222               0 :   const nsString& fontName = font->mFont.name;
    1223               0 :   if (font->mGenericID == kGenericFont_NONE && !font->mFont.systemFont) {
    1224                 :     const nsFont* defaultFont =
    1225                 :       presContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
    1226               0 :                                   font->mLanguage);
    1227                 : 
    1228               0 :     PRInt32 lendiff = fontName.Length() - defaultFont->name.Length();
    1229               0 :     if (lendiff > 0) {
    1230               0 :       val->SetString(Substring(fontName, 0, lendiff-1)); // -1 removes comma
    1231                 :     } else {
    1232               0 :       val->SetString(fontName);
    1233               0 :     }
    1234                 :   } else {
    1235               0 :     val->SetString(fontName);
    1236                 :   }
    1237                 : 
    1238               0 :   return val;
    1239                 : }
    1240                 : 
    1241                 : nsIDOMCSSValue*
    1242               0 : nsComputedDOMStyle::DoGetFontSize()
    1243                 : {
    1244               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1245                 : 
    1246                 :   // Note: GetStyleFont()->mSize is the 'computed size';
    1247                 :   // GetStyleFont()->mFont.size is the 'actual size'
    1248               0 :   val->SetAppUnits(GetStyleFont()->mSize);
    1249               0 :   return val;
    1250                 : }
    1251                 : 
    1252                 : nsIDOMCSSValue*
    1253               0 : nsComputedDOMStyle::DoGetFontSizeAdjust()
    1254                 : {
    1255               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1256                 : 
    1257               0 :   const nsStyleFont *font = GetStyleFont();
    1258                 : 
    1259               0 :   if (font->mFont.sizeAdjust) {
    1260               0 :     val->SetNumber(font->mFont.sizeAdjust);
    1261                 :   } else {
    1262               0 :     val->SetIdent(eCSSKeyword_none);
    1263                 :   }
    1264                 : 
    1265               0 :   return val;
    1266                 : }
    1267                 : 
    1268                 : nsIDOMCSSValue*
    1269               0 : nsComputedDOMStyle::DoGetFontStretch()
    1270                 : {
    1271               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1272                 : 
    1273               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleFont()->mFont.stretch,
    1274               0 :                                                nsCSSProps::kFontStretchKTable));
    1275                 : 
    1276               0 :   return val;
    1277                 : }
    1278                 : 
    1279                 : nsIDOMCSSValue*
    1280               0 : nsComputedDOMStyle::DoGetFontStyle()
    1281                 : {
    1282               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1283               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleFont()->mFont.style,
    1284               0 :                                                nsCSSProps::kFontStyleKTable));
    1285               0 :   return val;
    1286                 : }
    1287                 : 
    1288                 : nsIDOMCSSValue*
    1289               0 : nsComputedDOMStyle::DoGetFontWeight()
    1290                 : {
    1291               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1292                 : 
    1293               0 :   const nsStyleFont* font = GetStyleFont();
    1294                 : 
    1295               0 :   PRUint16 weight = font->mFont.weight;
    1296               0 :   if (weight % 100 == 0) {
    1297               0 :     val->SetNumber(font->mFont.weight);
    1298               0 :   } else if (weight % 100 > 50) {
    1299                 :     // FIXME: This doesn't represent the full range of computed values,
    1300                 :     // but at least it's legal CSS.
    1301               0 :     val->SetIdent(eCSSKeyword_lighter);
    1302                 :   } else {
    1303                 :     // FIXME: This doesn't represent the full range of computed values,
    1304                 :     // but at least it's legal CSS.
    1305               0 :     val->SetIdent(eCSSKeyword_bolder);
    1306                 :   }
    1307                 : 
    1308               0 :   return val;
    1309                 : }
    1310                 : 
    1311                 : nsIDOMCSSValue*
    1312               0 : nsComputedDOMStyle::DoGetFontVariant()
    1313                 : {
    1314               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1315                 :   val->SetIdent(
    1316               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleFont()->mFont.variant,
    1317               0 :                                    nsCSSProps::kFontVariantKTable));
    1318               0 :   return val;
    1319                 : }
    1320                 : 
    1321                 : nsIDOMCSSValue*
    1322               0 : nsComputedDOMStyle::DoGetMozFontFeatureSettings()
    1323                 : {
    1324               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1325                 : 
    1326               0 :   const nsStyleFont* font = GetStyleFont();
    1327               0 :   if (font->mFont.featureSettings.IsEmpty()) {
    1328               0 :     val->SetIdent(eCSSKeyword_normal);
    1329                 :   } else {
    1330               0 :     nsString str;
    1331               0 :     nsStyleUtil::AppendEscapedCSSString(font->mFont.featureSettings, str);
    1332               0 :     val->SetString(str);
    1333                 :   }
    1334               0 :   return val;
    1335                 : }
    1336                 : 
    1337                 : nsIDOMCSSValue*
    1338               0 : nsComputedDOMStyle::DoGetMozFontLanguageOverride()
    1339                 : {
    1340               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1341                 : 
    1342               0 :   const nsStyleFont* font = GetStyleFont();
    1343               0 :   if (font->mFont.languageOverride.IsEmpty()) {
    1344               0 :     val->SetIdent(eCSSKeyword_normal);
    1345                 :   } else {
    1346               0 :     nsString str;
    1347               0 :     nsStyleUtil::AppendEscapedCSSString(font->mFont.languageOverride, str);
    1348               0 :     val->SetString(str);
    1349                 :   }
    1350               0 :   return val;
    1351                 : }
    1352                 : 
    1353                 : nsIDOMCSSValue*
    1354               0 : nsComputedDOMStyle::GetBackgroundList(PRUint8 nsStyleBackground::Layer::* aMember,
    1355                 :                                       PRUint32 nsStyleBackground::* aCount,
    1356                 :                                       const PRInt32 aTable[])
    1357                 : {
    1358               0 :   const nsStyleBackground* bg = GetStyleBackground();
    1359                 : 
    1360               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    1361                 : 
    1362               0 :   for (PRUint32 i = 0, i_end = bg->*aCount; i < i_end; ++i) {
    1363               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1364               0 :     valueList->AppendCSSValue(val);
    1365               0 :     val->SetIdent(nsCSSProps::ValueToKeywordEnum(bg->mLayers[i].*aMember,
    1366               0 :                                                  aTable));
    1367                 :   }
    1368                 : 
    1369               0 :   return valueList;
    1370                 : }
    1371                 : 
    1372                 : nsIDOMCSSValue*
    1373               0 : nsComputedDOMStyle::DoGetBackgroundAttachment()
    1374                 : {
    1375                 :   return GetBackgroundList(&nsStyleBackground::Layer::mAttachment,
    1376                 :                            &nsStyleBackground::mAttachmentCount,
    1377               0 :                            nsCSSProps::kBackgroundAttachmentKTable);
    1378                 : }
    1379                 : 
    1380                 : nsIDOMCSSValue*
    1381               0 : nsComputedDOMStyle::DoGetBackgroundClip()
    1382                 : {
    1383                 :   return GetBackgroundList(&nsStyleBackground::Layer::mClip,
    1384                 :                            &nsStyleBackground::mClipCount,
    1385               0 :                            nsCSSProps::kBackgroundOriginKTable);
    1386                 : }
    1387                 : 
    1388                 : nsIDOMCSSValue*
    1389               0 : nsComputedDOMStyle::DoGetBackgroundColor()
    1390                 : {
    1391               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1392               0 :   SetToRGBAColor(val, GetStyleBackground()->mBackgroundColor);
    1393               0 :   return val;
    1394                 : }
    1395                 : 
    1396                 : 
    1397                 : static void
    1398               0 : SetValueToCalc(const nsStyleCoord::Calc *aCalc, nsROCSSPrimitiveValue *aValue)
    1399                 : {
    1400               0 :   nsRefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue();
    1401               0 :   nsAutoString tmp, result;
    1402                 : 
    1403               0 :   result.AppendLiteral("-moz-calc(");
    1404                 : 
    1405               0 :   val->SetAppUnits(aCalc->mLength);
    1406               0 :   val->GetCssText(tmp);
    1407               0 :   result.Append(tmp);
    1408                 : 
    1409               0 :   if (aCalc->mHasPercent) {
    1410               0 :     result.AppendLiteral(" + ");
    1411                 : 
    1412               0 :     val->SetPercent(aCalc->mPercent);
    1413               0 :     val->GetCssText(tmp);
    1414               0 :     result.Append(tmp);
    1415                 :   }
    1416                 : 
    1417               0 :   result.AppendLiteral(")");
    1418                 : 
    1419               0 :   aValue->SetString(result); // not really SetString
    1420               0 : }
    1421                 : 
    1422                 : static void
    1423               0 : AppendCSSGradientLength(const nsStyleCoord& aValue,
    1424                 :                         nsROCSSPrimitiveValue* aPrimitive,
    1425                 :                         nsAString& aString)
    1426                 : {
    1427               0 :   nsAutoString tokenString;
    1428               0 :   if (aValue.IsCalcUnit())
    1429               0 :     SetValueToCalc(aValue.GetCalcValue(), aPrimitive);
    1430               0 :   else if (aValue.GetUnit() == eStyleUnit_Coord)
    1431               0 :     aPrimitive->SetAppUnits(aValue.GetCoordValue());
    1432                 :   else
    1433               0 :     aPrimitive->SetPercent(aValue.GetPercentValue());
    1434               0 :   aPrimitive->GetCssText(tokenString);
    1435               0 :   aString.Append(tokenString);
    1436               0 : }
    1437                 : 
    1438                 : static void
    1439               0 : AppendCSSGradientToBoxPosition(const nsStyleGradient* aGradient,
    1440                 :                                nsAString& aString,
    1441                 :                                bool& aNeedSep)
    1442                 : {
    1443               0 :   float xValue = aGradient->mBgPosX.GetPercentValue();
    1444               0 :   float yValue = aGradient->mBgPosY.GetPercentValue();
    1445                 : 
    1446               0 :   if (yValue == 1.0f && xValue == 0.5f) {
    1447                 :     // omit "to bottom"
    1448               0 :     return;
    1449                 :   }
    1450               0 :   NS_ASSERTION(yValue != 0.5f || xValue != 0.5f, "invalid box position");
    1451                 : 
    1452               0 :   aString.AppendLiteral("to");
    1453                 : 
    1454               0 :   if (yValue == 0.0f) {
    1455               0 :     aString.AppendLiteral(" top");
    1456               0 :   } else if (yValue == 1.0f) {
    1457               0 :     aString.AppendLiteral(" bottom");
    1458               0 :   } else if (yValue != 0.5f) { // do not write "center" keyword
    1459               0 :     NS_NOTREACHED("invalid box position");
    1460                 :   }
    1461                 : 
    1462               0 :   if (xValue == 0.0f) {
    1463               0 :     aString.AppendLiteral(" left");
    1464               0 :   } else if (xValue == 1.0f) {
    1465               0 :     aString.AppendLiteral(" right");
    1466               0 :   } else if (xValue != 0.5f) { // do not write "center" keyword
    1467               0 :     NS_NOTREACHED("invalid box position");
    1468                 :   }
    1469                 : 
    1470               0 :   aNeedSep = true;
    1471                 : }
    1472                 : 
    1473                 : void
    1474               0 : nsComputedDOMStyle::GetCSSGradientString(const nsStyleGradient* aGradient,
    1475                 :                                          nsAString& aString)
    1476                 : {
    1477               0 :   if (aGradient->mRepeating) {
    1478               0 :     if (aGradient->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR)
    1479               0 :       aString.AssignLiteral("-moz-repeating-linear-gradient(");
    1480                 :     else
    1481               0 :       aString.AssignLiteral("-moz-repeating-radial-gradient(");
    1482                 :   } else {
    1483               0 :     if (aGradient->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR)
    1484               0 :       aString.AssignLiteral("-moz-linear-gradient(");
    1485                 :     else
    1486               0 :       aString.AssignLiteral("-moz-radial-gradient(");
    1487                 :   }
    1488                 : 
    1489               0 :   bool needSep = false;
    1490               0 :   nsAutoString tokenString;
    1491               0 :   nsROCSSPrimitiveValue *tmpVal = GetROCSSPrimitiveValue();
    1492                 : 
    1493               0 :   if (aGradient->mToCorner) {
    1494               0 :     AppendCSSGradientToBoxPosition(aGradient, aString, needSep);
    1495                 :   } else {
    1496               0 :     if (aGradient->mBgPosX.GetUnit() != eStyleUnit_None) {
    1497               0 :       AppendCSSGradientLength(aGradient->mBgPosX, tmpVal, aString);
    1498               0 :       needSep = true;
    1499                 :     }
    1500               0 :     if (aGradient->mBgPosY.GetUnit() != eStyleUnit_None) {
    1501               0 :       if (needSep) {
    1502               0 :         aString.AppendLiteral(" ");
    1503                 :       }
    1504               0 :       AppendCSSGradientLength(aGradient->mBgPosY, tmpVal, aString);
    1505               0 :       needSep = true;
    1506                 :     }
    1507                 :   }
    1508               0 :   if (aGradient->mAngle.GetUnit() != eStyleUnit_None) {
    1509               0 :     if (needSep) {
    1510               0 :       aString.AppendLiteral(" ");
    1511                 :     }
    1512               0 :     tmpVal->SetNumber(aGradient->mAngle.GetAngleValue());
    1513               0 :     tmpVal->GetCssText(tokenString);
    1514               0 :     aString.Append(tokenString);
    1515               0 :     switch (aGradient->mAngle.GetUnit()) {
    1516               0 :     case eStyleUnit_Degree: aString.AppendLiteral("deg"); break;
    1517               0 :     case eStyleUnit_Grad: aString.AppendLiteral("grad"); break;
    1518               0 :     case eStyleUnit_Radian: aString.AppendLiteral("rad"); break;
    1519               0 :     case eStyleUnit_Turn: aString.AppendLiteral("turn"); break;
    1520               0 :     default: NS_NOTREACHED("unrecognized angle unit");
    1521                 :     }
    1522               0 :     needSep = true;
    1523                 :   }
    1524                 : 
    1525               0 :   if (aGradient->mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR) {
    1526               0 :     if (needSep) {
    1527               0 :       aString.AppendLiteral(", ");
    1528                 :     }
    1529                 :     AppendASCIItoUTF16(nsCSSProps::
    1530                 :                        ValueToKeyword(aGradient->mShape,
    1531               0 :                                       nsCSSProps::kRadialGradientShapeKTable),
    1532               0 :                        aString);
    1533               0 :     if (aGradient->mSize != NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER) {
    1534               0 :       aString.AppendLiteral(" ");
    1535                 :       AppendASCIItoUTF16(nsCSSProps::
    1536                 :                          ValueToKeyword(aGradient->mSize,
    1537               0 :                                         nsCSSProps::kRadialGradientSizeKTable),
    1538               0 :                          aString);
    1539                 :     }
    1540               0 :     needSep = true;
    1541                 :   }
    1542                 : 
    1543                 : 
    1544                 :   // color stops
    1545               0 :   for (PRUint32 i = 0; i < aGradient->mStops.Length(); ++i) {
    1546               0 :     if (needSep) {
    1547               0 :       aString.AppendLiteral(", ");
    1548                 :     }
    1549               0 :     SetToRGBAColor(tmpVal, aGradient->mStops[i].mColor);
    1550               0 :     tmpVal->GetCssText(tokenString);
    1551               0 :     aString.Append(tokenString);
    1552                 : 
    1553               0 :     if (aGradient->mStops[i].mLocation.GetUnit() != eStyleUnit_None) {
    1554               0 :       aString.AppendLiteral(" ");
    1555               0 :       AppendCSSGradientLength(aGradient->mStops[i].mLocation, tmpVal, aString);
    1556                 :     }
    1557               0 :     needSep = true;
    1558                 :   }
    1559                 : 
    1560               0 :   delete tmpVal;
    1561               0 :   aString.AppendLiteral(")");
    1562               0 : }
    1563                 : 
    1564                 : // -moz-image-rect(<uri>, <top>, <right>, <bottom>, <left>)
    1565                 : void
    1566               0 : nsComputedDOMStyle::GetImageRectString(nsIURI* aURI,
    1567                 :                                        const nsStyleSides& aCropRect,
    1568                 :                                        nsString& aString)
    1569                 : {
    1570               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(true);
    1571                 : 
    1572                 :   // <uri>
    1573               0 :   nsROCSSPrimitiveValue *valURI = GetROCSSPrimitiveValue();
    1574               0 :   valueList->AppendCSSValue(valURI);
    1575               0 :   valURI->SetURI(aURI);
    1576                 : 
    1577                 :   // <top>, <right>, <bottom>, <left>
    1578               0 :   NS_FOR_CSS_SIDES(side) {
    1579               0 :     nsROCSSPrimitiveValue *valSide = GetROCSSPrimitiveValue();
    1580               0 :     valueList->AppendCSSValue(valSide);
    1581               0 :     SetValueToCoord(valSide, aCropRect.Get(side), false);
    1582                 :   }
    1583                 : 
    1584               0 :   nsAutoString argumentString;
    1585               0 :   valueList->GetCssText(argumentString);
    1586               0 :   delete valueList;
    1587                 : 
    1588               0 :   aString = NS_LITERAL_STRING("-moz-image-rect(") +
    1589               0 :             argumentString +
    1590               0 :             NS_LITERAL_STRING(")");
    1591               0 : }
    1592                 : 
    1593                 : void
    1594               0 : nsComputedDOMStyle::SetValueToStyleImage(const nsStyleImage& aStyleImage,
    1595                 :                                          nsROCSSPrimitiveValue* aValue)
    1596                 : {
    1597               0 :   switch (aStyleImage.GetType()) {
    1598                 :     case eStyleImageType_Image:
    1599                 :     {
    1600               0 :       imgIRequest *req = aStyleImage.GetImageData();
    1601               0 :       nsCOMPtr<nsIURI> uri;
    1602               0 :       req->GetURI(getter_AddRefs(uri));
    1603                 : 
    1604               0 :       const nsStyleSides* cropRect = aStyleImage.GetCropRect();
    1605               0 :       if (cropRect) {
    1606               0 :         nsAutoString imageRectString;
    1607               0 :         GetImageRectString(uri, *cropRect, imageRectString);
    1608               0 :         aValue->SetString(imageRectString);
    1609                 :       } else {
    1610               0 :         aValue->SetURI(uri);
    1611                 :       }
    1612                 :       break;
    1613                 :     }
    1614                 :     case eStyleImageType_Gradient:
    1615                 :     {
    1616               0 :       nsAutoString gradientString;
    1617               0 :       GetCSSGradientString(aStyleImage.GetGradientData(),
    1618               0 :                            gradientString);
    1619               0 :       aValue->SetString(gradientString);
    1620                 :       break;
    1621                 :     }
    1622                 :     case eStyleImageType_Element:
    1623                 :     {
    1624               0 :       nsAutoString elementId;
    1625                 :       nsStyleUtil::AppendEscapedCSSIdent(
    1626               0 :         nsDependentString(aStyleImage.GetElementId()), elementId);
    1627               0 :       nsAutoString elementString = NS_LITERAL_STRING("-moz-element(#") +
    1628               0 :                                    elementId +
    1629               0 :                                    NS_LITERAL_STRING(")");
    1630               0 :       aValue->SetString(elementString);
    1631                 :       break;
    1632                 :     }
    1633                 :     case eStyleImageType_Null:
    1634               0 :       aValue->SetIdent(eCSSKeyword_none);
    1635               0 :       break;
    1636                 :     default:
    1637               0 :       NS_NOTREACHED("unexpected image type");
    1638               0 :       break;
    1639                 :   }
    1640               0 : }
    1641                 : 
    1642                 : nsIDOMCSSValue*
    1643               0 : nsComputedDOMStyle::DoGetBackgroundImage()
    1644                 : {
    1645               0 :   const nsStyleBackground* bg = GetStyleBackground();
    1646                 : 
    1647               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    1648                 : 
    1649               0 :   for (PRUint32 i = 0, i_end = bg->mImageCount; i < i_end; ++i) {
    1650               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1651               0 :     valueList->AppendCSSValue(val);
    1652                 : 
    1653               0 :     const nsStyleImage& image = bg->mLayers[i].mImage;
    1654               0 :     SetValueToStyleImage(image, val);
    1655                 :   }
    1656                 : 
    1657               0 :   return valueList;
    1658                 : }
    1659                 : 
    1660                 : nsIDOMCSSValue*
    1661               0 : nsComputedDOMStyle::DoGetBackgroundInlinePolicy()
    1662                 : {
    1663               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1664                 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(
    1665               0 :                   GetStyleBackground()->mBackgroundInlinePolicy,
    1666               0 :                   nsCSSProps::kBackgroundInlinePolicyKTable));
    1667               0 :   return val;
    1668                 : }
    1669                 : 
    1670                 : nsIDOMCSSValue*
    1671               0 : nsComputedDOMStyle::DoGetBackgroundOrigin()
    1672                 : {
    1673                 :   return GetBackgroundList(&nsStyleBackground::Layer::mOrigin,
    1674                 :                            &nsStyleBackground::mOriginCount,
    1675               0 :                            nsCSSProps::kBackgroundOriginKTable);
    1676                 : }
    1677                 : 
    1678                 : nsIDOMCSSValue*
    1679               0 : nsComputedDOMStyle::DoGetBackgroundPosition()
    1680                 : {
    1681               0 :   const nsStyleBackground* bg = GetStyleBackground();
    1682                 : 
    1683               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    1684                 : 
    1685               0 :   for (PRUint32 i = 0, i_end = bg->mPositionCount; i < i_end; ++i) {
    1686               0 :     nsDOMCSSValueList *itemList = GetROCSSValueList(false);
    1687               0 :     valueList->AppendCSSValue(itemList);
    1688                 : 
    1689               0 :     nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
    1690               0 :     itemList->AppendCSSValue(valX);
    1691                 : 
    1692               0 :     nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
    1693               0 :     itemList->AppendCSSValue(valY);
    1694                 : 
    1695               0 :     const nsStyleBackground::Position &pos = bg->mLayers[i].mPosition;
    1696                 : 
    1697               0 :     if (!pos.mXPosition.mHasPercent) {
    1698               0 :       NS_ABORT_IF_FALSE(pos.mXPosition.mPercent == 0.0f,
    1699                 :                         "Shouldn't have mPercent!");
    1700               0 :       valX->SetAppUnits(pos.mXPosition.mLength);
    1701               0 :     } else if (pos.mXPosition.mLength == 0) {
    1702               0 :       valX->SetPercent(pos.mXPosition.mPercent);
    1703                 :     } else {
    1704               0 :       SetValueToCalc(&pos.mXPosition, valX);
    1705                 :     }
    1706                 : 
    1707               0 :     if (!pos.mYPosition.mHasPercent) {
    1708               0 :       NS_ABORT_IF_FALSE(pos.mYPosition.mPercent == 0.0f,
    1709                 :                         "Shouldn't have mPercent!");
    1710               0 :       valY->SetAppUnits(pos.mYPosition.mLength);
    1711               0 :     } else if (pos.mYPosition.mLength == 0) {
    1712               0 :       valY->SetPercent(pos.mYPosition.mPercent);
    1713                 :     } else {
    1714               0 :       SetValueToCalc(&pos.mYPosition, valY);
    1715                 :     }
    1716                 :   }
    1717                 : 
    1718               0 :   return valueList;
    1719                 : }
    1720                 : 
    1721                 : nsIDOMCSSValue*
    1722               0 : nsComputedDOMStyle::DoGetBackgroundRepeat()
    1723                 : {
    1724               0 :   const nsStyleBackground* bg = GetStyleBackground();
    1725                 : 
    1726               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    1727                 : 
    1728               0 :   for (PRUint32 i = 0, i_end = bg->mRepeatCount; i < i_end; ++i) {
    1729               0 :     nsDOMCSSValueList *itemList = GetROCSSValueList(false);
    1730               0 :     valueList->AppendCSSValue(itemList);
    1731                 : 
    1732               0 :     nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
    1733               0 :     itemList->AppendCSSValue(valX);
    1734                 : 
    1735               0 :     const PRUint8& xRepeat = bg->mLayers[i].mRepeat.mXRepeat;
    1736               0 :     const PRUint8& yRepeat = bg->mLayers[i].mRepeat.mYRepeat;
    1737                 : 
    1738               0 :     bool hasContraction = true;
    1739                 :     PRUintn contraction;
    1740               0 :     if (xRepeat == yRepeat) {
    1741               0 :       contraction = xRepeat;
    1742               0 :     } else if (xRepeat == NS_STYLE_BG_REPEAT_REPEAT &&
    1743                 :                yRepeat == NS_STYLE_BG_REPEAT_NO_REPEAT) {
    1744               0 :       contraction = NS_STYLE_BG_REPEAT_REPEAT_X;
    1745               0 :     } else if (xRepeat == NS_STYLE_BG_REPEAT_NO_REPEAT &&
    1746                 :                yRepeat == NS_STYLE_BG_REPEAT_REPEAT) {
    1747               0 :       contraction = NS_STYLE_BG_REPEAT_REPEAT_Y;
    1748                 :     } else {
    1749               0 :       hasContraction = false;
    1750                 :     }
    1751                 : 
    1752               0 :     if (hasContraction) {
    1753                 :       valX->SetIdent(nsCSSProps::ValueToKeywordEnum(contraction,
    1754               0 :                                          nsCSSProps::kBackgroundRepeatKTable));
    1755                 :     } else {
    1756               0 :       nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
    1757               0 :       itemList->AppendCSSValue(valY);
    1758                 :       
    1759                 :       valX->SetIdent(nsCSSProps::ValueToKeywordEnum(xRepeat,
    1760               0 :                                           nsCSSProps::kBackgroundRepeatKTable));
    1761                 :       valY->SetIdent(nsCSSProps::ValueToKeywordEnum(yRepeat,
    1762               0 :                                           nsCSSProps::kBackgroundRepeatKTable));
    1763                 :     }
    1764                 :   }
    1765                 : 
    1766               0 :   return valueList;
    1767                 : }
    1768                 : 
    1769                 : nsIDOMCSSValue*
    1770               0 : nsComputedDOMStyle::DoGetMozBackgroundSize()
    1771                 : {
    1772               0 :   const nsStyleBackground* bg = GetStyleBackground();
    1773                 : 
    1774               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    1775                 : 
    1776               0 :   for (PRUint32 i = 0, i_end = bg->mSizeCount; i < i_end; ++i) {
    1777               0 :     const nsStyleBackground::Size &size = bg->mLayers[i].mSize;
    1778                 : 
    1779               0 :     switch (size.mWidthType) {
    1780                 :       case nsStyleBackground::Size::eContain:
    1781                 :       case nsStyleBackground::Size::eCover: {
    1782               0 :         NS_ABORT_IF_FALSE(size.mWidthType == size.mHeightType,
    1783                 :                           "unsynced types");
    1784                 :         nsCSSKeyword keyword = size.mWidthType == nsStyleBackground::Size::eContain
    1785                 :                              ? eCSSKeyword_contain
    1786               0 :                              : eCSSKeyword_cover;
    1787               0 :         nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1788               0 :         valueList->AppendCSSValue(val);
    1789               0 :         val->SetIdent(keyword);
    1790               0 :         break;
    1791                 :       }
    1792                 :       default: {
    1793               0 :         nsDOMCSSValueList *itemList = GetROCSSValueList(false);
    1794               0 :         valueList->AppendCSSValue(itemList);
    1795                 : 
    1796               0 :         nsROCSSPrimitiveValue* valX = GetROCSSPrimitiveValue();
    1797               0 :         itemList->AppendCSSValue(valX);
    1798               0 :         nsROCSSPrimitiveValue* valY = GetROCSSPrimitiveValue();
    1799               0 :         itemList->AppendCSSValue(valY);
    1800                 : 
    1801               0 :         if (size.mWidthType == nsStyleBackground::Size::eAuto) {
    1802               0 :           valX->SetIdent(eCSSKeyword_auto);
    1803                 :         } else {
    1804               0 :           NS_ABORT_IF_FALSE(size.mWidthType ==
    1805                 :                               nsStyleBackground::Size::eLengthPercentage,
    1806                 :                             "bad mWidthType");
    1807               0 :           if (!size.mWidth.mHasPercent &&
    1808                 :               // negative values must have come from calc()
    1809                 :               size.mWidth.mLength >= 0) {
    1810               0 :             NS_ABORT_IF_FALSE(size.mWidth.mPercent == 0.0f,
    1811                 :                               "Shouldn't have mPercent");
    1812               0 :             valX->SetAppUnits(size.mWidth.mLength);
    1813               0 :           } else if (size.mWidth.mLength == 0 &&
    1814                 :                      // negative values must have come from calc()
    1815                 :                      size.mWidth.mPercent >= 0.0f) {
    1816               0 :             valX->SetPercent(size.mWidth.mPercent);
    1817                 :           } else {
    1818               0 :             SetValueToCalc(&size.mWidth, valX);
    1819                 :           }
    1820                 :         }
    1821                 : 
    1822               0 :         if (size.mHeightType == nsStyleBackground::Size::eAuto) {
    1823               0 :           valY->SetIdent(eCSSKeyword_auto);
    1824                 :         } else {
    1825               0 :           NS_ABORT_IF_FALSE(size.mHeightType ==
    1826                 :                               nsStyleBackground::Size::eLengthPercentage,
    1827                 :                             "bad mHeightType");
    1828               0 :           if (!size.mHeight.mHasPercent &&
    1829                 :               // negative values must have come from calc()
    1830                 :               size.mHeight.mLength >= 0) {
    1831               0 :             NS_ABORT_IF_FALSE(size.mHeight.mPercent == 0.0f,
    1832                 :                               "Shouldn't have mPercent");
    1833               0 :             valY->SetAppUnits(size.mHeight.mLength);
    1834               0 :           } else if (size.mHeight.mLength == 0 &&
    1835                 :                      // negative values must have come from calc()
    1836                 :                      size.mHeight.mPercent >= 0.0f) {
    1837               0 :             valY->SetPercent(size.mHeight.mPercent);
    1838                 :           } else {
    1839               0 :             SetValueToCalc(&size.mHeight, valY);
    1840                 :           }
    1841                 :         }
    1842               0 :         break;
    1843                 :       }
    1844                 :     }
    1845                 :   }
    1846                 : 
    1847               0 :   return valueList;
    1848                 : }
    1849                 : 
    1850                 : nsIDOMCSSValue*
    1851               0 : nsComputedDOMStyle::DoGetPadding()
    1852                 : {
    1853                 :   // return null per spec.
    1854               0 :   return nsnull;
    1855                 : }
    1856                 : 
    1857                 : nsIDOMCSSValue*
    1858               0 : nsComputedDOMStyle::DoGetPaddingTop()
    1859                 : {
    1860               0 :   return GetPaddingWidthFor(NS_SIDE_TOP);
    1861                 : }
    1862                 : 
    1863                 : nsIDOMCSSValue*
    1864               0 : nsComputedDOMStyle::DoGetPaddingBottom()
    1865                 : {
    1866               0 :   return GetPaddingWidthFor(NS_SIDE_BOTTOM);
    1867                 : }
    1868                 : 
    1869                 : nsIDOMCSSValue*
    1870               0 : nsComputedDOMStyle::DoGetPaddingLeft()
    1871                 : {
    1872               0 :   return GetPaddingWidthFor(NS_SIDE_LEFT);
    1873                 : }
    1874                 : 
    1875                 : nsIDOMCSSValue*
    1876               0 : nsComputedDOMStyle::DoGetPaddingRight()
    1877                 : {
    1878               0 :   return GetPaddingWidthFor(NS_SIDE_RIGHT);
    1879                 : }
    1880                 : 
    1881                 : nsIDOMCSSValue*
    1882               0 : nsComputedDOMStyle::DoGetBorderCollapse()
    1883                 : {
    1884               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    1885                 :   val->SetIdent(
    1886               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTableBorder()->mBorderCollapse,
    1887               0 :                                    nsCSSProps::kBorderCollapseKTable));
    1888               0 :   return val;
    1889                 : }
    1890                 : 
    1891                 : nsIDOMCSSValue*
    1892               0 : nsComputedDOMStyle::DoGetBorderSpacing()
    1893                 : {
    1894               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    1895                 : 
    1896               0 :   nsROCSSPrimitiveValue* xSpacing = GetROCSSPrimitiveValue();
    1897               0 :   valueList->AppendCSSValue(xSpacing);
    1898                 : 
    1899               0 :   nsROCSSPrimitiveValue* ySpacing = GetROCSSPrimitiveValue();
    1900               0 :   valueList->AppendCSSValue(ySpacing);
    1901                 : 
    1902               0 :   const nsStyleTableBorder *border = GetStyleTableBorder();
    1903               0 :   xSpacing->SetAppUnits(border->mBorderSpacingX);
    1904               0 :   ySpacing->SetAppUnits(border->mBorderSpacingY);
    1905                 : 
    1906               0 :   return valueList;
    1907                 : }
    1908                 : 
    1909                 : nsIDOMCSSValue*
    1910               0 : nsComputedDOMStyle::DoGetCaptionSide()
    1911                 : {
    1912               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1913                 :   val->SetIdent(
    1914               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTableBorder()->mCaptionSide,
    1915               0 :                                    nsCSSProps::kCaptionSideKTable));
    1916               0 :   return val;
    1917                 : }
    1918                 : 
    1919                 : nsIDOMCSSValue*
    1920               0 : nsComputedDOMStyle::DoGetEmptyCells()
    1921                 : {
    1922               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1923                 :   val->SetIdent(
    1924               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTableBorder()->mEmptyCells,
    1925               0 :                                    nsCSSProps::kEmptyCellsKTable));
    1926               0 :   return val;
    1927                 : }
    1928                 : 
    1929                 : nsIDOMCSSValue*
    1930               0 : nsComputedDOMStyle::DoGetTableLayout()
    1931                 : {
    1932               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    1933                 :   val->SetIdent(
    1934               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTable()->mLayoutStrategy,
    1935               0 :                                    nsCSSProps::kTableLayoutKTable));
    1936               0 :   return val;
    1937                 : }
    1938                 : 
    1939                 : nsIDOMCSSValue*
    1940               0 : nsComputedDOMStyle::DoGetBorderStyle()
    1941                 : {
    1942                 :   // return null per spec.
    1943               0 :   return nsnull;
    1944                 : }
    1945                 : 
    1946                 : nsIDOMCSSValue*
    1947               0 : nsComputedDOMStyle::DoGetBorderTopStyle()
    1948                 : {
    1949               0 :   return GetBorderStyleFor(NS_SIDE_TOP);
    1950                 : }
    1951                 : 
    1952                 : nsIDOMCSSValue*
    1953               0 : nsComputedDOMStyle::DoGetBorderBottomStyle()
    1954                 : {
    1955               0 :   return GetBorderStyleFor(NS_SIDE_BOTTOM);
    1956                 : }
    1957                 : 
    1958                 : nsIDOMCSSValue*
    1959               0 : nsComputedDOMStyle::DoGetBorderLeftStyle()
    1960                 : {
    1961               0 :   return GetBorderStyleFor(NS_SIDE_LEFT);
    1962                 : }
    1963                 : 
    1964                 : nsIDOMCSSValue*
    1965               0 : nsComputedDOMStyle::DoGetBorderRightStyle()
    1966                 : {
    1967               0 :   return GetBorderStyleFor(NS_SIDE_RIGHT);
    1968                 : }
    1969                 : 
    1970                 : nsIDOMCSSValue*
    1971               0 : nsComputedDOMStyle::DoGetBorderBottomColors()
    1972                 : {
    1973               0 :   return GetBorderColorsFor(NS_SIDE_BOTTOM);
    1974                 : }
    1975                 : 
    1976                 : nsIDOMCSSValue*
    1977               0 : nsComputedDOMStyle::DoGetBorderLeftColors()
    1978                 : {
    1979               0 :   return GetBorderColorsFor(NS_SIDE_LEFT);
    1980                 : }
    1981                 : 
    1982                 : nsIDOMCSSValue*
    1983               0 : nsComputedDOMStyle::DoGetBorderRightColors()
    1984                 : {
    1985               0 :   return GetBorderColorsFor(NS_SIDE_RIGHT);
    1986                 : }
    1987                 : 
    1988                 : 
    1989                 : nsIDOMCSSValue*
    1990               0 : nsComputedDOMStyle::DoGetBorderTopColors()
    1991                 : {
    1992               0 :   return GetBorderColorsFor(NS_SIDE_TOP);
    1993                 : }
    1994                 : 
    1995                 : nsIDOMCSSValue*
    1996               0 : nsComputedDOMStyle::DoGetBorderBottomLeftRadius()
    1997                 : {
    1998               0 :   return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
    1999               0 :                          NS_CORNER_BOTTOM_LEFT, true);
    2000                 : }
    2001                 : 
    2002                 : nsIDOMCSSValue*
    2003               0 : nsComputedDOMStyle::DoGetBorderBottomRightRadius()
    2004                 : {
    2005               0 :   return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
    2006               0 :                          NS_CORNER_BOTTOM_RIGHT, true);
    2007                 : }
    2008                 : 
    2009                 : nsIDOMCSSValue*
    2010               0 : nsComputedDOMStyle::DoGetBorderTopLeftRadius()
    2011                 : {
    2012               0 :   return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
    2013               0 :                          NS_CORNER_TOP_LEFT, true);
    2014                 : }
    2015                 : 
    2016                 : nsIDOMCSSValue*
    2017               0 : nsComputedDOMStyle::DoGetBorderTopRightRadius()
    2018                 : {
    2019               0 :   return GetEllipseRadii(GetStyleBorder()->mBorderRadius,
    2020               0 :                          NS_CORNER_TOP_RIGHT, true);
    2021                 : }
    2022                 : 
    2023                 : nsIDOMCSSValue*
    2024               0 : nsComputedDOMStyle::DoGetBorderWidth()
    2025                 : {
    2026                 :   // return null per spec.
    2027               0 :   return nsnull;
    2028                 : }
    2029                 : 
    2030                 : nsIDOMCSSValue*
    2031               0 : nsComputedDOMStyle::DoGetBorderTopWidth()
    2032                 : {
    2033               0 :   return GetBorderWidthFor(NS_SIDE_TOP);
    2034                 : }
    2035                 : 
    2036                 : nsIDOMCSSValue*
    2037               0 : nsComputedDOMStyle::DoGetBorderBottomWidth()
    2038                 : {
    2039               0 :   return GetBorderWidthFor(NS_SIDE_BOTTOM);
    2040                 : }
    2041                 : 
    2042                 : nsIDOMCSSValue*
    2043               0 : nsComputedDOMStyle::DoGetBorderLeftWidth()
    2044                 : {
    2045               0 :   return GetBorderWidthFor(NS_SIDE_LEFT);
    2046                 : }
    2047                 : 
    2048                 : nsIDOMCSSValue*
    2049               0 : nsComputedDOMStyle::DoGetBorderRightWidth()
    2050                 : {
    2051               0 :   return GetBorderWidthFor(NS_SIDE_RIGHT);
    2052                 : }
    2053                 : 
    2054                 : nsIDOMCSSValue*
    2055               0 : nsComputedDOMStyle::DoGetBorderTopColor()
    2056                 : {
    2057               0 :   return GetBorderColorFor(NS_SIDE_TOP);
    2058                 : }
    2059                 : 
    2060                 : nsIDOMCSSValue*
    2061               0 : nsComputedDOMStyle::DoGetBorderBottomColor()
    2062                 : {
    2063               0 :   return GetBorderColorFor(NS_SIDE_BOTTOM);
    2064                 : }
    2065                 : 
    2066                 : nsIDOMCSSValue*
    2067               0 : nsComputedDOMStyle::DoGetBorderLeftColor()
    2068                 : {
    2069               0 :   return GetBorderColorFor(NS_SIDE_LEFT);
    2070                 : }
    2071                 : 
    2072                 : nsIDOMCSSValue*
    2073               0 : nsComputedDOMStyle::DoGetBorderRightColor()
    2074                 : {
    2075               0 :   return GetBorderColorFor(NS_SIDE_RIGHT);
    2076                 : }
    2077                 : 
    2078                 : nsIDOMCSSValue*
    2079               0 : nsComputedDOMStyle::DoGetMarginWidth()
    2080                 : {
    2081                 :   // return null per spec.
    2082               0 :   return nsnull;
    2083                 : }
    2084                 : 
    2085                 : nsIDOMCSSValue*
    2086               0 : nsComputedDOMStyle::DoGetMarginTopWidth()
    2087                 : {
    2088               0 :   return GetMarginWidthFor(NS_SIDE_TOP);
    2089                 : }
    2090                 : 
    2091                 : nsIDOMCSSValue*
    2092               0 : nsComputedDOMStyle::DoGetMarginBottomWidth()
    2093                 : {
    2094               0 :   return GetMarginWidthFor(NS_SIDE_BOTTOM);
    2095                 : }
    2096                 : 
    2097                 : nsIDOMCSSValue*
    2098               0 : nsComputedDOMStyle::DoGetMarginLeftWidth()
    2099                 : {
    2100               0 :   return GetMarginWidthFor(NS_SIDE_LEFT);
    2101                 : }
    2102                 : 
    2103                 : nsIDOMCSSValue*
    2104               0 : nsComputedDOMStyle::DoGetMarginRightWidth()
    2105                 : {
    2106               0 :   return GetMarginWidthFor(NS_SIDE_RIGHT);
    2107                 : }
    2108                 : 
    2109                 : nsIDOMCSSValue*
    2110               0 : nsComputedDOMStyle::DoGetMarkerOffset()
    2111                 : {
    2112               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2113               0 :   SetValueToCoord(val, GetStyleContent()->mMarkerOffset, false);
    2114               0 :   return val;
    2115                 : }
    2116                 : 
    2117                 : nsIDOMCSSValue*
    2118               0 : nsComputedDOMStyle::DoGetOrient()
    2119                 : {
    2120               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2121                 :   val->SetIdent(
    2122               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mOrient,
    2123               0 :                                    nsCSSProps::kOrientKTable));
    2124               0 :   return val;
    2125                 : }
    2126                 : 
    2127                 : nsIDOMCSSValue*
    2128               0 : nsComputedDOMStyle::DoGetOutline()
    2129                 : {
    2130                 :   // return null per spec.
    2131               0 :   return nsnull;
    2132                 : }
    2133                 : 
    2134                 : nsIDOMCSSValue*
    2135               0 : nsComputedDOMStyle::DoGetOutlineWidth()
    2136                 : {
    2137               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2138                 : 
    2139               0 :   const nsStyleOutline* outline = GetStyleOutline();
    2140                 : 
    2141                 :   nscoord width;
    2142               0 :   if (outline->GetOutlineStyle() == NS_STYLE_BORDER_STYLE_NONE) {
    2143               0 :     NS_ASSERTION(outline->GetOutlineWidth(width) && width == 0,
    2144                 :                  "unexpected width");
    2145               0 :     width = 0;
    2146                 :   } else {
    2147                 : #ifdef DEBUG
    2148                 :     bool res =
    2149                 : #endif
    2150               0 :       outline->GetOutlineWidth(width);
    2151               0 :     NS_ASSERTION(res, "percent outline doesn't exist");
    2152                 :   }
    2153               0 :   val->SetAppUnits(width);
    2154                 : 
    2155               0 :   return val;
    2156                 : }
    2157                 : 
    2158                 : nsIDOMCSSValue*
    2159               0 : nsComputedDOMStyle::DoGetOutlineStyle()
    2160                 : {
    2161               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2162                 :   val->SetIdent(
    2163               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleOutline()->GetOutlineStyle(),
    2164               0 :                                    nsCSSProps::kOutlineStyleKTable));
    2165               0 :   return val;
    2166                 : }
    2167                 : 
    2168                 : nsIDOMCSSValue*
    2169               0 : nsComputedDOMStyle::DoGetOutlineOffset()
    2170                 : {
    2171               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2172               0 :   val->SetAppUnits(GetStyleOutline()->mOutlineOffset);
    2173               0 :   return val;
    2174                 : }
    2175                 : 
    2176                 : nsIDOMCSSValue*
    2177               0 : nsComputedDOMStyle::DoGetOutlineRadiusBottomLeft()
    2178                 : {
    2179               0 :   return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
    2180               0 :                          NS_CORNER_BOTTOM_LEFT, false);
    2181                 : }
    2182                 : 
    2183                 : nsIDOMCSSValue*
    2184               0 : nsComputedDOMStyle::DoGetOutlineRadiusBottomRight()
    2185                 : {
    2186               0 :   return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
    2187               0 :                          NS_CORNER_BOTTOM_RIGHT, false);
    2188                 : }
    2189                 : 
    2190                 : nsIDOMCSSValue*
    2191               0 : nsComputedDOMStyle::DoGetOutlineRadiusTopLeft()
    2192                 : {
    2193               0 :   return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
    2194               0 :                          NS_CORNER_TOP_LEFT, false);
    2195                 : }
    2196                 : 
    2197                 : nsIDOMCSSValue*
    2198               0 : nsComputedDOMStyle::DoGetOutlineRadiusTopRight()
    2199                 : {
    2200               0 :   return GetEllipseRadii(GetStyleOutline()->mOutlineRadius,
    2201               0 :                          NS_CORNER_TOP_RIGHT, false);
    2202                 : }
    2203                 : 
    2204                 : nsIDOMCSSValue*
    2205               0 : nsComputedDOMStyle::DoGetOutlineColor()
    2206                 : {
    2207               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2208                 : 
    2209                 :   nscolor color;
    2210               0 :   if (!GetStyleOutline()->GetOutlineColor(color))
    2211               0 :     color = GetStyleColor()->mColor;
    2212                 : 
    2213               0 :   SetToRGBAColor(val, color);
    2214               0 :   return val;
    2215                 : }
    2216                 : 
    2217                 : nsIDOMCSSValue*
    2218               0 : nsComputedDOMStyle::GetEllipseRadii(const nsStyleCorners& aRadius,
    2219                 :                                     PRUint8 aFullCorner,
    2220                 :                                     bool aIsBorder) // else outline
    2221                 : {
    2222               0 :   nsStyleCoord radiusX, radiusY;
    2223               0 :   if (mInnerFrame && aIsBorder) {
    2224                 :     nscoord radii[8];
    2225               0 :     mInnerFrame->GetBorderRadii(radii);
    2226               0 :     radiusX.SetCoordValue(radii[NS_FULL_TO_HALF_CORNER(aFullCorner, false)]);
    2227               0 :     radiusY.SetCoordValue(radii[NS_FULL_TO_HALF_CORNER(aFullCorner, true)]);
    2228                 :   } else {
    2229               0 :     radiusX = aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, false));
    2230               0 :     radiusY = aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, true));
    2231                 : 
    2232               0 :     if (mInnerFrame) {
    2233                 :       // We need to convert to absolute coordinates before doing the
    2234                 :       // equality check below.
    2235                 :       nscoord v;
    2236                 : 
    2237                 :       v = StyleCoordToNSCoord(radiusX,
    2238                 :                               &nsComputedDOMStyle::GetFrameBorderRectWidth,
    2239               0 :                               0, true);
    2240               0 :       radiusX.SetCoordValue(v);
    2241                 : 
    2242                 :       v = StyleCoordToNSCoord(radiusY,
    2243                 :                               &nsComputedDOMStyle::GetFrameBorderRectHeight,
    2244               0 :                               0, true);
    2245               0 :       radiusY.SetCoordValue(v);
    2246                 :     }
    2247                 :   }
    2248                 : 
    2249                 :   // for compatibility, return a single value if X and Y are equal
    2250               0 :   if (radiusX == radiusY) {
    2251               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2252                 : 
    2253               0 :     SetValueToCoord(val, radiusX, true);
    2254                 : 
    2255               0 :     return val;
    2256                 :   }
    2257                 : 
    2258               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    2259                 : 
    2260               0 :   nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
    2261               0 :   valueList->AppendCSSValue(valX);
    2262                 : 
    2263               0 :   nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
    2264               0 :   valueList->AppendCSSValue(valY);
    2265                 : 
    2266               0 :   SetValueToCoord(valX, radiusX, true);
    2267               0 :   SetValueToCoord(valY, radiusY, true);
    2268                 : 
    2269               0 :   return valueList;
    2270                 : }
    2271                 : 
    2272                 : nsIDOMCSSValue*
    2273               0 : nsComputedDOMStyle::GetCSSShadowArray(nsCSSShadowArray* aArray,
    2274                 :                                       const nscolor& aDefaultColor,
    2275                 :                                       bool aIsBoxShadow)
    2276                 : {
    2277               0 :   if (!aArray) {
    2278               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2279               0 :     val->SetIdent(eCSSKeyword_none);
    2280               0 :     return val;
    2281                 :   }
    2282                 : 
    2283                 :   static nscoord nsCSSShadowItem::* const shadowValuesNoSpread[] = {
    2284                 :     &nsCSSShadowItem::mXOffset,
    2285                 :     &nsCSSShadowItem::mYOffset,
    2286                 :     &nsCSSShadowItem::mRadius
    2287                 :   };
    2288                 : 
    2289                 :   static nscoord nsCSSShadowItem::* const shadowValuesWithSpread[] = {
    2290                 :     &nsCSSShadowItem::mXOffset,
    2291                 :     &nsCSSShadowItem::mYOffset,
    2292                 :     &nsCSSShadowItem::mRadius,
    2293                 :     &nsCSSShadowItem::mSpread
    2294                 :   };
    2295                 : 
    2296                 :   nscoord nsCSSShadowItem::* const * shadowValues;
    2297                 :   PRUint32 shadowValuesLength;
    2298               0 :   if (aIsBoxShadow) {
    2299               0 :     shadowValues = shadowValuesWithSpread;
    2300               0 :     shadowValuesLength = ArrayLength(shadowValuesWithSpread);
    2301                 :   } else {
    2302               0 :     shadowValues = shadowValuesNoSpread;
    2303               0 :     shadowValuesLength = ArrayLength(shadowValuesNoSpread);
    2304                 :   }
    2305                 : 
    2306               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    2307                 : 
    2308               0 :   for (nsCSSShadowItem *item = aArray->ShadowAt(0),
    2309               0 :                    *item_end = item + aArray->Length();
    2310                 :        item < item_end; ++item) {
    2311               0 :     nsDOMCSSValueList *itemList = GetROCSSValueList(false);
    2312               0 :     valueList->AppendCSSValue(itemList);
    2313                 : 
    2314                 :     // Color is either the specified shadow color or the foreground color
    2315               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2316               0 :     itemList->AppendCSSValue(val);
    2317                 :     nscolor shadowColor;
    2318               0 :     if (item->mHasColor) {
    2319               0 :       shadowColor = item->mColor;
    2320                 :     } else {
    2321               0 :       shadowColor = aDefaultColor;
    2322                 :     }
    2323               0 :     SetToRGBAColor(val, shadowColor);
    2324                 : 
    2325                 :     // Set the offsets, blur radius, and spread if available
    2326               0 :     for (PRUint32 i = 0; i < shadowValuesLength; ++i) {
    2327               0 :       val = GetROCSSPrimitiveValue();
    2328               0 :       itemList->AppendCSSValue(val);
    2329               0 :       val->SetAppUnits(item->*(shadowValues[i]));
    2330                 :     }
    2331                 : 
    2332               0 :     if (item->mInset && aIsBoxShadow) {
    2333                 :       // This is an inset box-shadow
    2334               0 :       val = GetROCSSPrimitiveValue();
    2335               0 :       itemList->AppendCSSValue(val);
    2336                 :       val->SetIdent(
    2337                 :         nsCSSProps::ValueToKeywordEnum(NS_STYLE_BOX_SHADOW_INSET,
    2338               0 :                                        nsCSSProps::kBoxShadowTypeKTable));
    2339                 :     }
    2340                 :   }
    2341                 : 
    2342               0 :   return valueList;
    2343                 : }
    2344                 : 
    2345                 : nsIDOMCSSValue*
    2346               0 : nsComputedDOMStyle::DoGetBoxShadow()
    2347                 : {
    2348               0 :   return GetCSSShadowArray(GetStyleBorder()->mBoxShadow,
    2349               0 :                            GetStyleColor()->mColor,
    2350               0 :                            true);
    2351                 : }
    2352                 : 
    2353                 : nsIDOMCSSValue*
    2354               0 : nsComputedDOMStyle::DoGetZIndex()
    2355                 : {
    2356               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2357               0 :   SetValueToCoord(val, GetStylePosition()->mZIndex, false);
    2358               0 :   return val;
    2359                 : }
    2360                 : 
    2361                 : nsIDOMCSSValue*
    2362               0 : nsComputedDOMStyle::DoGetListStyleImage()
    2363                 : {
    2364               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2365                 : 
    2366               0 :   const nsStyleList* list = GetStyleList();
    2367                 : 
    2368               0 :   if (!list->GetListStyleImage()) {
    2369               0 :     val->SetIdent(eCSSKeyword_none);
    2370                 :   } else {
    2371               0 :     nsCOMPtr<nsIURI> uri;
    2372               0 :     if (list->GetListStyleImage()) {
    2373               0 :       list->GetListStyleImage()->GetURI(getter_AddRefs(uri));
    2374                 :     }
    2375               0 :     val->SetURI(uri);
    2376                 :   }
    2377                 : 
    2378               0 :   return val;
    2379                 : }
    2380                 : 
    2381                 : nsIDOMCSSValue*
    2382               0 : nsComputedDOMStyle::DoGetListStylePosition()
    2383                 : {
    2384               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2385                 :   val->SetIdent(
    2386               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleList()->mListStylePosition,
    2387               0 :                                    nsCSSProps::kListStylePositionKTable));
    2388               0 :   return val;
    2389                 : }
    2390                 : 
    2391                 : nsIDOMCSSValue*
    2392               0 : nsComputedDOMStyle::DoGetListStyleType()
    2393                 : {
    2394               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2395                 :   val->SetIdent(
    2396               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleList()->mListStyleType,
    2397               0 :                                    nsCSSProps::kListStyleKTable));
    2398               0 :   return val;
    2399                 : }
    2400                 : 
    2401                 : nsIDOMCSSValue*
    2402               0 : nsComputedDOMStyle::DoGetImageRegion()
    2403                 : {
    2404               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2405                 : 
    2406               0 :   const nsStyleList* list = GetStyleList();
    2407                 : 
    2408               0 :   if (list->mImageRegion.width <= 0 || list->mImageRegion.height <= 0) {
    2409               0 :     val->SetIdent(eCSSKeyword_auto);
    2410                 :   } else {
    2411                 :     // create the cssvalues for the sides, stick them in the rect object
    2412               0 :     nsROCSSPrimitiveValue *topVal    = GetROCSSPrimitiveValue();
    2413               0 :     nsROCSSPrimitiveValue *rightVal  = GetROCSSPrimitiveValue();
    2414               0 :     nsROCSSPrimitiveValue *bottomVal = GetROCSSPrimitiveValue();
    2415               0 :     nsROCSSPrimitiveValue *leftVal   = GetROCSSPrimitiveValue();
    2416                 :     nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
    2417               0 :                                               bottomVal, leftVal);
    2418               0 :     topVal->SetAppUnits(list->mImageRegion.y);
    2419               0 :     rightVal->SetAppUnits(list->mImageRegion.width + list->mImageRegion.x);
    2420               0 :     bottomVal->SetAppUnits(list->mImageRegion.height + list->mImageRegion.y);
    2421               0 :     leftVal->SetAppUnits(list->mImageRegion.x);
    2422               0 :     val->SetRect(domRect);
    2423                 :   }
    2424                 : 
    2425               0 :   return val;
    2426                 : }
    2427                 : 
    2428                 : nsIDOMCSSValue*
    2429               0 : nsComputedDOMStyle::DoGetLineHeight()
    2430                 : {
    2431               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2432                 : 
    2433                 :   nscoord lineHeight;
    2434               0 :   if (GetLineHeightCoord(lineHeight)) {
    2435               0 :     val->SetAppUnits(lineHeight);
    2436                 :   } else {
    2437               0 :     SetValueToCoord(val, GetStyleText()->mLineHeight, true,
    2438               0 :                     nsnull, nsCSSProps::kLineHeightKTable);
    2439                 :   }
    2440                 : 
    2441               0 :   return val;
    2442                 : }
    2443                 : 
    2444                 : nsIDOMCSSValue*
    2445               0 : nsComputedDOMStyle::DoGetVerticalAlign()
    2446                 : {
    2447               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2448               0 :   SetValueToCoord(val, GetStyleTextReset()->mVerticalAlign, false,
    2449                 :                   &nsComputedDOMStyle::GetLineHeightCoord,
    2450               0 :                   nsCSSProps::kVerticalAlignKTable);
    2451               0 :   return val;
    2452                 : }
    2453                 : 
    2454                 : nsIDOMCSSValue*
    2455               0 : nsComputedDOMStyle::DoGetTextAlign()
    2456                 : {
    2457               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2458                 :   val->SetIdent(
    2459               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mTextAlign,
    2460               0 :                                    nsCSSProps::kTextAlignKTable));
    2461               0 :   return val;
    2462                 : }
    2463                 : 
    2464                 : nsIDOMCSSValue*
    2465               0 : nsComputedDOMStyle::DoGetTextAlignLast()
    2466                 : {
    2467               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2468                 :   val->SetIdent(
    2469               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mTextAlignLast,
    2470               0 :                                    nsCSSProps::kTextAlignLastKTable));
    2471               0 :   return val;
    2472                 : }
    2473                 : 
    2474                 : nsIDOMCSSValue*
    2475               0 : nsComputedDOMStyle::DoGetMozTextBlink()
    2476                 : {
    2477               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2478                 : 
    2479                 :   val->SetIdent(
    2480               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTextReset()->mTextBlink,
    2481               0 :                                    nsCSSProps::kTextBlinkKTable));
    2482                 : 
    2483               0 :   return val;
    2484                 : }
    2485                 : 
    2486                 : nsIDOMCSSValue*
    2487               0 : nsComputedDOMStyle::DoGetTextDecoration()
    2488                 : {
    2489               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2490                 : 
    2491               0 :   const nsStyleTextReset* textReset = GetStyleTextReset();
    2492                 : 
    2493                 :   // If decoration style or color wasn't initial value, the author knew the
    2494                 :   // text-decoration is a shorthand property in CSS 3.
    2495                 :   // Return NULL in such cases.
    2496               0 :   if (textReset->GetDecorationStyle() != NS_STYLE_TEXT_DECORATION_STYLE_SOLID) {
    2497               0 :     return nsnull;
    2498                 :   }
    2499                 : 
    2500                 :   nscolor color;
    2501                 :   bool isForegroundColor;
    2502               0 :   textReset->GetDecorationColor(color, isForegroundColor);
    2503               0 :   if (!isForegroundColor) {
    2504               0 :     return nsnull;
    2505                 :   }
    2506                 : 
    2507                 :   // Otherwise, the web pages may have been written for CSS 2.1 or earlier,
    2508                 :   // i.e., text-decoration was assumed as a longhand property.  In that case,
    2509                 :   // we should return computed value same as CSS 2.1 for backward compatibility.
    2510                 : 
    2511               0 :   PRUint8 line = textReset->mTextDecorationLine;
    2512                 :   // Clear the -moz-anchor-decoration bit and the OVERRIDE_ALL bits -- we
    2513                 :   // don't want these to appear in the computed style.
    2514                 :   line &= ~(NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS |
    2515               0 :             NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL);
    2516               0 :   PRUint8 blink = textReset->mTextBlink;
    2517                 : 
    2518               0 :   if (blink == NS_STYLE_TEXT_BLINK_NONE &&
    2519                 :       line == NS_STYLE_TEXT_DECORATION_LINE_NONE) {
    2520               0 :     val->SetIdent(eCSSKeyword_none);
    2521                 :   } else {
    2522               0 :     nsAutoString str;
    2523               0 :     if (line != NS_STYLE_TEXT_DECORATION_LINE_NONE) {
    2524                 :       nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_text_decoration_line,
    2525                 :         line, NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE,
    2526               0 :         NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH, str);
    2527                 :     }
    2528               0 :     if (blink != NS_STYLE_TEXT_BLINK_NONE) {
    2529               0 :       if (!str.IsEmpty()) {
    2530               0 :         str.Append(PRUnichar(' '));
    2531                 :       }
    2532                 :       nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_text_blink, blink,
    2533               0 :         NS_STYLE_TEXT_BLINK_BLINK, NS_STYLE_TEXT_BLINK_BLINK, str);
    2534                 :     }
    2535               0 :     val->SetString(str);
    2536                 :   }
    2537                 : 
    2538               0 :   return val;
    2539                 : }
    2540                 : 
    2541                 : nsIDOMCSSValue*
    2542               0 : nsComputedDOMStyle::DoGetMozTextDecorationColor()
    2543                 : {
    2544               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2545                 : 
    2546                 :   nscolor color;
    2547                 :   bool isForeground;
    2548               0 :   GetStyleTextReset()->GetDecorationColor(color, isForeground);
    2549               0 :   if (isForeground) {
    2550               0 :     color = GetStyleColor()->mColor;
    2551                 :   }
    2552                 : 
    2553               0 :   SetToRGBAColor(val, color);
    2554                 : 
    2555               0 :   return val;
    2556                 : }
    2557                 : 
    2558                 : nsIDOMCSSValue*
    2559               0 : nsComputedDOMStyle::DoGetMozTextDecorationLine()
    2560                 : {
    2561               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2562                 : 
    2563               0 :   PRInt32 intValue = GetStyleTextReset()->mTextDecorationLine;
    2564                 : 
    2565               0 :   if (NS_STYLE_TEXT_DECORATION_LINE_NONE == intValue) {
    2566               0 :     val->SetIdent(eCSSKeyword_none);
    2567                 :   } else {
    2568               0 :     nsAutoString decorationLineString;
    2569                 :     // Clear the -moz-anchor-decoration bit and the OVERRIDE_ALL bits -- we
    2570                 :     // don't want these to appear in the computed style.
    2571                 :     intValue &= ~(NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS |
    2572               0 :                   NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL);
    2573                 :     nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_text_decoration_line,
    2574                 :       intValue, NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE,
    2575               0 :       NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH, decorationLineString);
    2576               0 :     val->SetString(decorationLineString);
    2577                 :   }
    2578                 : 
    2579               0 :   return val;
    2580                 : }
    2581                 : 
    2582                 : nsIDOMCSSValue*
    2583               0 : nsComputedDOMStyle::DoGetMozTextDecorationStyle()
    2584                 : {
    2585               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2586                 : 
    2587                 :   val->SetIdent(
    2588               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleTextReset()->GetDecorationStyle(),
    2589               0 :                                    nsCSSProps::kTextDecorationStyleKTable));
    2590                 : 
    2591               0 :   return val;
    2592                 : }
    2593                 : 
    2594                 : nsIDOMCSSValue*
    2595               0 : nsComputedDOMStyle::DoGetTextIndent()
    2596                 : {
    2597               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2598               0 :   SetValueToCoord(val, GetStyleText()->mTextIndent, false,
    2599               0 :                   &nsComputedDOMStyle::GetCBContentWidth);
    2600               0 :   return val;
    2601                 : }
    2602                 : 
    2603                 : nsIDOMCSSValue*
    2604               0 : nsComputedDOMStyle::DoGetTextOverflow()
    2605                 : {
    2606               0 :   const nsStyleTextReset *style = GetStyleTextReset();
    2607               0 :   nsROCSSPrimitiveValue *first = GetROCSSPrimitiveValue();
    2608               0 :   const nsStyleTextOverflowSide *side = style->mTextOverflow.GetFirstValue();
    2609               0 :   if (side->mType == NS_STYLE_TEXT_OVERFLOW_STRING) {
    2610               0 :     nsString str;
    2611               0 :     nsStyleUtil::AppendEscapedCSSString(side->mString, str);
    2612               0 :     first->SetString(str);
    2613                 :   } else {
    2614                 :     first->SetIdent(
    2615                 :       nsCSSProps::ValueToKeywordEnum(side->mType,
    2616               0 :                                      nsCSSProps::kTextOverflowKTable));
    2617                 :   }
    2618               0 :   side = style->mTextOverflow.GetSecondValue();
    2619               0 :   if (!side) {
    2620               0 :     return first;
    2621                 :   }
    2622               0 :   nsROCSSPrimitiveValue *second = GetROCSSPrimitiveValue();
    2623               0 :   if (side->mType == NS_STYLE_TEXT_OVERFLOW_STRING) {
    2624               0 :     nsString str;
    2625               0 :     nsStyleUtil::AppendEscapedCSSString(side->mString, str);
    2626               0 :     second->SetString(str);
    2627                 :   } else {
    2628                 :     second->SetIdent(
    2629                 :       nsCSSProps::ValueToKeywordEnum(side->mType,
    2630               0 :                                      nsCSSProps::kTextOverflowKTable));
    2631                 :   }
    2632                 : 
    2633               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    2634               0 :   valueList->AppendCSSValue(first);
    2635               0 :   valueList->AppendCSSValue(second);
    2636               0 :   return valueList;
    2637                 : }
    2638                 : 
    2639                 : nsIDOMCSSValue*
    2640               0 : nsComputedDOMStyle::DoGetTextShadow()
    2641                 : {
    2642               0 :   return GetCSSShadowArray(GetStyleText()->mTextShadow,
    2643               0 :                            GetStyleColor()->mColor,
    2644               0 :                            false);
    2645                 : }
    2646                 : 
    2647                 : nsIDOMCSSValue*
    2648               0 : nsComputedDOMStyle::DoGetTextTransform()
    2649                 : {
    2650               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2651                 :   val->SetIdent(
    2652               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mTextTransform,
    2653               0 :                                    nsCSSProps::kTextTransformKTable));
    2654               0 :   return val;
    2655                 : }
    2656                 : 
    2657                 : nsIDOMCSSValue*
    2658               0 : nsComputedDOMStyle::DoGetMozTabSize()
    2659                 : {
    2660               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2661               0 :   val->SetNumber(GetStyleText()->mTabSize);
    2662               0 :   return val;
    2663                 : }
    2664                 : 
    2665                 : nsIDOMCSSValue*
    2666               0 : nsComputedDOMStyle::DoGetLetterSpacing()
    2667                 : {
    2668               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2669               0 :   SetValueToCoord(val, GetStyleText()->mLetterSpacing, false);
    2670               0 :   return val;
    2671                 : }
    2672                 : 
    2673                 : nsIDOMCSSValue*
    2674               0 : nsComputedDOMStyle::DoGetWordSpacing()
    2675                 : {
    2676               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2677               0 :   val->SetAppUnits(GetStyleText()->mWordSpacing);
    2678               0 :   return val;
    2679                 : }
    2680                 : 
    2681                 : nsIDOMCSSValue*
    2682               0 : nsComputedDOMStyle::DoGetWhiteSpace()
    2683                 : {
    2684               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2685                 :   val->SetIdent(
    2686               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mWhiteSpace,
    2687               0 :                                    nsCSSProps::kWhitespaceKTable));
    2688               0 :   return val;
    2689                 : }
    2690                 : 
    2691                 : nsIDOMCSSValue*
    2692               0 : nsComputedDOMStyle::DoGetWindowShadow()
    2693                 : {
    2694               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2695                 :   val->SetIdent(
    2696               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUIReset()->mWindowShadow,
    2697               0 :                                    nsCSSProps::kWindowShadowKTable));
    2698               0 :   return val;
    2699                 : }
    2700                 : 
    2701                 : 
    2702                 : nsIDOMCSSValue*
    2703               0 : nsComputedDOMStyle::DoGetWordWrap()
    2704                 : {
    2705               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2706                 :   val->SetIdent(
    2707               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mWordWrap,
    2708               0 :                                    nsCSSProps::kWordwrapKTable));
    2709               0 :   return val;
    2710                 : }
    2711                 : 
    2712                 : nsIDOMCSSValue*
    2713               0 : nsComputedDOMStyle::DoGetHyphens()
    2714                 : {
    2715               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2716                 :   val->SetIdent(
    2717               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleText()->mHyphens,
    2718               0 :                                    nsCSSProps::kHyphensKTable));
    2719               0 :   return val;
    2720                 : }
    2721                 : 
    2722                 : nsIDOMCSSValue*
    2723               0 : nsComputedDOMStyle::DoGetTextSizeAdjust()
    2724                 : {
    2725               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2726               0 :   switch (GetStyleText()->mTextSizeAdjust) {
    2727                 :     default:
    2728               0 :       NS_NOTREACHED("unexpected value");
    2729                 :       // fall through
    2730                 :     case NS_STYLE_TEXT_SIZE_ADJUST_AUTO:
    2731               0 :       val->SetIdent(eCSSKeyword_auto);
    2732               0 :       break;
    2733                 :     case NS_STYLE_TEXT_SIZE_ADJUST_NONE:
    2734               0 :       val->SetIdent(eCSSKeyword_none);
    2735               0 :       break;
    2736                 :   }
    2737               0 :   return val;
    2738                 : }
    2739                 : 
    2740                 : nsIDOMCSSValue*
    2741               0 : nsComputedDOMStyle::DoGetPointerEvents()
    2742                 : {
    2743               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2744                 :   val->SetIdent(
    2745               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleVisibility()->mPointerEvents,
    2746               0 :                                    nsCSSProps::kPointerEventsKTable));
    2747               0 :   return val;
    2748                 : }
    2749                 : 
    2750                 : nsIDOMCSSValue*
    2751               0 : nsComputedDOMStyle::DoGetVisibility()
    2752                 : {
    2753               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2754               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleVisibility()->mVisible,
    2755               0 :                                                nsCSSProps::kVisibilityKTable));
    2756               0 :   return val;
    2757                 : }
    2758                 : 
    2759                 : nsIDOMCSSValue*
    2760               0 : nsComputedDOMStyle::DoGetDirection()
    2761                 : {
    2762               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2763                 :   val->SetIdent(
    2764               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleVisibility()->mDirection,
    2765               0 :                                    nsCSSProps::kDirectionKTable));
    2766               0 :   return val;
    2767                 : }
    2768                 : 
    2769                 : MOZ_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
    2770                 :                   "unicode-bidi style constants not as expected");
    2771                 : 
    2772                 : nsIDOMCSSValue*
    2773               0 : nsComputedDOMStyle::DoGetUnicodeBidi()
    2774                 : {
    2775               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2776               0 :   PRInt32 intValue = GetStyleTextReset()->mUnicodeBidi;
    2777                 : 
    2778               0 :   if (NS_STYLE_UNICODE_BIDI_NORMAL == intValue) {
    2779               0 :     val->SetIdent(eCSSKeyword_normal);
    2780                 :   } else {
    2781               0 :     nsAutoString unicodeBidiString;
    2782                 :     nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_unicode_bidi, intValue,
    2783                 :                                        NS_STYLE_UNICODE_BIDI_EMBED,
    2784                 :                                        NS_STYLE_UNICODE_BIDI_PLAINTEXT,
    2785               0 :                                        unicodeBidiString);
    2786               0 :     val->SetString(unicodeBidiString);
    2787                 :   }
    2788                 : 
    2789               0 :   return val;
    2790                 : }
    2791                 : 
    2792                 : nsIDOMCSSValue*
    2793               0 : nsComputedDOMStyle::DoGetCursor()
    2794                 : {
    2795               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    2796                 : 
    2797               0 :   const nsStyleUserInterface *ui = GetStyleUserInterface();
    2798                 : 
    2799               0 :   for (nsCursorImage *item = ui->mCursorArray,
    2800               0 :          *item_end = ui->mCursorArray + ui->mCursorArrayLength;
    2801                 :        item < item_end; ++item) {
    2802               0 :     nsDOMCSSValueList *itemList = GetROCSSValueList(false);
    2803               0 :     valueList->AppendCSSValue(itemList);
    2804                 : 
    2805               0 :     nsCOMPtr<nsIURI> uri;
    2806               0 :     item->GetImage()->GetURI(getter_AddRefs(uri));
    2807                 : 
    2808               0 :     nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2809               0 :     itemList->AppendCSSValue(val);
    2810               0 :     val->SetURI(uri);
    2811                 : 
    2812               0 :     if (item->mHaveHotspot) {
    2813               0 :       nsROCSSPrimitiveValue *valX = GetROCSSPrimitiveValue();
    2814               0 :       itemList->AppendCSSValue(valX);
    2815               0 :       nsROCSSPrimitiveValue *valY = GetROCSSPrimitiveValue();
    2816               0 :       itemList->AppendCSSValue(valY);
    2817                 : 
    2818               0 :       valX->SetNumber(item->mHotspotX);
    2819               0 :       valY->SetNumber(item->mHotspotY);
    2820                 :     }
    2821                 :   }
    2822                 : 
    2823               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2824                 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(ui->mCursor,
    2825               0 :                                                nsCSSProps::kCursorKTable));
    2826               0 :   valueList->AppendCSSValue(val);
    2827               0 :   return valueList;
    2828                 : }
    2829                 : 
    2830                 : nsIDOMCSSValue*
    2831               0 : nsComputedDOMStyle::DoGetAppearance()
    2832                 : {
    2833               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2834               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mAppearance,
    2835               0 :                                                nsCSSProps::kAppearanceKTable));
    2836               0 :   return val;
    2837                 : }
    2838                 : 
    2839                 : 
    2840                 : nsIDOMCSSValue*
    2841               0 : nsComputedDOMStyle::DoGetBoxAlign()
    2842                 : {
    2843               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2844               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleXUL()->mBoxAlign,
    2845               0 :                                                nsCSSProps::kBoxAlignKTable));
    2846               0 :   return val;
    2847                 : }
    2848                 : 
    2849                 : nsIDOMCSSValue*
    2850               0 : nsComputedDOMStyle::DoGetBoxDirection()
    2851                 : {
    2852               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2853                 :   val->SetIdent(
    2854               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleXUL()->mBoxDirection,
    2855               0 :                                    nsCSSProps::kBoxDirectionKTable));
    2856               0 :   return val;
    2857                 : }
    2858                 : 
    2859                 : nsIDOMCSSValue*
    2860               0 : nsComputedDOMStyle::DoGetBoxFlex()
    2861                 : {
    2862               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2863               0 :   val->SetNumber(GetStyleXUL()->mBoxFlex);
    2864               0 :   return val;
    2865                 : }
    2866                 : 
    2867                 : nsIDOMCSSValue*
    2868               0 : nsComputedDOMStyle::DoGetBoxOrdinalGroup()
    2869                 : {
    2870               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2871               0 :   val->SetNumber(GetStyleXUL()->mBoxOrdinal);
    2872               0 :   return val;
    2873                 : }
    2874                 : 
    2875                 : nsIDOMCSSValue*
    2876               0 : nsComputedDOMStyle::DoGetBoxOrient()
    2877                 : {
    2878               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2879                 :   val->SetIdent(
    2880               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleXUL()->mBoxOrient,
    2881               0 :                                    nsCSSProps::kBoxOrientKTable));
    2882               0 :   return val;
    2883                 : }
    2884                 : 
    2885                 : nsIDOMCSSValue*
    2886               0 : nsComputedDOMStyle::DoGetBoxPack()
    2887                 : {
    2888               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2889               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleXUL()->mBoxPack,
    2890               0 :                                                nsCSSProps::kBoxPackKTable));
    2891               0 :   return val;
    2892                 : }
    2893                 : 
    2894                 : nsIDOMCSSValue*
    2895               0 : nsComputedDOMStyle::DoGetBoxSizing()
    2896                 : {
    2897               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    2898                 :   val->SetIdent(
    2899               0 :     nsCSSProps::ValueToKeywordEnum(GetStylePosition()->mBoxSizing,
    2900               0 :                                    nsCSSProps::kBoxSizingKTable));
    2901               0 :   return val;
    2902                 : }
    2903                 : 
    2904                 : /* Border image properties */
    2905                 : 
    2906                 : nsIDOMCSSValue*
    2907               0 : nsComputedDOMStyle::DoGetBorderImageSource()
    2908                 : {
    2909               0 :   const nsStyleBorder* border = GetStyleBorder();
    2910                 : 
    2911               0 :   imgIRequest* imgSrc = border->GetBorderImage();
    2912               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2913               0 :   if (imgSrc) {
    2914               0 :     nsCOMPtr<nsIURI> uri;
    2915               0 :     imgSrc->GetURI(getter_AddRefs(uri));
    2916               0 :     val->SetURI(uri);
    2917                 :   } else {
    2918               0 :     val->SetIdent(eCSSKeyword_none);
    2919                 :   }
    2920                 : 
    2921               0 :   return val;
    2922                 : }
    2923                 : 
    2924                 : nsIDOMCSSValue*
    2925               0 : nsComputedDOMStyle::DoGetBorderImageSlice()
    2926                 : {
    2927               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
    2928                 : 
    2929               0 :   const nsStyleBorder* border = GetStyleBorder();
    2930                 :   // Four slice numbers.
    2931               0 :   NS_FOR_CSS_SIDES (side) {
    2932               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2933               0 :     valueList->AppendCSSValue(val);
    2934               0 :     SetValueToCoord(val, border->mBorderImageSlice.Get(side), nsnull, nsnull);
    2935                 :   }
    2936                 : 
    2937                 :   // Fill keyword.
    2938               0 :   if (NS_STYLE_BORDER_IMAGE_SLICE_FILL == border->mBorderImageFill) {
    2939               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2940               0 :     valueList->AppendCSSValue(val);
    2941               0 :     val->SetIdent(eCSSKeyword_fill);
    2942                 :   }
    2943                 : 
    2944               0 :   return valueList;
    2945                 : }
    2946                 : 
    2947                 : nsIDOMCSSValue*
    2948               0 : nsComputedDOMStyle::DoGetBorderImageWidth()
    2949                 : {
    2950               0 :   const nsStyleBorder* border = GetStyleBorder();
    2951               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
    2952               0 :   NS_FOR_CSS_SIDES (side) {
    2953               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2954               0 :     valueList->AppendCSSValue(val);
    2955                 :     SetValueToCoord(val, border->mBorderImageWidth.Get(side),
    2956               0 :                     nsnull, nsnull);
    2957                 :   }
    2958                 : 
    2959               0 :   return valueList;
    2960                 : }
    2961                 : 
    2962                 : nsIDOMCSSValue*
    2963               0 : nsComputedDOMStyle::DoGetBorderImageOutset()
    2964                 : {
    2965               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    2966                 : 
    2967               0 :   const nsStyleBorder* border = GetStyleBorder();
    2968                 :   // four slice numbers
    2969               0 :   NS_FOR_CSS_SIDES (side) {
    2970               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    2971               0 :     valueList->AppendCSSValue(val);
    2972                 :     SetValueToCoord(val, border->mBorderImageOutset.Get(side),
    2973               0 :                     nsnull, nsnull);
    2974                 :   }
    2975                 : 
    2976               0 :   return valueList;
    2977                 : }
    2978                 : 
    2979                 : nsIDOMCSSValue*
    2980               0 : nsComputedDOMStyle::DoGetBorderImageRepeat()
    2981                 : {
    2982               0 :   nsDOMCSSValueList* valueList = GetROCSSValueList(false);
    2983                 : 
    2984               0 :   const nsStyleBorder* border = GetStyleBorder();
    2985                 : 
    2986                 :   // horizontal repeat
    2987               0 :   nsROCSSPrimitiveValue* valX = GetROCSSPrimitiveValue();
    2988               0 :   valueList->AppendCSSValue(valX);
    2989                 :   valX->SetIdent(
    2990                 :     nsCSSProps::ValueToKeywordEnum(border->mBorderImageRepeatH,
    2991               0 :                                    nsCSSProps::kBorderImageRepeatKTable));
    2992                 : 
    2993                 :   // vertical repeat
    2994               0 :   nsROCSSPrimitiveValue* valY = GetROCSSPrimitiveValue();
    2995               0 :   valueList->AppendCSSValue(valY);
    2996                 :   valY->SetIdent(
    2997                 :     nsCSSProps::ValueToKeywordEnum(border->mBorderImageRepeatV,
    2998               0 :                                    nsCSSProps::kBorderImageRepeatKTable));
    2999               0 :   return valueList;
    3000                 : }
    3001                 : 
    3002                 : nsIDOMCSSValue*
    3003               0 : nsComputedDOMStyle::DoGetFloatEdge()
    3004                 : {
    3005               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3006                 :   val->SetIdent(
    3007               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleBorder()->mFloatEdge,
    3008               0 :                                    nsCSSProps::kFloatEdgeKTable));
    3009               0 :   return val;
    3010                 : }
    3011                 : 
    3012                 : nsIDOMCSSValue*
    3013               0 : nsComputedDOMStyle::DoGetForceBrokenImageIcon()
    3014                 : {
    3015               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3016               0 :   val->SetNumber(GetStyleUIReset()->mForceBrokenImageIcon);
    3017               0 :   return val;
    3018                 : }
    3019                 : 
    3020                 : nsIDOMCSSValue*
    3021               0 : nsComputedDOMStyle::DoGetIMEMode()
    3022                 : {
    3023               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3024                 :   val->SetIdent(
    3025               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUIReset()->mIMEMode,
    3026               0 :                                    nsCSSProps::kIMEModeKTable));
    3027               0 :   return val;
    3028                 : }
    3029                 : 
    3030                 : nsIDOMCSSValue*
    3031               0 : nsComputedDOMStyle::DoGetUserFocus()
    3032                 : {
    3033               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3034                 :   val->SetIdent(
    3035               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUserInterface()->mUserFocus,
    3036               0 :                                    nsCSSProps::kUserFocusKTable));
    3037               0 :   return val;
    3038                 : }
    3039                 : 
    3040                 : nsIDOMCSSValue*
    3041               0 : nsComputedDOMStyle::DoGetUserInput()
    3042                 : {
    3043               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3044                 :   val->SetIdent(
    3045               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUserInterface()->mUserInput,
    3046               0 :                                    nsCSSProps::kUserInputKTable));
    3047               0 :   return val;
    3048                 : }
    3049                 : 
    3050                 : nsIDOMCSSValue*
    3051               0 : nsComputedDOMStyle::DoGetUserModify()
    3052                 : {
    3053               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3054                 :   val->SetIdent(
    3055               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUserInterface()->mUserModify,
    3056               0 :                                    nsCSSProps::kUserModifyKTable));
    3057               0 :   return val;
    3058                 : }
    3059                 : 
    3060                 : nsIDOMCSSValue*
    3061               0 : nsComputedDOMStyle::DoGetUserSelect()
    3062                 : {
    3063               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3064                 :   val->SetIdent(
    3065               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleUIReset()->mUserSelect,
    3066               0 :                                    nsCSSProps::kUserSelectKTable));
    3067               0 :   return val;
    3068                 : }
    3069                 : 
    3070                 : nsIDOMCSSValue*
    3071               0 : nsComputedDOMStyle::DoGetDisplay()
    3072                 : {
    3073               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3074               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mDisplay,
    3075               0 :                                                nsCSSProps::kDisplayKTable));
    3076               0 :   return val;
    3077                 : }
    3078                 : 
    3079                 : nsIDOMCSSValue*
    3080               0 : nsComputedDOMStyle::DoGetPosition()
    3081                 : {
    3082               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3083               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mPosition,
    3084               0 :                                                nsCSSProps::kPositionKTable));
    3085               0 :   return val;
    3086                 : }
    3087                 : 
    3088                 : nsIDOMCSSValue*
    3089               0 : nsComputedDOMStyle::DoGetClip()
    3090                 : {
    3091               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3092                 : 
    3093               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    3094                 : 
    3095               0 :   if (display->mClipFlags == NS_STYLE_CLIP_AUTO) {
    3096               0 :     val->SetIdent(eCSSKeyword_auto);
    3097                 :   } else {
    3098                 :     // create the cssvalues for the sides, stick them in the rect object
    3099               0 :     nsROCSSPrimitiveValue *topVal    = GetROCSSPrimitiveValue();
    3100               0 :     nsROCSSPrimitiveValue *rightVal  = GetROCSSPrimitiveValue();
    3101               0 :     nsROCSSPrimitiveValue *bottomVal = GetROCSSPrimitiveValue();
    3102               0 :     nsROCSSPrimitiveValue *leftVal   = GetROCSSPrimitiveValue();
    3103                 :     nsDOMCSSRect * domRect = new nsDOMCSSRect(topVal, rightVal,
    3104               0 :                                               bottomVal, leftVal);
    3105               0 :     if (display->mClipFlags & NS_STYLE_CLIP_TOP_AUTO) {
    3106               0 :       topVal->SetIdent(eCSSKeyword_auto);
    3107                 :     } else {
    3108               0 :       topVal->SetAppUnits(display->mClip.y);
    3109                 :     }
    3110                 : 
    3111               0 :     if (display->mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO) {
    3112               0 :       rightVal->SetIdent(eCSSKeyword_auto);
    3113                 :     } else {
    3114               0 :       rightVal->SetAppUnits(display->mClip.width + display->mClip.x);
    3115                 :     }
    3116                 : 
    3117               0 :     if (display->mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO) {
    3118               0 :       bottomVal->SetIdent(eCSSKeyword_auto);
    3119                 :     } else {
    3120               0 :       bottomVal->SetAppUnits(display->mClip.height + display->mClip.y);
    3121                 :     }
    3122                 : 
    3123               0 :     if (display->mClipFlags & NS_STYLE_CLIP_LEFT_AUTO) {
    3124               0 :       leftVal->SetIdent(eCSSKeyword_auto);
    3125                 :     } else {
    3126               0 :       leftVal->SetAppUnits(display->mClip.x);
    3127                 :     }
    3128               0 :     val->SetRect(domRect);
    3129                 :   }
    3130                 : 
    3131               0 :   return val;
    3132                 : }
    3133                 : 
    3134                 : nsIDOMCSSValue*
    3135               0 : nsComputedDOMStyle::DoGetOverflow()
    3136                 : {
    3137               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    3138                 : 
    3139               0 :   if (display->mOverflowX != display->mOverflowY) {
    3140                 :     // No value to return.  We can't express this combination of
    3141                 :     // values as a shorthand.
    3142               0 :     return nsnull;
    3143                 :   }
    3144                 : 
    3145               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3146                 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(display->mOverflowX,
    3147               0 :                                                nsCSSProps::kOverflowKTable));
    3148               0 :   return val;
    3149                 : }
    3150                 : 
    3151                 : nsIDOMCSSValue*
    3152               0 : nsComputedDOMStyle::DoGetOverflowX()
    3153                 : {
    3154               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3155                 :   val->SetIdent(
    3156               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mOverflowX,
    3157               0 :                                    nsCSSProps::kOverflowSubKTable));
    3158               0 :   return val;
    3159                 : }
    3160                 : 
    3161                 : nsIDOMCSSValue*
    3162               0 : nsComputedDOMStyle::DoGetOverflowY()
    3163                 : {
    3164               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3165                 :   val->SetIdent(
    3166               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mOverflowY,
    3167               0 :                                    nsCSSProps::kOverflowSubKTable));
    3168               0 :   return val;
    3169                 : }
    3170                 : 
    3171                 : nsIDOMCSSValue*
    3172               0 : nsComputedDOMStyle::DoGetResize()
    3173                 : {
    3174               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3175               0 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mResize,
    3176               0 :                                                nsCSSProps::kResizeKTable));
    3177               0 :   return val;
    3178                 : }
    3179                 : 
    3180                 : 
    3181                 : nsIDOMCSSValue*
    3182               0 : nsComputedDOMStyle::DoGetPageBreakAfter()
    3183                 : {
    3184               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3185                 : 
    3186               0 :   const nsStyleDisplay *display = GetStyleDisplay();
    3187                 : 
    3188               0 :   if (display->mBreakAfter) {
    3189               0 :     val->SetIdent(eCSSKeyword_always);
    3190                 :   } else {
    3191               0 :     val->SetIdent(eCSSKeyword_auto);
    3192                 :   }
    3193                 : 
    3194               0 :   return val;
    3195                 : }
    3196                 : 
    3197                 : nsIDOMCSSValue*
    3198               0 : nsComputedDOMStyle::DoGetPageBreakBefore()
    3199                 : {
    3200               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3201                 : 
    3202               0 :   const nsStyleDisplay *display = GetStyleDisplay();
    3203                 : 
    3204               0 :   if (display->mBreakBefore) {
    3205               0 :     val->SetIdent(eCSSKeyword_always);
    3206                 :   } else {
    3207               0 :     val->SetIdent(eCSSKeyword_auto);
    3208                 :   }
    3209                 : 
    3210               0 :   return val;
    3211                 : }
    3212                 : 
    3213                 : nsIDOMCSSValue*
    3214               0 : nsComputedDOMStyle::DoGetHeight()
    3215                 : {
    3216               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3217                 : 
    3218               0 :   bool calcHeight = false;
    3219                 : 
    3220               0 :   if (mInnerFrame) {
    3221               0 :     calcHeight = true;
    3222                 : 
    3223               0 :     const nsStyleDisplay* displayData = GetStyleDisplay();
    3224               0 :     if (displayData->mDisplay == NS_STYLE_DISPLAY_INLINE &&
    3225               0 :         !(mInnerFrame->IsFrameOfType(nsIFrame::eReplaced))) {
    3226               0 :       calcHeight = false;
    3227                 :     }
    3228                 :   }
    3229                 : 
    3230               0 :   if (calcHeight) {
    3231               0 :     AssertFlushedPendingReflows();
    3232                 : 
    3233               0 :     val->SetAppUnits(mInnerFrame->GetContentRect().height);
    3234                 :   } else {
    3235               0 :     const nsStylePosition *positionData = GetStylePosition();
    3236                 : 
    3237                 :     nscoord minHeight =
    3238                 :       StyleCoordToNSCoord(positionData->mMinHeight,
    3239               0 :                           &nsComputedDOMStyle::GetCBContentHeight, 0, true);
    3240                 : 
    3241                 :     nscoord maxHeight =
    3242                 :       StyleCoordToNSCoord(positionData->mMaxHeight,
    3243                 :                           &nsComputedDOMStyle::GetCBContentHeight,
    3244               0 :                           nscoord_MAX, true);
    3245                 : 
    3246                 :     SetValueToCoord(val, positionData->mHeight, true, nsnull, nsnull,
    3247               0 :                     minHeight, maxHeight);
    3248                 :   }
    3249                 : 
    3250               0 :   return val;
    3251                 : }
    3252                 : 
    3253                 : nsIDOMCSSValue*
    3254               0 : nsComputedDOMStyle::DoGetWidth()
    3255                 : {
    3256               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3257                 : 
    3258               0 :   bool calcWidth = false;
    3259                 : 
    3260               0 :   if (mInnerFrame) {
    3261               0 :     calcWidth = true;
    3262                 : 
    3263               0 :     const nsStyleDisplay *displayData = GetStyleDisplay();
    3264               0 :     if (displayData->mDisplay == NS_STYLE_DISPLAY_INLINE &&
    3265               0 :         !(mInnerFrame->IsFrameOfType(nsIFrame::eReplaced))) {
    3266               0 :       calcWidth = false;
    3267                 :     }
    3268                 :   }
    3269                 : 
    3270               0 :   if (calcWidth) {
    3271               0 :     AssertFlushedPendingReflows();
    3272                 : 
    3273               0 :     val->SetAppUnits(mInnerFrame->GetContentRect().width);
    3274                 :   } else {
    3275               0 :     const nsStylePosition *positionData = GetStylePosition();
    3276                 : 
    3277                 :     nscoord minWidth =
    3278                 :       StyleCoordToNSCoord(positionData->mMinWidth,
    3279               0 :                           &nsComputedDOMStyle::GetCBContentWidth, 0, true);
    3280                 : 
    3281                 :     nscoord maxWidth =
    3282                 :       StyleCoordToNSCoord(positionData->mMaxWidth,
    3283                 :                           &nsComputedDOMStyle::GetCBContentWidth,
    3284               0 :                           nscoord_MAX, true);
    3285                 : 
    3286                 :     SetValueToCoord(val, positionData->mWidth, true, nsnull,
    3287               0 :                     nsCSSProps::kWidthKTable, minWidth, maxWidth);
    3288                 :   }
    3289                 : 
    3290               0 :   return val;
    3291                 : }
    3292                 : 
    3293                 : nsIDOMCSSValue*
    3294               0 : nsComputedDOMStyle::DoGetMaxHeight()
    3295                 : {
    3296               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3297               0 :   SetValueToCoord(val, GetStylePosition()->mMaxHeight, true,
    3298               0 :                   &nsComputedDOMStyle::GetCBContentHeight);
    3299               0 :   return val;
    3300                 : }
    3301                 : 
    3302                 : nsIDOMCSSValue*
    3303               0 : nsComputedDOMStyle::DoGetMaxWidth()
    3304                 : {
    3305               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3306               0 :   SetValueToCoord(val, GetStylePosition()->mMaxWidth, true,
    3307                 :                   &nsComputedDOMStyle::GetCBContentWidth,
    3308               0 :                   nsCSSProps::kWidthKTable);
    3309               0 :   return val;
    3310                 : }
    3311                 : 
    3312                 : nsIDOMCSSValue*
    3313               0 : nsComputedDOMStyle::DoGetMinHeight()
    3314                 : {
    3315               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3316               0 :   SetValueToCoord(val, GetStylePosition()->mMinHeight, true,
    3317               0 :                   &nsComputedDOMStyle::GetCBContentHeight);
    3318               0 :   return val;
    3319                 : }
    3320                 : 
    3321                 : nsIDOMCSSValue*
    3322               0 : nsComputedDOMStyle::DoGetMinWidth()
    3323                 : {
    3324               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3325               0 :   SetValueToCoord(val, GetStylePosition()->mMinWidth, true,
    3326                 :                   &nsComputedDOMStyle::GetCBContentWidth,
    3327               0 :                   nsCSSProps::kWidthKTable);
    3328               0 :   return val;
    3329                 : }
    3330                 : 
    3331                 : nsIDOMCSSValue*
    3332               0 : nsComputedDOMStyle::DoGetLeft()
    3333                 : {
    3334               0 :   return GetOffsetWidthFor(NS_SIDE_LEFT);
    3335                 : }
    3336                 : 
    3337                 : nsIDOMCSSValue*
    3338               0 : nsComputedDOMStyle::DoGetRight()
    3339                 : {
    3340               0 :   return GetOffsetWidthFor(NS_SIDE_RIGHT);
    3341                 : }
    3342                 : 
    3343                 : nsIDOMCSSValue*
    3344               0 : nsComputedDOMStyle::DoGetTop()
    3345                 : {
    3346               0 :   return GetOffsetWidthFor(NS_SIDE_TOP);
    3347                 : }
    3348                 : 
    3349                 : nsROCSSPrimitiveValue*
    3350               0 : nsComputedDOMStyle::GetROCSSPrimitiveValue()
    3351                 : {
    3352               0 :   nsROCSSPrimitiveValue *primitiveValue = new nsROCSSPrimitiveValue();
    3353                 : 
    3354               0 :   NS_ASSERTION(primitiveValue != 0, "ran out of memory");
    3355                 : 
    3356               0 :   return primitiveValue;
    3357                 : }
    3358                 : 
    3359                 : nsDOMCSSValueList*
    3360               0 : nsComputedDOMStyle::GetROCSSValueList(bool aCommaDelimited)
    3361                 : {
    3362                 :   nsDOMCSSValueList *valueList = new nsDOMCSSValueList(aCommaDelimited,
    3363               0 :                                                        true);
    3364               0 :   NS_ASSERTION(valueList != 0, "ran out of memory");
    3365                 : 
    3366               0 :   return valueList;
    3367                 : }
    3368                 : 
    3369                 : nsIDOMCSSValue*
    3370               0 : nsComputedDOMStyle::GetOffsetWidthFor(mozilla::css::Side aSide)
    3371                 : {
    3372               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    3373                 : 
    3374               0 :   AssertFlushedPendingReflows();
    3375                 : 
    3376               0 :   PRUint8 position = display->mPosition;
    3377               0 :   if (!mOuterFrame) {
    3378                 :     // GetRelativeOffset and GetAbsoluteOffset don't handle elements
    3379                 :     // without frames in any sensible way.  GetStaticOffset, however,
    3380                 :     // is perfect for that case.
    3381               0 :     position = NS_STYLE_POSITION_STATIC;
    3382                 :   }
    3383                 : 
    3384               0 :   switch (position) {
    3385                 :     case NS_STYLE_POSITION_STATIC:
    3386               0 :       return GetStaticOffset(aSide);
    3387                 :     case NS_STYLE_POSITION_RELATIVE:
    3388               0 :       return GetRelativeOffset(aSide);
    3389                 :     case NS_STYLE_POSITION_ABSOLUTE:
    3390                 :     case NS_STYLE_POSITION_FIXED:
    3391               0 :       return GetAbsoluteOffset(aSide);
    3392                 :     default:
    3393               0 :       NS_ERROR("Invalid position");
    3394               0 :       return nsnull;
    3395                 :   }
    3396                 : }
    3397                 : 
    3398                 : nsIDOMCSSValue*
    3399               0 : nsComputedDOMStyle::GetAbsoluteOffset(mozilla::css::Side aSide)
    3400                 : {
    3401               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3402                 : 
    3403               0 :   nsIFrame* container = GetContainingBlockFor(mOuterFrame);
    3404               0 :   if (container) {
    3405               0 :     nsMargin margin = mOuterFrame->GetUsedMargin();
    3406               0 :     nsMargin border = container->GetUsedBorder();
    3407               0 :     nsMargin scrollbarSizes(0, 0, 0, 0);
    3408               0 :     nsRect rect = mOuterFrame->GetRect();
    3409               0 :     nsRect containerRect = container->GetRect();
    3410                 : 
    3411               0 :     if (container->GetType() == nsGkAtoms::viewportFrame) {
    3412                 :       // For absolutely positioned frames scrollbars are taken into
    3413                 :       // account by virtue of getting a containing block that does
    3414                 :       // _not_ include the scrollbars.  For fixed positioned frames,
    3415                 :       // the containing block is the viewport, which _does_ include
    3416                 :       // scrollbars.  We have to do some extra work.
    3417                 :       // the first child in the default frame list is what we want
    3418               0 :       nsIFrame* scrollingChild = container->GetFirstPrincipalChild();
    3419               0 :       nsIScrollableFrame *scrollFrame = do_QueryFrame(scrollingChild);
    3420               0 :       if (scrollFrame) {
    3421               0 :         scrollbarSizes = scrollFrame->GetActualScrollbarSizes();
    3422                 :       }
    3423                 :     }
    3424                 : 
    3425               0 :     nscoord offset = 0;
    3426               0 :     switch (aSide) {
    3427                 :       case NS_SIDE_TOP:
    3428               0 :         offset = rect.y - margin.top - border.top - scrollbarSizes.top;
    3429                 : 
    3430               0 :         break;
    3431                 :       case NS_SIDE_RIGHT:
    3432                 :         offset = containerRect.width - rect.width -
    3433               0 :           rect.x - margin.right - border.right - scrollbarSizes.right;
    3434                 : 
    3435               0 :         break;
    3436                 :       case NS_SIDE_BOTTOM:
    3437                 :         offset = containerRect.height - rect.height -
    3438               0 :           rect.y - margin.bottom - border.bottom - scrollbarSizes.bottom;
    3439                 : 
    3440               0 :         break;
    3441                 :       case NS_SIDE_LEFT:
    3442               0 :         offset = rect.x - margin.left - border.left - scrollbarSizes.left;
    3443                 : 
    3444               0 :         break;
    3445                 :       default:
    3446               0 :         NS_ERROR("Invalid side");
    3447               0 :         break;
    3448                 :     }
    3449               0 :     val->SetAppUnits(offset);
    3450                 :   } else {
    3451                 :     // XXX no frame.  This property makes no sense
    3452               0 :     val->SetAppUnits(0);
    3453                 :   }
    3454                 : 
    3455               0 :   return val;
    3456                 : }
    3457                 : 
    3458                 : MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
    3459                 :                   NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
    3460                 :                   "box side constants not as expected for NS_OPPOSITE_SIDE");
    3461                 : #define NS_OPPOSITE_SIDE(s_) mozilla::css::Side(((s_) + 2) & 3)
    3462                 : 
    3463                 : nsIDOMCSSValue*
    3464               0 : nsComputedDOMStyle::GetRelativeOffset(mozilla::css::Side aSide)
    3465                 : {
    3466               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3467                 : 
    3468               0 :   const nsStylePosition* positionData = GetStylePosition();
    3469               0 :   PRInt32 sign = 1;
    3470               0 :   nsStyleCoord coord = positionData->mOffset.Get(aSide);
    3471                 : 
    3472               0 :   NS_ASSERTION(coord.GetUnit() == eStyleUnit_Coord ||
    3473                 :                coord.GetUnit() == eStyleUnit_Percent ||
    3474                 :                coord.GetUnit() == eStyleUnit_Auto ||
    3475                 :                coord.IsCalcUnit(),
    3476                 :                "Unexpected unit");
    3477                 : 
    3478               0 :   if (coord.GetUnit() == eStyleUnit_Auto) {
    3479               0 :     coord = positionData->mOffset.Get(NS_OPPOSITE_SIDE(aSide));
    3480               0 :     sign = -1;
    3481                 :   }
    3482                 :   PercentageBaseGetter baseGetter;
    3483               0 :   if (aSide == NS_SIDE_LEFT || aSide == NS_SIDE_RIGHT) {
    3484               0 :     baseGetter = &nsComputedDOMStyle::GetCBContentWidth;
    3485                 :   } else {
    3486               0 :     baseGetter = &nsComputedDOMStyle::GetCBContentHeight;
    3487                 :   }
    3488                 : 
    3489               0 :   val->SetAppUnits(sign * StyleCoordToNSCoord(coord, baseGetter, 0, false));
    3490               0 :   return val;
    3491                 : }
    3492                 : 
    3493                 : nsIDOMCSSValue*
    3494               0 : nsComputedDOMStyle::GetStaticOffset(mozilla::css::Side aSide)
    3495                 : 
    3496                 : {
    3497               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3498               0 :   SetValueToCoord(val, GetStylePosition()->mOffset.Get(aSide), false);
    3499               0 :   return val;
    3500                 : }
    3501                 : 
    3502                 : nsIDOMCSSValue*
    3503               0 : nsComputedDOMStyle::GetPaddingWidthFor(mozilla::css::Side aSide)
    3504                 : {
    3505               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3506                 : 
    3507               0 :   if (!mInnerFrame) {
    3508               0 :     SetValueToCoord(val, GetStylePadding()->mPadding.Get(aSide), true);
    3509                 :   } else {
    3510               0 :     AssertFlushedPendingReflows();
    3511                 : 
    3512               0 :     val->SetAppUnits(mInnerFrame->GetUsedPadding().Side(aSide));
    3513                 :   }
    3514                 : 
    3515               0 :   return val;
    3516                 : }
    3517                 : 
    3518                 : bool
    3519               0 : nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
    3520                 : {
    3521               0 :   AssertFlushedPendingReflows();
    3522                 : 
    3523               0 :   nscoord blockHeight = NS_AUTOHEIGHT;
    3524               0 :   if (GetStyleText()->mLineHeight.GetUnit() == eStyleUnit_Enumerated) {
    3525               0 :     if (!mInnerFrame)
    3526               0 :       return false;
    3527                 : 
    3528               0 :     if (nsLayoutUtils::IsNonWrapperBlock(mInnerFrame)) {
    3529               0 :       blockHeight = mInnerFrame->GetContentRect().height;
    3530                 :     } else {
    3531               0 :       GetCBContentHeight(blockHeight);
    3532                 :     }
    3533                 :   }
    3534                 : 
    3535                 :   // lie about font size inflation since we lie about font size (since
    3536                 :   // the inflation only applies to text)
    3537                 :   aCoord = nsHTMLReflowState::CalcLineHeight(mStyleContextHolder,
    3538               0 :                                              blockHeight, 1.0f);
    3539                 : 
    3540                 :   // CalcLineHeight uses font->mFont.size, but we want to use
    3541                 :   // font->mSize as the font size.  Adjust for that.  Also adjust for
    3542                 :   // the text zoom, if any.
    3543               0 :   const nsStyleFont* font = GetStyleFont();
    3544                 :   aCoord = NSToCoordRound((float(aCoord) *
    3545                 :                            (float(font->mSize) / float(font->mFont.size))) /
    3546               0 :                           mPresShell->GetPresContext()->TextZoom());
    3547                 : 
    3548               0 :   return true;
    3549                 : }
    3550                 : 
    3551                 : nsIDOMCSSValue*
    3552               0 : nsComputedDOMStyle::GetBorderColorsFor(mozilla::css::Side aSide)
    3553                 : {
    3554               0 :   const nsStyleBorder *border = GetStyleBorder();
    3555                 : 
    3556               0 :   if (border->mBorderColors) {
    3557               0 :     nsBorderColors* borderColors = border->mBorderColors[aSide];
    3558               0 :     if (borderColors) {
    3559               0 :       nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    3560                 : 
    3561               0 :       do {
    3562               0 :         nsROCSSPrimitiveValue *primitive = GetROCSSPrimitiveValue();
    3563                 : 
    3564               0 :         SetToRGBAColor(primitive, borderColors->mColor);
    3565                 : 
    3566               0 :         valueList->AppendCSSValue(primitive);
    3567               0 :         borderColors = borderColors->mNext;
    3568                 :       } while (borderColors);
    3569                 : 
    3570               0 :       return valueList;
    3571                 :     }
    3572                 :   }
    3573                 : 
    3574               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3575               0 :   val->SetIdent(eCSSKeyword_none);
    3576               0 :   return val;
    3577                 : }
    3578                 : 
    3579                 : nsIDOMCSSValue*
    3580               0 : nsComputedDOMStyle::GetBorderWidthFor(mozilla::css::Side aSide)
    3581                 : {
    3582               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3583                 : 
    3584                 :   nscoord width;
    3585               0 :   if (mInnerFrame) {
    3586               0 :     AssertFlushedPendingReflows();
    3587               0 :     width = mInnerFrame->GetUsedBorder().Side(aSide);
    3588                 :   } else {
    3589               0 :     width = GetStyleBorder()->GetActualBorderWidth(aSide);
    3590                 :   }
    3591               0 :   val->SetAppUnits(width);
    3592                 : 
    3593               0 :   return val;
    3594                 : }
    3595                 : 
    3596                 : nsIDOMCSSValue*
    3597               0 : nsComputedDOMStyle::GetBorderColorFor(mozilla::css::Side aSide)
    3598                 : {
    3599               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3600                 : 
    3601                 :   nscolor color;
    3602                 :   bool foreground;
    3603               0 :   GetStyleBorder()->GetBorderColor(aSide, color, foreground);
    3604               0 :   if (foreground) {
    3605               0 :     color = GetStyleColor()->mColor;
    3606                 :   }
    3607                 : 
    3608               0 :   SetToRGBAColor(val, color);
    3609               0 :   return val;
    3610                 : }
    3611                 : 
    3612                 : nsIDOMCSSValue*
    3613               0 : nsComputedDOMStyle::GetMarginWidthFor(mozilla::css::Side aSide)
    3614                 : {
    3615               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3616                 : 
    3617               0 :   if (!mInnerFrame) {
    3618               0 :     SetValueToCoord(val, GetStyleMargin()->mMargin.Get(aSide), false);
    3619                 :   } else {
    3620               0 :     AssertFlushedPendingReflows();
    3621                 : 
    3622                 :     // For tables, GetUsedMargin always returns an empty margin, so we
    3623                 :     // should read the margin from the outer table frame instead.
    3624               0 :     val->SetAppUnits(mOuterFrame->GetUsedMargin().Side(aSide));
    3625               0 :     NS_ASSERTION(mOuterFrame == mInnerFrame ||
    3626                 :                  mInnerFrame->GetUsedMargin() == nsMargin(0, 0, 0, 0),
    3627                 :                  "Inner tables must have zero margins");
    3628                 :   }
    3629                 : 
    3630               0 :   return val;
    3631                 : }
    3632                 : 
    3633                 : nsIDOMCSSValue*
    3634               0 : nsComputedDOMStyle::GetBorderStyleFor(mozilla::css::Side aSide)
    3635                 : {
    3636               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3637                 :   val->SetIdent(
    3638               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleBorder()->GetBorderStyle(aSide),
    3639               0 :                                    nsCSSProps::kBorderStyleKTable));
    3640               0 :   return val;
    3641                 : }
    3642                 : 
    3643                 : void
    3644               0 : nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
    3645                 :                                     const nsStyleCoord& aCoord,
    3646                 :                                     bool aClampNegativeCalc,
    3647                 :                                     PercentageBaseGetter aPercentageBaseGetter,
    3648                 :                                     const PRInt32 aTable[],
    3649                 :                                     nscoord aMinAppUnits,
    3650                 :                                     nscoord aMaxAppUnits)
    3651                 : {
    3652               0 :   NS_PRECONDITION(aValue, "Must have a value to work with");
    3653                 : 
    3654               0 :   switch (aCoord.GetUnit()) {
    3655                 :     case eStyleUnit_Normal:
    3656               0 :       aValue->SetIdent(eCSSKeyword_normal);
    3657               0 :       break;
    3658                 : 
    3659                 :     case eStyleUnit_Auto:
    3660               0 :       aValue->SetIdent(eCSSKeyword_auto);
    3661               0 :       break;
    3662                 : 
    3663                 :     case eStyleUnit_Percent:
    3664                 :       {
    3665                 :         nscoord percentageBase;
    3666               0 :         if (aPercentageBaseGetter &&
    3667               0 :             (this->*aPercentageBaseGetter)(percentageBase)) {
    3668                 :           nscoord val = NSCoordSaturatingMultiply(percentageBase,
    3669               0 :                                                   aCoord.GetPercentValue());
    3670               0 :           aValue->SetAppUnits(NS_MAX(aMinAppUnits, NS_MIN(val, aMaxAppUnits)));
    3671                 :         } else {
    3672               0 :           aValue->SetPercent(aCoord.GetPercentValue());
    3673                 :         }
    3674                 :       }
    3675               0 :       break;
    3676                 : 
    3677                 :     case eStyleUnit_Factor:
    3678               0 :       aValue->SetNumber(aCoord.GetFactorValue());
    3679               0 :       break;
    3680                 : 
    3681                 :     case eStyleUnit_Coord:
    3682                 :       {
    3683               0 :         nscoord val = aCoord.GetCoordValue();
    3684               0 :         aValue->SetAppUnits(NS_MAX(aMinAppUnits, NS_MIN(val, aMaxAppUnits)));
    3685                 :       }
    3686               0 :       break;
    3687                 : 
    3688                 :     case eStyleUnit_Integer:
    3689               0 :       aValue->SetNumber(aCoord.GetIntValue());
    3690               0 :       break;
    3691                 : 
    3692                 :     case eStyleUnit_Enumerated:
    3693               0 :       NS_ASSERTION(aTable, "Must have table to handle this case");
    3694                 :       aValue->SetIdent(nsCSSProps::ValueToKeywordEnum(aCoord.GetIntValue(),
    3695               0 :                                                       aTable));
    3696               0 :       break;
    3697                 : 
    3698                 :     case eStyleUnit_None:
    3699               0 :       aValue->SetIdent(eCSSKeyword_none);
    3700               0 :       break;
    3701                 : 
    3702                 :     case eStyleUnit_Calc:
    3703                 :       nscoord percentageBase;
    3704               0 :       if (!aCoord.CalcHasPercent()) {
    3705               0 :         nscoord val = nsRuleNode::ComputeCoordPercentCalc(aCoord, 0);
    3706               0 :         if (aClampNegativeCalc && val < 0) {
    3707               0 :           NS_ABORT_IF_FALSE(aCoord.IsCalcUnit(),
    3708                 :                             "parser should have rejected value");
    3709               0 :           val = 0;
    3710                 :         }
    3711               0 :         aValue->SetAppUnits(NS_MAX(aMinAppUnits, NS_MIN(val, aMaxAppUnits)));
    3712               0 :       } else if (aPercentageBaseGetter &&
    3713               0 :                  (this->*aPercentageBaseGetter)(percentageBase)) {
    3714                 :         nscoord val =
    3715               0 :           nsRuleNode::ComputeCoordPercentCalc(aCoord, percentageBase);
    3716               0 :         if (aClampNegativeCalc && val < 0) {
    3717               0 :           NS_ABORT_IF_FALSE(aCoord.IsCalcUnit(),
    3718                 :                             "parser should have rejected value");
    3719               0 :           val = 0;
    3720                 :         }
    3721               0 :         aValue->SetAppUnits(NS_MAX(aMinAppUnits, NS_MIN(val, aMaxAppUnits)));
    3722                 :       } else {
    3723               0 :         nsStyleCoord::Calc *calc = aCoord.GetCalcValue();
    3724               0 :         SetValueToCalc(calc, aValue);
    3725                 :       }
    3726               0 :       break;
    3727                 :     default:
    3728               0 :       NS_ERROR("Can't handle this unit");
    3729               0 :       break;
    3730                 :   }
    3731               0 : }
    3732                 : 
    3733                 : nscoord
    3734               0 : nsComputedDOMStyle::StyleCoordToNSCoord(const nsStyleCoord& aCoord,
    3735                 :                                         PercentageBaseGetter aPercentageBaseGetter,
    3736                 :                                         nscoord aDefaultValue,
    3737                 :                                         bool aClampNegativeCalc)
    3738                 : {
    3739               0 :   NS_PRECONDITION(aPercentageBaseGetter, "Must have a percentage base getter");
    3740               0 :   if (aCoord.GetUnit() == eStyleUnit_Coord) {
    3741               0 :     return aCoord.GetCoordValue();
    3742                 :   }
    3743               0 :   if (aCoord.GetUnit() == eStyleUnit_Percent || aCoord.IsCalcUnit()) {
    3744                 :     nscoord percentageBase;
    3745               0 :     if ((this->*aPercentageBaseGetter)(percentageBase)) {
    3746                 :       nscoord result =
    3747               0 :         nsRuleNode::ComputeCoordPercentCalc(aCoord, percentageBase);
    3748               0 :       if (aClampNegativeCalc && result < 0) {
    3749               0 :         NS_ABORT_IF_FALSE(aCoord.IsCalcUnit(),
    3750                 :                           "parser should have rejected value");
    3751               0 :         result = 0;
    3752                 :       }
    3753               0 :       return result;
    3754                 :     }
    3755                 :     // Fall through to returning aDefaultValue if we have no percentage base.
    3756                 :   }
    3757                 : 
    3758               0 :   return aDefaultValue;
    3759                 : }
    3760                 : 
    3761                 : bool
    3762               0 : nsComputedDOMStyle::GetCBContentWidth(nscoord& aWidth)
    3763                 : {
    3764               0 :   if (!mOuterFrame) {
    3765               0 :     return false;
    3766                 :   }
    3767                 : 
    3768               0 :   nsIFrame* container = GetContainingBlockFor(mOuterFrame);
    3769               0 :   if (!container) {
    3770               0 :     return false;
    3771                 :   }
    3772                 : 
    3773               0 :   AssertFlushedPendingReflows();
    3774                 : 
    3775               0 :   aWidth = container->GetContentRect().width;
    3776               0 :   return true;
    3777                 : }
    3778                 : 
    3779                 : bool
    3780               0 : nsComputedDOMStyle::GetCBContentHeight(nscoord& aHeight)
    3781                 : {
    3782               0 :   if (!mOuterFrame) {
    3783               0 :     return false;
    3784                 :   }
    3785                 : 
    3786               0 :   nsIFrame* container = GetContainingBlockFor(mOuterFrame);
    3787               0 :   if (!container) {
    3788               0 :     return false;
    3789                 :   }
    3790                 : 
    3791               0 :   AssertFlushedPendingReflows();
    3792                 : 
    3793               0 :   aHeight = container->GetContentRect().height;
    3794               0 :   return true;
    3795                 : }
    3796                 : 
    3797                 : bool
    3798               0 : nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord& aWidth)
    3799                 : {
    3800               0 :   if (!mInnerFrame) {
    3801               0 :     return false;
    3802                 :   }
    3803                 : 
    3804               0 :   AssertFlushedPendingReflows();
    3805                 : 
    3806               0 :   aWidth = mInnerFrame->GetSize().width;
    3807               0 :   return true;
    3808                 : }
    3809                 : 
    3810                 : bool
    3811               0 : nsComputedDOMStyle::GetFrameBorderRectHeight(nscoord& aHeight)
    3812                 : {
    3813               0 :   if (!mInnerFrame) {
    3814               0 :     return false;
    3815                 :   }
    3816                 : 
    3817               0 :   AssertFlushedPendingReflows();
    3818                 : 
    3819               0 :   aHeight = mInnerFrame->GetSize().height;
    3820               0 :   return true;
    3821                 : }
    3822                 : 
    3823                 : bool
    3824               0 : nsComputedDOMStyle::GetFrameBoundsWidthForTransform(nscoord& aWidth)
    3825                 : {
    3826                 :   // We need a frame to work with.
    3827               0 :   if (!mInnerFrame) {
    3828               0 :     return false;
    3829                 :   }
    3830                 : 
    3831               0 :   AssertFlushedPendingReflows();
    3832                 : 
    3833               0 :   aWidth = nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame).width;
    3834               0 :   return true;
    3835                 : }
    3836                 : 
    3837                 : bool
    3838               0 : nsComputedDOMStyle::GetFrameBoundsHeightForTransform(nscoord& aHeight)
    3839                 : {
    3840                 :   // We need a frame to work with.
    3841               0 :   if (!mInnerFrame) {
    3842               0 :     return false;
    3843                 :   }
    3844                 : 
    3845               0 :   AssertFlushedPendingReflows();
    3846                 : 
    3847               0 :   aHeight = nsDisplayTransform::GetFrameBoundsForTransform(mInnerFrame).height;
    3848               0 :   return true;
    3849                 : }
    3850                 : 
    3851                 : nsIDOMCSSValue*
    3852               0 : nsComputedDOMStyle::GetSVGPaintFor(bool aFill)
    3853                 : {
    3854               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3855                 : 
    3856               0 :   const nsStyleSVG* svg = GetStyleSVG();
    3857               0 :   const nsStyleSVGPaint* paint = nsnull;
    3858                 : 
    3859               0 :   if (aFill)
    3860               0 :     paint = &svg->mFill;
    3861                 :   else
    3862               0 :     paint = &svg->mStroke;
    3863                 : 
    3864               0 :   nsAutoString paintString;
    3865                 : 
    3866               0 :   switch (paint->mType) {
    3867                 :     case eStyleSVGPaintType_None:
    3868                 :     {
    3869               0 :       val->SetIdent(eCSSKeyword_none);
    3870               0 :       break;
    3871                 :     }
    3872                 :     case eStyleSVGPaintType_Color:
    3873                 :     {
    3874               0 :       SetToRGBAColor(val, paint->mPaint.mColor);
    3875               0 :       break;
    3876                 :     }
    3877                 :     case eStyleSVGPaintType_Server:
    3878                 :     {
    3879               0 :       nsDOMCSSValueList *valueList = GetROCSSValueList(false);
    3880               0 :       valueList->AppendCSSValue(val);
    3881                 : 
    3882               0 :       nsROCSSPrimitiveValue* fallback = GetROCSSPrimitiveValue();
    3883               0 :       valueList->AppendCSSValue(fallback);
    3884                 : 
    3885               0 :       val->SetURI(paint->mPaint.mPaintServer);
    3886               0 :       SetToRGBAColor(fallback, paint->mFallbackColor);
    3887               0 :       return valueList;
    3888                 :     }
    3889                 :   }
    3890                 : 
    3891               0 :   return val;
    3892                 : }
    3893                 : 
    3894                 : nsIDOMCSSValue*
    3895               0 : nsComputedDOMStyle::DoGetFill()
    3896                 : {
    3897               0 :   return GetSVGPaintFor(true);
    3898                 : }
    3899                 : 
    3900                 : nsIDOMCSSValue*
    3901               0 : nsComputedDOMStyle::DoGetStroke()
    3902                 : {
    3903               0 :   return GetSVGPaintFor(false);
    3904                 : }
    3905                 : 
    3906                 : nsIDOMCSSValue*
    3907               0 : nsComputedDOMStyle::DoGetMarkerEnd()
    3908                 : {
    3909               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3910                 : 
    3911               0 :   const nsStyleSVG* svg = GetStyleSVG();
    3912                 : 
    3913               0 :   if (svg->mMarkerEnd)
    3914               0 :     val->SetURI(svg->mMarkerEnd);
    3915                 :   else
    3916               0 :     val->SetIdent(eCSSKeyword_none);
    3917                 : 
    3918               0 :   return val;
    3919                 : }
    3920                 : 
    3921                 : nsIDOMCSSValue*
    3922               0 : nsComputedDOMStyle::DoGetMarkerMid()
    3923                 : {
    3924               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3925                 : 
    3926               0 :   const nsStyleSVG* svg = GetStyleSVG();
    3927                 : 
    3928               0 :   if (svg->mMarkerMid)
    3929               0 :     val->SetURI(svg->mMarkerMid);
    3930                 :   else
    3931               0 :     val->SetIdent(eCSSKeyword_none);
    3932                 : 
    3933               0 :   return val;
    3934                 : }
    3935                 : 
    3936                 : nsIDOMCSSValue*
    3937               0 : nsComputedDOMStyle::DoGetMarkerStart()
    3938                 : {
    3939               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3940                 : 
    3941               0 :   const nsStyleSVG* svg = GetStyleSVG();
    3942                 : 
    3943               0 :   if (svg->mMarkerStart)
    3944               0 :     val->SetURI(svg->mMarkerStart);
    3945                 :   else
    3946               0 :     val->SetIdent(eCSSKeyword_none);
    3947                 : 
    3948               0 :   return val;
    3949                 : }
    3950                 : 
    3951                 : nsIDOMCSSValue*
    3952               0 : nsComputedDOMStyle::DoGetStrokeDasharray()
    3953                 : {
    3954               0 :   const nsStyleSVG* svg = GetStyleSVG();
    3955                 : 
    3956               0 :   if (!svg->mStrokeDasharrayLength || !svg->mStrokeDasharray) {
    3957               0 :     nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3958               0 :     val->SetIdent(eCSSKeyword_none);
    3959               0 :     return val;
    3960                 :   }
    3961                 : 
    3962               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    3963                 : 
    3964               0 :   for (PRUint32 i = 0; i < svg->mStrokeDasharrayLength; i++) {
    3965               0 :     nsROCSSPrimitiveValue* dash = GetROCSSPrimitiveValue();
    3966               0 :     valueList->AppendCSSValue(dash);
    3967                 : 
    3968               0 :     SetValueToCoord(dash, svg->mStrokeDasharray[i], true);
    3969                 :   }
    3970                 : 
    3971               0 :   return valueList;
    3972                 : }
    3973                 : 
    3974                 : nsIDOMCSSValue*
    3975               0 : nsComputedDOMStyle::DoGetStrokeDashoffset()
    3976                 : {
    3977               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3978               0 :   SetValueToCoord(val, GetStyleSVG()->mStrokeDashoffset, false);
    3979               0 :   return val;
    3980                 : }
    3981                 : 
    3982                 : nsIDOMCSSValue*
    3983               0 : nsComputedDOMStyle::DoGetStrokeWidth()
    3984                 : {
    3985               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    3986               0 :   SetValueToCoord(val, GetStyleSVG()->mStrokeWidth, true);
    3987               0 :   return val;
    3988                 : }
    3989                 : 
    3990                 : nsIDOMCSSValue*
    3991               0 : nsComputedDOMStyle::DoGetFillOpacity()
    3992                 : {
    3993               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    3994               0 :   val->SetNumber(GetStyleSVG()->mFillOpacity);
    3995               0 :   return val;
    3996                 : }
    3997                 : 
    3998                 : nsIDOMCSSValue*
    3999               0 : nsComputedDOMStyle::DoGetFloodOpacity()
    4000                 : {
    4001               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4002               0 :   val->SetNumber(GetStyleSVGReset()->mFloodOpacity);
    4003               0 :   return val;
    4004                 : }
    4005                 : 
    4006                 : nsIDOMCSSValue*
    4007               0 : nsComputedDOMStyle::DoGetStopOpacity()
    4008                 : {
    4009               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4010               0 :   val->SetNumber(GetStyleSVGReset()->mStopOpacity);
    4011               0 :   return val;
    4012                 : }
    4013                 : 
    4014                 : nsIDOMCSSValue*
    4015               0 : nsComputedDOMStyle::DoGetStrokeMiterlimit()
    4016                 : {
    4017               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4018               0 :   val->SetNumber(GetStyleSVG()->mStrokeMiterlimit);
    4019               0 :   return val;
    4020                 : }
    4021                 : 
    4022                 : nsIDOMCSSValue*
    4023               0 : nsComputedDOMStyle::DoGetStrokeOpacity()
    4024                 : {
    4025               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4026               0 :   val->SetNumber(GetStyleSVG()->mStrokeOpacity);
    4027               0 :   return val;
    4028                 : }
    4029                 : 
    4030                 : nsIDOMCSSValue*
    4031               0 : nsComputedDOMStyle::DoGetClipRule()
    4032                 : {
    4033               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4034                 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(
    4035               0 :                   GetStyleSVG()->mClipRule, nsCSSProps::kFillRuleKTable));
    4036               0 :   return val;
    4037                 : }
    4038                 : 
    4039                 : nsIDOMCSSValue*
    4040               0 : nsComputedDOMStyle::DoGetFillRule()
    4041                 : {
    4042               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4043                 :   val->SetIdent(nsCSSProps::ValueToKeywordEnum(
    4044               0 :                   GetStyleSVG()->mFillRule, nsCSSProps::kFillRuleKTable));
    4045               0 :   return val;
    4046                 : }
    4047                 : 
    4048                 : nsIDOMCSSValue*
    4049               0 : nsComputedDOMStyle::DoGetStrokeLinecap()
    4050                 : {
    4051               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4052                 :   val->SetIdent(
    4053               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mStrokeLinecap,
    4054               0 :                                    nsCSSProps::kStrokeLinecapKTable));
    4055               0 :   return val;
    4056                 : }
    4057                 : 
    4058                 : nsIDOMCSSValue*
    4059               0 : nsComputedDOMStyle::DoGetStrokeLinejoin()
    4060                 : {
    4061               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4062                 :   val->SetIdent(
    4063               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mStrokeLinejoin,
    4064               0 :                                    nsCSSProps::kStrokeLinejoinKTable));
    4065               0 :   return val;
    4066                 : }
    4067                 : 
    4068                 : nsIDOMCSSValue*
    4069               0 : nsComputedDOMStyle::DoGetTextAnchor()
    4070                 : {
    4071               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4072                 :   val->SetIdent(
    4073               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mTextAnchor,
    4074               0 :                                    nsCSSProps::kTextAnchorKTable));
    4075               0 :   return val;
    4076                 : }
    4077                 : 
    4078                 : nsIDOMCSSValue*
    4079               0 : nsComputedDOMStyle::DoGetColorInterpolation()
    4080                 : {
    4081               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4082                 :   val->SetIdent(
    4083               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mColorInterpolation,
    4084               0 :                                    nsCSSProps::kColorInterpolationKTable));
    4085               0 :   return val;
    4086                 : }
    4087                 : 
    4088                 : nsIDOMCSSValue*
    4089               0 : nsComputedDOMStyle::DoGetColorInterpolationFilters()
    4090                 : {
    4091               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4092                 :   val->SetIdent(
    4093               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mColorInterpolationFilters,
    4094               0 :                                    nsCSSProps::kColorInterpolationKTable));
    4095               0 :   return val;
    4096                 : }
    4097                 : 
    4098                 : nsIDOMCSSValue*
    4099               0 : nsComputedDOMStyle::DoGetDominantBaseline()
    4100                 : {
    4101               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4102                 :   val->SetIdent(
    4103               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVGReset()->mDominantBaseline,
    4104               0 :                                    nsCSSProps::kDominantBaselineKTable));
    4105               0 :   return val;
    4106                 : }
    4107                 : 
    4108                 : nsIDOMCSSValue*
    4109               0 : nsComputedDOMStyle::DoGetImageRendering()
    4110                 : {
    4111               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4112                 :   val->SetIdent(
    4113               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mImageRendering,
    4114               0 :                                    nsCSSProps::kImageRenderingKTable));
    4115               0 :   return val;
    4116                 : }
    4117                 : 
    4118                 : nsIDOMCSSValue*
    4119               0 : nsComputedDOMStyle::DoGetShapeRendering()
    4120                 : {
    4121               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4122                 :   val->SetIdent(
    4123               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mShapeRendering,
    4124               0 :                                    nsCSSProps::kShapeRenderingKTable));
    4125               0 :   return val;
    4126                 : }
    4127                 : 
    4128                 : nsIDOMCSSValue*
    4129               0 : nsComputedDOMStyle::DoGetTextRendering()
    4130                 : {
    4131               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4132                 :   val->SetIdent(
    4133               0 :     nsCSSProps::ValueToKeywordEnum(GetStyleSVG()->mTextRendering,
    4134               0 :                                    nsCSSProps::kTextRenderingKTable));
    4135               0 :   return val;
    4136                 : }
    4137                 : 
    4138                 : nsIDOMCSSValue*
    4139               0 : nsComputedDOMStyle::DoGetFloodColor()
    4140                 : {
    4141               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4142               0 :   SetToRGBAColor(val, GetStyleSVGReset()->mFloodColor);
    4143               0 :   return val;
    4144                 : }
    4145                 : 
    4146                 : nsIDOMCSSValue*
    4147               0 : nsComputedDOMStyle::DoGetLightingColor()
    4148                 : {
    4149               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4150               0 :   SetToRGBAColor(val, GetStyleSVGReset()->mLightingColor);
    4151               0 :   return val;
    4152                 : }
    4153                 : 
    4154                 : nsIDOMCSSValue*
    4155               0 : nsComputedDOMStyle::DoGetStopColor()
    4156                 : {
    4157               0 :   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
    4158               0 :   SetToRGBAColor(val, GetStyleSVGReset()->mStopColor);
    4159               0 :   return val;
    4160                 : }
    4161                 : 
    4162                 : nsIDOMCSSValue*
    4163               0 : nsComputedDOMStyle::DoGetClipPath()
    4164                 : {
    4165               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    4166                 : 
    4167               0 :   const nsStyleSVGReset* svg = GetStyleSVGReset();
    4168                 : 
    4169               0 :   if (svg->mClipPath)
    4170               0 :     val->SetURI(svg->mClipPath);
    4171                 :   else
    4172               0 :     val->SetIdent(eCSSKeyword_none);
    4173                 : 
    4174               0 :   return val;
    4175                 : }
    4176                 : 
    4177                 : nsIDOMCSSValue*
    4178               0 : nsComputedDOMStyle::DoGetFilter()
    4179                 : {
    4180               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    4181                 : 
    4182               0 :   const nsStyleSVGReset* svg = GetStyleSVGReset();
    4183                 : 
    4184               0 :   if (svg->mFilter)
    4185               0 :     val->SetURI(svg->mFilter);
    4186                 :   else
    4187               0 :     val->SetIdent(eCSSKeyword_none);
    4188                 : 
    4189               0 :   return val;
    4190                 : }
    4191                 : 
    4192                 : nsIDOMCSSValue*
    4193               0 : nsComputedDOMStyle::DoGetMask()
    4194                 : {
    4195               0 :   nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
    4196                 : 
    4197               0 :   const nsStyleSVGReset* svg = GetStyleSVGReset();
    4198                 : 
    4199               0 :   if (svg->mMask)
    4200               0 :     val->SetURI(svg->mMask);
    4201                 :   else
    4202               0 :     val->SetIdent(eCSSKeyword_none);
    4203                 : 
    4204               0 :   return val;
    4205                 : }
    4206                 : 
    4207                 : nsIDOMCSSValue*
    4208               0 : nsComputedDOMStyle::DoGetTransitionDelay()
    4209                 : {
    4210               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4211                 : 
    4212               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4213                 : 
    4214               0 :   NS_ABORT_IF_FALSE(display->mTransitionDelayCount > 0,
    4215                 :                     "first item must be explicit");
    4216               0 :   PRUint32 i = 0;
    4217               0 :   do {
    4218               0 :     const nsTransition *transition = &display->mTransitions[i];
    4219               0 :     nsROCSSPrimitiveValue* delay = GetROCSSPrimitiveValue();
    4220               0 :     valueList->AppendCSSValue(delay);
    4221               0 :     delay->SetTime((float)transition->GetDelay() / (float)PR_MSEC_PER_SEC);
    4222                 :   } while (++i < display->mTransitionDelayCount);
    4223                 : 
    4224               0 :   return valueList;
    4225                 : }
    4226                 : 
    4227                 : nsIDOMCSSValue*
    4228               0 : nsComputedDOMStyle::DoGetTransitionDuration()
    4229                 : {
    4230               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4231                 : 
    4232               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4233                 : 
    4234               0 :   NS_ABORT_IF_FALSE(display->mTransitionDurationCount > 0,
    4235                 :                     "first item must be explicit");
    4236               0 :   PRUint32 i = 0;
    4237               0 :   do {
    4238               0 :     const nsTransition *transition = &display->mTransitions[i];
    4239               0 :     nsROCSSPrimitiveValue* duration = GetROCSSPrimitiveValue();
    4240               0 :     valueList->AppendCSSValue(duration);
    4241                 : 
    4242               0 :     duration->SetTime((float)transition->GetDuration() / (float)PR_MSEC_PER_SEC);
    4243                 :   } while (++i < display->mTransitionDurationCount);
    4244                 : 
    4245               0 :   return valueList;
    4246                 : }
    4247                 : 
    4248                 : nsIDOMCSSValue*
    4249               0 : nsComputedDOMStyle::DoGetTransitionProperty()
    4250                 : {
    4251               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4252                 : 
    4253               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4254                 : 
    4255               0 :   NS_ABORT_IF_FALSE(display->mTransitionPropertyCount > 0,
    4256                 :                     "first item must be explicit");
    4257               0 :   PRUint32 i = 0;
    4258               0 :   do {
    4259               0 :     const nsTransition *transition = &display->mTransitions[i];
    4260               0 :     nsROCSSPrimitiveValue* property = GetROCSSPrimitiveValue();
    4261               0 :     valueList->AppendCSSValue(property);
    4262               0 :     nsCSSProperty cssprop = transition->GetProperty();
    4263               0 :     if (cssprop == eCSSPropertyExtra_all_properties)
    4264               0 :       property->SetIdent(eCSSKeyword_all);
    4265               0 :     else if (cssprop == eCSSPropertyExtra_no_properties)
    4266               0 :       property->SetIdent(eCSSKeyword_none);
    4267               0 :     else if (cssprop == eCSSProperty_UNKNOWN)
    4268                 :     {
    4269               0 :       nsAutoString escaped;
    4270                 :       nsStyleUtil::AppendEscapedCSSIdent(
    4271               0 :         nsDependentAtomString(transition->GetUnknownProperty()), escaped);
    4272               0 :       property->SetString(escaped); // really want SetIdent
    4273                 :     }
    4274                 :     else
    4275               0 :       property->SetString(nsCSSProps::GetStringValue(cssprop));
    4276                 :   } while (++i < display->mTransitionPropertyCount);
    4277                 : 
    4278               0 :   return valueList;
    4279                 : }
    4280                 : 
    4281                 : void
    4282               0 : nsComputedDOMStyle::AppendTimingFunction(nsDOMCSSValueList *aValueList,
    4283                 :                                          const nsTimingFunction& aTimingFunction)
    4284                 : {
    4285               0 :   nsROCSSPrimitiveValue* timingFunction = GetROCSSPrimitiveValue();
    4286               0 :   aValueList->AppendCSSValue(timingFunction);
    4287                 : 
    4288               0 :   nsAutoString tmp;
    4289                 : 
    4290               0 :   if (aTimingFunction.mType == nsTimingFunction::Function) {
    4291                 :     // set the value from the cubic-bezier control points
    4292                 :     // (We could try to regenerate the keywords if we want.)
    4293               0 :     tmp.AppendLiteral("cubic-bezier(");
    4294               0 :     tmp.AppendFloat(aTimingFunction.mFunc.mX1);
    4295               0 :     tmp.AppendLiteral(", ");
    4296               0 :     tmp.AppendFloat(aTimingFunction.mFunc.mY1);
    4297               0 :     tmp.AppendLiteral(", ");
    4298               0 :     tmp.AppendFloat(aTimingFunction.mFunc.mX2);
    4299               0 :     tmp.AppendLiteral(", ");
    4300               0 :     tmp.AppendFloat(aTimingFunction.mFunc.mY2);
    4301               0 :     tmp.AppendLiteral(")");
    4302                 :   } else {
    4303               0 :     tmp.AppendLiteral("steps(");
    4304               0 :     tmp.AppendInt(aTimingFunction.mSteps);
    4305               0 :     if (aTimingFunction.mType == nsTimingFunction::StepStart) {
    4306               0 :       tmp.AppendLiteral(", start)");
    4307                 :     } else {
    4308               0 :       tmp.AppendLiteral(", end)");
    4309                 :     }
    4310                 :   }
    4311               0 :   timingFunction->SetString(tmp);
    4312               0 : }
    4313                 : 
    4314                 : nsIDOMCSSValue*
    4315               0 : nsComputedDOMStyle::DoGetTransitionTimingFunction()
    4316                 : {
    4317               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4318                 : 
    4319               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4320                 : 
    4321               0 :   NS_ABORT_IF_FALSE(display->mTransitionTimingFunctionCount > 0,
    4322                 :                     "first item must be explicit");
    4323               0 :   PRUint32 i = 0;
    4324               0 :   do {
    4325                 :     AppendTimingFunction(valueList,
    4326               0 :                          display->mTransitions[i].GetTimingFunction());
    4327                 :   } while (++i < display->mTransitionTimingFunctionCount);
    4328                 : 
    4329               0 :   return valueList;
    4330                 : }
    4331                 : 
    4332                 : nsIDOMCSSValue*
    4333               0 : nsComputedDOMStyle::DoGetAnimationName()
    4334                 : {
    4335               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4336                 : 
    4337               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4338                 : 
    4339               0 :   NS_ABORT_IF_FALSE(display->mAnimationNameCount > 0,
    4340                 :                     "first item must be explicit");
    4341               0 :   PRUint32 i = 0;
    4342               0 :   do {
    4343               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4344               0 :     nsROCSSPrimitiveValue* property = GetROCSSPrimitiveValue();
    4345               0 :     valueList->AppendCSSValue(property);
    4346                 : 
    4347               0 :     const nsString& name = animation->GetName();
    4348               0 :     if (name.IsEmpty()) {
    4349               0 :       property->SetIdent(eCSSKeyword_none);
    4350                 :     } else {
    4351               0 :       nsAutoString escaped;
    4352               0 :       nsStyleUtil::AppendEscapedCSSIdent(animation->GetName(), escaped);
    4353               0 :       property->SetString(escaped); // really want SetIdent
    4354                 :     }
    4355                 :   } while (++i < display->mAnimationNameCount);
    4356                 : 
    4357               0 :   return valueList;
    4358                 : }
    4359                 : 
    4360                 : nsIDOMCSSValue*
    4361               0 : nsComputedDOMStyle::DoGetAnimationDelay()
    4362                 : {
    4363               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4364                 : 
    4365               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4366                 : 
    4367               0 :   NS_ABORT_IF_FALSE(display->mAnimationDelayCount > 0,
    4368                 :                     "first item must be explicit");
    4369               0 :   PRUint32 i = 0;
    4370               0 :   do {
    4371               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4372               0 :     nsROCSSPrimitiveValue* delay = GetROCSSPrimitiveValue();
    4373               0 :     valueList->AppendCSSValue(delay);
    4374               0 :     delay->SetTime((float)animation->GetDelay() / (float)PR_MSEC_PER_SEC);
    4375                 :   } while (++i < display->mAnimationDelayCount);
    4376                 : 
    4377               0 :   return valueList;
    4378                 : }
    4379                 : 
    4380                 : nsIDOMCSSValue*
    4381               0 : nsComputedDOMStyle::DoGetAnimationDuration()
    4382                 : {
    4383               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4384                 : 
    4385               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4386                 : 
    4387               0 :   NS_ABORT_IF_FALSE(display->mAnimationDurationCount > 0,
    4388                 :                     "first item must be explicit");
    4389               0 :   PRUint32 i = 0;
    4390               0 :   do {
    4391               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4392               0 :     nsROCSSPrimitiveValue* duration = GetROCSSPrimitiveValue();
    4393               0 :     valueList->AppendCSSValue(duration);
    4394                 : 
    4395               0 :     duration->SetTime((float)animation->GetDuration() / (float)PR_MSEC_PER_SEC);
    4396                 :   } while (++i < display->mAnimationDurationCount);
    4397                 : 
    4398               0 :   return valueList;
    4399                 : }
    4400                 : 
    4401                 : nsIDOMCSSValue*
    4402               0 : nsComputedDOMStyle::DoGetAnimationTimingFunction()
    4403                 : {
    4404               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4405                 : 
    4406               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4407                 : 
    4408               0 :   NS_ABORT_IF_FALSE(display->mAnimationTimingFunctionCount > 0,
    4409                 :                     "first item must be explicit");
    4410               0 :   PRUint32 i = 0;
    4411               0 :   do {
    4412                 :     AppendTimingFunction(valueList,
    4413               0 :                          display->mAnimations[i].GetTimingFunction());
    4414                 :   } while (++i < display->mAnimationTimingFunctionCount);
    4415                 : 
    4416               0 :   return valueList;
    4417                 : }
    4418                 : 
    4419                 : nsIDOMCSSValue*
    4420               0 : nsComputedDOMStyle::DoGetAnimationDirection()
    4421                 : {
    4422               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4423                 : 
    4424               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4425                 : 
    4426               0 :   NS_ABORT_IF_FALSE(display->mAnimationDirectionCount > 0,
    4427                 :                     "first item must be explicit");
    4428               0 :   PRUint32 i = 0;
    4429               0 :   do {
    4430               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4431               0 :     nsROCSSPrimitiveValue* direction = GetROCSSPrimitiveValue();
    4432               0 :     valueList->AppendCSSValue(direction);
    4433                 :     direction->SetIdent(
    4434               0 :       nsCSSProps::ValueToKeywordEnum(animation->GetDirection(),
    4435               0 :                                      nsCSSProps::kAnimationDirectionKTable));
    4436                 :   } while (++i < display->mAnimationDirectionCount);
    4437                 : 
    4438               0 :   return valueList;
    4439                 : }
    4440                 : 
    4441                 : nsIDOMCSSValue*
    4442               0 : nsComputedDOMStyle::DoGetAnimationFillMode()
    4443                 : {
    4444               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4445                 : 
    4446               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4447                 : 
    4448               0 :   NS_ABORT_IF_FALSE(display->mAnimationFillModeCount > 0,
    4449                 :                     "first item must be explicit");
    4450               0 :   PRUint32 i = 0;
    4451               0 :   do {
    4452               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4453               0 :     nsROCSSPrimitiveValue* fillMode = GetROCSSPrimitiveValue();
    4454               0 :     valueList->AppendCSSValue(fillMode);
    4455                 :     fillMode->SetIdent(
    4456               0 :       nsCSSProps::ValueToKeywordEnum(animation->GetFillMode(),
    4457               0 :                                      nsCSSProps::kAnimationFillModeKTable));
    4458                 :   } while (++i < display->mAnimationFillModeCount);
    4459                 : 
    4460               0 :   return valueList;
    4461                 : }
    4462                 : 
    4463                 : nsIDOMCSSValue*
    4464               0 : nsComputedDOMStyle::DoGetAnimationIterationCount()
    4465                 : {
    4466               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4467                 : 
    4468               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4469                 : 
    4470               0 :   NS_ABORT_IF_FALSE(display->mAnimationIterationCountCount > 0,
    4471                 :                     "first item must be explicit");
    4472               0 :   PRUint32 i = 0;
    4473               0 :   do {
    4474               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4475               0 :     nsROCSSPrimitiveValue* iterationCount = GetROCSSPrimitiveValue();
    4476               0 :     valueList->AppendCSSValue(iterationCount);
    4477                 : 
    4478               0 :     float f = animation->GetIterationCount();
    4479                 :     /* Need a nasty hack here to work around an optimizer bug in gcc
    4480                 :        4.2 on Mac, which somehow gets confused when directly comparing
    4481                 :        a float to the return value of NS_IEEEPositiveInfinity when
    4482                 :        building 32-bit builds. */
    4483                 : #ifdef XP_MACOSX
    4484                 :     volatile
    4485                 : #endif
    4486               0 :       float inf = NS_IEEEPositiveInfinity();
    4487               0 :     if (f == inf) {
    4488               0 :       iterationCount->SetIdent(eCSSKeyword_infinite);
    4489                 :     } else {
    4490               0 :       iterationCount->SetNumber(f);
    4491                 :     }
    4492                 :   } while (++i < display->mAnimationIterationCountCount);
    4493                 : 
    4494               0 :   return valueList;
    4495                 : }
    4496                 : 
    4497                 : nsIDOMCSSValue*
    4498               0 : nsComputedDOMStyle::DoGetAnimationPlayState()
    4499                 : {
    4500               0 :   const nsStyleDisplay* display = GetStyleDisplay();
    4501                 : 
    4502               0 :   nsDOMCSSValueList *valueList = GetROCSSValueList(true);
    4503                 : 
    4504               0 :   NS_ABORT_IF_FALSE(display->mAnimationPlayStateCount > 0,
    4505                 :                     "first item must be explicit");
    4506               0 :   PRUint32 i = 0;
    4507               0 :   do {
    4508               0 :     const nsAnimation *animation = &display->mAnimations[i];
    4509               0 :     nsROCSSPrimitiveValue* playState = GetROCSSPrimitiveValue();
    4510               0 :     valueList->AppendCSSValue(playState);
    4511                 :     playState->SetIdent(
    4512               0 :       nsCSSProps::ValueToKeywordEnum(animation->GetPlayState(),
    4513               0 :                                      nsCSSProps::kAnimationPlayStateKTable));
    4514                 :   } while (++i < display->mAnimationPlayStateCount);
    4515                 : 
    4516               0 :   return valueList;
    4517                 : }
    4518                 : 
    4519                 : #define COMPUTED_STYLE_MAP_ENTRY(_prop, _method)              \
    4520                 :   { eCSSProperty_##_prop, &nsComputedDOMStyle::DoGet##_method, false }
    4521                 : #define COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_prop, _method)       \
    4522                 :   { eCSSProperty_##_prop, &nsComputedDOMStyle::DoGet##_method, true }
    4523                 : 
    4524                 : const nsComputedDOMStyle::ComputedStyleMapEntry*
    4525               0 : nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
    4526                 : {
    4527                 :   /* ******************************************************************* *\
    4528                 :    * Properties below are listed in alphabetical order.                  *
    4529                 :    * Please keep them that way.                                          *
    4530                 :    *                                                                     *
    4531                 :    * Properties commented out with // are not yet implemented            *
    4532                 :    * Properties commented out with //// are shorthands and not queryable *
    4533                 :   \* ******************************************************************* */
    4534                 :   static const ComputedStyleMapEntry map[] = {
    4535                 :     /* ***************************** *\
    4536                 :      * Implementations of CSS styles *
    4537                 :     \* ***************************** */
    4538                 : 
    4539                 :     //// COMPUTED_STYLE_MAP_ENTRY(background,               Background),
    4540                 :     COMPUTED_STYLE_MAP_ENTRY(background_attachment,         BackgroundAttachment),
    4541                 :     COMPUTED_STYLE_MAP_ENTRY(background_clip,               BackgroundClip),
    4542                 :     COMPUTED_STYLE_MAP_ENTRY(background_color,              BackgroundColor),
    4543                 :     COMPUTED_STYLE_MAP_ENTRY(background_image,              BackgroundImage),
    4544                 :     COMPUTED_STYLE_MAP_ENTRY(background_origin,             BackgroundOrigin),
    4545                 :     COMPUTED_STYLE_MAP_ENTRY(background_position,           BackgroundPosition),
    4546                 :     COMPUTED_STYLE_MAP_ENTRY(background_repeat,             BackgroundRepeat),
    4547                 :     COMPUTED_STYLE_MAP_ENTRY(background_size,               MozBackgroundSize),
    4548                 :     //// COMPUTED_STYLE_MAP_ENTRY(border,                   Border),
    4549                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_bottom,            BorderBottom),
    4550                 :     COMPUTED_STYLE_MAP_ENTRY(border_bottom_color,           BorderBottomColor),
    4551                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_bottom_left_radius, BorderBottomLeftRadius),
    4552                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_bottom_right_radius,BorderBottomRightRadius),
    4553                 :     COMPUTED_STYLE_MAP_ENTRY(border_bottom_style,           BorderBottomStyle),
    4554                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_bottom_width,    BorderBottomWidth),
    4555                 :     COMPUTED_STYLE_MAP_ENTRY(border_collapse,               BorderCollapse),
    4556                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_color,             BorderColor),
    4557                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_left,              BorderLeft),
    4558                 :     COMPUTED_STYLE_MAP_ENTRY(border_left_color,             BorderLeftColor),
    4559                 :     COMPUTED_STYLE_MAP_ENTRY(border_left_style,             BorderLeftStyle),
    4560                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_left_width,      BorderLeftWidth),
    4561                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_right,             BorderRight),
    4562                 :     COMPUTED_STYLE_MAP_ENTRY(border_right_color,            BorderRightColor),
    4563                 :     COMPUTED_STYLE_MAP_ENTRY(border_right_style,            BorderRightStyle),
    4564                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_right_width,     BorderRightWidth),
    4565                 :     COMPUTED_STYLE_MAP_ENTRY(border_spacing,                BorderSpacing),
    4566                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_style,             BorderStyle),
    4567                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_top,               BorderTop),
    4568                 :     COMPUTED_STYLE_MAP_ENTRY(border_top_color,              BorderTopColor),
    4569                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_top_left_radius,    BorderTopLeftRadius),
    4570                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_top_right_radius,   BorderTopRightRadius),
    4571                 :     COMPUTED_STYLE_MAP_ENTRY(border_top_style,              BorderTopStyle),
    4572                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(border_top_width,       BorderTopWidth),
    4573                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_width,             BorderWidth),
    4574                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(bottom,                 Bottom),
    4575                 :     COMPUTED_STYLE_MAP_ENTRY(box_shadow,                    BoxShadow),
    4576                 :     COMPUTED_STYLE_MAP_ENTRY(caption_side,                  CaptionSide),
    4577                 :     COMPUTED_STYLE_MAP_ENTRY(clear,                         Clear),
    4578                 :     COMPUTED_STYLE_MAP_ENTRY(clip,                          Clip),
    4579                 :     COMPUTED_STYLE_MAP_ENTRY(color,                         Color),
    4580                 :     COMPUTED_STYLE_MAP_ENTRY(content,                       Content),
    4581                 :     COMPUTED_STYLE_MAP_ENTRY(counter_increment,             CounterIncrement),
    4582                 :     COMPUTED_STYLE_MAP_ENTRY(counter_reset,                 CounterReset),
    4583                 :     COMPUTED_STYLE_MAP_ENTRY(cursor,                        Cursor),
    4584                 :     COMPUTED_STYLE_MAP_ENTRY(direction,                     Direction),
    4585                 :     COMPUTED_STYLE_MAP_ENTRY(display,                       Display),
    4586                 :     COMPUTED_STYLE_MAP_ENTRY(empty_cells,                   EmptyCells),
    4587                 :     COMPUTED_STYLE_MAP_ENTRY(float,                         CssFloat),
    4588                 :     //// COMPUTED_STYLE_MAP_ENTRY(font,                     Font),
    4589                 :     COMPUTED_STYLE_MAP_ENTRY(font_family,                   FontFamily),
    4590                 :     COMPUTED_STYLE_MAP_ENTRY(font_size,                     FontSize),
    4591                 :     COMPUTED_STYLE_MAP_ENTRY(font_size_adjust,              FontSizeAdjust),
    4592                 :     COMPUTED_STYLE_MAP_ENTRY(font_stretch,                  FontStretch),
    4593                 :     COMPUTED_STYLE_MAP_ENTRY(font_style,                    FontStyle),
    4594                 :     COMPUTED_STYLE_MAP_ENTRY(font_variant,                  FontVariant),
    4595                 :     COMPUTED_STYLE_MAP_ENTRY(font_weight,                   FontWeight),
    4596                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(height,                 Height),
    4597                 :     COMPUTED_STYLE_MAP_ENTRY(ime_mode,                      IMEMode),
    4598                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(left,                   Left),
    4599                 :     COMPUTED_STYLE_MAP_ENTRY(letter_spacing,                LetterSpacing),
    4600                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(line_height,            LineHeight),
    4601                 :     //// COMPUTED_STYLE_MAP_ENTRY(list_style,               ListStyle),
    4602                 :     COMPUTED_STYLE_MAP_ENTRY(list_style_image,              ListStyleImage),
    4603                 :     COMPUTED_STYLE_MAP_ENTRY(list_style_position,           ListStylePosition),
    4604                 :     COMPUTED_STYLE_MAP_ENTRY(list_style_type,               ListStyleType),
    4605                 :     //// COMPUTED_STYLE_MAP_ENTRY(margin,                   Margin),
    4606                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(margin_bottom,          MarginBottomWidth),
    4607                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(margin_left,            MarginLeftWidth),
    4608                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(margin_right,           MarginRightWidth),
    4609                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(margin_top,             MarginTopWidth),
    4610                 :     COMPUTED_STYLE_MAP_ENTRY(marker_offset,                 MarkerOffset),
    4611                 :     // COMPUTED_STYLE_MAP_ENTRY(marks,                      Marks),
    4612                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(max_height,             MaxHeight),
    4613                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(max_width,              MaxWidth),
    4614                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(min_height,             MinHeight),
    4615                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(min_width,              MinWidth),
    4616                 :     COMPUTED_STYLE_MAP_ENTRY(opacity,                       Opacity),
    4617                 :     // COMPUTED_STYLE_MAP_ENTRY(orphans,                    Orphans),
    4618                 :     //// COMPUTED_STYLE_MAP_ENTRY(outline,                  Outline),
    4619                 :     COMPUTED_STYLE_MAP_ENTRY(outline_color,                 OutlineColor),
    4620                 :     COMPUTED_STYLE_MAP_ENTRY(outline_offset,                OutlineOffset),
    4621                 :     COMPUTED_STYLE_MAP_ENTRY(outline_style,                 OutlineStyle),
    4622                 :     COMPUTED_STYLE_MAP_ENTRY(outline_width,                 OutlineWidth),
    4623                 :     COMPUTED_STYLE_MAP_ENTRY(overflow,                      Overflow),
    4624                 :     COMPUTED_STYLE_MAP_ENTRY(overflow_x,                    OverflowX),
    4625                 :     COMPUTED_STYLE_MAP_ENTRY(overflow_y,                    OverflowY),
    4626                 :     //// COMPUTED_STYLE_MAP_ENTRY(padding,                  Padding),
    4627                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(padding_bottom,         PaddingBottom),
    4628                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(padding_left,           PaddingLeft),
    4629                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(padding_right,          PaddingRight),
    4630                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(padding_top,            PaddingTop),
    4631                 :     // COMPUTED_STYLE_MAP_ENTRY(page,                       Page),
    4632                 :     COMPUTED_STYLE_MAP_ENTRY(page_break_after,              PageBreakAfter),
    4633                 :     COMPUTED_STYLE_MAP_ENTRY(page_break_before,             PageBreakBefore),
    4634                 :     // COMPUTED_STYLE_MAP_ENTRY(page_break_inside,          PageBreakInside),
    4635                 :     COMPUTED_STYLE_MAP_ENTRY(pointer_events,                PointerEvents),
    4636                 :     COMPUTED_STYLE_MAP_ENTRY(position,                      Position),
    4637                 :     COMPUTED_STYLE_MAP_ENTRY(quotes,                        Quotes),
    4638                 :     COMPUTED_STYLE_MAP_ENTRY(resize,                        Resize),
    4639                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(right,                  Right),
    4640                 :     //// COMPUTED_STYLE_MAP_ENTRY(size,                     Size),
    4641                 :     COMPUTED_STYLE_MAP_ENTRY(table_layout,                  TableLayout),
    4642                 :     COMPUTED_STYLE_MAP_ENTRY(text_align,                    TextAlign),
    4643                 :     COMPUTED_STYLE_MAP_ENTRY(text_decoration,               TextDecoration),
    4644                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(text_indent,            TextIndent),
    4645                 :     COMPUTED_STYLE_MAP_ENTRY(text_overflow,                 TextOverflow),
    4646                 :     COMPUTED_STYLE_MAP_ENTRY(text_shadow,                   TextShadow),
    4647                 :     COMPUTED_STYLE_MAP_ENTRY(text_transform,                TextTransform),
    4648                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(top,                    Top),
    4649                 :     COMPUTED_STYLE_MAP_ENTRY(unicode_bidi,                  UnicodeBidi),
    4650                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(vertical_align,         VerticalAlign),
    4651                 :     COMPUTED_STYLE_MAP_ENTRY(visibility,                    Visibility),
    4652                 :     COMPUTED_STYLE_MAP_ENTRY(white_space,                   WhiteSpace),
    4653                 :     // COMPUTED_STYLE_MAP_ENTRY(widows,                     Widows),
    4654                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(width,                  Width),
    4655                 :     COMPUTED_STYLE_MAP_ENTRY(word_spacing,                  WordSpacing),
    4656                 :     COMPUTED_STYLE_MAP_ENTRY(word_wrap,                     WordWrap),
    4657                 :     COMPUTED_STYLE_MAP_ENTRY(z_index,                       ZIndex),
    4658                 : 
    4659                 :     /* ******************************* *\
    4660                 :      * Implementations of -moz- styles *
    4661                 :     \* ******************************* */
    4662                 : 
    4663                 :     COMPUTED_STYLE_MAP_ENTRY(animation_delay,               AnimationDelay),
    4664                 :     COMPUTED_STYLE_MAP_ENTRY(animation_direction,           AnimationDirection),
    4665                 :     COMPUTED_STYLE_MAP_ENTRY(animation_duration,            AnimationDuration),
    4666                 :     COMPUTED_STYLE_MAP_ENTRY(animation_fill_mode,           AnimationFillMode),
    4667                 :     COMPUTED_STYLE_MAP_ENTRY(animation_iteration_count,     AnimationIterationCount),
    4668                 :     COMPUTED_STYLE_MAP_ENTRY(animation_name,                AnimationName),
    4669                 :     COMPUTED_STYLE_MAP_ENTRY(animation_play_state,          AnimationPlayState),
    4670                 :     COMPUTED_STYLE_MAP_ENTRY(animation_timing_function,     AnimationTimingFunction),
    4671                 :     COMPUTED_STYLE_MAP_ENTRY(appearance,                    Appearance),
    4672                 :     COMPUTED_STYLE_MAP_ENTRY(backface_visibility,           MozBackfaceVisibility),
    4673                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_background_inline_policy, BackgroundInlinePolicy),
    4674                 :     COMPUTED_STYLE_MAP_ENTRY(binding,                       Binding),
    4675                 :     COMPUTED_STYLE_MAP_ENTRY(border_bottom_colors,          BorderBottomColors),
    4676                 :     //// COMPUTED_STYLE_MAP_ENTRY(border_image,             BorderImage),
    4677                 :     COMPUTED_STYLE_MAP_ENTRY(border_image_outset,           BorderImageOutset),
    4678                 :     COMPUTED_STYLE_MAP_ENTRY(border_image_repeat,           BorderImageRepeat),
    4679                 :     COMPUTED_STYLE_MAP_ENTRY(border_image_slice,            BorderImageSlice),
    4680                 :     COMPUTED_STYLE_MAP_ENTRY(border_image_source,           BorderImageSource),
    4681                 :     COMPUTED_STYLE_MAP_ENTRY(border_image_width,            BorderImageWidth),
    4682                 :     COMPUTED_STYLE_MAP_ENTRY(border_left_colors,            BorderLeftColors),
    4683                 :     COMPUTED_STYLE_MAP_ENTRY(border_right_colors,           BorderRightColors),
    4684                 :     COMPUTED_STYLE_MAP_ENTRY(border_top_colors,             BorderTopColors),
    4685                 :     COMPUTED_STYLE_MAP_ENTRY(box_align,                     BoxAlign),
    4686                 :     COMPUTED_STYLE_MAP_ENTRY(box_direction,                 BoxDirection),
    4687                 :     COMPUTED_STYLE_MAP_ENTRY(box_flex,                      BoxFlex),
    4688                 :     COMPUTED_STYLE_MAP_ENTRY(box_ordinal_group,             BoxOrdinalGroup),
    4689                 :     COMPUTED_STYLE_MAP_ENTRY(box_orient,                    BoxOrient),
    4690                 :     COMPUTED_STYLE_MAP_ENTRY(box_pack,                      BoxPack),
    4691                 :     COMPUTED_STYLE_MAP_ENTRY(box_sizing,                    BoxSizing),
    4692                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_count,             ColumnCount),
    4693                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_fill,              ColumnFill),
    4694                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_gap,               ColumnGap),
    4695                 :     //// COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule,         ColumnRule),
    4696                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_color,        ColumnRuleColor),
    4697                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_style,        ColumnRuleStyle),
    4698                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_width,        ColumnRuleWidth),
    4699                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_column_width,             ColumnWidth),
    4700                 :     COMPUTED_STYLE_MAP_ENTRY(float_edge,                    FloatEdge),
    4701                 :     COMPUTED_STYLE_MAP_ENTRY(font_feature_settings,         MozFontFeatureSettings),
    4702                 :     COMPUTED_STYLE_MAP_ENTRY(font_language_override,        MozFontLanguageOverride),
    4703                 :     COMPUTED_STYLE_MAP_ENTRY(force_broken_image_icon,       ForceBrokenImageIcon),
    4704                 :     COMPUTED_STYLE_MAP_ENTRY(hyphens,                       Hyphens),
    4705                 :     COMPUTED_STYLE_MAP_ENTRY(image_region,                  ImageRegion),
    4706                 :     COMPUTED_STYLE_MAP_ENTRY(orient,                        Orient),
    4707                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_bottomLeft, OutlineRadiusBottomLeft),
    4708                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_bottomRight,OutlineRadiusBottomRight),
    4709                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_topLeft,    OutlineRadiusTopLeft),
    4710                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_topRight,   OutlineRadiusTopRight),
    4711                 :     COMPUTED_STYLE_MAP_ENTRY(perspective,                   MozPerspective),
    4712                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(perspective_origin,     MozPerspectiveOrigin),
    4713                 :     COMPUTED_STYLE_MAP_ENTRY(stack_sizing,                  StackSizing),
    4714                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_tab_size,                 MozTabSize),
    4715                 :     COMPUTED_STYLE_MAP_ENTRY(text_align_last,               TextAlignLast),
    4716                 :     COMPUTED_STYLE_MAP_ENTRY(text_blink,                    MozTextBlink),
    4717                 :     COMPUTED_STYLE_MAP_ENTRY(text_decoration_color,         MozTextDecorationColor),
    4718                 :     COMPUTED_STYLE_MAP_ENTRY(text_decoration_line,          MozTextDecorationLine),
    4719                 :     COMPUTED_STYLE_MAP_ENTRY(text_decoration_style,         MozTextDecorationStyle),
    4720                 :     COMPUTED_STYLE_MAP_ENTRY(text_size_adjust,              TextSizeAdjust),
    4721                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform,         MozTransform),
    4722                 :     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform_origin,  MozTransformOrigin),
    4723                 :     COMPUTED_STYLE_MAP_ENTRY(transform_style,               MozTransformStyle),
    4724                 :     COMPUTED_STYLE_MAP_ENTRY(transition_delay,              TransitionDelay),
    4725                 :     COMPUTED_STYLE_MAP_ENTRY(transition_duration,           TransitionDuration),
    4726                 :     COMPUTED_STYLE_MAP_ENTRY(transition_property,           TransitionProperty),
    4727                 :     COMPUTED_STYLE_MAP_ENTRY(transition_timing_function,    TransitionTimingFunction),
    4728                 :     COMPUTED_STYLE_MAP_ENTRY(user_focus,                    UserFocus),
    4729                 :     COMPUTED_STYLE_MAP_ENTRY(user_input,                    UserInput),
    4730                 :     COMPUTED_STYLE_MAP_ENTRY(user_modify,                   UserModify),
    4731                 :     COMPUTED_STYLE_MAP_ENTRY(user_select,                   UserSelect),
    4732                 :     COMPUTED_STYLE_MAP_ENTRY(_moz_window_shadow,            WindowShadow),
    4733                 : 
    4734                 :     /* ***************************** *\
    4735                 :      * Implementations of SVG styles *
    4736                 :     \* ***************************** */
    4737                 : 
    4738                 :     COMPUTED_STYLE_MAP_ENTRY(clip_path,                     ClipPath),
    4739                 :     COMPUTED_STYLE_MAP_ENTRY(clip_rule,                     ClipRule),
    4740                 :     COMPUTED_STYLE_MAP_ENTRY(color_interpolation,           ColorInterpolation),
    4741                 :     COMPUTED_STYLE_MAP_ENTRY(color_interpolation_filters,   ColorInterpolationFilters),
    4742                 :     COMPUTED_STYLE_MAP_ENTRY(dominant_baseline,             DominantBaseline),
    4743                 :     COMPUTED_STYLE_MAP_ENTRY(fill,                          Fill),
    4744                 :     COMPUTED_STYLE_MAP_ENTRY(fill_opacity,                  FillOpacity),
    4745                 :     COMPUTED_STYLE_MAP_ENTRY(fill_rule,                     FillRule),
    4746                 :     COMPUTED_STYLE_MAP_ENTRY(filter,                        Filter),
    4747                 :     COMPUTED_STYLE_MAP_ENTRY(flood_color,                   FloodColor),
    4748                 :     COMPUTED_STYLE_MAP_ENTRY(flood_opacity,                 FloodOpacity),
    4749                 :     COMPUTED_STYLE_MAP_ENTRY(image_rendering,               ImageRendering),
    4750                 :     COMPUTED_STYLE_MAP_ENTRY(lighting_color,                LightingColor),
    4751                 :     COMPUTED_STYLE_MAP_ENTRY(marker_end,                    MarkerEnd),
    4752                 :     COMPUTED_STYLE_MAP_ENTRY(marker_mid,                    MarkerMid),
    4753                 :     COMPUTED_STYLE_MAP_ENTRY(marker_start,                  MarkerStart),
    4754                 :     COMPUTED_STYLE_MAP_ENTRY(mask,                          Mask),
    4755                 :     COMPUTED_STYLE_MAP_ENTRY(shape_rendering,               ShapeRendering),
    4756                 :     COMPUTED_STYLE_MAP_ENTRY(stop_color,                    StopColor),
    4757                 :     COMPUTED_STYLE_MAP_ENTRY(stop_opacity,                  StopOpacity),
    4758                 :     COMPUTED_STYLE_MAP_ENTRY(stroke,                        Stroke),
    4759                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_dasharray,              StrokeDasharray),
    4760                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_dashoffset,             StrokeDashoffset),
    4761                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_linecap,                StrokeLinecap),
    4762                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_linejoin,               StrokeLinejoin),
    4763                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_miterlimit,             StrokeMiterlimit),
    4764                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_opacity,                StrokeOpacity),
    4765                 :     COMPUTED_STYLE_MAP_ENTRY(stroke_width,                  StrokeWidth),
    4766                 :     COMPUTED_STYLE_MAP_ENTRY(text_anchor,                   TextAnchor),
    4767                 :     COMPUTED_STYLE_MAP_ENTRY(text_rendering,                TextRendering)
    4768                 : 
    4769                 :   };
    4770                 : 
    4771               0 :   *aLength = ArrayLength(map);
    4772                 : 
    4773               0 :   return map;
    4774            4188 : }
    4775                 : 

Generated by: LCOV version 1.7