Skip to content

Commit

Permalink
Return ErrorStatus from webdriver_handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeroman committed Aug 18, 2019
1 parent 6a637ce commit d7b9fed
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 440 deletions.
8 changes: 6 additions & 2 deletions components/script/dom/node.rs
Expand Up @@ -1654,7 +1654,7 @@ impl Node {

#[allow(unrooted_must_root)]
fn new_(flags: NodeFlags, doc: Option<&Document>) -> Node {
Node {
let node = Node {
eventtarget: EventTarget::new_inherited(),

parent_node: Default::default(),
Expand All @@ -1673,7 +1673,11 @@ impl Node {
style_and_layout_data: Cell::new(None),

unique_id: UniqueId::new(),
}
};

ScriptThread::save_node_id(node.unique_id());

node
}

// https://dom.spec.whatwg.org/#concept-node-adopt
Expand Down
24 changes: 24 additions & 0 deletions components/script/script_thread.rs
Expand Up @@ -687,6 +687,9 @@ pub struct ScriptThread {

/// A mechanism to force the compositor's event loop to process events.
event_loop_waker: Option<Box<dyn EventLoopWaker>>,

/// A set of all nodes ever created in this script thread
node_ids: DomRefCell<HashSet<String>>,
}

/// In the event of thread panic, all data on the stack runs its destructor. However, there
Expand Down Expand Up @@ -1183,6 +1186,25 @@ impl ScriptThread {
})
}

pub fn save_node_id(node_id: String) {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
let script_thread = unsafe { &*script_thread };
script_thread.node_ids.borrow_mut().insert(node_id);
}
})
}

pub fn has_node_id(node_id: &str) -> bool {
SCRIPT_THREAD_ROOT.with(|root| match root.get() {
Some(script_thread) => {
let script_thread = unsafe { &*script_thread };
script_thread.node_ids.borrow().contains(node_id)
},
None => false,
})
}

/// Creates a new script thread.
pub fn new(
state: InitialScriptState,
Expand Down Expand Up @@ -1315,6 +1337,8 @@ impl ScriptThread {
user_agent,
player_context: state.player_context,
event_loop_waker: state.event_loop_waker,

node_ids: Default::default(),
}
}

Expand Down

0 comments on commit d7b9fed

Please sign in to comment.