mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix CSSStyleDeclaration's item() to provide properties instead of values (#31299)
For example, style.cssText = "margin: 1px 2px 3px 4px"; [...style]; will now be ["margin-top", "margin-right", "margin-bottom", "margin-left"] instead of ["1px", "2px", "3px", "4px"]
This commit is contained in:
parent
9d42602fe7
commit
f2adcc3a12
19 changed files with 8 additions and 149 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::CssStringWriter;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::local_name;
|
||||
use servo_arc::Arc;
|
||||
|
@ -14,7 +15,7 @@ use style::properties::{
|
|||
use style::selector_parser::PseudoElement;
|
||||
use style::shared_lock::Locked;
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style_traits::ParsingMode;
|
||||
use style_traits::{CssWriter, ParsingMode, ToCss};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
|
@ -431,13 +432,11 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
fn IndexedGetter(&self, index: u32) -> Option<DOMString> {
|
||||
self.owner.with_block(|pdb| {
|
||||
let declaration = pdb.declarations().get(index as usize)?;
|
||||
let important = pdb.declarations_importance().get(index as usize)?;
|
||||
let mut css = String::new();
|
||||
declaration.to_css(&mut css).unwrap();
|
||||
if important {
|
||||
css += " !important";
|
||||
}
|
||||
Some(DOMString::from(css))
|
||||
let mut dest = String::new();
|
||||
let mut writer = CssStringWriter::new(&mut dest);
|
||||
let mut writer = CssWriter::new(&mut writer);
|
||||
declaration.id().to_css(&mut writer).ok()?;
|
||||
Some(DOMString::from(dest))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
[variable-invalidation.html]
|
||||
[css rule test]
|
||||
expected: FAIL
|
||||
|
||||
[css rule test important]
|
||||
expected: FAIL
|
||||
|
||||
[inline style test]
|
||||
expected: FAIL
|
||||
|
||||
[inline style test important]
|
||||
expected: FAIL
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
[css-style-declaration-modifications.html]
|
||||
bug: https://github.com/servo/servo/issues/21579
|
||||
expected: TIMEOUT
|
|
@ -1,18 +1,3 @@
|
|||
[cssom-getPropertyValue-common-checks.html]
|
||||
[All properties (except 'all') can serialize their initial value (computed)]
|
||||
expected: FAIL
|
||||
|
||||
[All shorthands can serialize their longhands set to 'initial']
|
||||
expected: FAIL
|
||||
|
||||
[All aliases can serialize target property set to 'initial']
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand when longhands are set to different css-wide keywords]
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand when longhands have different priority]
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand set to 'initial' when some longhand is missing]
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[cssstyledeclaration-custom-properties.html]
|
||||
[Custom properties are included in computed style]
|
||||
expected: FAIL
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[cssstyledeclaration-setter-declarations.html]
|
||||
[setProperty with longhand should update only the declaration being set]
|
||||
expected: FAIL
|
||||
|
||||
[property setter should update only the declaration being set]
|
||||
expected: FAIL
|
||||
|
||||
[setProperty with shorthand should update only the declarations being set]
|
||||
expected: FAIL
|
||||
|
||||
[longhand property setter should update only the decoarations being set]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[cssstyledeclaration-setter-logical.html]
|
||||
[newly set declaration should be after all declarations in the same logical property group but have different logical kind]
|
||||
expected: FAIL
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
[inline-style-001.html]
|
||||
bug: https://github.com/servo/servo/issues/21579
|
||||
expected: TIMEOUT
|
|
@ -1,6 +1,3 @@
|
|||
[serialize-all-longhands.html]
|
||||
[Specified style]
|
||||
expected: FAIL
|
||||
|
||||
[Computed style]
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
[variable-names.html]
|
||||
[custom property '--a']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--a;b']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '---']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--\\']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--ab']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--0']
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
[variable-invalidation.html]
|
||||
[css rule test]
|
||||
expected: FAIL
|
||||
|
||||
[css rule test important]
|
||||
expected: FAIL
|
||||
|
||||
[inline style test]
|
||||
expected: FAIL
|
||||
|
||||
[inline style test important]
|
||||
expected: FAIL
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[css-style-declaration-modifications.html]
|
||||
expected: TIMEOUT
|
|
@ -2,17 +2,5 @@
|
|||
[All properties (except 'all') can serialize their initial value (computed)]
|
||||
expected: FAIL
|
||||
|
||||
[All shorthands can serialize their longhands set to 'initial']
|
||||
expected: FAIL
|
||||
|
||||
[All aliases can serialize target property set to 'initial']
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand when longhands are set to different css-wide keywords]
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand when longhands have different priority]
|
||||
expected: FAIL
|
||||
|
||||
[Can't serialize shorthand set to 'initial' when some longhand is missing]
|
||||
[All shorthands (except 'all') can serialize their longhands set to their initial value]
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[cssstyledeclaration-custom-properties.html]
|
||||
[Custom properties are included in computed style]
|
||||
expected: FAIL
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[cssstyledeclaration-setter-declarations.html]
|
||||
[setProperty with longhand should update only the declaration being set]
|
||||
expected: FAIL
|
||||
|
||||
[longhand property setter should update only the decoarations being set]
|
||||
expected: FAIL
|
||||
|
||||
[property setter should update only the declaration being set]
|
||||
expected: FAIL
|
||||
|
||||
[setProperty with shorthand should update only the declarations being set]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[cssstyledeclaration-setter-logical.html]
|
||||
[newly set declaration should be after all declarations in the same logical property group but have different logical kind]
|
||||
expected: FAIL
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[inline-style-001.html]
|
||||
expected: TIMEOUT
|
|
@ -1,6 +0,0 @@
|
|||
[serialize-all-longhands.html]
|
||||
[Specified style]
|
||||
expected: FAIL
|
||||
|
||||
[Computed style]
|
||||
expected: FAIL
|
|
@ -1,19 +1,6 @@
|
|||
[variable-names.html]
|
||||
[custom property '--a']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '---']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--ab']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--0']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--a;b']
|
||||
expected: FAIL
|
||||
|
||||
[custom property '--\\']
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue