mirror of
https://github.com/servo/servo.git
synced 2025-09-18 19:08:22 +01:00
Auto merge of #16968 - HeyZoos:stylist-accessors, r=emilio
Stylist accessors <!-- Please describe your changes on the following line: --> Add accessor methods for the `device` and `ruleset` fields in the `Stylist` struct. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #16857 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16968) <!-- Reviewable:end -->
This commit is contained in:
commit
1306b16d5a
8 changed files with 61 additions and 25 deletions
|
@ -3,10 +3,13 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::SourceLocation;
|
||||
use euclid::TypedSize2D;
|
||||
use html5ever::LocalName;
|
||||
use selectors::parser::LocalName as LocalNameSelector;
|
||||
use selectors::parser::Selector;
|
||||
use servo_atoms::Atom;
|
||||
use style::context::QuirksMode;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration};
|
||||
use style::properties::{longhands, Importance};
|
||||
use style::rule_tree::CascadeLevel;
|
||||
|
@ -15,7 +18,7 @@ use style::shared_lock::SharedRwLock;
|
|||
use style::stylearc::Arc;
|
||||
use style::stylesheets::StyleRule;
|
||||
use style::stylist;
|
||||
use style::stylist::{Rule, SelectorMap};
|
||||
use style::stylist::{Rule, SelectorMap, Stylist};
|
||||
use style::stylist::needs_revalidation;
|
||||
use style::thread_state;
|
||||
|
||||
|
@ -218,3 +221,23 @@ fn test_get_universal_rules() {
|
|||
|
||||
assert_eq!(decls.len(), 1, "{:?}", decls);
|
||||
}
|
||||
|
||||
fn mock_stylist() -> Stylist {
|
||||
let device = Device::new(MediaType::Screen, TypedSize2D::new(0f32, 0f32));
|
||||
Stylist::new(device, QuirksMode::NoQuirks)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stylist_device_accessors() {
|
||||
let stylist = mock_stylist();
|
||||
assert_eq!(stylist.device().media_type(), MediaType::Screen);
|
||||
let mut stylist_mut = mock_stylist();
|
||||
assert_eq!(stylist_mut.device_mut().media_type(), MediaType::Screen);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stylist_rule_tree_accessors() {
|
||||
let stylist = mock_stylist();
|
||||
stylist.rule_tree();
|
||||
stylist.rule_tree().root();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue