-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve aspect ratio of images #242
Commits on Oct 17, 2024
-
Tests several combinations of size contraints on images so we can check if the aspect ratio is kept or not.
Configuration menu - View commit details
-
Copy full SHA for 277b72c - Browse repository at this point
Copy the full SHA 277b72cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 25a381f - Browse repository at this point
Copy the full SHA 25a381fView commit details -
Preserve aspect ratio of images
When posible, change the image size so the aspect ratio is always preserved. This is only posible when one or both dimensions have some room to play. When both dimensions are not fixed, a naive algorithm tries to satisfy all {min,max}-{width,height} and aspect ratio constraints, but it may fail. In that case, the aspect ratio is not preserved. Fixes the HTML tests img-aspect-ratio and img-max-bounds.
Configuration menu - View commit details
-
Copy full SHA for 557e194 - Browse repository at this point
Copy the full SHA 557e194View commit details -
Don't apply min/max-width if the width is auto
Prevents reducing the available width of a body with width:auto and min-width:100px to 100px. The Widget::calcFinalWidth() method is also heavily documented, so we can understand precisely what it does.
Configuration menu - View commit details
-
Copy full SHA for 6321304 - Browse repository at this point
Copy the full SHA 6321304View commit details -
Set the viewport width as initial width value
When the initial width is -1, the contrainsts of min-width and max-width are not applied. If we set the viewport width after calcFinalWidth() it may exceed max-width. It is guaranteed to return a value different from -1 when the initial width is positive.
Configuration menu - View commit details
-
Copy full SHA for c11d213 - Browse repository at this point
Copy the full SHA c11d213View commit details -
Expand percentage height values for requisitions
When correcting a requisition, percent values were not being computed which prevents the min-height or max-height values to be taken into account.
Configuration menu - View commit details
-
Copy full SHA for 931f824 - Browse repository at this point
Copy the full SHA 931f824View commit details -
Configuration menu - View commit details
-
Copy full SHA for bcc4fac - Browse repository at this point
Copy the full SHA bcc4facView commit details -
Configuration menu - View commit details
-
Copy full SHA for b6c8599 - Browse repository at this point
Copy the full SHA b6c8599View commit details -
Allow widgets to adjust new requisition
When a widget calls the parent to correct its own requisition, let the child widget perform adjustments on the requisition. This allows images to control the height when the parent changes the width, so the image can preserve its own aspect ratio.
Configuration menu - View commit details
-
Copy full SHA for 4962383 - Browse repository at this point
Copy the full SHA 4962383View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d7212a - Browse repository at this point
Copy the full SHA 7d7212aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 519f5c8 - Browse repository at this point
Copy the full SHA 519f5c8View commit details -
Only use the viewport height with forceValue set
For cases where the available height is being computed and the CSS style has the height to auto, there available height is infinite. Don't return the viewport unless forceValue is set.
Configuration menu - View commit details
-
Copy full SHA for a4301a9 - Browse repository at this point
Copy the full SHA a4301a9View commit details -
Add support for aspect ratio in Widget
Images should preserve their own aspect ratio, which is determined by the image buffer size, also known as the intrinsic size. Currently, when a child requests a requisition to be corrected by correctRequisition(), only the size was adjusted, ignoring the aspect ratio. The new Widget ratio variable holds the desired aspect ratio for the widget, and will only be taken into account when non-zero. In that case, then correcting the requisition, a naive algorithm tries to first increase the length of the small size to fill the preferred aspect ratio. In the case that it is not enough, the larger size is then decreased to fit the aspect ratio. And if that doesn't work either, the aspect ratio is not enforced and the widget will be distorted. There are special cases for correctRequisition() depending if the parent exists or not. The same approach is taken for both cases, but using the viewport size instead of the parent size.
Configuration menu - View commit details
-
Copy full SHA for 7823c15 - Browse repository at this point
Copy the full SHA 7823c15View commit details -
Use maximum size for pathological CSS cases
When CSS min-{width,height} > max-{width,height} set the max-{width,heigh} to the maximum value min-{width,height}.
Configuration menu - View commit details
-
Copy full SHA for e4fbfd6 - Browse repository at this point
Copy the full SHA e4fbfd6View commit details -
Configuration menu - View commit details
-
Copy full SHA for ae0a634 - Browse repository at this point
Copy the full SHA ae0a634View commit details -
Remove aspect ratio logic from Image
The aspect ratio is now preserved by Widget::correctRequisition(), so we don't need to do more steps after the call.
Configuration menu - View commit details
-
Copy full SHA for 15b878c - Browse repository at this point
Copy the full SHA 15b878cView commit details -
Configuration menu - View commit details
-
Copy full SHA for df3ed48 - Browse repository at this point
Copy the full SHA df3ed48View commit details -
Configuration menu - View commit details
-
Copy full SHA for 51e023b - Browse repository at this point
Copy the full SHA 51e023bView commit details -
Use the aspect ratio of the content box
The requisition box includes the margin, padding and border. To compute the aspect ratio of the image we need to remove them to get the content box. Once the adjustment is done, we add the borders again.
Configuration menu - View commit details
-
Copy full SHA for 572b934 - Browse repository at this point
Copy the full SHA 572b934View commit details