зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642588 - Make Triple click only select within editing host r=masayuki,emilio
Differential Revision: https://phabricator.services.mozilla.com/D78315
This commit is contained in:
Родитель
a1dd5f9cd7
Коммит
d02396bd67
|
@ -228,6 +228,7 @@ skip-if = os == "android" #Bug 1575739
|
|||
[test_bug1581337.html]
|
||||
[test_bug1619852.html]
|
||||
[test_bug1620778.html]
|
||||
[test_bug1642588.html]
|
||||
[test_abs_positioner_appearance.html]
|
||||
[test_abs_positioner_positioning_elements.html]
|
||||
skip-if = os == 'android' # Bug 1525959
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test for Bug 1642588</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
<style>
|
||||
[contenteditable] {
|
||||
padding: .5em 40%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
Intentionally not in WPT as triple click is not guaranteed to have same
|
||||
behavior on every browser.
|
||||
</p>
|
||||
<span contenteditable></span><hr>
|
||||
<div contenteditable style="display: inline;"></div><hr>
|
||||
<div contenteditable style="display: inline-block;"></div><hr>
|
||||
<table contenteditable style="display: inline-table;"><tr><td></table><hr>
|
||||
<div contenteditable style="display: inline-flex;"></div><hr>
|
||||
<div contenteditable style="display: inline-grid;"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function selectHostByClicks(host, number) {
|
||||
for (let i = 1; i <= number; i++) {
|
||||
synthesizeMouseAtCenter(host, { clickCount: i });
|
||||
}
|
||||
}
|
||||
|
||||
function nonCollapsedDeletionTest(host, clickCount) {
|
||||
host.textContent = "contenteditable";
|
||||
selectHostByClicks(host, clickCount);
|
||||
const selection = getSelection();
|
||||
|
||||
is(selection.isCollapsed, false, "Noncollapsed selection should occur");
|
||||
|
||||
synthesizeKey("KEY_Backspace");
|
||||
is(host.textContent, "", "Backspace should delete the content of the editing host");
|
||||
}
|
||||
|
||||
function collapsedSelectionTest(host, clickCount) {
|
||||
host.textContent = "";
|
||||
selectHostByClicks(host, clickCount);
|
||||
const selection = getSelection();
|
||||
|
||||
is(selection.isCollapsed, true, "Collapsed selection should occur");
|
||||
is(selection.anchorNode, host, "Caret should be in host");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(() => {
|
||||
const hosts = document.querySelectorAll("[contenteditable]");
|
||||
for (const host of hosts) {
|
||||
nonCollapsedDeletionTest(host, 2);
|
||||
nonCollapsedDeletionTest(host, 3);
|
||||
collapsedSelectionTest(host, 3);
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -8173,7 +8173,7 @@ nsresult nsIFrame::PeekOffsetParagraph(nsPeekOffsetStruct* aPos) {
|
|||
nsIFrame* frame = this;
|
||||
nsContentAndOffset blockFrameOrBR;
|
||||
blockFrameOrBR.mContent = nullptr;
|
||||
bool reachedBlockAncestor = frame->IsBlockOutside();
|
||||
bool reachedLimit = frame->IsBlockOutside() || IsEditingHost(frame);
|
||||
|
||||
auto traverse = [&aPos](nsIFrame* current) {
|
||||
return aPos->mDirection == eDirPrevious ? current->GetPrevSibling()
|
||||
|
@ -8184,12 +8184,12 @@ nsresult nsIFrame::PeekOffsetParagraph(nsPeekOffsetStruct* aPos) {
|
|||
// In each step, search the previous (or next) siblings for the closest
|
||||
// "stop frame" (a block frame or a BRFrame).
|
||||
// If found, set it to be the selection boundary and abort.
|
||||
while (!reachedBlockAncestor) {
|
||||
while (!reachedLimit) {
|
||||
nsIFrame* parent = frame->GetParent();
|
||||
// Treat a frame associated with the root content as if it were a block
|
||||
// frame.
|
||||
if (!frame->mContent || !frame->mContent->GetParent()) {
|
||||
reachedBlockAncestor = true;
|
||||
reachedLimit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -8209,10 +8209,10 @@ nsresult nsIFrame::PeekOffsetParagraph(nsPeekOffsetStruct* aPos) {
|
|||
break;
|
||||
}
|
||||
frame = parent;
|
||||
reachedBlockAncestor = frame && frame->IsBlockOutside();
|
||||
reachedLimit = frame && (frame->IsBlockOutside() || IsEditingHost(frame));
|
||||
}
|
||||
|
||||
if (reachedBlockAncestor) { // no "stop frame" found
|
||||
if (reachedLimit) { // no "stop frame" found
|
||||
aPos->mResultContent = frame->GetContent();
|
||||
if (aPos->mDirection == eDirPrevious) {
|
||||
aPos->mContentOffset = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче