mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Do not panic on navigating across documents
This commit is contained in:
parent
da45522085
commit
962e620529
3 changed files with 12 additions and 8 deletions
|
@ -560,7 +560,8 @@ impl Document {
|
||||||
|
|
||||||
let new_dirty_root = element
|
let new_dirty_root = element
|
||||||
.upcast::<Node>()
|
.upcast::<Node>()
|
||||||
.common_ancestor(dirty_root.upcast(), ShadowIncluding::Yes);
|
.common_ancestor(dirty_root.upcast(), ShadowIncluding::Yes)
|
||||||
|
.expect("Couldn't find common ancestor");
|
||||||
|
|
||||||
let mut has_dirty_descendants = true;
|
let mut has_dirty_descendants = true;
|
||||||
for ancestor in dirty_root
|
for ancestor in dirty_root
|
||||||
|
@ -1515,10 +1516,12 @@ impl Document {
|
||||||
FireMouseEventType::Enter | FireMouseEventType::Leave
|
FireMouseEventType::Enter | FireMouseEventType::Leave
|
||||||
));
|
));
|
||||||
|
|
||||||
let common_ancestor = related_target.as_ref().map_or_else(
|
let common_ancestor = match related_target.as_ref() {
|
||||||
|| DomRoot::from_ref(&*event_target),
|
Some(related_target) => event_target
|
||||||
|related_target| event_target.common_ancestor(related_target, ShadowIncluding::No),
|
.common_ancestor(related_target, ShadowIncluding::No)
|
||||||
);
|
.unwrap_or_else(|| DomRoot::from_ref(&*event_target)),
|
||||||
|
None => DomRoot::from_ref(&*event_target),
|
||||||
|
};
|
||||||
|
|
||||||
// We need to create a target chain in case the event target shares
|
// We need to create a target chain in case the event target shares
|
||||||
// its boundaries with its ancestors.
|
// its boundaries with its ancestors.
|
||||||
|
|
|
@ -708,16 +708,16 @@ impl Node {
|
||||||
&self,
|
&self,
|
||||||
other: &Node,
|
other: &Node,
|
||||||
shadow_including: ShadowIncluding,
|
shadow_including: ShadowIncluding,
|
||||||
) -> DomRoot<Node> {
|
) -> Option<DomRoot<Node>> {
|
||||||
for ancestor in self.inclusive_ancestors(shadow_including) {
|
for ancestor in self.inclusive_ancestors(shadow_including) {
|
||||||
if other
|
if other
|
||||||
.inclusive_ancestors(shadow_including)
|
.inclusive_ancestors(shadow_including)
|
||||||
.any(|node| node == ancestor)
|
.any(|node| node == ancestor)
|
||||||
{
|
{
|
||||||
return ancestor;
|
return Some(ancestor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable!();
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
||||||
|
|
|
@ -298,6 +298,7 @@ impl RangeMethods for Range {
|
||||||
fn CommonAncestorContainer(&self) -> DomRoot<Node> {
|
fn CommonAncestorContainer(&self) -> DomRoot<Node> {
|
||||||
self.EndContainer()
|
self.EndContainer()
|
||||||
.common_ancestor(&self.StartContainer(), ShadowIncluding::No)
|
.common_ancestor(&self.StartContainer(), ShadowIncluding::No)
|
||||||
|
.expect("Couldn't find common ancestor container")
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-range-setstart
|
// https://dom.spec.whatwg.org/#dom-range-setstart
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue