Last Comment Bug 316981 - background-position property is not available through the CSS DOM interface
: background-position property is not available through the CSS DOM interface
Status: RESOLVED FIXED
: dom2, testcase
Product: Core
Classification: Components
Component: DOM: CSS Object Model (show other bugs)
: Trunk
: x86 All
: -- normal with 1 vote (vote)
: ---
Assigned To: David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch)
: Hixie (not reading bugmail)
Mentors:
: 299960 397324 (view as bug list)
Depends on: 258080
Blocks: 42417
  Show dependency treegraph
 
Reported: 2005-11-18 06:11 PST by Patrice Levesque
Modified: 2008-01-16 02:50 PST (History)
8 users (show)
jonas: blocking1.9-
reed: wanted1.9+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Self-explanatory basic testcase (1.76 KB, text/html)
2005-11-19 19:12 PST, Gérard Talbot
no flags Details
Better self-explanatory basic testcase (19.69 KB, text/html)
2005-11-19 19:28 PST, Gérard Talbot
no flags Details
Better self-explanatory basic testcase (2.49 KB, text/html)
2005-11-19 19:33 PST, Gérard Talbot
no flags Details
patch to implement rest of properties we compute (26.63 KB, patch)
2007-07-21 15:51 PDT, David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch)
bzbarsky: review+
bzbarsky: superreview+
Details | Diff | Review

Description Patrice Levesque 2005-11-18 06:11:29 PST
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051107 Firefox/1.5
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051107 Firefox/1.5

Positioning a background-image with background-position works, but the background-position property can't be fetched through getComputedStyle.  

Looking at FF1.5's DOM Inspector, in the 'Computed Style' section, this property is not enumerated; in the 'Javascript Object' section, in the style sub-object, backgroundPosition is there but empty.  In the 'CSS Style Rules', there are two variables containing the data, called '-x-background-x-position' and '-x-background-y-position'.

The clean way should be to use getComputedStyle.getPropertyValue('background-position'), but meanwhile maybe there's a workaround?


Reproducible: Always

Steps to Reproduce:
1. Create an element with a 'background-position' style property;
2. Try to fetch this background-position through Javascript's getComputedStyle
3. Fail!




This is using FF1.5-RC2
Comment 1 zug_treno 2005-11-19 04:04:45 PST
Duplicate of/related to bug 299960?
Comment 2 Patrice Levesque 2005-11-19 05:30:23 PST

*** This bug has been marked as a duplicate of 258080 ***
Comment 3 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2005-11-19 10:04:36 PST
*** Bug 299960 has been marked as a duplicate of this bug. ***
Comment 4 Gérard Talbot 2005-11-19 19:12:02 PST
Created attachment 203687 [details]
Self-explanatory basic testcase
Comment 5 Gérard Talbot 2005-11-19 19:28:22 PST
Created attachment 203688 [details]
Better self-explanatory basic testcase
Comment 6 Gérard Talbot 2005-11-19 19:33:27 PST
Created attachment 203689 [details]
Better self-explanatory basic testcase

Sorry: previous attachment was a wrong filename selection.
Comment 7 Simon Richardson 2006-08-21 16:24:52 PDT
Setting the backgroundPosition via javascript also fails (including backgroundPositionX and backgroundPositionY)

1.5.0.6
Comment 8 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2007-07-21 15:51:25 PDT
Created attachment 273270 [details] [diff] [review]
patch to implement rest of properties we compute

Since tor landed the SVG properties yesterday, it wasn't that hard to implement the rest of the properties that we compute, and get the mochitests passing.  So here's a patch to implement computed style for:
  -moz-force-broken-image-icon
  background-position
  content
  page-break-after
  page-break-before
  quotes

I took a rather hacky approach for the counter() and counters() values inside content.  They technically require us to implement another DOM interface, but I didn't bother.  I stored CSS_COUNTER values like CSS_STRING, but made them not respond to getStringValue().  I also added CSS_ATTR support to nsROCSSPrimitiveValue (correctly, maybe).

I fixed the bugs with page-break-before and page-break-after than this exposed (except for parsing 'avoid' but handling it like 'auto'.)  In other words, we now let the 'auto' value override others at computation time, and we handle 'left' and 'right' like 'always' rather than 'auto', and we handle 'inherit' and '-moz-initial'.  Hooray for r=alexsavulov.

But I didn't fix quotes: -moz-initial, which was the other bug adding this turned up.

The mochitests could use some further cleanup:  the remaining properties in gNoComputedStyle shouldn't have it, but should be detectable in the computed style for other properties.  And I left an empty gNoComputedValue array in test_value_storage.html to be cleaned up later.
Comment 9 Boris Zbarsky [:bz] 2007-07-22 10:05:19 PDT
Comment on attachment 273270 [details] [diff] [review]
patch to implement rest of properties we compute

>+nsComputedDOMStyle::GetContent(nsIDOMCSSValue** aValue)

>+          str.Append(nsDependentString(a->Item(0).GetStringBufferValue()));

I don't think you need the nsDependentString() here.

With that, r+sr=bzbarsky.

We could really use more code refactoring and consolidation in this file...  Less codesize should be easy.
Comment 10 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2007-07-22 11:39:25 PDT
Fix checked in.

How we do the codesize refactoring depends on whether we're going to remove support for getPropertyCSSValue, I suppose.
Comment 11 Erik Fabert 2007-09-24 04:45:32 PDT
*** Bug 397324 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.