mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
servo: Merge #7181 - layout: Stop double-counting inline margins on <input type=button>
and friends (from pcwalton:input-button-margins); r=mbrubeck
Improves the Google home page. r? @mbrubeck Source-Repo: https://github.com/servo/servo Source-Revision: 94c8dcd575a5187e02ec043c686b1cdfa6b30ba6
This commit is contained in:
parent
e54fe99057
commit
9f2164d29e
@ -673,11 +673,13 @@ impl<'a> FlowConstructor<'a> {
|
||||
fn build_flow_for_block_like(&mut self, flow: FlowRef, node: &ThreadSafeLayoutNode)
|
||||
-> ConstructionResult {
|
||||
let mut initial_fragments = IntermediateInlineFragments::new();
|
||||
if node.get_pseudo_element_type() != PseudoElementType::Normal ||
|
||||
let node_is_input_or_text_area =
|
||||
node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLInputElement))) ||
|
||||
node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLTextAreaElement))) {
|
||||
HTMLElementTypeId::HTMLTextAreaElement)));
|
||||
if node.get_pseudo_element_type() != PseudoElementType::Normal ||
|
||||
node_is_input_or_text_area {
|
||||
// A TextArea's text contents are displayed through the input text
|
||||
// box, so don't construct them.
|
||||
if node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
@ -687,9 +689,12 @@ impl<'a> FlowConstructor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
self.create_fragments_for_node_text_content(&mut initial_fragments,
|
||||
node,
|
||||
&*node.style());
|
||||
let mut style = node.style().clone();
|
||||
if node_is_input_or_text_area {
|
||||
properties::modify_style_for_input_text(&mut style);
|
||||
}
|
||||
|
||||
self.create_fragments_for_node_text_content(&mut initial_fragments, node, &style)
|
||||
}
|
||||
|
||||
self.build_flow_for_block_starting_with_fragments(flow, node, initial_fragments)
|
||||
|
@ -6518,6 +6518,19 @@ pub fn modify_style_for_text(style: &mut Arc<ComputedValues>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Adjusts the `margin` property as necessary to account for the text of an `input` element.
|
||||
///
|
||||
/// Margins apply to the `input` element itself, so including them in the text will cause them to
|
||||
/// be double-counted.
|
||||
pub fn modify_style_for_input_text(style: &mut Arc<ComputedValues>) {
|
||||
let mut style = Arc::make_unique(style);
|
||||
let margin_style = Arc::make_unique(&mut style.margin);
|
||||
margin_style.margin_top = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin_style.margin_right = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin_style.margin_bottom = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
margin_style.margin_left = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
}
|
||||
|
||||
pub fn is_supported_property(property: &str) -> bool {
|
||||
match_ignore_ascii_case! { property,
|
||||
% for property in SHORTHANDS + LONGHANDS[:-1]:
|
||||
|
Loading…
Reference in New Issue
Block a user