mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Store parser's current line when script elements are created.
Use the newly stored line as the starting line number when evaluating JS. This ensures that inline scripts will report errors with meaningful line numbers.
This commit is contained in:
parent
d1bc1a4f1b
commit
db2082bc6e
11 changed files with 61 additions and 22 deletions
|
@ -52,6 +52,7 @@ impl Tokenizer {
|
|||
let sink = Sink {
|
||||
base_url: url,
|
||||
document: JS::from_ref(document),
|
||||
current_line: 1,
|
||||
};
|
||||
|
||||
let options = TreeBuilderOpts {
|
||||
|
@ -122,6 +123,7 @@ unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> {
|
|||
struct Sink {
|
||||
base_url: ServoUrl,
|
||||
document: JS<Document>,
|
||||
current_line: u64,
|
||||
}
|
||||
|
||||
impl TreeSink for Sink {
|
||||
|
@ -156,7 +158,7 @@ impl TreeSink for Sink {
|
|||
fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>)
|
||||
-> JS<Node> {
|
||||
let elem = Element::create(name, None, &*self.document,
|
||||
ElementCreator::ParserCreated);
|
||||
ElementCreator::ParserCreated(self.current_line));
|
||||
|
||||
for attr in attrs {
|
||||
elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None);
|
||||
|
@ -234,6 +236,10 @@ impl TreeSink for Sink {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_current_line(&mut self, line_number: u64) {
|
||||
self.current_line = line_number;
|
||||
}
|
||||
|
||||
fn pop(&mut self, node: JS<Node>) {
|
||||
let node = Root::from_ref(&*node);
|
||||
vtable_for(&node).pop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue