Add a fast path in Element::SetInnerHTML when the value is small and trivial text

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892
This commit is contained in:
Bastien Orivel 2020-05-03 15:12:58 +02:00
parent d08c4fff15
commit 1b2464b4b6
13 changed files with 89 additions and 24 deletions

View file

@ -196,6 +196,10 @@ bitflags! {
/// Specifies whether this node's shadow-including root is a document.
const IS_CONNECTED = 1 << 10;
/// Whether this node has a weird parser insertion mode. i.e whether setting innerHTML
/// needs extra work or not
const HAS_WEIRD_PARSER_INSERTION_MODE = 1 << 11;
}
}
@ -554,6 +558,16 @@ impl Node {
self.flags.get().contains(NodeFlags::IS_IN_SHADOW_TREE)
}
pub fn has_weird_parser_insertion_mode(&self) -> bool {
self.flags
.get()
.contains(NodeFlags::HAS_WEIRD_PARSER_INSERTION_MODE)
}
pub fn set_weird_parser_insertion_mode(&self) {
self.set_flag(NodeFlags::HAS_WEIRD_PARSER_INSERTION_MODE, true)
}
pub fn is_connected(&self) -> bool {
self.flags.get().contains(NodeFlags::IS_CONNECTED)
}