mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
parent
99ad3678fa
commit
138a0480fe
22 changed files with 500 additions and 20 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use app_units::Au;
|
||||
use cssparser::Parser;
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
|
||||
use dom::bindings::callback::ExceptionHandling;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
|
@ -35,6 +36,7 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::history::History;
|
||||
use dom::htmliframeelement::build_mozbrowser_custom_event;
|
||||
use dom::location::Location;
|
||||
use dom::mediaquerylist::{MediaQueryList, WeakMediaQueryListVec};
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::navigator::Navigator;
|
||||
use dom::node::{Node, from_untrusted_node_address, window_from_node};
|
||||
|
@ -87,6 +89,7 @@ use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
|
|||
use string_cache::Atom;
|
||||
use style::context::ReflowGoal;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries;
|
||||
use style::properties::longhands::overflow_x;
|
||||
use style::selector_impl::PseudoElement;
|
||||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
|
@ -234,6 +237,9 @@ pub struct Window {
|
|||
|
||||
/// A list of scroll offsets for each scrollable element.
|
||||
scroll_offsets: DOMRefCell<HashMap<UntrustedNodeAddress, Point2D<f32>>>,
|
||||
|
||||
/// All the MediaQueryLists we need to update
|
||||
media_query_lists: WeakMediaQueryListVec,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -310,6 +316,10 @@ impl Window {
|
|||
pub fn set_scroll_offsets(&self, offsets: HashMap<UntrustedNodeAddress, Point2D<f32>>) {
|
||||
*self.scroll_offsets.borrow_mut() = offsets
|
||||
}
|
||||
|
||||
pub fn current_viewport(&self) -> Rect<Au> {
|
||||
self.current_viewport.clone().get()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
|
@ -857,6 +867,16 @@ impl WindowMethods for Window {
|
|||
}
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-matchmedia
|
||||
fn MatchMedia(&self, query: DOMString) -> Root<MediaQueryList> {
|
||||
let mut parser = Parser::new(&query);
|
||||
let media_query_list = media_queries::parse_media_query_list(&mut parser);
|
||||
let document = self.Document();
|
||||
let mql = MediaQueryList::new(&document, media_query_list);
|
||||
self.media_query_lists.push(&*mql);
|
||||
mql
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
// https://fetch.spec.whatwg.org/#fetch-method
|
||||
fn Fetch(&self, input: RequestOrUSVString, init: &RequestInit) -> Rc<Promise> {
|
||||
|
@ -1486,6 +1506,10 @@ impl Window {
|
|||
let custom_event = build_mozbrowser_custom_event(&self, event);
|
||||
custom_event.upcast::<Event>().fire(self.upcast());
|
||||
}
|
||||
|
||||
pub fn evaluate_media_queries_and_report_changes(&self) {
|
||||
self.media_query_lists.evaluate_and_report_changes();
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -1572,6 +1596,7 @@ impl Window {
|
|||
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
|
||||
error_reporter: error_reporter,
|
||||
scroll_offsets: DOMRefCell::new(HashMap::new()),
|
||||
media_query_lists: WeakMediaQueryListVec::new(),
|
||||
};
|
||||
|
||||
WindowBinding::Wrap(runtime.cx(), win)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue