Skip to content
Permalink
Browse files
REGRESSION (r201701): Unable to copy from CodeMirror editor version u…
…sed in Jenkins install website

https://bugs.webkit.org/show_bug.cgi?id=161386
<rdar://problem/27590077>

Reviewed by Dan Bernstein.

Source/WebCore:

This CodeMirror version uses a hidden <textarea> to implement copy/paste. The textarea has width:1px; border-width:1px.
Jenkins page has also has a stylesheet that contains * { box-sizing:border-box } and as a result the textarea content
width gets computed as 0. With r201701 we use content size instead of box size for clipping and the textarea content is
(correctly) considered invisible.

Add a quirk that allows this to continue working.

Test: editing/text-iterator/hidden-textarea-selection-quirk.html

* editing/TextIterator.cpp:
(WebCore::fullyClipsContents):

LayoutTests:

* editing/text-iterator/hidden-textarea-selection-quirk-expected.txt: Added.
* editing/text-iterator/hidden-textarea-selection-quirk.html: Added.
* platform/ios-simulator/editing/text-iterator/hidden-textarea-selection-quirk-expected.txt: Added.

    textarea.select() doesn't select the text content on iOS.


Canonical link: https://commits.webkit.org/179588@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
anttijk committed Aug 31, 2016
1 parent d54e92a commit 2d7ba5125b57edd29d81fc8f2f19430e0e8561d0
Showing 6 changed files with 163 additions and 0 deletions.
@@ -1,3 +1,17 @@
2016-08-31 Antti Koivisto <antti@apple.com>

REGRESSION (r201701): Unable to copy from CodeMirror editor version used in Jenkins install website
https://bugs.webkit.org/show_bug.cgi?id=161386
<rdar://problem/27590077>

Reviewed by Dan Bernstein.

* editing/text-iterator/hidden-textarea-selection-quirk-expected.txt: Added.
* editing/text-iterator/hidden-textarea-selection-quirk.html: Added.
* platform/ios-simulator/editing/text-iterator/hidden-textarea-selection-quirk-expected.txt: Added.

textarea.select() doesn't select the text content on iOS.

2016-08-30 Jiewen Tan <jiewen_tan@apple.com>

Unreviewed, update iOS simulator WK1 flaky tests.
@@ -0,0 +1,11 @@


PASS Selecting in barely visible textarea
PASS Selecting in barely visible div
PASS Selecting in textarea hidden by container
PASS Selecting in div hidden by container
PASS Selecting in absolute positioned textarea hidden by container
PASS Selecting in absolute positioned div hidden by container
PASS Selecting in absolute positioned zero content width textarea hidden by container (quirk behavior)
PASS Selecting in absolute positioned zero content width div hidden by container

@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html>
<head>
<title>Selections in hidden elements</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<link rel='stylesheet' href='../../resources/testharness.css'>
</head>
<body>
<style>
container, my-text {
display: block;
}

.hide {
position:relative;
overflow:hidden;
height:0px;
width:10px;
}
.select {
height:11px;
width:1px;
padding:0px;
border:1px solid blue;
box-sizing:content-box;
overflow:hidden;
}
.abs {
position: absolute;
}
.borderBox {
box-sizing:border-box;
}
</style>
<container>
<textarea class=select>test text</textarea>
<my-text class=select>test text</my-text>
</container>
<script>
function checkSelectable(element, expected)
{
var selection = document.getSelection();
if (element.select)
element.select();
else
selection.selectAllChildren(element);

var selectionText = selection.toString();
if (expected)
assert_equals(selectionText, "test text");
else
assert_equals(selectionText, "");
}

var textarea = document.querySelector("textarea");
var myText = document.querySelector("my-text");

test(function () {
checkSelectable(textarea, true);
}, "Selecting in barely visible textarea");

test(function () {
checkSelectable(myText, true);
}, "Selecting in barely visible div");

document.querySelector("container").classList.add("hide");

test(function () {
checkSelectable(textarea, false);
}, "Selecting in textarea hidden by container");

test(function () {
checkSelectable(myText, false);
}, "Selecting in div hidden by container");

textarea.classList.add("abs");
myText.classList.add("abs");

test(function () {
checkSelectable(textarea, true);
}, "Selecting in absolute positioned textarea hidden by container");

test(function () {
checkSelectable(myText, true);
}, "Selecting in absolute positioned div hidden by container");

textarea.classList.add("borderBox");
myText.classList.add("borderBox");

test(function () {
checkSelectable(textarea, true);
}, "Selecting in absolute positioned zero content width textarea hidden by container (quirk behavior)");

test(function () {
checkSelectable(myText, false);
}, "Selecting in absolute positioned zero content width div hidden by container");

</script>
</body>
</html>
@@ -0,0 +1,11 @@


FAIL Selecting in barely visible textarea assert_equals: expected "test text" but got ""
PASS Selecting in barely visible div
PASS Selecting in textarea hidden by container
PASS Selecting in div hidden by container
FAIL Selecting in absolute positioned textarea hidden by container assert_equals: expected "test text" but got ""
PASS Selecting in absolute positioned div hidden by container
FAIL Selecting in absolute positioned zero content width textarea hidden by container (quirk behavior) assert_equals: expected "test text" but got ""
PASS Selecting in absolute positioned zero content width div hidden by container

@@ -1,3 +1,23 @@
2016-08-31 Antti Koivisto <antti@apple.com>

REGRESSION (r201701): Unable to copy from CodeMirror editor version used in Jenkins install website
https://bugs.webkit.org/show_bug.cgi?id=161386
<rdar://problem/27590077>

Reviewed by Dan Bernstein.

This CodeMirror version uses a hidden <textarea> to implement copy/paste. The textarea has width:1px; border-width:1px.
Jenkins page has also has a stylesheet that contains * { box-sizing:border-box } and as a result the textarea content
width gets computed as 0. With r201701 we use content size instead of box size for clipping and the textarea content is
(correctly) considered invisible.

Add a quirk that allows this to continue working.

Test: editing/text-iterator/hidden-textarea-selection-quirk.html

* editing/TextIterator.cpp:
(WebCore::fullyClipsContents):

2016-08-31 Joseph Pecoraro <pecoraro@apple.com>

Remove unused member variable in WebCore::File
@@ -40,6 +40,7 @@
#include "HTMLNames.h"
#include "HTMLParagraphElement.h"
#include "HTMLProgressElement.h"
#include "HTMLTextAreaElement.h"
#include "HTMLTextFormControlElement.h"
#include "InlineTextBox.h"
#include "NodeTraversal.h"
@@ -213,6 +214,11 @@ static inline bool fullyClipsContents(Node& node)
auto& box = downcast<RenderBox>(*renderer);
if (!box.hasOverflowClip())
return false;

// Quirk to keep copy/paste in the CodeMirror editor version used in Jenkins working.
if (is<HTMLTextAreaElement>(node))
return box.size().isEmpty();

return box.contentSize().isEmpty();
}

0 comments on commit 2d7ba51

Please sign in to comment.