mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Remove the last of the explicit style fixups.
This one is particularly dumb, I think.
This commit is contained in:
parent
a2403c5cd6
commit
5e4b5105f9
2 changed files with 96 additions and 104 deletions
|
@ -50,8 +50,8 @@ use std::sync::Arc;
|
|||
use style::computed_values::{background_attachment, background_clip, background_origin};
|
||||
use style::computed_values::{background_repeat, border_style, cursor};
|
||||
use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility};
|
||||
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{self, ComputedValues};
|
||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
|
||||
use style::properties::style_structs;
|
||||
use style::servo::restyle_damage::REPAINT;
|
||||
|
@ -138,12 +138,16 @@ fn get_cyclic<T>(arr: &[T], index: usize) -> &T {
|
|||
&arr[index % arr.len()]
|
||||
}
|
||||
|
||||
pub struct InlineNodeBorderInfo {
|
||||
is_first_fragment_of_element: bool,
|
||||
is_last_fragment_of_element: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct StackingContextInfo {
|
||||
children: Vec<StackingContext>,
|
||||
clip_scroll_nodes: Vec<ClipScrollNode>,
|
||||
}
|
||||
|
||||
impl StackingContextInfo {
|
||||
fn new() -> StackingContextInfo {
|
||||
StackingContextInfo {
|
||||
|
@ -506,10 +510,12 @@ pub trait FragmentDisplayListBuilding {
|
|||
&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ComputedValues,
|
||||
inline_node_info: Option<InlineNodeBorderInfo>,
|
||||
border_painting_mode: BorderPaintingMode,
|
||||
bounds: &Rect<Au>,
|
||||
display_list_section: DisplayListSection,
|
||||
clip: &Rect<Au>);
|
||||
clip: &Rect<Au>,
|
||||
);
|
||||
|
||||
/// Adds the display items necessary to paint the outline of this fragment to the display list
|
||||
/// if necessary.
|
||||
|
@ -1491,12 +1497,18 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
&self,
|
||||
state: &mut DisplayListBuildState,
|
||||
style: &ComputedValues,
|
||||
inline_info: Option<InlineNodeBorderInfo>,
|
||||
border_painting_mode: BorderPaintingMode,
|
||||
bounds: &Rect<Au>,
|
||||
display_list_section: DisplayListSection,
|
||||
clip: &Rect<Au>) {
|
||||
clip: &Rect<Au>
|
||||
) {
|
||||
let mut border = style.logical_border_width();
|
||||
|
||||
if let Some(inline_info) = inline_info {
|
||||
modify_border_width_for_inline_sides(&mut border, inline_info);
|
||||
}
|
||||
|
||||
match border_painting_mode {
|
||||
BorderPaintingMode::Separate => {}
|
||||
BorderPaintingMode::Collapse(collapsed_borders) => {
|
||||
|
@ -1518,6 +1530,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
border_style_struct.border_right_style,
|
||||
border_style_struct.border_bottom_style,
|
||||
border_style_struct.border_left_style);
|
||||
|
||||
if let BorderPaintingMode::Collapse(collapsed_borders) = border_painting_mode {
|
||||
collapsed_borders.adjust_border_colors_and_styles_for_painting(&mut colors,
|
||||
&mut border_style,
|
||||
|
@ -1880,55 +1893,73 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
state,
|
||||
&*node.style,
|
||||
display_list_section,
|
||||
&stacking_relative_border_box);
|
||||
&stacking_relative_border_box,
|
||||
);
|
||||
|
||||
self.build_display_list_for_box_shadow_if_applicable(
|
||||
state,
|
||||
&*node.style,
|
||||
display_list_section,
|
||||
&stacking_relative_border_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
|
||||
let mut style = node.style.clone();
|
||||
properties::modify_border_style_for_inline_sides(
|
||||
&mut style,
|
||||
node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT),
|
||||
node.flags.contains(LAST_FRAGMENT_OF_ELEMENT));
|
||||
self.build_display_list_for_borders_if_applicable(
|
||||
state,
|
||||
&*style,
|
||||
&*node.style,
|
||||
Some(InlineNodeBorderInfo {
|
||||
is_first_fragment_of_element: node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT),
|
||||
is_last_fragment_of_element: node.flags.contains(LAST_FRAGMENT_OF_ELEMENT),
|
||||
}),
|
||||
border_painting_mode,
|
||||
&stacking_relative_border_box,
|
||||
display_list_section,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
|
||||
// FIXME(emilio): Why does outline not do the same width
|
||||
// fixup as border?
|
||||
self.build_display_list_for_outline_if_applicable(
|
||||
state,
|
||||
&*node.style,
|
||||
&stacking_relative_border_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if !self.is_scanned_text_fragment() {
|
||||
self.build_display_list_for_background_if_applicable(state,
|
||||
&*self.style,
|
||||
display_list_section,
|
||||
&stacking_relative_border_box);
|
||||
self.build_display_list_for_box_shadow_if_applicable(state,
|
||||
self.build_display_list_for_background_if_applicable(
|
||||
state,
|
||||
&*self.style,
|
||||
display_list_section,
|
||||
&stacking_relative_border_box,
|
||||
clip);
|
||||
self.build_display_list_for_borders_if_applicable(state,
|
||||
);
|
||||
|
||||
self.build_display_list_for_box_shadow_if_applicable(
|
||||
state,
|
||||
&*self.style,
|
||||
display_list_section,
|
||||
&stacking_relative_border_box,
|
||||
clip,
|
||||
);
|
||||
|
||||
self.build_display_list_for_borders_if_applicable(
|
||||
state,
|
||||
&*self.style,
|
||||
/* inline_node_info = */ None,
|
||||
border_painting_mode,
|
||||
&stacking_relative_border_box,
|
||||
display_list_section,
|
||||
clip);
|
||||
self.build_display_list_for_outline_if_applicable(state,
|
||||
clip,
|
||||
);
|
||||
|
||||
self.build_display_list_for_outline_if_applicable(
|
||||
state,
|
||||
&*self.style,
|
||||
&stacking_relative_border_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3135,6 +3166,24 @@ fn shadow_bounds(content_rect: &Rect<Au>, blur: Au, spread: Au) -> Rect<Au> {
|
|||
content_rect.inflate(inflation, inflation)
|
||||
}
|
||||
|
||||
/// Adjusts borders as appropriate to account for a fragment's status as the
|
||||
/// first or last fragment within the range of an element.
|
||||
///
|
||||
/// Specifically, this function sets border widths to zero on the sides for
|
||||
/// which the fragment is not outermost.
|
||||
fn modify_border_width_for_inline_sides(
|
||||
border_width: &mut LogicalMargin<Au>,
|
||||
inline_border_info: InlineNodeBorderInfo,
|
||||
) {
|
||||
if !inline_border_info.is_first_fragment_of_element {
|
||||
border_width.inline_start = Au(0);
|
||||
}
|
||||
|
||||
if !inline_border_info.is_last_fragment_of_element {
|
||||
border_width.inline_end = Au(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows a CSS color to be converted into a graphics color.
|
||||
pub trait ToGfxColor {
|
||||
/// Converts a CSS color to a graphics color.
|
||||
|
|
|
@ -28,7 +28,7 @@ use context::QuirksMode;
|
|||
use font_metrics::FontMetricsProvider;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
|
||||
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
|
||||
#[cfg(feature = "servo")] use logical_geometry::LogicalMargin;
|
||||
use logical_geometry::WritingMode;
|
||||
use media_queries::Device;
|
||||
use parser::ParserContext;
|
||||
|
@ -49,7 +49,6 @@ use values::computed::NonNegativeLength;
|
|||
use rule_tree::{CascadeLevel, StrongRuleNode};
|
||||
use self::computed_value_flags::*;
|
||||
use style_adjuster::StyleAdjuster;
|
||||
#[cfg(feature = "servo")] use values::specified::BorderStyle;
|
||||
|
||||
pub use self::declaration_block::*;
|
||||
|
||||
|
@ -3598,62 +3597,6 @@ pub fn adjust_border_width(style: &mut StyleBuilder) {
|
|||
% endfor
|
||||
}
|
||||
|
||||
/// Adjusts borders as appropriate to account for a fragment's status as the
|
||||
/// first or last fragment within the range of an element.
|
||||
///
|
||||
/// Specifically, this function sets border widths to zero on the sides for
|
||||
/// which the fragment is not outermost.
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_border_style_for_inline_sides(style: &mut Arc<ComputedValues>,
|
||||
is_first_fragment_of_element: bool,
|
||||
is_last_fragment_of_element: bool) {
|
||||
fn modify_side(style: &mut Arc<ComputedValues>, side: PhysicalSide) {
|
||||
{
|
||||
let border = &style.border;
|
||||
let current_style = match side {
|
||||
PhysicalSide::Left => (border.border_left_width, border.border_left_style),
|
||||
PhysicalSide::Right => (border.border_right_width, border.border_right_style),
|
||||
PhysicalSide::Top => (border.border_top_width, border.border_top_style),
|
||||
PhysicalSide::Bottom => (border.border_bottom_width, border.border_bottom_style),
|
||||
};
|
||||
if current_style == (NonNegativeLength::zero(), BorderStyle::none) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let style = Arc::make_mut(style);
|
||||
let border = Arc::make_mut(&mut style.border);
|
||||
match side {
|
||||
PhysicalSide::Left => {
|
||||
border.border_left_width = NonNegativeLength::zero();
|
||||
border.border_left_style = BorderStyle::none;
|
||||
}
|
||||
PhysicalSide::Right => {
|
||||
border.border_right_width = NonNegativeLength::zero();
|
||||
border.border_right_style = BorderStyle::none;
|
||||
}
|
||||
PhysicalSide::Bottom => {
|
||||
border.border_bottom_width = NonNegativeLength::zero();
|
||||
border.border_bottom_style = BorderStyle::none;
|
||||
}
|
||||
PhysicalSide::Top => {
|
||||
border.border_top_width = NonNegativeLength::zero();
|
||||
border.border_top_style = BorderStyle::none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !is_first_fragment_of_element {
|
||||
let side = style.writing_mode.inline_start_physical_side();
|
||||
modify_side(style, side)
|
||||
}
|
||||
|
||||
if !is_last_fragment_of_element {
|
||||
let side = style.writing_mode.inline_end_physical_side();
|
||||
modify_side(style, side)
|
||||
}
|
||||
}
|
||||
|
||||
/// An identifier for a given alias property.
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue