Closed Bug 316981 Opened 19 years ago Closed 17 years ago

background-position property is not available through the CSS DOM interface

Categories

(Core :: DOM: CSS Object Model, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bugzilla.mozilla.wayne, Assigned: dbaron)

References

Details

(Keywords: dom2, testcase)

Attachments

(2 files, 2 obsolete files)

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
Blocks: 42417
Duplicate of/related to bug 299960?

*** This bug has been marked as a duplicate of 258080 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → UNCONFIRMED
Depends on: 258080
Resolution: DUPLICATE → ---
*** Bug 299960 has been marked as a duplicate of this bug. ***
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached file Self-explanatory basic testcase (obsolete) —
Keywords: testcase
OS: Linux → All
Attached file Better self-explanatory basic testcase (obsolete) —
Attachment #203687 - Attachment is obsolete: true
Sorry: previous attachment was a wrong filename selection.
Attachment #203688 - Attachment is obsolete: true
Keywords: dom2
Setting the backgroundPosition via javascript also fails (including backgroundPositionX and backgroundPositionY)

1.5.0.6
Flags: blocking1.9?
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
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.
Assignee: general → dbaron
Status: NEW → ASSIGNED
Attachment #273270 - Flags: superreview?(bzbarsky)
Attachment #273270 - Flags: review?(bzbarsky)
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.
Attachment #273270 - Flags: superreview?(bzbarsky)
Attachment #273270 - Flags: superreview+
Attachment #273270 - Flags: review?(bzbarsky)
Attachment #273270 - Flags: review+
Fix checked in.

How we do the codesize refactoring depends on whether we're going to remove support for getPropertyCSSValue, I suppose.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago17 years ago
Resolution: --- → FIXED
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: