mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #19957 - gootorov:move-counter-from-mako, r=emilio
style: Move content property out of mako. <!-- Please describe your changes on the following line: --> r? emilio --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19936 (github issue number if applicable). <!-- Either: --> - [x] These changes do not require tests <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19957) <!-- Reviewable:end -->
This commit is contained in:
commit
804b4b3db6
11 changed files with 302 additions and 281 deletions
|
@ -37,14 +37,12 @@ use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
|
|||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
use servo_config::opts;
|
||||
use servo_url::ServoUrl;
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::LinkedList;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use style::computed_values::caption_side::T as CaptionSide;
|
||||
use style::computed_values::content::ContentItem;
|
||||
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;
|
||||
|
@ -58,6 +56,7 @@ use style::properties::longhands::list_style_image;
|
|||
use style::selector_parser::{PseudoElement, RestyleDamage};
|
||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||
use style::values::Either;
|
||||
use style::values::computed::counters::ContentItem;
|
||||
use table::TableFlow;
|
||||
use table_caption::TableCaptionFlow;
|
||||
use table_cell::TableCellFlow;
|
||||
|
@ -598,7 +597,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
// Add whitespace results. They will be stripped out later on when
|
||||
// between block elements, and retained when between inline elements.
|
||||
let fragment_info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(" ".to_owned(), None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(" "), None))
|
||||
);
|
||||
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
|
||||
whitespace_pseudo,
|
||||
|
@ -754,7 +753,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
ContentItem::String(string) => {
|
||||
let info = Box::new(UnscannedTextFragmentInfo::new(string, None));
|
||||
SpecificFragmentInfo::UnscannedText(info)
|
||||
}
|
||||
},
|
||||
content_item => {
|
||||
let content_item = Box::new(GeneratedContentInfo::ContentItem(content_item));
|
||||
SpecificFragmentInfo::GeneratedContent(content_item)
|
||||
|
@ -873,7 +872,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
whitespace_damage)) => {
|
||||
// Instantiate the whitespace fragment.
|
||||
let fragment_info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(" ".to_owned(), None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(" "), None))
|
||||
);
|
||||
let fragment =
|
||||
Fragment::from_opaque_node_and_style(whitespace_node,
|
||||
|
@ -895,7 +894,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
if is_empty && node_style.has_padding_or_border() {
|
||||
// An empty inline box needs at least one fragment to draw its background and borders.
|
||||
let info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(String::new(), None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(""), None))
|
||||
);
|
||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
node.get_pseudo_element_type(),
|
||||
|
@ -1296,7 +1295,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
unscanned_marker_fragments.push_back(Fragment::new(
|
||||
node,
|
||||
SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(text, None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(text), None))
|
||||
),
|
||||
self.layout_context));
|
||||
let marker_fragments =
|
||||
|
@ -1899,7 +1898,7 @@ where
|
|||
E: TElement,
|
||||
{
|
||||
let info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(String::from(text), None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(Box::<str>::from(text), None))
|
||||
);
|
||||
let text_style = context.stylist.style_for_anonymous::<E>(
|
||||
&context.guards,
|
||||
|
|
|
@ -44,7 +44,6 @@ use style::computed_values::border_collapse::T as BorderCollapse;
|
|||
use style::computed_values::box_sizing::T as BoxSizing;
|
||||
use style::computed_values::clear::T as Clear;
|
||||
use style::computed_values::color::T as Color;
|
||||
use style::computed_values::content::ContentItem;
|
||||
use style::computed_values::display::T as Display;
|
||||
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
||||
use style::computed_values::overflow_wrap::T as OverflowWrap;
|
||||
|
@ -61,6 +60,7 @@ use style::servo::restyle_damage::ServoRestyleDamage;
|
|||
use style::str::char_is_whitespace;
|
||||
use style::values::{self, Either, Auto};
|
||||
use style::values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::counters::ContentItem;
|
||||
use style::values::generics::box_::VerticalAlign;
|
||||
use style::values::generics::transform;
|
||||
use text;
|
||||
|
@ -570,9 +570,9 @@ pub struct UnscannedTextFragmentInfo {
|
|||
impl UnscannedTextFragmentInfo {
|
||||
/// Creates a new instance of `UnscannedTextFragmentInfo` from the given text.
|
||||
#[inline]
|
||||
pub fn new(text: String, selection: Option<Range<ByteIndex>>) -> UnscannedTextFragmentInfo {
|
||||
pub fn new(text: Box<str>, selection: Option<Range<ByteIndex>>) -> UnscannedTextFragmentInfo {
|
||||
UnscannedTextFragmentInfo {
|
||||
text: text.into_boxed_str(),
|
||||
text: text,
|
||||
selection: selection,
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ impl Fragment {
|
|||
let mut ellipsis_fragment = self.transform(
|
||||
self.border_box.size,
|
||||
SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(text_overflow_string, None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(text_overflow_string.into_boxed_str(), None))
|
||||
)
|
||||
);
|
||||
unscanned_ellipsis_fragments.push_back(ellipsis_fragment);
|
||||
|
|
|
@ -15,12 +15,12 @@ use gfx::display_list::OpaqueNode;
|
|||
use script_layout_interface::wrapper_traits::PseudoElementType;
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::{HashMap, LinkedList};
|
||||
use style::computed_values::content::ContentItem;
|
||||
use style::computed_values::display::T as Display;
|
||||
use style::computed_values::list_style_type::T as ListStyleType;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||
use style::values::computed::counters::ContentItem;
|
||||
use text::TextRunScanner;
|
||||
use traversal::InorderFlowTraversal;
|
||||
|
||||
|
@ -189,7 +189,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
let temporary_counter = Counter::new();
|
||||
let counter = self.traversal
|
||||
.counters
|
||||
.get(&*counter_name)
|
||||
.get(&**counter_name)
|
||||
.unwrap_or(&temporary_counter);
|
||||
new_info = counter.render(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
|
@ -204,7 +204,7 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
|
|||
let temporary_counter = Counter::new();
|
||||
let counter = self.traversal
|
||||
.counters
|
||||
.get(&*counter_name)
|
||||
.get(&**counter_name)
|
||||
.unwrap_or(&temporary_counter);
|
||||
new_info = counter.render(self.traversal.layout_context,
|
||||
fragment.node,
|
||||
|
@ -437,7 +437,7 @@ fn render_text(layout_context: &LayoutContext,
|
|||
-> Option<SpecificFragmentInfo> {
|
||||
let mut fragments = LinkedList::new();
|
||||
let info = SpecificFragmentInfo::UnscannedText(
|
||||
Box::new(UnscannedTextFragmentInfo::new(string, None))
|
||||
Box::new(UnscannedTextFragmentInfo::new(string.into_boxed_str(), None))
|
||||
);
|
||||
fragments.push_back(Fragment::from_opaque_node_and_style(node,
|
||||
pseudo,
|
||||
|
|
|
@ -532,7 +532,7 @@ fn split_first_fragment_at_newline_if_necessary(fragments: &mut LinkedList<Fragm
|
|||
first_fragment.transform(
|
||||
first_fragment.border_box.size,
|
||||
SpecificFragmentInfo::UnscannedText(Box::new(
|
||||
UnscannedTextFragmentInfo::new(string_before, selection_before)
|
||||
UnscannedTextFragmentInfo::new(string_before.into_boxed_str(), selection_before)
|
||||
))
|
||||
)
|
||||
};
|
||||
|
|
|
@ -34,9 +34,9 @@ use atomic_refcell::{AtomicRef, AtomicRefMut};
|
|||
use data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
|
||||
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
use script_layout_interface::wrapper_traits::GetLayoutData;
|
||||
use style::computed_values::content::{self, ContentItem};
|
||||
use style::dom::{NodeInfo, TNode};
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::values::computed::counters::{Content, ContentItem};
|
||||
|
||||
pub trait LayoutNodeLayoutData {
|
||||
/// Similar to borrow_data*, but returns the full PersistentLayoutData rather
|
||||
|
@ -114,14 +114,14 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T {
|
|||
let style = self.as_element().unwrap().resolved_style();
|
||||
|
||||
return match style.as_ref().get_counters().content {
|
||||
content::T::Items(ref value) if !value.is_empty() => {
|
||||
TextContent::GeneratedContent((*value).clone())
|
||||
Content::Items(ref value) if !value.is_empty() => {
|
||||
TextContent::GeneratedContent((*value).to_vec())
|
||||
}
|
||||
_ => TextContent::GeneratedContent(vec![]),
|
||||
};
|
||||
}
|
||||
|
||||
return TextContent::Text(self.node_text_content());
|
||||
TextContent::Text(self.node_text_content().into_boxed_str())
|
||||
}
|
||||
|
||||
fn restyle_damage(self) -> RestyleDamage {
|
||||
|
@ -156,7 +156,7 @@ impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T {
|
|||
}
|
||||
|
||||
pub enum TextContent {
|
||||
Text(String),
|
||||
Text(Box<str>),
|
||||
GeneratedContent(Vec<ContentItem>),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue