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
|
||||
.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;
|
||||
for ancestor in dirty_root
|
||||
|
@ -1515,10 +1516,12 @@ impl Document {
|
|||
FireMouseEventType::Enter | FireMouseEventType::Leave
|
||||
));
|
||||
|
||||
let common_ancestor = related_target.as_ref().map_or_else(
|
||||
|| DomRoot::from_ref(&*event_target),
|
||||
|related_target| event_target.common_ancestor(related_target, ShadowIncluding::No),
|
||||
);
|
||||
let common_ancestor = match related_target.as_ref() {
|
||||
Some(related_target) => event_target
|
||||
.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
|
||||
// its boundaries with its ancestors.
|
||||
|
|
|
@ -708,16 +708,16 @@ impl Node {
|
|||
&self,
|
||||
other: &Node,
|
||||
shadow_including: ShadowIncluding,
|
||||
) -> DomRoot<Node> {
|
||||
) -> Option<DomRoot<Node>> {
|
||||
for ancestor in self.inclusive_ancestors(shadow_including) {
|
||||
if other
|
||||
.inclusive_ancestors(shadow_including)
|
||||
.any(|node| node == ancestor)
|
||||
{
|
||||
return ancestor;
|
||||
return Some(ancestor);
|
||||
}
|
||||
}
|
||||
unreachable!();
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
||||
|
|
|
@ -298,6 +298,7 @@ impl RangeMethods for Range {
|
|||
fn CommonAncestorContainer(&self) -> DomRoot<Node> {
|
||||
self.EndContainer()
|
||||
.common_ancestor(&self.StartContainer(), ShadowIncluding::No)
|
||||
.expect("Couldn't find common ancestor container")
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-range-setstart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue