mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Miscellaneous Servo build fixes.
This commit is contained in:
parent
18cda1567a
commit
e227715aee
12 changed files with 59 additions and 10 deletions
|
@ -840,7 +840,10 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
|
|
||||||
match text_content {
|
match text_content {
|
||||||
TextContent::Text(string) => {
|
TextContent::Text(string) => {
|
||||||
let info = Box::new(UnscannedTextFragmentInfo::new(string, node.selection()));
|
let info = Box::new(UnscannedTextFragmentInfo::new(
|
||||||
|
string.into(),
|
||||||
|
node.selection(),
|
||||||
|
));
|
||||||
let specific_fragment_info = SpecificFragmentInfo::UnscannedText(info);
|
let specific_fragment_info = SpecificFragmentInfo::UnscannedText(info);
|
||||||
fragments
|
fragments
|
||||||
.fragments
|
.fragments
|
||||||
|
@ -857,7 +860,8 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
for content_item in content_items.into_iter() {
|
for content_item in content_items.into_iter() {
|
||||||
let specific_fragment_info = match content_item {
|
let specific_fragment_info = match content_item {
|
||||||
ContentItem::String(string) => {
|
ContentItem::String(string) => {
|
||||||
let info = Box::new(UnscannedTextFragmentInfo::new(string, None));
|
let info =
|
||||||
|
Box::new(UnscannedTextFragmentInfo::new(string.into(), None));
|
||||||
SpecificFragmentInfo::UnscannedText(info)
|
SpecificFragmentInfo::UnscannedText(info)
|
||||||
},
|
},
|
||||||
content_item => {
|
content_item => {
|
||||||
|
|
|
@ -95,7 +95,7 @@ impl ToLayout for TransformStyle {
|
||||||
type Type = wr::TransformStyle;
|
type Type = wr::TransformStyle;
|
||||||
fn to_layout(&self) -> Self::Type {
|
fn to_layout(&self) -> Self::Type {
|
||||||
match *self {
|
match *self {
|
||||||
TransformStyle::Auto | TransformStyle::Flat => wr::TransformStyle::Flat,
|
TransformStyle::Flat => wr::TransformStyle::Flat,
|
||||||
TransformStyle::Preserve3d => wr::TransformStyle::Preserve3D,
|
TransformStyle::Preserve3d => wr::TransformStyle::Preserve3D,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ impl Flow for TableFlow {
|
||||||
percentage: match *specified_inline_size {
|
percentage: match *specified_inline_size {
|
||||||
Size::Auto => 0.0,
|
Size::Auto => 0.0,
|
||||||
Size::LengthPercentage(ref lp) => {
|
Size::LengthPercentage(ref lp) => {
|
||||||
lp.0.as_percentage().map_or(0.0, |p| p.0)
|
lp.0.to_percentage().map_or(0.0, |p| p.0)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
preferred: Au(0),
|
preferred: Au(0),
|
||||||
|
|
|
@ -437,7 +437,7 @@ impl Flow for TableRowFlow {
|
||||||
.unwrap_or(child_base.intrinsic_inline_sizes.minimum_inline_size),
|
.unwrap_or(child_base.intrinsic_inline_sizes.minimum_inline_size),
|
||||||
percentage: match child_specified_inline_size {
|
percentage: match child_specified_inline_size {
|
||||||
Size::Auto => 0.0,
|
Size::Auto => 0.0,
|
||||||
Size::LengthPercentage(ref lp) => lp.0.as_percentage().map_or(0.0, |p| p.0),
|
Size::LengthPercentage(ref lp) => lp.0.to_percentage().map_or(0.0, |p| p.0),
|
||||||
},
|
},
|
||||||
preferred: child_base.intrinsic_inline_sizes.preferred_inline_size,
|
preferred: child_base.intrinsic_inline_sizes.preferred_inline_size,
|
||||||
constrained: match child_specified_inline_size {
|
constrained: match child_specified_inline_size {
|
||||||
|
|
|
@ -117,12 +117,12 @@ impl BoxContentSizes {
|
||||||
.auto_is(Length::zero);
|
.auto_is(Length::zero);
|
||||||
let max_inline_size = match style.max_box_size().inline {
|
let max_inline_size = match style.max_box_size().inline {
|
||||||
MaxSize::None => None,
|
MaxSize::None => None,
|
||||||
MaxSize::LengthPercentage(ref lp) => lp.as_length(),
|
MaxSize::LengthPercentage(ref lp) => lp.to_length(),
|
||||||
};
|
};
|
||||||
let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size);
|
let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size);
|
||||||
|
|
||||||
// Percentages for 'width' are treated as 'auto'
|
// Percentages for 'width' are treated as 'auto'
|
||||||
let inline_size = inline_size.map(|lp| lp.as_length());
|
let inline_size = inline_size.map(|lp| lp.to_length());
|
||||||
// The (inner) min/max-content are only used for 'auto'
|
// The (inner) min/max-content are only used for 'auto'
|
||||||
let mut outer = match inline_size.non_auto().flatten() {
|
let mut outer = match inline_size.non_auto().flatten() {
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl ComputedValuesExt for ComputedValues {
|
||||||
} else {
|
} else {
|
||||||
&position.height
|
&position.height
|
||||||
};
|
};
|
||||||
matches!(size, Size::LengthPercentage(lp) if lp.0.as_length().is_some())
|
matches!(size, Size::LengthPercentage(lp) if lp.0.to_length().is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_box_offsets_are_both_non_auto(&self) -> bool {
|
fn inline_box_offsets_are_both_non_auto(&self) -> bool {
|
||||||
|
|
|
@ -2902,6 +2902,7 @@ pub struct ComputedValues {
|
||||||
|
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
/// Returns the pseudo-element that this style represents.
|
/// Returns the pseudo-element that this style represents.
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
pub fn pseudo(&self) -> Option<<&PseudoElement> {
|
pub fn pseudo(&self) -> Option<<&PseudoElement> {
|
||||||
self.pseudo.as_ref()
|
self.pseudo.as_ref()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1718,6 +1718,7 @@ impl Clone for StrongRuleNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for StrongRuleNode {
|
impl Drop for StrongRuleNode {
|
||||||
|
#[cfg_attr(feature = "servo", allow(unused_mut))]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let node = unsafe { &*self.ptr() };
|
let node = unsafe { &*self.ptr() };
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,19 @@ impl LengthPercentage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts to a `<percentage>` if possible.
|
||||||
|
#[inline]
|
||||||
|
pub fn to_percentage(&self) -> Option<Percentage> {
|
||||||
|
match self.unpack() {
|
||||||
|
Unpacked::Length(..) => None,
|
||||||
|
Unpacked::Percentage(p) => Some(p),
|
||||||
|
Unpacked::Calc(ref c) => {
|
||||||
|
debug_assert!(!c.length.is_zero());
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the specified percentage if any.
|
/// Return the specified percentage if any.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn specified_percentage(&self) -> Option<Percentage> {
|
pub fn specified_percentage(&self) -> Option<Percentage> {
|
||||||
|
@ -405,7 +418,7 @@ impl LengthPercentage {
|
||||||
|
|
||||||
/// Convert the computed value into used value.
|
/// Convert the computed value into used value.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn maybe_to_used_value(&self, container_len: Option<Length>) -> Option<Au> {
|
pub fn maybe_to_used_value(&self, container_len: Option<Length>) -> Option<Au> {
|
||||||
self.maybe_percentage_relative_to(container_len).map(Au::from)
|
self.maybe_percentage_relative_to(container_len).map(Au::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,8 +168,9 @@ pub enum GenericContent<ImageUrl> {
|
||||||
pub use self::GenericContent as Content;
|
pub use self::GenericContent as Content;
|
||||||
|
|
||||||
impl<ImageUrl> Content<ImageUrl> {
|
impl<ImageUrl> Content<ImageUrl> {
|
||||||
|
/// Whether `self` represents list of items.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn is_items(&self) -> bool {
|
pub fn is_items(&self) -> bool {
|
||||||
matches!(*self, Self::Items(..))
|
matches!(*self, Self::Items(..))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ impl Parse for Content {
|
||||||
// normal | none | [ <string> | <counter> | open-quote | close-quote | no-open-quote |
|
// normal | none | [ <string> | <counter> | open-quote | close-quote | no-open-quote |
|
||||||
// no-close-quote ]+
|
// no-close-quote ]+
|
||||||
// TODO: <uri>, attr(<identifier>)
|
// TODO: <uri>, attr(<identifier>)
|
||||||
|
#[cfg_attr(feature = "servo", allow(unused_mut))]
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
|
|
|
@ -38,6 +38,34 @@ impl DerefMut for OwnedStr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl OwnedStr {
|
||||||
|
/// Convert the OwnedStr into a boxed str.
|
||||||
|
#[inline]
|
||||||
|
pub fn into_box(self) -> Box<str> {
|
||||||
|
self.into_string().into_boxed_str()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert the OwnedStr into a `String`.
|
||||||
|
#[inline]
|
||||||
|
pub fn into_string(self) -> String {
|
||||||
|
unsafe { String::from_utf8_unchecked(self.0.into_vec()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OwnedStr> for String {
|
||||||
|
#[inline]
|
||||||
|
fn from(b: OwnedStr) -> Self {
|
||||||
|
b.into_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OwnedStr> for Box<str> {
|
||||||
|
#[inline]
|
||||||
|
fn from(b: OwnedStr) -> Self {
|
||||||
|
b.into_box()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<Box<str>> for OwnedStr {
|
impl From<Box<str>> for OwnedStr {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(b: Box<str>) -> Self {
|
fn from(b: Box<str>) -> Self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue