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