Closed Bug 1561440 Opened 5 years ago Closed 5 years ago

Add support for non-integer values in HTML dimension attributes

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(4 files)

Something like this:

  <img src="whatever" width="50.5%">

should make the image 101px wide in a 200px container. Similarly,

  <img src="whatever" width="50.5">

should end up 50.5 CSS px wide (so 101 device pixels on 2dppx screen).

We don't do that right now, because we parse those as "50%" and "50" respectively. The issue is that nsAttrValue doesn't have generic (non-percentage) float storage. And even for percentages, we only use the mPercent of the misc container from SetIntValueAndType, if the value doesn't fit in the bits we have available to store it.

We should just add a SetFloatValueAndType that would explicitly store floats in the misc container as needed.

Bugbug thinks this bug is a enhancement, but please change it back in case of error.

Type: defect → enhancement

Well, it's technically a spec violation, and may have web compat impact, though none has been reported yet.

Type: enhancement → defect
Priority: -- → P3
Depends on: 1560055

In the new setup, if the value is an integer and fits in our restricted integer
range we store it directly; otherwise we just go ahead and store it as a double
in the misc container, since we have a double available there anyway.

Blocks: 1562257
Attachment #9074643 - Attachment description: Bug 1561440 part 1. Refactor mapping of dimension attributes so we don't duplicate code. r=mccr8 → Bug 1561440 part 1. Move MapSizeAttributeInto to earlier in the file, where we will need it, and rename to be clearer about what sort of things it maps. r=mccr8
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/56b4d2258093 part 1. Move MapSizeAttributeInto to earlier in the file, where we will need it, and rename to be clearer about what sort of things it maps. r=mccr8 https://hg.mozilla.org/integration/autoland/rev/3065c80f6ca8 part 2. Add mapping and reflection support for dimension attributes stored as doubles. r=mccr8,emilio https://hg.mozilla.org/integration/autoland/rev/6e8779559140 part 3. Add a way to store a non-integer percent value in nsAttrValue. r=mccr8 https://hg.mozilla.org/integration/autoland/rev/5277a23512a6 part 4. Parse non-integer HTML dimension values. r=mccr8
Assignee: nobody → bzbarsky
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/17757 for changes under testing/web-platform/tests
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: