mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Use DisplayListSection everywhere
DisplayListSection, StackingLevel, and BackgroundAndBorderLevel all represent pretty much the same thing, a particular section of the display list. Instead of maintaining three enums which do the same thing, just use DisplayListSection everywhere. It's a superset of the other two and this change will make it easier to flatten the DisplayList in the future for WebRender.
This commit is contained in:
parent
083d3e0201
commit
d720452698
2 changed files with 63 additions and 110 deletions
|
@ -146,6 +146,10 @@ impl DisplayList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the given display item at the specified section of this display list.
|
||||||
|
pub fn add_to_section(&mut self, display_item: DisplayItem, section: DisplayListSection) {
|
||||||
|
self.get_section_mut(section).push_back(display_item);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a new display list which contains a single stacking context.
|
/// Creates a new display list which contains a single stacking context.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -554,7 +558,7 @@ impl DisplayList {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum DisplayListSection {
|
pub enum DisplayListSection {
|
||||||
BackgroundAndBorders,
|
BackgroundAndBorders,
|
||||||
BlockBackgroundsAndBorders,
|
BlockBackgroundsAndBorders,
|
||||||
Floats,
|
Floats,
|
||||||
|
@ -876,7 +880,7 @@ impl StackingContextLayerCreator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent_stacking_context.display_list.get_section_mut(section).push_back(item);
|
parent_stacking_context.display_list.add_to_section(item, section);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,7 +934,7 @@ impl StackingContextLayerCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut display_list) = self.display_list_for_next_layer {
|
if let Some(ref mut display_list) = self.display_list_for_next_layer {
|
||||||
display_list.get_section_mut(section).push_back(item);
|
display_list.add_to_section(item, section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use fragment::{CoordinateSystem, Fragment, HAS_LAYER, ImageFragmentInfo, Scanned
|
||||||
use fragment::{SpecificFragmentInfo};
|
use fragment::{SpecificFragmentInfo};
|
||||||
use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
|
use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
|
||||||
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
|
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
|
||||||
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayList};
|
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayList, DisplayListSection};
|
||||||
use gfx::display_list::{GradientDisplayItem};
|
use gfx::display_list::{GradientDisplayItem};
|
||||||
use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo};
|
use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo};
|
||||||
use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem};
|
use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem};
|
||||||
|
@ -71,7 +71,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion);
|
clip: &ClippingRegion);
|
||||||
|
|
||||||
|
@ -84,21 +84,21 @@ pub trait FragmentDisplayListBuilding {
|
||||||
-> Size2D<Au>;
|
-> Size2D<Au>;
|
||||||
|
|
||||||
/// Adds the display items necessary to paint the background image of this fragment to the
|
/// Adds the display items necessary to paint the background image of this fragment to the
|
||||||
/// display list at the appropriate stacking level.
|
/// appropriate section of the display list.
|
||||||
fn build_display_list_for_background_image(&self,
|
fn build_display_list_for_background_image(&self,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
image_url: &Url);
|
image_url: &Url);
|
||||||
|
|
||||||
/// Adds the display items necessary to paint the background linear gradient of this fragment
|
/// Adds the display items necessary to paint the background linear gradient of this fragment
|
||||||
/// to the display list at the appropriate stacking level.
|
/// to the appropriate section of the display list.
|
||||||
fn build_display_list_for_background_linear_gradient(&self,
|
fn build_display_list_for_background_linear_gradient(&self,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
gradient: &LinearGradient,
|
gradient: &LinearGradient,
|
||||||
|
@ -112,7 +112,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
bounds: &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion);
|
clip: &ClippingRegion);
|
||||||
|
|
||||||
/// Adds the display items necessary to paint the outline of this fragment to the display list
|
/// Adds the display items necessary to paint the outline of this fragment to the display list
|
||||||
|
@ -129,7 +129,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
list: &mut DisplayList,
|
list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion);
|
clip: &ClippingRegion);
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
relative_containing_block_size: &LogicalSize<Au>,
|
relative_containing_block_size: &LogicalSize<Au>,
|
||||||
relative_containing_block_mode: WritingMode,
|
relative_containing_block_mode: WritingMode,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_and_border_level: BackgroundAndBorderLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
stacking_relative_display_port: &Rect<Au>);
|
stacking_relative_display_port: &Rect<Au>);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ pub trait FragmentDisplayListBuilding {
|
||||||
fn build_display_items_for_selection_if_necessary(&self,
|
fn build_display_items_for_selection_if_necessary(&self,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
stacking_relative_border_box: &Rect<Au>,
|
stacking_relative_border_box: &Rect<Au>,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion);
|
clip: &ClippingRegion);
|
||||||
|
|
||||||
/// Creates the text display item for one text fragment. This can be called multiple times for
|
/// Creates the text display item for one text fragment. This can be called multiple times for
|
||||||
|
@ -279,7 +279,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion) {
|
clip: &ClippingRegion) {
|
||||||
// Adjust the clipping region as necessary to account for `border-radius`.
|
// Adjust the clipping region as necessary to account for `border-radius`.
|
||||||
|
@ -317,14 +317,14 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display_list.push(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
display_list.add_to_section(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
||||||
base: BaseDisplayItem::new(&bounds,
|
base: BaseDisplayItem::new(&bounds,
|
||||||
DisplayItemMetadata::new(self.node,
|
DisplayItemMetadata::new(self.node,
|
||||||
style,
|
style,
|
||||||
Cursor::DefaultCursor),
|
Cursor::DefaultCursor),
|
||||||
&clip),
|
&clip),
|
||||||
color: background_color.to_gfx_color(),
|
color: background_color.to_gfx_color(),
|
||||||
}), level);
|
}), display_list_section);
|
||||||
|
|
||||||
// The background image is painted on top of the background color.
|
// The background image is painted on top of the background color.
|
||||||
// Implements background image, per spec:
|
// Implements background image, per spec:
|
||||||
|
@ -334,7 +334,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
None => {}
|
None => {}
|
||||||
Some(computed::Image::LinearGradient(ref gradient)) => {
|
Some(computed::Image::LinearGradient(ref gradient)) => {
|
||||||
self.build_display_list_for_background_linear_gradient(display_list,
|
self.build_display_list_for_background_linear_gradient(display_list,
|
||||||
level,
|
display_list_section,
|
||||||
&bounds,
|
&bounds,
|
||||||
&clip,
|
&clip,
|
||||||
gradient,
|
gradient,
|
||||||
|
@ -344,7 +344,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
self.build_display_list_for_background_image(style,
|
self.build_display_list_for_background_image(style,
|
||||||
display_list,
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
level,
|
display_list_section,
|
||||||
&bounds,
|
&bounds,
|
||||||
&clip,
|
&clip,
|
||||||
image_url)
|
image_url)
|
||||||
|
@ -409,7 +409,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
image_url: &Url) {
|
image_url: &Url) {
|
||||||
|
@ -504,7 +504,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the image display item.
|
// Create the image display item.
|
||||||
display_list.push(DisplayItem::ImageClass(box ImageDisplayItem {
|
display_list.add_to_section(DisplayItem::ImageClass(box ImageDisplayItem {
|
||||||
base: BaseDisplayItem::new(&bounds,
|
base: BaseDisplayItem::new(&bounds,
|
||||||
DisplayItemMetadata::new(self.node,
|
DisplayItemMetadata::new(self.node,
|
||||||
style,
|
style,
|
||||||
|
@ -513,13 +513,13 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
image: image.clone(),
|
image: image.clone(),
|
||||||
stretch_size: Size2D::new(image_size.width, image_size.height),
|
stretch_size: Size2D::new(image_size.width, image_size.height),
|
||||||
image_rendering: style.get_effects().image_rendering.clone(),
|
image_rendering: style.get_effects().image_rendering.clone(),
|
||||||
}), level);
|
}), display_list_section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list_for_background_linear_gradient(&self,
|
fn build_display_list_for_background_linear_gradient(&self,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
gradient: &LinearGradient,
|
gradient: &LinearGradient,
|
||||||
|
@ -633,14 +633,14 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
stops: stops,
|
stops: stops,
|
||||||
});
|
});
|
||||||
|
|
||||||
display_list.push(gradient_display_item, level)
|
display_list.add_to_section(gradient_display_item, display_list_section)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list_for_box_shadow_if_applicable(&self,
|
fn build_display_list_for_box_shadow_if_applicable(&self,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
list: &mut DisplayList,
|
list: &mut DisplayList,
|
||||||
_layout_context: &LayoutContext,
|
_layout_context: &LayoutContext,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion) {
|
clip: &ClippingRegion) {
|
||||||
// NB: According to CSS-BACKGROUNDS, box shadows render in *reverse* order (front to back).
|
// NB: According to CSS-BACKGROUNDS, box shadows render in *reverse* order (front to back).
|
||||||
|
@ -652,7 +652,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
box_shadow.spread_radius);
|
box_shadow.spread_radius);
|
||||||
|
|
||||||
// TODO(pcwalton): Multiple border radii; elliptical border radii.
|
// TODO(pcwalton): Multiple border radii; elliptical border radii.
|
||||||
list.push(DisplayItem::BoxShadowClass(box BoxShadowDisplayItem {
|
list.add_to_section(DisplayItem::BoxShadowClass(box BoxShadowDisplayItem {
|
||||||
base: BaseDisplayItem::new(&bounds,
|
base: BaseDisplayItem::new(&bounds,
|
||||||
DisplayItemMetadata::new(self.node,
|
DisplayItemMetadata::new(self.node,
|
||||||
style,
|
style,
|
||||||
|
@ -671,7 +671,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
} else {
|
} else {
|
||||||
BoxShadowClipMode::Outset
|
BoxShadowClipMode::Outset
|
||||||
},
|
},
|
||||||
}), level);
|
}), display_list_section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
bounds: &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion) {
|
clip: &ClippingRegion) {
|
||||||
let mut border = style.logical_border_width();
|
let mut border = style.logical_border_width();
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the border to the display list.
|
// Append the border to the display list.
|
||||||
display_list.push(DisplayItem::BorderClass(box BorderDisplayItem {
|
display_list.add_to_section(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||||
base: BaseDisplayItem::new(&bounds,
|
base: BaseDisplayItem::new(&bounds,
|
||||||
DisplayItemMetadata::new(self.node,
|
DisplayItemMetadata::new(self.node,
|
||||||
style,
|
style,
|
||||||
|
@ -736,7 +736,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
colors.left.to_gfx_color()),
|
colors.left.to_gfx_color()),
|
||||||
style: border_style,
|
style: border_style,
|
||||||
radius: build_border_radius(&bounds, border_style_struct),
|
radius: build_border_radius(&bounds, border_style_struct),
|
||||||
}), level);
|
}), display_list_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list_for_outline_if_applicable(&self,
|
fn build_display_list_for_outline_if_applicable(&self,
|
||||||
|
@ -862,7 +862,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
fn build_display_items_for_selection_if_necessary(&self,
|
fn build_display_items_for_selection_if_necessary(&self,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
stacking_relative_border_box: &Rect<Au>,
|
stacking_relative_border_box: &Rect<Au>,
|
||||||
level: StackingLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion) {
|
clip: &ClippingRegion) {
|
||||||
let scanned_text_fragment_info = match self.specific {
|
let scanned_text_fragment_info = match self.specific {
|
||||||
SpecificFragmentInfo::ScannedText(ref scanned_text_fragment_info) => {
|
SpecificFragmentInfo::ScannedText(ref scanned_text_fragment_info) => {
|
||||||
|
@ -895,12 +895,12 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
cursor = Cursor::VerticalTextCursor;
|
cursor = Cursor::VerticalTextCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
display_list.push(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
display_list.add_to_section(DisplayItem::SolidColorClass(box SolidColorDisplayItem {
|
||||||
base: BaseDisplayItem::new(&insertion_point_bounds,
|
base: BaseDisplayItem::new(&insertion_point_bounds,
|
||||||
DisplayItemMetadata::new(self.node, &*self.style, cursor),
|
DisplayItemMetadata::new(self.node, &*self.style, cursor),
|
||||||
&clip),
|
&clip),
|
||||||
color: self.style().get_color().color.to_gfx_color(),
|
color: self.style().get_color().color.to_gfx_color(),
|
||||||
}), level);
|
}), display_list_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list(&mut self,
|
fn build_display_list(&mut self,
|
||||||
|
@ -910,7 +910,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
relative_containing_block_size: &LogicalSize<Au>,
|
relative_containing_block_size: &LogicalSize<Au>,
|
||||||
relative_containing_block_mode: WritingMode,
|
relative_containing_block_mode: WritingMode,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_and_border_level: BackgroundAndBorderLevel,
|
display_list_section: DisplayListSection,
|
||||||
clip: &ClippingRegion,
|
clip: &ClippingRegion,
|
||||||
stacking_relative_display_port: &Rect<Au>) {
|
stacking_relative_display_port: &Rect<Au>) {
|
||||||
if self.style().get_inheritedbox().visibility != visibility::T::visible {
|
if self.style().get_inheritedbox().visibility != visibility::T::visible {
|
||||||
|
@ -947,9 +947,6 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
debug!("Fragment::build_display_list: intersected. Adding display item...");
|
debug!("Fragment::build_display_list: intersected. Adding display item...");
|
||||||
|
|
||||||
if self.is_primary_fragment() {
|
if self.is_primary_fragment() {
|
||||||
let level =
|
|
||||||
StackingLevel::from_background_and_border_level(background_and_border_level);
|
|
||||||
|
|
||||||
// Add shadows, background, borders, and outlines, if applicable.
|
// Add shadows, background, borders, and outlines, if applicable.
|
||||||
if let Some(ref inline_context) = self.inline_context {
|
if let Some(ref inline_context) = self.inline_context {
|
||||||
for node in inline_context.nodes.iter().rev() {
|
for node in inline_context.nodes.iter().rev() {
|
||||||
|
@ -957,14 +954,14 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
&*node.style,
|
&*node.style,
|
||||||
display_list,
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
level,
|
display_list_section,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
&clip);
|
&clip);
|
||||||
self.build_display_list_for_box_shadow_if_applicable(
|
self.build_display_list_for_box_shadow_if_applicable(
|
||||||
&*node.style,
|
&*node.style,
|
||||||
display_list,
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
level,
|
display_list_section,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
&clip);
|
&clip);
|
||||||
|
|
||||||
|
@ -978,7 +975,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
display_list,
|
display_list,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
level,
|
display_list_section,
|
||||||
&clip);
|
&clip);
|
||||||
|
|
||||||
self.build_display_list_for_outline_if_applicable(
|
self.build_display_list_for_outline_if_applicable(
|
||||||
|
@ -993,20 +990,20 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
self.build_display_list_for_background_if_applicable(&*self.style,
|
self.build_display_list_for_background_if_applicable(&*self.style,
|
||||||
display_list,
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
level,
|
display_list_section,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
&clip);
|
&clip);
|
||||||
self.build_display_list_for_box_shadow_if_applicable(&*self.style,
|
self.build_display_list_for_box_shadow_if_applicable(&*self.style,
|
||||||
display_list,
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
level,
|
display_list_section,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
&clip);
|
&clip);
|
||||||
self.build_display_list_for_borders_if_applicable(&*self.style,
|
self.build_display_list_for_borders_if_applicable(&*self.style,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
display_list,
|
display_list,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
level,
|
display_list_section,
|
||||||
&clip);
|
&clip);
|
||||||
self.build_display_list_for_outline_if_applicable(&*self.style,
|
self.build_display_list_for_outline_if_applicable(&*self.style,
|
||||||
display_list,
|
display_list,
|
||||||
|
@ -1017,7 +1014,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
// Paint the selection point if necessary.
|
// Paint the selection point if necessary.
|
||||||
self.build_display_items_for_selection_if_necessary(display_list,
|
self.build_display_items_for_selection_if_necessary(display_list,
|
||||||
&stacking_relative_border_box,
|
&stacking_relative_border_box,
|
||||||
level,
|
display_list_section,
|
||||||
&clip);
|
&clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,12 +1504,12 @@ pub trait BlockFlowDisplayListBuilding {
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_border_level: BackgroundAndBorderLevel);
|
background_border_level: DisplayListSection);
|
||||||
fn build_display_list_for_static_block(&mut self,
|
fn build_display_list_for_static_block(&mut self,
|
||||||
display_list: Box<DisplayList>,
|
display_list: Box<DisplayList>,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_border_level: BackgroundAndBorderLevel);
|
background_border_level: DisplayListSection);
|
||||||
fn build_display_list_for_absolutely_positioned_block(
|
fn build_display_list_for_absolutely_positioned_block(
|
||||||
&mut self,
|
&mut self,
|
||||||
display_list: Box<DisplayList>,
|
display_list: Box<DisplayList>,
|
||||||
|
@ -1533,7 +1530,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_border_level: BackgroundAndBorderLevel) {
|
background_border_level: DisplayListSection) {
|
||||||
// Add the box that starts the block context.
|
// Add the box that starts the block context.
|
||||||
let clip = if self.fragment.establishes_stacking_context() {
|
let clip = if self.fragment.establishes_stacking_context() {
|
||||||
self.base.clip.translate(&-self.base.stacking_relative_position)
|
self.base.clip.translate(&-self.base.stacking_relative_position)
|
||||||
|
@ -1567,7 +1564,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
mut display_list: Box<DisplayList>,
|
mut display_list: Box<DisplayList>,
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
border_painting_mode: BorderPaintingMode,
|
border_painting_mode: BorderPaintingMode,
|
||||||
background_border_level: BackgroundAndBorderLevel) {
|
background_border_level: DisplayListSection) {
|
||||||
self.build_display_list_for_block_base(&mut *display_list,
|
self.build_display_list_for_block_base(&mut *display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
|
@ -1617,7 +1614,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
&self.base.early_absolute_position_info.relative_containing_block_size,
|
&self.base.early_absolute_position_info.relative_containing_block_size,
|
||||||
self.base.early_absolute_position_info.relative_containing_block_mode,
|
self.base.early_absolute_position_info.relative_containing_block_mode,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
BackgroundAndBorderLevel::RootOfStackingContext,
|
DisplayListSection::BackgroundAndBorders,
|
||||||
&clip,
|
&clip,
|
||||||
&self.base.stacking_relative_position_of_display_port);
|
&self.base.stacking_relative_position_of_display_port);
|
||||||
|
|
||||||
|
@ -1630,17 +1627,16 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
Some(outer_display_list_for_overflow_scroll)
|
Some(outer_display_list_for_overflow_scroll)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let establishes_stacking_context = self.fragment.establishes_stacking_context();
|
let display_list_section = if self.fragment.establishes_stacking_context() {
|
||||||
let background_and_border_level = if establishes_stacking_context {
|
DisplayListSection::BackgroundAndBorders
|
||||||
BackgroundAndBorderLevel::RootOfStackingContext
|
|
||||||
} else {
|
} else {
|
||||||
BackgroundAndBorderLevel::Block
|
DisplayListSection::BlockBackgroundsAndBorders
|
||||||
};
|
};
|
||||||
|
|
||||||
self.build_display_list_for_block_base(&mut *display_list,
|
self.build_display_list_for_block_base(&mut *display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
background_and_border_level);
|
display_list_section);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1692,7 +1688,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
self.build_display_list_for_block_base(&mut *display_list,
|
self.build_display_list_for_block_base(&mut *display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
BackgroundAndBorderLevel::RootOfStackingContext);
|
DisplayListSection::BackgroundAndBorders);
|
||||||
display_list.form_float_pseudo_stacking_context();
|
display_list.form_float_pseudo_stacking_context();
|
||||||
|
|
||||||
self.base.display_list_building_result = if self.fragment.establishes_stacking_context() {
|
self.base.display_list_building_result = if self.fragment.establishes_stacking_context() {
|
||||||
|
@ -1722,10 +1718,11 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
|
||||||
layout_context,
|
layout_context,
|
||||||
border_painting_mode);
|
border_painting_mode);
|
||||||
} else {
|
} else {
|
||||||
self.build_display_list_for_static_block(display_list,
|
self.build_display_list_for_static_block(
|
||||||
|
display_list,
|
||||||
layout_context,
|
layout_context,
|
||||||
border_painting_mode,
|
border_painting_mode,
|
||||||
BackgroundAndBorderLevel::Block);
|
DisplayListSection::BlockBackgroundsAndBorders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1754,7 +1751,7 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
|
||||||
.early_absolute_position_info
|
.early_absolute_position_info
|
||||||
.relative_containing_block_mode,
|
.relative_containing_block_mode,
|
||||||
BorderPaintingMode::Separate,
|
BorderPaintingMode::Separate,
|
||||||
BackgroundAndBorderLevel::Content,
|
DisplayListSection::Content,
|
||||||
&self.base.clip,
|
&self.base.clip,
|
||||||
&self.base.stacking_relative_position_of_display_port);
|
&self.base.stacking_relative_position_of_display_port);
|
||||||
|
|
||||||
|
@ -1854,7 +1851,7 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow {
|
||||||
.early_absolute_position_info
|
.early_absolute_position_info
|
||||||
.relative_containing_block_mode,
|
.relative_containing_block_mode,
|
||||||
BorderPaintingMode::Separate,
|
BorderPaintingMode::Separate,
|
||||||
BackgroundAndBorderLevel::Content,
|
DisplayListSection::Content,
|
||||||
&self.block_flow.base.clip,
|
&self.block_flow.base.clip,
|
||||||
&self.block_flow
|
&self.block_flow
|
||||||
.base
|
.base
|
||||||
|
@ -1906,7 +1903,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
|
||||||
|
|
||||||
let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()];
|
let mut color = THREAD_TINT_COLORS[thread_id as usize % THREAD_TINT_COLORS.len()];
|
||||||
color.a = 1.0;
|
color.a = 1.0;
|
||||||
display_list.push(DisplayItem::BorderClass(box BorderDisplayItem {
|
display_list.add_to_section(DisplayItem::BorderClass(box BorderDisplayItem {
|
||||||
base: BaseDisplayItem::new(&stacking_context_relative_bounds.inflate(Au::from_px(2),
|
base: BaseDisplayItem::new(&stacking_context_relative_bounds.inflate(Au::from_px(2),
|
||||||
Au::from_px(2)),
|
Au::from_px(2)),
|
||||||
DisplayItemMetadata {
|
DisplayItemMetadata {
|
||||||
|
@ -1918,7 +1915,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
|
||||||
color: SideOffsets2D::new_all_same(color),
|
color: SideOffsets2D::new_all_same(color),
|
||||||
style: SideOffsets2D::new_all_same(border_style::T::solid),
|
style: SideOffsets2D::new_all_same(border_style::T::solid),
|
||||||
radius: BorderRadii::all_same(Au(0)),
|
radius: BorderRadii::all_same(Au(0)),
|
||||||
}), StackingLevel::Content);
|
}), DisplayListSection::Content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,54 +1947,6 @@ fn position_to_offset(position: LengthOrPercentage, Au(total_length): Au) -> f32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "Steps" as defined by CSS 2.1 § E.2.
|
|
||||||
#[derive(Clone, PartialEq, Debug, Copy)]
|
|
||||||
pub enum StackingLevel {
|
|
||||||
/// The border and backgrounds for the root of this stacking context: steps 1 and 2.
|
|
||||||
BackgroundAndBorders,
|
|
||||||
/// Borders and backgrounds for block-level descendants: step 4.
|
|
||||||
BlockBackgroundsAndBorders,
|
|
||||||
/// All non-positioned content.
|
|
||||||
Content,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StackingLevel {
|
|
||||||
#[inline]
|
|
||||||
pub fn from_background_and_border_level(level: BackgroundAndBorderLevel) -> StackingLevel {
|
|
||||||
match level {
|
|
||||||
BackgroundAndBorderLevel::RootOfStackingContext => StackingLevel::BackgroundAndBorders,
|
|
||||||
BackgroundAndBorderLevel::Block => StackingLevel::BlockBackgroundsAndBorders,
|
|
||||||
BackgroundAndBorderLevel::Content => StackingLevel::Content,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Which level to place backgrounds and borders in.
|
|
||||||
pub enum BackgroundAndBorderLevel {
|
|
||||||
RootOfStackingContext,
|
|
||||||
Block,
|
|
||||||
Content,
|
|
||||||
}
|
|
||||||
|
|
||||||
trait StackingContextConstruction {
|
|
||||||
/// Adds the given display item at the specified level to this display list.
|
|
||||||
fn push(&mut self, display_item: DisplayItem, level: StackingLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StackingContextConstruction for DisplayList {
|
|
||||||
fn push(&mut self, display_item: DisplayItem, level: StackingLevel) {
|
|
||||||
match level {
|
|
||||||
StackingLevel::BackgroundAndBorders => {
|
|
||||||
self.background_and_borders.push_back(display_item)
|
|
||||||
}
|
|
||||||
StackingLevel::BlockBackgroundsAndBorders => {
|
|
||||||
self.block_backgrounds_and_borders.push_back(display_item)
|
|
||||||
}
|
|
||||||
StackingLevel::Content => self.content.push_back(display_item),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adjusts `content_rect` as necessary for the given spread, and blur so that the resulting
|
/// Adjusts `content_rect` as necessary for the given spread, and blur so that the resulting
|
||||||
/// bounding rect contains all of a shadow's ink.
|
/// bounding rect contains all of a shadow's ink.
|
||||||
fn shadow_bounds(content_rect: &Rect<Au>, blur_radius: Au, spread_radius: Au) -> Rect<Au> {
|
fn shadow_bounds(content_rect: &Rect<Au>, blur_radius: Au, spread_radius: Au) -> Rect<Au> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue