mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
parent
65454e51c8
commit
64ba4a914e
3 changed files with 39 additions and 9 deletions
|
@ -120,6 +120,9 @@ pub struct Document {
|
|||
focused: MutNullableJS<Element>,
|
||||
/// The script element that is currently executing.
|
||||
current_script: MutNullableJS<HTMLScriptElement>,
|
||||
/// https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-noscript
|
||||
/// True if scripting is enabled for all scripts in this document
|
||||
scripting_enabled: Cell<bool>,
|
||||
}
|
||||
|
||||
impl DocumentDerived for EventTarget {
|
||||
|
@ -203,6 +206,7 @@ pub trait DocumentHelpers<'a> {
|
|||
fn find_fragment_node(self, fragid: DOMString) -> Option<Temporary<Element>>;
|
||||
fn set_ready_state(self, state: DocumentReadyState);
|
||||
fn get_focused_element(self) -> Option<Temporary<Element>>;
|
||||
fn is_scripting_enabled(self) -> bool;
|
||||
fn begin_focus_transaction(self);
|
||||
fn request_focus(self, elem: JSRef<Element>);
|
||||
fn commit_focus_transaction(self);
|
||||
|
@ -389,6 +393,11 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
let _ = event.r().fire(target);
|
||||
}
|
||||
|
||||
/// Return whether scripting is enabled or not
|
||||
fn is_scripting_enabled(self) -> bool {
|
||||
self.scripting_enabled.get()
|
||||
}
|
||||
|
||||
/// Return the element that currently has focus.
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus
|
||||
fn get_focused_element(self) -> Option<Temporary<Element>> {
|
||||
|
@ -710,6 +719,7 @@ impl Document {
|
|||
possibly_focused: Default::default(),
|
||||
focused: Default::default(),
|
||||
current_script: Default::default(),
|
||||
scripting_enabled: Cell::new(true),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue