Improve how intrinsic sizes work for videos (#31746)

* feat: patch for video layout sizes

added rebase from main 2024/10/05

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: eri <epazos@igalia.com>

* feat: take width and height parameters if provided

Signed-off-by: eri <epazos@igalia.com>

* chore: tidy the code and update test expectations

Signed-off-by: eri <epazos@igalia.com>

* feat: handle removing poster

Signed-off-by: eri <epazos@igalia.com>

* chore: update test expectations and remove debug code

Signed-off-by: eri <epazos@igalia.com>

* fix: issues after rebasing to main

Signed-off-by: eri <epazos@igalia.com>

* feat: pass src remove test and tidy

Signed-off-by: eri <epazos@igalia.com>

* chore: clippy fixes

Signed-off-by: eri <epazos@igalia.com>

* chore: update passing test expectations

Signed-off-by: eri <epazos@igalia.com>

* fix object-position-svg test

Signed-off-by: eri <epazos@igalia.com>

* fix unintentional override of video size and resize events

Signed-off-by: eri <epazos@igalia.com>

* change how resize events are sent to better match the spec

Signed-off-by: eri <epazos@igalia.com>

* simplify poster mutation handling

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: eri <eri@inventati.org>

* improved handling of intrinsic sizes

- differentiate between natural size and css size
- presentational attributes
- fallback ratio for video element
- handle more cases where the src/poster are added/removed
- aspect ratio hints

Signed-off-by: eri <epazos@igalia.com>

* update test expectations

Signed-off-by: eri <epazos@igalia.com>

* fix cleaning current frame

Signed-off-by: eri <epazos@igalia.com>

* update test expectations

Signed-off-by: eri <epazos@igalia.com>

* Apply suggestions from code review

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: eri <eri@inventati.org>

* More code review suggestions

Signed-off-by: eri <epazos@igalia.com>

* Prevent aspect-ratio:auto from pulling the ratio from the default object size

As resolved in https://github.com/w3c/csswg-drafts/issues/7524#issuecomment-1204462924

Signed-off-by: Oriol Brufau <obrufau@igalia.com>

---------

Signed-off-by: eri <epazos@igalia.com>
Signed-off-by: eri <eri@inventati.org>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
eri 2024-10-29 22:42:22 +00:00 committed by GitHub
parent 43d1601016
commit 01820e2a8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 290 additions and 360 deletions

View file

@ -1,3 +0,0 @@
[img-aspect-ratio-lazy.html]
[Image width and height attributes are used to infer aspect-ratio for lazy-loaded images]
expected: FAIL

View file

@ -2,50 +2,20 @@
[Computed style]
expected: FAIL
[Create, append and test immediately: <img> with attributes width=250, height=100]
expected: FAIL
[Create, append and test immediately: <img> with attributes width=0.8, height=0.2]
expected: FAIL
[Create, append and test immediately: <img> with invalid trailing attributes width=50pp height=25xx]
expected: FAIL
[Computed style test: img with {"width":"10","height":"20"}]
expected: FAIL
[Computed style test: input with {"type":"image","width":"10","height":"20"}]
expected: FAIL
[Computed style test: img with {"width":"0","height":"1"}]
expected: FAIL
[Computed style test: input with {"type":"image","width":"0","height":"1"}]
expected: FAIL
[Computed style test: img with {"width":"1","height":"0"}]
expected: FAIL
[Computed style test: input with {"type":"image","width":"1","height":"0"}]
expected: FAIL
[Computed style test: img with {"width":"0","height":"0"}]
expected: FAIL
[Computed style test: input with {"type":"image","width":"0","height":"0"}]
expected: FAIL
[Computed style test: img with {"width":"0.5","height":"1.5"}]
expected: FAIL
[Computed style test: input with {"type":"image","width":"0.5","height":"1.5"}]
expected: FAIL
[Loaded images test: <img> with width, height and empty src attributes]
expected: FAIL
[Loaded images test: Error image with width and height attributes]
expected: FAIL
[Loaded images test: Error image with width, height and alt attributes]
expected: FAIL

View file

@ -8,15 +8,9 @@
[Source width/height should take precedence over img attributes.]
expected: FAIL
[Make sure style gets invalidated correctly when the source gets removed.]
expected: FAIL
[If the <source> has only one of width/height, we don't get an aspect ratio, even if the <img> has both.]
expected: FAIL
[If we don't have width/height on the source, we fall back to width/height on the <img>.]
expected: FAIL
[If we only have one width/height attribute, we should get that attribute mapped but no aspect ratio, even if <img> has attributes.]
expected: FAIL

View file

@ -1,24 +0,0 @@
[video-aspect-ratio.html]
[Video width and height attributes are not used to infer aspect-ratio]
expected: FAIL
[Computed style]
expected: FAIL
[Computed style test: video with {"width":"10","height":"20"}]
expected: FAIL
[Computed style test: video with {"width":"0.5","height":"1.5"}]
expected: FAIL
[Computed style test: video with {"width":"0","height":"1"}]
expected: FAIL
[Computed style test: video with {"width":"1","height":"0"}]
expected: FAIL
[Computed style test: video with {"width":"0","height":"0"}]
expected: FAIL
[Video width and height attributes are used to infer aspect-ratio]
expected: FAIL