mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Don't drain ranges across shadow boundaries
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
6c83f145e4
commit
7b6684a9b8
2 changed files with 8 additions and 5 deletions
|
@ -3936,7 +3936,12 @@ impl VirtualMethods for Node {
|
|||
/// <https://dom.spec.whatwg.org/#concept-node-remove>
|
||||
fn unbind_from_tree(&self, context: &UnbindContext, can_gc: CanGc) {
|
||||
self.super_type().unwrap().unbind_from_tree(context, can_gc);
|
||||
if !self.ranges_is_empty() {
|
||||
|
||||
// Ranges should only drain to the parent from inclusive non-shadow
|
||||
// including descendants. If we're in a shadow tree at this point then the
|
||||
// unbind operation happened further up in the tree and we should not
|
||||
// drain any ranges.
|
||||
if !self.is_in_a_shadow_tree() && !self.ranges_is_empty() {
|
||||
self.ranges().drain_to_parent(context, self);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,6 +346,7 @@ impl Range {
|
|||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#concept-range-bp-set>
|
||||
#[allow(clippy::neg_cmp_op_on_partial_ord)]
|
||||
fn set_the_start_or_end(
|
||||
&self,
|
||||
node: &Node,
|
||||
|
@ -373,7 +374,6 @@ impl Range {
|
|||
// Step 4.2 Set range’s start to bp.
|
||||
self.set_start(node, offset);
|
||||
if !(self.start() <= self.end()) {
|
||||
// Step 4.
|
||||
self.set_end(node, offset);
|
||||
}
|
||||
},
|
||||
|
@ -384,7 +384,6 @@ impl Range {
|
|||
// Step 4.2 Set range’s end to bp.
|
||||
self.set_end(node, offset);
|
||||
if !(self.end() >= self.start()) {
|
||||
// Step 4.
|
||||
self.set_start(node, offset);
|
||||
}
|
||||
},
|
||||
|
@ -418,13 +417,11 @@ impl RangeMethods<crate::DomTypeHolder> for Range {
|
|||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-range-setstart>
|
||||
#[allow(clippy::neg_cmp_op_on_partial_ord)]
|
||||
fn SetStart(&self, node: &Node, offset: u32) -> ErrorResult {
|
||||
self.set_the_start_or_end(node, offset, StartOrEnd::Start)
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-range-setend>
|
||||
#[allow(clippy::neg_cmp_op_on_partial_ord)]
|
||||
fn SetEnd(&self, node: &Node, offset: u32) -> ErrorResult {
|
||||
self.set_the_start_or_end(node, offset, StartOrEnd::End)
|
||||
}
|
||||
|
@ -1229,6 +1226,7 @@ impl WeakRangeVec {
|
|||
}
|
||||
|
||||
/// Used for steps 2-3. when removing a node.
|
||||
///
|
||||
/// <https://dom.spec.whatwg.org/#concept-node-remove>
|
||||
pub(crate) fn drain_to_parent(&self, context: &UnbindContext, child: &Node) {
|
||||
if self.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue