diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2019-01-14 12:27:27 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2019-01-14 16:51:26 +0100 |
commit | e57d09abb83b26f4471477653819f3a1637c04aa (patch) | |
tree | 1d7e4a6a3beca09ae6a4fe60b5a2fc6d44c0e062 /components/script/dom/window.rs | |
parent | 887cc6255684864c1c5e282c30743f7126b346a1 (diff) | |
download | servo-e57d09abb83b26f4471477653819f3a1637c04aa.tar.gz servo-e57d09abb83b26f4471477653819f3a1637c04aa.zip |
Make Window::scroll_offsets store keys as OpaqueNode values
This is the type that is supposed to signal that we will never ever
try to get back a Node from it in an unsafe way, unlike
UntrustedNodeAddress.
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r-- | components/script/dom/window.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index f8669ccd858..b557246e6b1 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -102,7 +102,7 @@ use script_layout_interface::{PendingImageState, TrustedNodeAddress}; use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use script_traits::{ConstellationControlMsg, DocumentState, LoadData}; use script_traits::{ScriptMsg, ScriptToConstellationChan, ScrollState, TimerEvent, TimerEventId}; -use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType}; +use script_traits::{TimerSchedulerMsg, WindowSizeData, WindowSizeType}; use selectors::attr::CaseSensitivity; use servo_config::opts; use servo_geometry::{f32_rect_to_au_rect, MaxRect}; @@ -119,6 +119,7 @@ use std::mem; use std::rc::Rc; use std::sync::atomic::Ordering; use std::sync::{Arc, Mutex}; +use style::dom::OpaqueNode; use style::error_reporting::{ContextualParseError, ParseErrorReporter}; use style::media_queries; use style::parser::ParserContext as CssParserContext; @@ -247,7 +248,7 @@ pub struct Window { error_reporter: CSSErrorReporter, /// A list of scroll offsets for each scrollable element. - scroll_offsets: DomRefCell<HashMap<UntrustedNodeAddress, Vector2D<f32>>>, + scroll_offsets: DomRefCell<HashMap<OpaqueNode, Vector2D<f32>>>, /// All the MediaQueryLists we need to update media_query_lists: DOMTracker<MediaQueryList>, @@ -389,7 +390,7 @@ impl Window { /// Sets a new list of scroll offsets. /// /// This is called when layout gives us new ones and WebRender is in use. - pub fn set_scroll_offsets(&self, offsets: HashMap<UntrustedNodeAddress, Vector2D<f32>>) { + pub fn set_scroll_offsets(&self, offsets: HashMap<OpaqueNode, Vector2D<f32>>) { *self.scroll_offsets.borrow_mut() = offsets } @@ -1601,11 +1602,7 @@ impl Window { } pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32> { - if let Some(scroll_offset) = self - .scroll_offsets - .borrow() - .get(&node.to_untrusted_node_address()) - { + if let Some(scroll_offset) = self.scroll_offsets.borrow().get(&node.to_opaque()) { return *scroll_offset; } Vector2D::new(0.0, 0.0) @@ -1620,10 +1617,9 @@ impl Window { // The scroll offsets are immediatly updated since later calls // to topScroll and others may access the properties before // webrender has a chance to update the offsets. - self.scroll_offsets.borrow_mut().insert( - node.to_untrusted_node_address(), - Vector2D::new(x_ as f32, y_ as f32), - ); + self.scroll_offsets + .borrow_mut() + .insert(node.to_opaque(), Vector2D::new(x_ as f32, y_ as f32)); let NodeScrollIdResponse(scroll_id) = self.layout_rpc.node_scroll_id(); |