Add the -servo-overflow-clip-box property.

This commit is contained in:
Simon Sapin 2016-03-04 19:47:20 +01:00
parent 7126fdfc10
commit 142610265e
2 changed files with 29 additions and 4 deletions

View file

@ -44,6 +44,7 @@ use std::default::Default;
use std::sync::Arc; use std::sync::Arc;
use std::{cmp, f32}; use std::{cmp, f32};
use style::computed_values::filter::Filter; use style::computed_values::filter::Filter;
use style::computed_values::{_servo_overflow_clip_box as overflow_clip_box};
use style::computed_values::{background_attachment, background_clip, background_origin}; use style::computed_values::{background_attachment, background_clip, background_origin};
use style::computed_values::{background_repeat, background_size}; use style::computed_values::{background_repeat, background_size};
use style::computed_values::{border_style, image_rendering, overflow_x, position}; use style::computed_values::{border_style, image_rendering, overflow_x, position};
@ -1430,6 +1431,25 @@ impl FragmentDisplayListBuilding for Fragment {
// Account for style-specified `clip`. // Account for style-specified `clip`.
self.adjust_clip_for_style(current_clip, stacking_relative_border_box); self.adjust_clip_for_style(current_clip, stacking_relative_border_box);
let overflow_x = self.style.get_box().overflow_x;
let overflow_y = self.style.get_box().overflow_y.0;
if let (overflow_x::T::visible, overflow_x::T::visible) = (overflow_x, overflow_y) {
return
}
let tmp;
let overflow_clip_rect = match self.style.get_box()._servo_overflow_clip_box {
overflow_clip_box::T::padding_box => {
// FIXME(SimonSapin): should be the padding box, not border box.
stacking_relative_border_box
}
overflow_clip_box::T::content_box => {
tmp = self.stacking_relative_content_box(stacking_relative_border_box);
&tmp
}
};
// Clip according to the values of `overflow-x` and `overflow-y`. // Clip according to the values of `overflow-x` and `overflow-y`.
// //
// TODO(pcwalton): Support scrolling of non-absolutely-positioned elements. // TODO(pcwalton): Support scrolling of non-absolutely-positioned elements.
@ -1441,8 +1461,8 @@ impl FragmentDisplayListBuilding for Fragment {
(overflow_x::T::auto, false) | (overflow_x::T::auto, false) |
(overflow_x::T::scroll, false) => { (overflow_x::T::scroll, false) => {
let mut bounds = current_clip.bounding_rect(); let mut bounds = current_clip.bounding_rect();
let max_x = cmp::min(bounds.max_x(), stacking_relative_border_box.max_x()); let max_x = cmp::min(bounds.max_x(), overflow_clip_rect.max_x());
bounds.origin.x = cmp::max(bounds.origin.x, stacking_relative_border_box.origin.x); bounds.origin.x = cmp::max(bounds.origin.x, overflow_clip_rect.origin.x);
bounds.size.width = max_x - bounds.origin.x; bounds.size.width = max_x - bounds.origin.x;
current_clip.intersect_rect(&bounds) current_clip.intersect_rect(&bounds)
} }
@ -1453,8 +1473,8 @@ impl FragmentDisplayListBuilding for Fragment {
(overflow_x::T::auto, false) | (overflow_x::T::auto, false) |
(overflow_x::T::scroll, false) => { (overflow_x::T::scroll, false) => {
let mut bounds = current_clip.bounding_rect(); let mut bounds = current_clip.bounding_rect();
let max_y = cmp::min(bounds.max_y(), stacking_relative_border_box.max_y()); let max_y = cmp::min(bounds.max_y(), overflow_clip_rect.max_y());
bounds.origin.y = cmp::max(bounds.origin.y, stacking_relative_border_box.origin.y); bounds.origin.y = cmp::max(bounds.origin.y, overflow_clip_rect.origin.y);
bounds.size.height = max_y - bounds.origin.y; bounds.size.height = max_y - bounds.origin.y;
current_clip.intersect_rect(&bounds) current_clip.intersect_rect(&bounds)
} }

View file

@ -854,6 +854,9 @@ pub mod longhands {
// CSS 2.1, Section 11 - Visual effects // CSS 2.1, Section 11 - Visual effects
// Non-standard, see https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box#Specifications
${single_keyword("-servo-overflow-clip-box", "padding-box content-box", internal=True)}
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
<%self:single_keyword_computed name="overflow-x" values="visible hidden scroll auto"> <%self:single_keyword_computed name="overflow-x" values="visible hidden scroll auto">
use values::computed::Context; use values::computed::Context;
@ -5638,6 +5641,7 @@ mod property_bit_field {
% for property in LONGHANDS: % for property in LONGHANDS:
% if property.derived_from is None: % if property.derived_from is None:
#[allow(non_snake_case)]
fn substitute_variables_${property.ident}<F, R>( fn substitute_variables_${property.ident}<F, R>(
value: &DeclaredValue<longhands::${property.ident}::SpecifiedValue>, value: &DeclaredValue<longhands::${property.ident}::SpecifiedValue>,
custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>, custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>,
@ -5661,6 +5665,7 @@ mod property_bit_field {
} }
} }
#[allow(non_snake_case)]
#[inline(never)] #[inline(never)]
fn substitute_variables_${property.ident}_slow<F, R>( fn substitute_variables_${property.ident}_slow<F, R>(
css: &String, css: &String,