mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #9875 - servo:overflow-clip-box, r=mbrubeck
Hide overflow of <input> Fix #9477 r? @mbrubeck <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9875) <!-- Reviewable:end -->
This commit is contained in:
commit
b46d2e2737
3 changed files with 64 additions and 16 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,26 +51,29 @@ def to_camel_case(ident):
|
||||||
return re.sub("_([a-z])", lambda m: m.group(1).upper(), ident.strip("_").capitalize())
|
return re.sub("_([a-z])", lambda m: m.group(1).upper(), ident.strip("_").capitalize())
|
||||||
|
|
||||||
class Longhand(object):
|
class Longhand(object):
|
||||||
def __init__(self, name, derived_from=None, custom_cascade=False, experimental=False):
|
def __init__(self, name, derived_from=None, custom_cascade=False, experimental=False,
|
||||||
|
internal=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ident = to_rust_ident(name)
|
self.ident = to_rust_ident(name)
|
||||||
self.camel_case = to_camel_case(self.ident)
|
self.camel_case = to_camel_case(self.ident)
|
||||||
self.style_struct = THIS_STYLE_STRUCT
|
self.style_struct = THIS_STYLE_STRUCT
|
||||||
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
||||||
self.custom_cascade = custom_cascade
|
self.custom_cascade = custom_cascade
|
||||||
|
self.internal = internal
|
||||||
if derived_from is None:
|
if derived_from is None:
|
||||||
self.derived_from = None
|
self.derived_from = None
|
||||||
else:
|
else:
|
||||||
self.derived_from = [ to_rust_ident(name) for name in derived_from ]
|
self.derived_from = [ to_rust_ident(name) for name in derived_from ]
|
||||||
|
|
||||||
class Shorthand(object):
|
class Shorthand(object):
|
||||||
def __init__(self, name, sub_properties, experimental=False):
|
def __init__(self, name, sub_properties, experimental=False, internal=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ident = to_rust_ident(name)
|
self.ident = to_rust_ident(name)
|
||||||
self.camel_case = to_camel_case(self.ident)
|
self.camel_case = to_camel_case(self.ident)
|
||||||
self.derived_from = None
|
self.derived_from = None
|
||||||
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
||||||
self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties]
|
self.sub_properties = [LONGHANDS_BY_NAME[s] for s in sub_properties]
|
||||||
|
self.internal = internal
|
||||||
|
|
||||||
class StyleStruct(object):
|
class StyleStruct(object):
|
||||||
def __init__(self, name, inherited):
|
def __init__(self, name, inherited):
|
||||||
|
@ -109,7 +112,8 @@ pub mod longhands {
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
use values::specified;
|
use values::specified;
|
||||||
|
|
||||||
<%def name="raw_longhand(name, derived_from=None, custom_cascade=False, experimental=False)">
|
<%def name="raw_longhand(name, derived_from=None, custom_cascade=False, experimental=False,
|
||||||
|
internal=False)">
|
||||||
<%
|
<%
|
||||||
if derived_from is not None:
|
if derived_from is not None:
|
||||||
derived_from = derived_from.split()
|
derived_from = derived_from.split()
|
||||||
|
@ -117,7 +121,8 @@ pub mod longhands {
|
||||||
property = Longhand(name,
|
property = Longhand(name,
|
||||||
derived_from=derived_from,
|
derived_from=derived_from,
|
||||||
custom_cascade=custom_cascade,
|
custom_cascade=custom_cascade,
|
||||||
experimental=experimental)
|
experimental=experimental,
|
||||||
|
internal=internal)
|
||||||
property.style_struct = THIS_STYLE_STRUCT
|
property.style_struct = THIS_STYLE_STRUCT
|
||||||
THIS_STYLE_STRUCT.longhands.append(property)
|
THIS_STYLE_STRUCT.longhands.append(property)
|
||||||
LONGHANDS.append(property)
|
LONGHANDS.append(property)
|
||||||
|
@ -234,9 +239,11 @@ pub mod longhands {
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="longhand(name, derived_from=None, custom_cascade=False, experimental=False)">
|
<%def name="longhand(name, derived_from=None, custom_cascade=False, experimental=False,
|
||||||
|
internal=False)">
|
||||||
<%self:raw_longhand name="${name}" derived_from="${derived_from}"
|
<%self:raw_longhand name="${name}" derived_from="${derived_from}"
|
||||||
custom_cascade="${custom_cascade}" experimental="${experimental}">
|
custom_cascade="${custom_cascade}" experimental="${experimental}"
|
||||||
|
internal="${internal}">
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
% if derived_from is None:
|
% if derived_from is None:
|
||||||
pub fn parse_specified(context: &ParserContext, input: &mut Parser)
|
pub fn parse_specified(context: &ParserContext, input: &mut Parser)
|
||||||
|
@ -247,9 +254,10 @@ pub mod longhands {
|
||||||
</%self:raw_longhand>
|
</%self:raw_longhand>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="single_keyword_computed(name, values, custom_cascade=False, experimental=False)">
|
<%def name="single_keyword_computed(name, values, custom_cascade=False, experimental=False,
|
||||||
|
internal=False)">
|
||||||
<%self:longhand name="${name}" custom_cascade="${custom_cascade}"
|
<%self:longhand name="${name}" custom_cascade="${custom_cascade}"
|
||||||
experimental="${experimental}">
|
experimental="${experimental}" internal="${internal}">
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
|
@ -269,10 +277,11 @@ pub mod longhands {
|
||||||
</%self:longhand>
|
</%self:longhand>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="single_keyword(name, values, experimental=False)">
|
<%def name="single_keyword(name, values, experimental=False, internal=False)">
|
||||||
<%self:single_keyword_computed name="${name}"
|
<%self:single_keyword_computed name="${name}"
|
||||||
values="${values}"
|
values="${values}"
|
||||||
experimental="${experimental}">
|
experimental="${experimental}"
|
||||||
|
internal="${internal}">
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
</%self:single_keyword_computed>
|
</%self:single_keyword_computed>
|
||||||
|
@ -845,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;
|
||||||
|
@ -5629,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>>,
|
||||||
|
@ -5652,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,
|
||||||
|
@ -6054,6 +6068,11 @@ impl PropertyDeclaration {
|
||||||
% for property in LONGHANDS:
|
% for property in LONGHANDS:
|
||||||
% if property.derived_from is None:
|
% if property.derived_from is None:
|
||||||
"${property.name}" => {
|
"${property.name}" => {
|
||||||
|
% if property.internal:
|
||||||
|
if context.stylesheet_origin != Origin::UserAgent {
|
||||||
|
return PropertyDeclarationParseResult::UnknownProperty
|
||||||
|
}
|
||||||
|
% endif
|
||||||
% if property.experimental:
|
% if property.experimental:
|
||||||
if !::util::prefs::get_pref("${property.experimental}")
|
if !::util::prefs::get_pref("${property.experimental}")
|
||||||
.as_boolean().unwrap_or(false) {
|
.as_boolean().unwrap_or(false) {
|
||||||
|
@ -6074,6 +6093,11 @@ impl PropertyDeclaration {
|
||||||
% endfor
|
% endfor
|
||||||
% for shorthand in SHORTHANDS:
|
% for shorthand in SHORTHANDS:
|
||||||
"${shorthand.name}" => {
|
"${shorthand.name}" => {
|
||||||
|
% if shorthand.internal:
|
||||||
|
if context.stylesheet_origin != Origin::UserAgent {
|
||||||
|
return PropertyDeclarationParseResult::UnknownProperty
|
||||||
|
}
|
||||||
|
% endif
|
||||||
% if shorthand.experimental:
|
% if shorthand.experimental:
|
||||||
if !::util::prefs::get_pref("${shorthand.experimental}")
|
if !::util::prefs::get_pref("${shorthand.experimental}")
|
||||||
.as_boolean().unwrap_or(false) {
|
.as_boolean().unwrap_or(false) {
|
||||||
|
@ -7011,7 +7035,7 @@ macro_rules! css_properties_accessors {
|
||||||
($macro_name: ident) => {
|
($macro_name: ident) => {
|
||||||
$macro_name! {
|
$macro_name! {
|
||||||
% for property in SHORTHANDS + LONGHANDS:
|
% for property in SHORTHANDS + LONGHANDS:
|
||||||
% if property.derived_from is None:
|
% if property.derived_from is None and not property.internal:
|
||||||
% if '-' in property.name:
|
% if '-' in property.name:
|
||||||
[${property.ident.capitalize()}, Set${property.ident.capitalize()}, "${property.name}"],
|
[${property.ident.capitalize()}, Set${property.ident.capitalize()}, "${property.name}"],
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -31,5 +31,9 @@ td[align="right"] { text-align: right; }
|
||||||
center { text-align: -servo-center; }
|
center { text-align: -servo-center; }
|
||||||
|
|
||||||
input:not([type=radio i]):not([type=checkbox i]):not([type=reset i]):not([type=button i]):not([type=submit i]),
|
input:not([type=radio i]):not([type=checkbox i]):not([type=reset i]):not([type=button i]):not([type=submit i]),
|
||||||
textarea { cursor: text }
|
textarea {
|
||||||
|
cursor: text;
|
||||||
|
overflow: hidden;
|
||||||
|
-servo-overflow-clip-box: content-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue