[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 15:46:37 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 9b22f5cc68936befade9d5dd5c0b342058ed44e4
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Nov 12 03:56:31 2010 +0000
2010-11-11 Julie-Jeongeun-Kim <jiyuluna at gmail.com>
Reviewed by Kent Tamura.
SelectionStart, selectionEnd properties return wrong values when the selection is in a read-only input or textarea element
https://bugs.webkit.org/show_bug.cgi?id=25444
* fast/forms/selection-start-end-readonly-expected.txt: Added.
* fast/forms/selection-start-end-readonly.html: Added.
2010-11-11 Julie-Jeongeun-Kim <jiyuluna at gmail.com>
Reviewed by Kent Tamura.
SelectionStart, selectionEnd properties return wrong values when the selection is in a read-only input or textarea element
https://bugs.webkit.org/show_bug.cgi?id=25444
'rootEditableElement()' is checked on RenderTextControl::indexForVisiblePosition.
It means that just editable elements can get selection information.
ReadOnly element is not editable element. So, it just returns and can't get correct selection information.
INPUT and TEXTAREA elements can be read-only but 'indexForVisiblePosition' doesn't accept them.
So, Selectable elements, INPUT and TEXTAREA, checking is added for that case.
Even if they are read-only, they are selectable.
new tests:fast/forms/selection-start-end-readonly.html
* html/HTMLInputElement.idl:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::isSelectableElement):
(WebCore::RenderTextControl::indexForVisiblePosition):
* rendering/RenderTextControl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9437593..f5b3bdf 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-11 Julie-Jeongeun-Kim <jiyuluna at gmail.com>
+
+ Reviewed by Kent Tamura.
+
+ SelectionStart, selectionEnd properties return wrong values when the selection is in a read-only input or textarea element
+ https://bugs.webkit.org/show_bug.cgi?id=25444
+
+ * fast/forms/selection-start-end-readonly-expected.txt: Added.
+ * fast/forms/selection-start-end-readonly.html: Added.
+
2010-11-11 Mihai Parparita <mihaip at chromium.org>
Unreviewed Chromium rebaseline.
diff --git a/LayoutTests/fast/forms/selection-start-end-readonly-expected.txt b/LayoutTests/fast/forms/selection-start-end-readonly-expected.txt
new file mode 100644
index 0000000..3f20e69
--- /dev/null
+++ b/LayoutTests/fast/forms/selection-start-end-readonly-expected.txt
@@ -0,0 +1,40 @@
+Tests for selectionStart and selectionEnd on read-only INPUT and TEXTAREA.
+bug 25444: SelectionStart, selectionEnd properties return wrong values when the selection is in a form input.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 10
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 9
+PASS element.selectionStart is 1
+PASS element.selectionEnd is 10
+PASS element.selectionStart is 5
+PASS element.selectionEnd is 5
+PASS element.selectionStart is 5
+PASS element.selectionEnd is 5
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 0
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 10
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 10
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 9
+PASS element.selectionStart is 1
+PASS element.selectionEnd is 10
+PASS element.selectionStart is 5
+PASS element.selectionEnd is 5
+PASS element.selectionStart is 5
+PASS element.selectionEnd is 5
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 0
+PASS element.selectionStart is 0
+PASS element.selectionEnd is 10
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/selection-start-end-readonly.html b/LayoutTests/fast/forms/selection-start-end-readonly.html
new file mode 100644
index 0000000..65e396f
--- /dev/null
+++ b/LayoutTests/fast/forms/selection-start-end-readonly.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<input id="text" readonly="readonly" value="2009-04-29"/><br/>
+<textarea id="area" readonly="readonly">2009-04-29</textarea></div>
+<div id="console"></div>
+<div>
+<script type="text/javascript">
+description('Tests for selectionStart and selectionEnd on read-only INPUT and TEXTAREA. <br/> <a href="https://bugs.webkit.org/show_bug.cgi?id=25444">bug 25444</a>: SelectionStart, selectionEnd properties return wrong values when the selection is in a form input.');
+
+function startTest(element, start, end) {
+ element.setSelectionRange(start, end);
+
+ start = start < 0 ? 0 : start;
+ end = end > 10 ? 10 : end;
+ start = start > end ? end : start;
+
+ if (element.selectionStart != start)
+ testFailed('element.selectionStart' + ' should be ' + start + ' but it is ' + element.selectionStart);
+ else
+ testPassed('element.selectionStart' + ' is ' + element.selectionStart);
+
+ if (element.selectionEnd != end)
+ testFailed('element.selectionEnd' + ' should be ' + end + ' but it is ' + element.selectionEnd);
+ else
+ testPassed('element.selectionEnd' + ' is ' + element.selectionEnd);
+}
+
+function testHandler(element) {
+ var offsets = [[0, 10], [0, 9], [1, 10], [5,5], [8,5], [-1,0], [-1,50]];
+ for (var i = 0; i < offsets.length; i++)
+ startTest(element, offsets[i][0], offsets[i][1]);
+}
+
+testHandler(document.getElementById('text'));
+testHandler(document.getElementById('area'));
+
+var successfullyParsed = true;
+ </script>
+ <script src="../js/resources/js-test-post.js"></script>
+ </body>
+</html>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 25f1718..38956d5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-11-11 Julie-Jeongeun-Kim <jiyuluna at gmail.com>
+
+ Reviewed by Kent Tamura.
+
+ SelectionStart, selectionEnd properties return wrong values when the selection is in a read-only input or textarea element
+ https://bugs.webkit.org/show_bug.cgi?id=25444
+
+ 'rootEditableElement()' is checked on RenderTextControl::indexForVisiblePosition.
+ It means that just editable elements can get selection information.
+ ReadOnly element is not editable element. So, it just returns and can't get correct selection information.
+ INPUT and TEXTAREA elements can be read-only but 'indexForVisiblePosition' doesn't accept them.
+ So, Selectable elements, INPUT and TEXTAREA, checking is added for that case.
+ Even if they are read-only, they are selectable.
+
+ new tests:fast/forms/selection-start-end-readonly.html
+
+ * html/HTMLInputElement.idl:
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::isSelectableElement):
+ (WebCore::RenderTextControl::indexForVisiblePosition):
+ * rendering/RenderTextControl.h:
+
2010-11-11 Adam Barth <abarth at webkit.org>
Reviewed by David Levin.
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index b873826..157989e 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -84,8 +84,6 @@ module html {
// WinIE extension:
attribute boolean indeterminate;
- // WinIE & FireFox extension:
-
attribute [Custom] long selectionStart;
attribute [Custom] long selectionEnd;
[Custom] void setSelectionRange(in long start, in long end);
diff --git a/WebCore/rendering/RenderTextControl.cpp b/WebCore/rendering/RenderTextControl.cpp
index e81dfb9..b3d4df0 100644
--- a/WebCore/rendering/RenderTextControl.cpp
+++ b/WebCore/rendering/RenderTextControl.cpp
@@ -30,6 +30,7 @@
#include "Frame.h"
#include "HTMLBRElement.h"
#include "HTMLFormControlElement.h"
+#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "RenderLayer.h"
@@ -256,6 +257,22 @@ void setSelectionRange(Node* node, int start, int end)
frame->selection()->setSelection(newSelection);
}
+bool RenderTextControl::isSelectableElement(Node* node) const
+{
+ if (!node || !m_innerText)
+ return false;
+
+ if (node->rootEditableElement() == m_innerText)
+ return true;
+
+ if (!m_innerText->contains(node))
+ return false;
+
+ Node* shadowAncestor = node->shadowAncestorNode();
+ return shadowAncestor && (shadowAncestor->hasTagName(textareaTag)
+ || (shadowAncestor->hasTagName(inputTag) && static_cast<HTMLInputElement*>(shadowAncestor)->isTextField()));
+}
+
PassRefPtr<Range> RenderTextControl::selection(int start, int end) const
{
if (!m_innerText)
@@ -284,7 +301,7 @@ VisiblePosition RenderTextControl::visiblePositionForIndex(int index) const
int RenderTextControl::indexForVisiblePosition(const VisiblePosition& pos) const
{
Position indexPosition = pos.deepEquivalent();
- if (!indexPosition.node() || indexPosition.node()->rootEditableElement() != m_innerText)
+ if (!isSelectableElement(indexPosition.node()))
return 0;
ExceptionCode ec = 0;
RefPtr<Range> range = Range::create(document());
diff --git a/WebCore/rendering/RenderTextControl.h b/WebCore/rendering/RenderTextControl.h
index 0060973..ed5b52b 100644
--- a/WebCore/rendering/RenderTextControl.h
+++ b/WebCore/rendering/RenderTextControl.h
@@ -107,6 +107,7 @@ private:
bool hasVisibleTextArea() const;
friend void setSelectionRange(Node*, int start, int end);
+ bool isSelectableElement(Node*) const;
bool m_wasChangedSinceLastChangeEvent;
bool m_lastChangeWasUserEdit;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list