Bug 1368521 Selection::SelectFrames() shouldn't skip first content invalidation if it's different from handled text node r=mats

The first node of |iter| in Selection::SelectFrames() may be different from the start parent of given range.  Therefore, if they are different, it shouldn't skip first item of |iter|.

MozReview-Commit-ID: DgE2dSziaxo

--HG--
extra : rebase_source : b35f52d194bf437cc79d1917ad497ebb1a8c27f0
This commit is contained in:
Masayuki Nakano 2017-05-31 15:57:53 +09:00
Родитель f131594dd6
Коммит 3f6dead134
16 изменённых файлов: 289 добавлений и 1 удалений

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

@ -4582,7 +4582,8 @@ Selection::SelectFrames(nsPresContext* aPresContext, nsRange* aRange,
nsCOMPtr<nsIContentIterator> iter = NS_NewContentSubtreeIterator();
iter->Init(aRange);
if (isFirstContentTextNode && !iter->IsDone()) {
if (isFirstContentTextNode && !iter->IsDone() &&
iter->GetCurrentNode() == startNode) {
iter->Next(); // first content has already been handled.
}
nsCOMPtr<nsIContentIterator> inneriter = NS_NewContentIterator();

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

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p2.firstChild, 2);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.collapse(p1.firstChild, 0);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p1.firstChild, 1);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p1.childNodes.item(1).firstChild, 0);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p1.childNodes.item(1).firstChild, 1);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p1.lastChild, 0);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p1.lastChild, 1);
function doTest() {
selection.extend(p2.firstChild, 2);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 0, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.firstChild, 1, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.childNodes.item(1).firstChild, 0, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.childNodes.item(1).firstChild, 1, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.lastChild, 0, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<body>
<p id="first">f<span>o</span>o</p>
<p id="second">bar</p>
<script>
document.body.offsetTop;
var p1 = document.getElementById("first");
var p2 = document.getElementById("second");
var selection = window.getSelection();
selection.setBaseAndExtent(p1.lastChild, 1, p2.firstChild, 2);
function doTest() {
selection.collapse(p2.firstChild, 3);
document.documentElement.removeAttribute('class');
}
document.addEventListener("MozReftestInvalidate", doTest);
</script>
</body>
</html>

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

@ -35,3 +35,16 @@ fuzzy-if(skiaContent,1,1200) == addrange-2.html addrange-ref.html
== modify-range.html modify-range-ref.html
== dom-mutations.html dom-mutations-ref.html
fuzzy-if(OSX==1010,9,1) fuzzy-if(OSX&&skiaContent,6,1) fuzzy-if(skiaContent&&!OSX,1,2138) == trailing-space-1.html trailing-space-1-ref.html
!= invalidation-1-ref.html invalidation-2-ref.html
== invalidation-1a.html invalidation-1-ref.html
== invalidation-1b.html invalidation-1-ref.html
== invalidation-1c.html invalidation-1-ref.html
== invalidation-1d.html invalidation-1-ref.html
== invalidation-1e.html invalidation-1-ref.html
== invalidation-1f.html invalidation-1-ref.html
== invalidation-2a.html invalidation-2-ref.html
== invalidation-2b.html invalidation-2-ref.html
== invalidation-2c.html invalidation-2-ref.html
== invalidation-2d.html invalidation-2-ref.html
== invalidation-2e.html invalidation-2-ref.html
== invalidation-2f.html invalidation-2-ref.html