mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
script_thread: HTML parser doesn't set relevant option (#36622)
This patch ensures that the Servo HTML parser uses the appropriate `TreeBuilderOpts` settings as specified by the HTML specification. Changes: - **iframe_srcdoc:** Detect if the parsed document's URL scheme is `about:srcdoc`, and set the parser’s iframe_srcdoc option accordingly. - **quirks_mode:** Use the associated Document's quirks mode to set the parser’s quirks mode flag, improving fragment parsing behavior. - **scripting_enabled:** Add a `scripting_enabled` method to Document, based on whether it has a browsing context, and set this flag for the parser. These updates align Servo's parsing behavior more closely with the specification: https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #35478 <!-- Either: --> - [ ] There are tests for these changes Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
This commit is contained in:
parent
989739316e
commit
085ad9ea48
2 changed files with 17 additions and 2 deletions
|
@ -11,11 +11,12 @@ use html5ever::buffer_queue::BufferQueue;
|
|||
use html5ever::serialize::TraversalScope::IncludeNode;
|
||||
use html5ever::serialize::{AttrRef, Serialize, Serializer, TraversalScope};
|
||||
use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts};
|
||||
use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts};
|
||||
use html5ever::tree_builder::{QuirksMode as HTML5EverQuirksMode, TreeBuilder, TreeBuilderOpts};
|
||||
use html5ever::{QualName, local_name, ns};
|
||||
use markup5ever::TokenizerResult;
|
||||
use script_bindings::trace::CustomTraceable;
|
||||
use servo_url::ServoUrl;
|
||||
use style::context::QuirksMode as StyleContextQuirksMode;
|
||||
use xml5ever::LocalName;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods;
|
||||
|
@ -58,9 +59,17 @@ impl Tokenizer {
|
|||
parsing_algorithm,
|
||||
};
|
||||
|
||||
let quirks_mode = match document.quirks_mode() {
|
||||
StyleContextQuirksMode::Quirks => HTML5EverQuirksMode::Quirks,
|
||||
StyleContextQuirksMode::LimitedQuirks => HTML5EverQuirksMode::LimitedQuirks,
|
||||
StyleContextQuirksMode::NoQuirks => HTML5EverQuirksMode::NoQuirks,
|
||||
};
|
||||
|
||||
let options = TreeBuilderOpts {
|
||||
ignore_missing_rules: true,
|
||||
scripting_enabled: document.has_browsing_context(),
|
||||
scripting_enabled: document.scripting_enabled(),
|
||||
iframe_srcdoc: document.url().as_str() == "about:srcdoc",
|
||||
quirks_mode,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue