diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 4d78afd8c46..dfe649a0ca7 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -235,7 +235,7 @@ impl FontHandleMethods for FontHandle { } } - let average_advance = self.glyph_index('x') + let average_advance = self.glyph_index('0') .and_then(|idx| self.glyph_h_advance(idx)) .map(|advance| self.font_units_to_au(advance)) .unwrap_or(max_advance_width); diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index ad3d5bd1b29..dd48e797cd1 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -154,7 +154,7 @@ impl FontHandleMethods for FontHandle { let line_gap = (ascent + descent + leading + 0.5).floor(); let max_advance_width = Au::from_pt(bounding_rect.size.width as f64); - let average_advance = self.glyph_index('x') + let average_advance = self.glyph_index('0') .and_then(|idx| self.glyph_h_advance(idx)) .map(|advance| Au::from_frac_px(advance)) .unwrap_or(max_advance_width); diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 24d85b7fece..2897f04fa43 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -226,10 +226,10 @@ 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(node.get_input_checked()), + Some("checkbox") => InputCheckbox, Some("button") | Some("submit") | Some("reset") => InputButton(node.get_input_value().len() as u32), - Some("radio") => InputRadioButton(node.get_input_checked()), + Some("radio") => InputRadioButton, Some("file") => InputFile(node.get_input_size()), _ => InputText(node.get_input_size()), }; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 010d26f98e0..0be128ccb27 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -161,8 +161,8 @@ impl InlineBlockFragmentInfo { pub enum InputFragmentInfo { InputButton(u32), InputText(u32), - InputCheckbox(bool), - InputRadioButton(bool), + InputCheckbox, + InputRadioButton, InputFile(u32), } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 5c634ab3caf..eb1be0b09de 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -731,16 +731,6 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { } } - pub fn get_input_checked(&self) -> bool { - unsafe { - if !self.get().is_htmlinputelement() { - fail!("not an input element!") - } - let input: JS = self.get_jsmanaged().transmute_copy(); - input.get_checked_for_layout() - } - } - pub fn get_input_value(&self) -> String { unsafe { if !self.get().is_htmlinputelement() { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 251a0dd0439..8c50c6519a0 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -81,17 +81,11 @@ impl HTMLInputElement { } pub trait LayoutHTMLInputElementHelpers { - unsafe fn get_checked_for_layout(&self) -> bool; unsafe fn get_value_for_layout(&self) -> String; unsafe fn get_size_for_layout(&self) -> u32; } impl LayoutHTMLInputElementHelpers for JS { - #[allow(unrooted_must_root)] - unsafe fn get_checked_for_layout(&self) -> bool { - (*self.unsafe_get()).checked.get() - } - #[allow(unrooted_must_root)] unsafe fn get_value_for_layout(&self) -> String { unsafe fn get_raw_value(input: &JS) -> Option { @@ -99,16 +93,7 @@ impl LayoutHTMLInputElementHelpers for JS { } match (*self.unsafe_get()).input_type.get() { - InputCheckbox => if self.get_checked_for_layout() { - "[X]" - } else { - "[ ]" - }.to_string(), - InputRadio => if self.get_checked_for_layout() { - "(*)" - } else { - "( )" - }.to_string(), + InputCheckbox | InputRadio => "".to_string(), InputFile | InputImage => "".to_string(), InputButton(ref default) => get_raw_value(self) .or_else(|| default.map(|v| v.to_string())) @@ -117,7 +102,7 @@ impl LayoutHTMLInputElementHelpers for JS { let raw = get_raw_value(self).unwrap_or_else(|| "".to_string()); String::from_char(raw.len(), '*') } - _ => get_raw_value(self).unwrap_or("".to_string()), + _ => get_raw_value(self).unwrap_or_else(|| "".to_string()), } } @@ -369,9 +354,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> { if "click" == event.Type().as_slice() && !event.DefaultPrevented() { match self.input_type.get() { - InputCheckbox | InputRadio => { - self.SetChecked(!self.checked.get()); - } + InputCheckbox => self.SetChecked(!self.checked.get()), + InputRadio => self.SetChecked(true), _ => {} } } diff --git a/components/style/user-agent.css b/components/style/user-agent.css index a9def733ef2..4ca752f344d 100644 --- a/components/style/user-agent.css +++ b/components/style/user-agent.css @@ -123,3 +123,8 @@ input[type="reset"] { background: lightgrey; border-top: solid 1px #EEEEEE; input[type="hidden"] { display: none !important } input[type="checkbox"], input[type="radio"] { font-family: monospace !important; border: none !important; background: transparent; } + +input[type="checkbox"]::before { content: "[ ]"; padding: 0; } +input[type="checkbox"][checked]::before { content: "[✓]"; } +input[type="radio"]::before { content: "( )"; padding: 0; } +input[type="radio"][checked]::before { content: "(●)"; }