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