aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout/construct.rs16
-rw-r--r--components/layout/fragment.rs26
2 files changed, 13 insertions, 29 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 2897f04fa43..818fa1602e6 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -31,8 +31,8 @@ use fragment::{InlineBlockFragment, InlineBlockFragmentInfo, InputFragment};
use fragment::{Fragment, GenericFragment, IframeFragment, IframeFragmentInfo};
use fragment::{ImageFragment, ImageFragmentInfo, SpecificFragmentInfo, TableFragment};
use fragment::{TableCellFragment, TableColumnFragment, TableColumnFragmentInfo};
-use fragment::{TableRowFragment, TableWrapperFragment, UnscannedTextFragment, InputRadioButton};
-use fragment::{UnscannedTextFragmentInfo, InputCheckbox, InputButton, InputText, InputFile};
+use fragment::{TableRowFragment, TableWrapperFragment, UnscannedTextFragment};
+use fragment::{UnscannedTextFragmentInfo, InputFragmentInfo};
use inline::{InlineFragments, InlineFlow};
use parallel;
use table_wrapper::TableWrapperFlow;
@@ -226,14 +226,14 @@ impl<'a> FlowConstructor<'a> {
// value? definitely for string comparisons.
let elem = node.as_element();
let data = match elem.get_attr(&ns!(""), "type") {
- Some("checkbox") => InputCheckbox,
+ Some("checkbox") | Some("radio") => None,
Some("button") | Some("submit") | Some("reset") =>
- InputButton(node.get_input_value().len() as u32),
- Some("radio") => InputRadioButton,
- Some("file") => InputFile(node.get_input_size()),
- _ => InputText(node.get_input_size()),
+ Some(node.get_input_value().len() as u32),
+ Some("file") => Some(node.get_input_size()),
+ _ => Some(node.get_input_size()),
};
- InputFragment(data)
+ data.map(|size| InputFragment(InputFragmentInfo { size: size }))
+ .unwrap_or(GenericFragment)
}
/// Builds specific `Fragment` info for the given node.
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 0be128ccb27..7c2ef5c4a05 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -158,33 +158,17 @@ impl InlineBlockFragmentInfo {
/// A fragment that represents a displayable form element
#[deriving(Clone)]
-pub enum InputFragmentInfo {
- InputButton(u32),
- InputText(u32),
- InputCheckbox,
- InputRadioButton,
- InputFile(u32),
+pub struct InputFragmentInfo {
+ pub size: u32,
}
impl InputFragmentInfo {
- fn size(&self) -> Option<u32> {
- match self {
- &InputText(size) | &InputFile(size) | &InputButton(size) => Some(size),
- _ => None,
- }
- }
-
/// Returns the original inline-size of the input.
fn input_inline_size(&self, font_style: &FontStyle, layout_context: &LayoutContext) -> Au {
- match self.size() {
- Some(size) => {
- let metrics = text::font_metrics_for_style(layout_context.font_context(), font_style);
+ let metrics = text::font_metrics_for_style(layout_context.font_context(), font_style);
- // https://html.spec.whatwg.org/#converting-a-character-width-to-pixels
- metrics.average_advance * (size as i32 - 1) + metrics.max_advance
- }
- None => Au::from_px(10)
- }
+ // https://html.spec.whatwg.org/#converting-a-character-width-to-pixels
+ metrics.average_advance * (self.size as i32 - 1) + metrics.max_advance
}
}