diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-05 22:13:50 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-06 02:35:10 +0100 |
commit | af879523eabbdb72b672aab50da1f83bb782ed1e (patch) | |
tree | 4071fb814c411a6c2fd52192d0994bd4861af94d /components/layout/construct.rs | |
parent | 37cd870a9e41fe6e6ba12e0622f2e2a935fda89a (diff) | |
download | servo-af879523eabbdb72b672aab50da1f83bb782ed1e.tar.gz servo-af879523eabbdb72b672aab50da1f83bb782ed1e.zip |
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 112 |
1 files changed, 59 insertions, 53 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 888348e3688..07e4b783b2a 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -43,9 +43,13 @@ use std::marker::PhantomData; use std::mem; use std::sync::Arc; use std::sync::atomic::Ordering; -use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; +use style::computed_values::caption_side::T as CaptionSide; use style::computed_values::content::ContentItem; -use style::computed_values::position; +use style::computed_values::display::T as Display; +use style::computed_values::empty_cells::T as EmptyCells; +use style::computed_values::float::T as Float; +use style::computed_values::list_style_position::T as ListStylePosition; +use style::computed_values::position::T as Position; use style::context::SharedStyleContext; use style::logical_geometry::Direction; use style::properties::ComputedValues; @@ -862,7 +866,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> // If the node is positioned, then it's the containing block for all absolutely- // positioned descendants. - if node_style.get_box().position != position::T::static_ { + if node_style.get_box().position != Position::Static { fragment_accumulator.fragments .absolute_descendants .mark_as_having_reached_containing_block(); @@ -925,11 +929,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> } /// Build the fragment for an inline-block or inline-flex, based on the `display` flag - fn build_fragment_for_inline_block_or_inline_flex(&mut self, node: &ConcreteThreadSafeLayoutNode, - display: display::T) -> ConstructionResult { + fn build_fragment_for_inline_block_or_inline_flex( + &mut self, + node: &ConcreteThreadSafeLayoutNode, + display: Display, + ) -> ConstructionResult { let block_flow_result = match display { - display::T::inline_block => self.build_flow_for_block(node, None), - display::T::inline_flex => self.build_flow_for_flex(node, None), + Display::InlineBlock => self.build_flow_for_block(node, None), + Display::InlineFlex => self.build_flow_for_flex(node, None), _ => panic!("The flag should be inline-block or inline-flex") }; let (block_flow, abs_descendants) = match block_flow_result { @@ -1017,7 +1024,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> fn place_table_caption_under_table_wrapper_on_side(&mut self, table_wrapper_flow: &mut FlowRef, node: &ConcreteThreadSafeLayoutNode, - side: caption_side::T) { + side: CaptionSide) { // Only flows that are table captions are matched here. for kid in node.children() { match kid.get_construction_result() { @@ -1078,7 +1085,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> /// Builds a flow for a node with `display: table`. This yields a `TableWrapperFlow` with /// possibly other `TableCaptionFlow`s or `TableFlow`s underneath it. - fn build_flow_for_table(&mut self, node: &ConcreteThreadSafeLayoutNode, float_value: float::T) + fn build_flow_for_table(&mut self, node: &ConcreteThreadSafeLayoutNode, float_value: Float) -> ConstructionResult { let mut legalizer = Legalizer::new(); @@ -1115,7 +1122,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> // value of `caption-side`. self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, node, - caption_side::T::top); + CaptionSide::Top); if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result { legalizer.add_child(self.style_context(), &mut wrapper_flow, table_flow); @@ -1125,7 +1132,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> // If the value of `caption-side` is `bottom`, place it now. self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, node, - caption_side::T::bottom); + CaptionSide::Bottom); // The flow is done. legalizer.finish(&mut wrapper_flow); @@ -1180,12 +1187,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> // Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true // if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to // `hide`. - let hide = node.style(self.style_context()).get_inheritedtable().empty_cells == empty_cells::T::hide && + let hide = node.style(self.style_context()).get_inheritedtable().empty_cells == EmptyCells::Hide && node.children().all(|kid| { let position = kid.style(self.style_context()).get_box().position; !kid.is_content() || - position == position::T::absolute || - position == position::T::fixed + position == Position::Absolute || + position == Position::Fixed }); let flow = FlowRef::new(Arc::new( @@ -1197,7 +1204,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> /// possibly other `BlockFlow`s or `InlineFlow`s underneath it. fn build_flow_for_list_item(&mut self, node: &ConcreteThreadSafeLayoutNode, - flotation: float::T) + flotation: Float) -> ConstructionResult { let flotation = FloatKind::from_property(flotation); let marker_fragments = match node.style(self.style_context()).get_list().list_style_image { @@ -1243,11 +1250,11 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let mut initial_fragments = IntermediateInlineFragments::new(); let main_fragment = self.build_fragment_for_block(node); let flow = match node.style(self.style_context()).get_list().list_style_position { - list_style_position::T::outside => { + ListStylePosition::Outside => { Arc::new(ListItemFlow::from_fragments_and_flotation( main_fragment, marker_fragments, flotation)) } - list_style_position::T::inside => { + ListStylePosition::Inside => { for marker_fragment in marker_fragments { initial_fragments.fragments.push_back(marker_fragment) } @@ -1327,7 +1334,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> // If the node has display: none, it's possible that we haven't even // styled the children once, so we need to bailout early here. - if node.style(self.style_context()).get_box().clone_display() == display::T::none { + if node.style(self.style_context()).get_box().clone_display() == Display::None { return false; } @@ -1466,8 +1473,7 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS // Pseudo-element. let style = node.style(self.style_context()); let display = match node.get_pseudo_element_type() { - PseudoElementType::Normal - => display::T::inline, + PseudoElementType::Normal => Display::Inline, PseudoElementType::Before(maybe_display) | PseudoElementType::After(maybe_display) | PseudoElementType::DetailsContent(maybe_display) | @@ -1480,13 +1486,13 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS let style = node.style(self.style_context()); let original_display = style.get_box()._servo_display_for_hypothetical_box; let munged_display = match original_display { - display::T::inline | display::T::inline_block => original_display, + Display::Inline | Display::InlineBlock => original_display, _ => style.get_box().display, }; (munged_display, style.get_box().float, style.get_box().position) } Some(LayoutNodeType::Text) => - (display::T::inline, float::T::none, position::T::static_), + (Display::Inline, Float::None, Position::Static), }; debug!("building flow for node: {:?} {:?} {:?} {:?}", display, float, positioning, node.type_id()); @@ -1494,12 +1500,12 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS // Switch on display and floatedness. match (display, float, positioning) { // `display: none` contributes no flow construction result. - (display::T::none, _, _) => { + (Display::None, _, _) => { self.set_flow_construction_result(node, ConstructionResult::None); } // Table items contribute table flow construction results. - (display::T::table, float_value, _) => { + (Display::Table, float_value, _) => { let construction_result = self.build_flow_for_table(node, float_value); self.set_flow_construction_result(node, construction_result) } @@ -1510,22 +1516,22 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS // positioned, but inline we shouldn't try to construct a block // flow here - instead, let it match the inline case // below. - (display::T::block, _, position::T::absolute) | - (display::T::block, _, position::T::fixed) => { + (Display::Block, _, Position::Absolute) | + (Display::Block, _, Position::Fixed) => { let construction_result = self.build_flow_for_block(node, None); self.set_flow_construction_result(node, construction_result) } // List items contribute their own special flows. - (display::T::list_item, float_value, _) => { + (Display::ListItem, float_value, _) => { let construction_result = self.build_flow_for_list_item(node, float_value); self.set_flow_construction_result(node, construction_result) } // Inline items that are absolutely-positioned contribute inline fragment construction // results with a hypothetical fragment. - (display::T::inline, _, position::T::absolute) | - (display::T::inline_block, _, position::T::absolute) => { + (Display::Inline, _, Position::Absolute) | + (Display::InlineBlock, _, Position::Absolute) => { let construction_result = self.build_fragment_for_absolutely_positioned_inline(node); self.set_flow_construction_result(node, construction_result) @@ -1534,66 +1540,66 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS // Inline items contribute inline fragment construction results. // // FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content. - (display::T::inline, float::T::none, _) => { + (Display::Inline, Float::None, _) => { let construction_result = self.build_fragments_for_inline(node); self.set_flow_construction_result(node, construction_result) } // Inline-block items contribute inline fragment construction results. - (display::T::inline_block, float::T::none, _) => { + (Display::InlineBlock, Float::None, _) => { let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, - display::T::inline_block); + Display::InlineBlock); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_caption, _, _) => { + (Display::TableCaption, _, _) => { let construction_result = self.build_flow_for_table_caption(node); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_column_group, _, _) => { + (Display::TableColumnGroup, _, _) => { let construction_result = self.build_flow_for_table_colgroup(node); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_column, _, _) => { + (Display::TableColumn, _, _) => { let construction_result = self.build_fragments_for_table_column(node); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_row_group, _, _) | - (display::T::table_header_group, _, _) | - (display::T::table_footer_group, _, _) => { + (Display::TableRowGroup, _, _) | + (Display::TableHeaderGroup, _, _) | + (Display::TableFooterGroup, _, _) => { let construction_result = self.build_flow_for_table_rowgroup(node); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_row, _, _) => { + (Display::TableRow, _, _) => { let construction_result = self.build_flow_for_table_row(node); self.set_flow_construction_result(node, construction_result) } // Table items contribute table flow construction results. - (display::T::table_cell, _, _) => { + (Display::TableCell, _, _) => { let construction_result = self.build_flow_for_table_cell(node); self.set_flow_construction_result(node, construction_result) } // Flex items contribute flex flow construction results. - (display::T::flex, float_value, _) => { + (Display::Flex, float_value, _) => { let float_kind = FloatKind::from_property(float_value); let construction_result = self.build_flow_for_flex(node, float_kind); self.set_flow_construction_result(node, construction_result) } - (display::T::inline_flex, _, _) => { + (Display::InlineFlex, _, _) => { let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, - display::T::inline_flex); + Display::InlineFlex); self.set_flow_construction_result(node, construction_result) } @@ -1810,16 +1816,16 @@ fn bidi_control_chars(style: &ServoArc<ComputedValues>) -> Option<(&'static str, // See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi match (unicode_bidi, direction) { - (normal, _) => None, - (embed, ltr) => Some(("\u{202A}", "\u{202C}")), - (embed, rtl) => Some(("\u{202B}", "\u{202C}")), - (isolate, ltr) => Some(("\u{2066}", "\u{2069}")), - (isolate, rtl) => Some(("\u{2067}", "\u{2069}")), - (bidi_override, ltr) => Some(("\u{202D}", "\u{202C}")), - (bidi_override, rtl) => Some(("\u{202E}", "\u{202C}")), - (isolate_override, ltr) => Some(("\u{2068}\u{202D}", "\u{202C}\u{2069}")), - (isolate_override, rtl) => Some(("\u{2068}\u{202E}", "\u{202C}\u{2069}")), - (plaintext, _) => Some(("\u{2068}", "\u{2069}")), + (Normal, _) => None, + (Embed, Ltr) => Some(("\u{202A}", "\u{202C}")), + (Embed, Rtl) => Some(("\u{202B}", "\u{202C}")), + (Isolate, Ltr) => Some(("\u{2066}", "\u{2069}")), + (Isolate, Rtl) => Some(("\u{2067}", "\u{2069}")), + (BidiOverride, Ltr) => Some(("\u{202D}", "\u{202C}")), + (BidiOverride, Rtl) => Some(("\u{202E}", "\u{202C}")), + (IsolateOverride, Ltr) => Some(("\u{2068}\u{202D}", "\u{202C}\u{2069}")), + (IsolateOverride, Rtl) => Some(("\u{2068}\u{202E}", "\u{202C}\u{2069}")), + (Plaintext, _) => Some(("\u{2068}", "\u{2069}")), } } |