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

RESOLVED FIXED

Status

()

Core
DOM: CSS Object Model
RESOLVED FIXED
12 years ago
10 years ago

People

(Reporter: Patrice Levesque, Assigned: dbaron)

Tracking

(Blocks: 1 bug, {dom2, testcase})

Trunk
x86
All
dom2, testcase
Points:
---
Dependency tree / graph
Bug Flags:
blocking1.9 -
wanted1.9 +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 2 obsolete attachments)

(Reporter)

Description

12 years ago
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
(Reporter)

Updated

12 years ago
Blocks: 42417

Comment 1

12 years ago
Duplicate of/related to bug 299960?
(Reporter)

Comment 2

12 years ago

*** This bug has been marked as a duplicate of 258080 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → DUPLICATE
(Assignee)

Updated

12 years ago
Status: RESOLVED → UNCONFIRMED
Depends on: 258080
Resolution: DUPLICATE → ---
(Assignee)

Comment 3

12 years ago
*** Bug 299960 has been marked as a duplicate of this bug. ***
(Assignee)

Updated

12 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 4

12 years ago
Created attachment 203687 [details]
Self-explanatory basic testcase

Updated

12 years ago
Keywords: testcase
OS: Linux → All

Comment 5

12 years ago
Created attachment 203688 [details]
Better self-explanatory basic testcase
Attachment #203687 - Attachment is obsolete: true

Comment 6

12 years ago
Created attachment 203689 [details]
Better self-explanatory basic testcase

Sorry: previous attachment was a wrong filename selection.
Attachment #203688 - Attachment is obsolete: true

Updated

12 years ago
Keywords: dom2

Comment 7

11 years ago
Setting the backgroundPosition via javascript also fails (including backgroundPositionX and backgroundPositionY)

1.5.0.6

Updated

11 years ago
Flags: blocking1.9?
Flags: blocking1.9? → blocking1.9-
Whiteboard: [wanted-1.9]
(Assignee)

Comment 8

10 years ago
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.
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+
(Assignee)

Comment 10

10 years ago
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
Last Resolved: 12 years ago10 years ago
Resolution: --- → FIXED

Updated

10 years ago
Duplicate of this bug: 397324
Flags: wanted1.9+
Whiteboard: [wanted-1.9]
You need to log in before you can comment on or make changes to this bug.