mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement non-zero dimension attribute parsing
Fixes #8445 The only attributes I found that we have implemented that uses non-zero dimenion attributes: * `width` for `<td>` and `<th>` (table cells) * `width` for `<table>` I updated these implementations to use the new non-zero dimension attribute parsing and added associated regression tests.
This commit is contained in:
parent
dafdc856ac
commit
ba659cb99c
13 changed files with 227 additions and 291 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use cssparser::{self, Color, RGBA};
|
||||
use euclid::num::Zero;
|
||||
use js::conversions::{FromJSValConvertible, ToJSValConvertible, latin1_to_string};
|
||||
use js::jsapi::{JSContext, JSString, HandleValue, MutableHandleValue};
|
||||
use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_StringHasLatin1Chars};
|
||||
|
@ -372,6 +373,17 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
|
|||
}
|
||||
}
|
||||
|
||||
/// HTML5 § 2.4.4.5.
|
||||
///
|
||||
/// https://html.spec.whatwg.org/multipage/#rules-for-parsing-non-zero-dimension-values
|
||||
pub fn parse_nonzero_length(value: &str) -> LengthOrPercentageOrAuto {
|
||||
match parse_length(value) {
|
||||
LengthOrPercentageOrAuto::Length(x) if x == Au::zero() => LengthOrPercentageOrAuto::Auto,
|
||||
LengthOrPercentageOrAuto::Percentage(0.) => LengthOrPercentageOrAuto::Auto,
|
||||
x => x,
|
||||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#rules-for-parsing-a-legacy-font-size
|
||||
pub fn parse_legacy_font_size(mut input: &str) -> Option<&'static str> {
|
||||
// Steps 1 & 2 are not relevant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue