From 6496efd0e70940e6d3ed1503308631de95a6751e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 17 Sep 2016 12:04:09 -0700 Subject: [PATCH 1/4] build: Honor SERVO_ENABLE_DEBUG_ASSERTIONS. --- python/servo/build_commands.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 29efd935353..2e2051b44d5 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -216,6 +216,12 @@ class MachCommands(CommandBase): build_start = time() env = self.build_env(target=target, is_build=True) + # TODO: If this ends up making it, we should probably add a + # --release-with-debug-assertions option or similar, so it's easier to + # build locally. + if env.get("SERVO_ENABLE_DEBUG_ASSERTIONS", None): + env["RUSTFLAGS"] = "-C debug_assertions" + if android: # Build OpenSSL for android make_cmd = ["make"] From 3dddb70038deb4a4f41ae5aa6dcbbbfc3cb58a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 26 Sep 2016 09:45:43 +0200 Subject: [PATCH 2/4] script: Fix bogus is_listed_element assertion. --- components/script/dom/htmlformelement.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index a4cb42711d7..8759fbafe5e 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -203,7 +203,8 @@ impl HTMLFormElementMethods for HTMLFormElement { elem.downcast::().unwrap().form_owner() } _ => { - debug_assert!(!elem.downcast::().unwrap().is_listed_element()); + debug_assert!(!elem.downcast::().unwrap().is_listed_element() || + elem.local_name() == &atom!("keygen")); return false; } } From bdf1d179bae0541f53259dc28e5b4bbadaeef47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 26 Sep 2016 12:10:48 +0200 Subject: [PATCH 3/4] layout: Use the fragment's writing mode when computing sizes relevant to that fragment. Otherwise we might mix writing modes. Not totally sure this change is correct in the case we're mixing them, we might need to just not checking that operation. --- components/layout/fragment.rs | 20 +++++++++++++------ components/layout/model.rs | 13 +++++++----- .../style/properties/properties.mako.rs | 9 +++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index f7f46d2fdcc..db5fd265690 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1155,8 +1155,14 @@ impl Fragment { match self.inline_context { None => style_border_width, Some(ref inline_fragment_context) => { + // NOTE: We can have nodes with different writing mode inside + // the inline fragment context, so we need to overwrite the + // writing mode to compute the child logical sizes. + let writing_mode = self.style.writing_mode; + inline_fragment_context.nodes.iter().fold(style_border_width, |accumulator, node| { - let mut this_border_width = node.style.logical_border_width(); + let mut this_border_width = + node.style.border_width_for_writing_mode(writing_mode); if !node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT) { this_border_width.inline_start = Au(0) } @@ -1289,7 +1295,7 @@ impl Fragment { SpecificFragmentInfo::TableRow | SpecificFragmentInfo::TableWrapper | SpecificFragmentInfo::InlineBlock(_) => LogicalMargin::zero(self.style.writing_mode), - _ => model::padding_from_style(self.style(), containing_block_inline_size), + _ => model::padding_from_style(self.style(), containing_block_inline_size, self.style().writing_mode), }; // Compute padding from the inline fragment context. @@ -1301,9 +1307,10 @@ impl Fragment { LogicalMargin::zero(self.style.writing_mode) } (_, &Some(ref inline_fragment_context)) => { - let zero_padding = LogicalMargin::zero(self.style.writing_mode); + let writing_mode = self.style.writing_mode; + let zero_padding = LogicalMargin::zero(writing_mode); inline_fragment_context.nodes.iter().fold(zero_padding, |accumulator, node| { - let mut padding = model::padding_from_style(&*node.style, Au(0)); + let mut padding = model::padding_from_style(&*node.style, Au(0), writing_mode); if !node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT) { padding.inline_start = Au(0) } @@ -1529,11 +1536,12 @@ impl Fragment { // Take borders and padding for parent inline fragments into account, if necessary. if self.is_primary_fragment() { + let writing_mode = self.style.writing_mode; if let Some(ref context) = self.inline_context { for node in &context.nodes { let mut border_width = node.style.logical_border_width(); - let mut padding = model::padding_from_style(&*node.style, Au(0)); - let mut margin = model::specified_margin_from_style(&*node.style); + let mut padding = model::padding_from_style(&*node.style, Au(0), writing_mode); + let mut margin = model::specified_margin_from_style(&*node.style, writing_mode); if !node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT) { border_width.inline_start = Au(0); padding.inline_start = Au(0); diff --git a/components/layout/model.rs b/components/layout/model.rs index a336c7ecf93..823ca6469d3 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -12,7 +12,7 @@ use fragment::Fragment; use std::cmp::{max, min}; use std::fmt; use style::computed_values::transform::ComputedMatrix; -use style::logical_geometry::LogicalMargin; +use style::logical_geometry::{LogicalMargin, WritingMode}; use style::properties::ServoComputedValues; use style::values::computed::{BorderRadiusSize, LengthOrPercentageOrAuto}; use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone}; @@ -463,10 +463,12 @@ pub fn specified_border_radius(radius: BorderRadiusSize, containing_length: Au) } #[inline] -pub fn padding_from_style(style: &ServoComputedValues, containing_block_inline_size: Au) +pub fn padding_from_style(style: &ServoComputedValues, + containing_block_inline_size: Au, + writing_mode: WritingMode) -> LogicalMargin { let padding_style = style.get_padding(); - LogicalMargin::from_physical(style.writing_mode, SideOffsets2D::new( + LogicalMargin::from_physical(writing_mode, SideOffsets2D::new( specified(padding_style.padding_top, containing_block_inline_size), specified(padding_style.padding_right, containing_block_inline_size), specified(padding_style.padding_bottom, containing_block_inline_size), @@ -478,9 +480,10 @@ pub fn padding_from_style(style: &ServoComputedValues, containing_block_inline_s /// /// This is used when calculating intrinsic inline sizes. #[inline] -pub fn specified_margin_from_style(style: &ServoComputedValues) -> LogicalMargin { +pub fn specified_margin_from_style(style: &ServoComputedValues, + writing_mode: WritingMode) -> LogicalMargin { let margin_style = style.get_margin(); - LogicalMargin::from_physical(style.writing_mode, SideOffsets2D::new( + LogicalMargin::from_physical(writing_mode, SideOffsets2D::new( MaybeAuto::from_style(margin_style.margin_top, Au(0)).specified_or_zero(), MaybeAuto::from_style(margin_style.margin_right, Au(0)).specified_or_zero(), MaybeAuto::from_style(margin_style.margin_bottom, Au(0)).specified_or_zero(), diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index e55d3d1c06d..4629ed49be3 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1526,9 +1526,9 @@ impl ComputedValues { } #[inline] - pub fn logical_border_width(&self) -> LogicalMargin { + pub fn border_width_for_writing_mode(&self, writing_mode: WritingMode) -> LogicalMargin { let border_style = self.get_border(); - LogicalMargin::from_physical(self.writing_mode, SideOffsets2D::new( + LogicalMargin::from_physical(writing_mode, SideOffsets2D::new( border_style.border_top_width, border_style.border_right_width, border_style.border_bottom_width, @@ -1536,6 +1536,11 @@ impl ComputedValues { )) } + #[inline] + pub fn logical_border_width(&self) -> LogicalMargin { + self.border_width_for_writing_mode(self.writing_mode) + } + #[inline] pub fn logical_margin(&self) -> LogicalMargin { let margin_style = self.get_margin(); From fdd84713105b5c87f7adde1319711966d00e5b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 26 Sep 2016 17:28:35 +0200 Subject: [PATCH 4/4] script: Prevent an integer overflow that was hitting us on htmlimageelement.rs --- components/script/dom/htmlimageelement.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 9236c75c699..b9b1c95d72e 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use app_units::Au; +use app_units::{Au, AU_PER_PX}; use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; @@ -28,6 +28,7 @@ use net_traits::image_cache_thread::{ImageResponder, ImageResponse}; use script_runtime::CommonScriptMsg; use script_runtime::ScriptThreadEventCategory::UpdateReplacedElement; use script_thread::Runnable; +use std::i32; use std::sync::Arc; use string_cache::Atom; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; @@ -442,7 +443,19 @@ fn image_dimension_setter(element: &Element, attr: Atom, value: u32) { } else { value }; - let dim = LengthOrPercentageOrAuto::Length(Au::from_px(value as i32)); + + // FIXME: There are probably quite a few more cases of this. This is the + // only overflow that was hitting on automation, but we should consider what + // to do in the general case case. + // + // See + let pixel_value = if value > (i32::MAX / AU_PER_PX) as u32 { + 0 + } else { + value + }; + + let dim = LengthOrPercentageOrAuto::Length(Au::from_px(pixel_value as i32)); let value = AttrValue::Dimension(value.to_string(), dim); element.set_attribute(&attr, value); }