servo: Merge #9799 - Fix step 14.2 of Range::ExtractContents (from nox:range-extractcontents); r=KiChjang

We need the last inclusive ancestor of start node that is not an inclusive ancestor
of end node, not the first that is an inclusive ancestor of it.

Source-Repo: https://github.com/servo/servo
Source-Revision: dfdeabf57df02cf4b8a878b3b9933a08d156082d
This commit is contained in:
Anthony Ramine 2016-02-29 04:42:28 +05:01
Родитель 68cac04d75
Коммит 9c9ecfeffe
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -564,8 +564,9 @@ impl RangeMethods for Range {
} else {
// Step 14.1-2.
let reference_node = start_node.ancestors()
.find(|n| n.is_inclusive_ancestor_of(end_node.r()))
.unwrap();
.take_while(|n| !n.is_inclusive_ancestor_of(&end_node))
.last()
.unwrap_or(Root::from_ref(&start_node));
// Step 14.3.
(reference_node.GetParentNode().unwrap(), reference_node.index() + 1)
};