aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-08-18 16:56:36 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-08-18 16:58:18 -0700
commitc328c38804da7a95b4f2774ab083ffa9c0bfc244 (patch)
tree25ee1683a6404fbe6386590c4f19c361c5f08a8c
parent19d466b06250f10169e88fc7f0b447c7f2f8209e (diff)
downloadservo-c328c38804da7a95b4f2774ab083ffa9c0bfc244.tar.gz
servo-c328c38804da7a95b4f2774ab083ffa9c0bfc244.zip
layout: Make inline absolute hypothetical boxes not clip their contents.
Improves the logo on ebay.com.
-rw-r--r--components/layout/construct.rs8
-rw-r--r--components/style/properties.mako.rs10
-rw-r--r--tests/ref/basic.list1
-rw-r--r--tests/ref/inline_absolute_hypothetical_clip_a.html15
-rw-r--r--tests/ref/inline_absolute_hypothetical_clip_ref.html16
5 files changed, 49 insertions, 1 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index e90d46a00ca..60a547094b0 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -978,7 +978,13 @@ impl<'a> FlowConstructor<'a> {
let fragment_info = SpecificFragmentInfo::InlineAbsoluteHypothetical(
InlineAbsoluteHypotheticalFragmentInfo::new(block_flow));
- let fragment = Fragment::new(node, fragment_info);
+ let mut style = node.style().clone();
+ properties::modify_style_for_inline_absolute_hypothetical_fragment(&mut style);
+ let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
+ PseudoElementType::Normal,
+ style,
+ node.restyle_damage(),
+ fragment_info);
let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node);
fragment_accumulator.fragments.fragments.push_back(fragment);
diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs
index 74776bdfd5c..bafa23e948b 100644
--- a/components/style/properties.mako.rs
+++ b/components/style/properties.mako.rs
@@ -6533,6 +6533,16 @@ pub fn modify_style_for_input_text(style: &mut Arc<ComputedValues>) {
margin_style.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
}
+/// Adjusts the `clip` property so that an inline absolute hypothetical fragment doesn't clip its
+/// children.
+pub fn modify_style_for_inline_absolute_hypothetical_fragment(style: &mut Arc<ComputedValues>) {
+ if style.get_effects().clip.0.is_some() {
+ let mut style = Arc::make_unique(style);
+ let effects_style = Arc::make_unique(&mut style.effects);
+ effects_style.clip.0 = None
+ }
+}
+
pub fn is_supported_property(property: &str) -> bool {
match_ignore_ascii_case! { property,
% for property in SHORTHANDS + LONGHANDS[:-1]:
diff --git a/tests/ref/basic.list b/tests/ref/basic.list
index 5eba71f26b0..f67e057abc6 100644
--- a/tests/ref/basic.list
+++ b/tests/ref/basic.list
@@ -146,6 +146,7 @@ experimental == iframe/size_attributes_vertical_writing_mode.html iframe/size_at
== img_width_attribute_intrinsic_width_a.html img_width_attribute_intrinsic_width_ref.html
== incremental_float_a.html incremental_float_ref.html
== incremental_inline_layout_a.html incremental_inline_layout_ref.html
+== inline_absolute_hypothetical_clip_a.html inline_absolute_hypothetical_clip_ref.html
!= inline_background_a.html inline_background_ref.html
== inline_block_baseline_a.html inline_block_baseline_ref.html
== inline_block_block_direction_margins_a.html inline_block_block_direction_margins_ref.html
diff --git a/tests/ref/inline_absolute_hypothetical_clip_a.html b/tests/ref/inline_absolute_hypothetical_clip_a.html
new file mode 100644
index 00000000000..7be29db3249
--- /dev/null
+++ b/tests/ref/inline_absolute_hypothetical_clip_a.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<style>
+body {
+ margin: 16px;
+}
+#a {
+ position: relative;
+}
+#b {
+ clip: rect(47px, 118px, 95px, 0);
+ position: absolute;
+}
+</style>
+<a href="http://bogus" id=a><img id=b width=250 src=400x400_green.png>
+
diff --git a/tests/ref/inline_absolute_hypothetical_clip_ref.html b/tests/ref/inline_absolute_hypothetical_clip_ref.html
new file mode 100644
index 00000000000..05f21048b94
--- /dev/null
+++ b/tests/ref/inline_absolute_hypothetical_clip_ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+html, body {
+ margin: 0;
+}
+section {
+ position: absolute;
+ background: lime;
+ top: 63px;
+ width: 118px;
+ height: 48px;
+ left: 16px;
+}
+</style>
+<section></section>
+