mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #6046 - Jinwoo-Song:background_origin, r=pcwalton
This property determines the background positioning area, that is the position of the origin of an image specified using the 'background-image' CSS property. 'background-origin' is ignored when background-attachment is fixed. Spec: http://dev.w3.org/csswg/css-backgrounds-3/#background-origin Fixes #6045. r? @pcwalton cc @yichoi <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6046) <!-- Reviewable:end -->
This commit is contained in:
commit
8c40272824
7 changed files with 119 additions and 8 deletions
|
@ -43,7 +43,7 @@ use std::sync::Arc;
|
|||
use std::sync::mpsc::channel;
|
||||
use style::computed_values::filter::Filter;
|
||||
use style::computed_values::transform::ComputedMatrix;
|
||||
use style::computed_values::{background_attachment, background_repeat, background_size};
|
||||
use style::computed_values::{background_attachment, background_origin, background_repeat, background_size};
|
||||
use style::computed_values::{border_style, image_rendering, overflow_x, position, visibility};
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::style_structs::Border;
|
||||
|
@ -419,12 +419,32 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
// TODO: Check the bounds to see if a clip item is actually required.
|
||||
let clip = clip.clone().intersect_rect(&bounds);
|
||||
|
||||
// Background image should be positioned on the padding box basis.
|
||||
let border = style.logical_border_width().to_physical(style.writing_mode);
|
||||
|
||||
// Use 'background-origin' to get the origin value.
|
||||
let (mut origin_x, mut origin_y) = match background.background_origin {
|
||||
background_origin::T::padding_box => {
|
||||
(Au(0), Au(0))
|
||||
}
|
||||
background_origin::T::border_box => {
|
||||
(-border.left, -border.top)
|
||||
}
|
||||
background_origin::T::content_box => {
|
||||
let border_padding = (self.border_padding).to_physical(self.style.writing_mode);
|
||||
(border_padding.left - border.left, border_padding.top - border.top)
|
||||
}
|
||||
};
|
||||
|
||||
// Use `background-attachment` to get the initial virtual origin
|
||||
let (virtual_origin_x, virtual_origin_y) = match background.background_attachment {
|
||||
background_attachment::T::scroll => {
|
||||
(absolute_bounds.origin.x, absolute_bounds.origin.y)
|
||||
}
|
||||
background_attachment::T::fixed => {
|
||||
// If the ‘background-attachment’ value for this image is ‘fixed’, then 'background-origin' has no effect.
|
||||
origin_x = Au(0);
|
||||
origin_y = Au(0);
|
||||
(Au(0), Au(0))
|
||||
}
|
||||
};
|
||||
|
@ -435,11 +455,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
let vertical_position = model::specified(background.background_position.vertical,
|
||||
bounds.size.height - image_size.height);
|
||||
|
||||
// Background image should be positioned on the padding box basis.
|
||||
let border = style.logical_border_width().to_physical(style.writing_mode);
|
||||
|
||||
let abs_x = border.left + virtual_origin_x + horizontal_position;
|
||||
let abs_y = border.top + virtual_origin_y + vertical_position;
|
||||
let abs_x = border.left + virtual_origin_x + horizontal_position + origin_x;
|
||||
let abs_y = border.top + virtual_origin_y + vertical_position + origin_y;
|
||||
|
||||
// Adjust origin and size based on background-repeat
|
||||
match background.background_repeat {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue