- Revision
- 141196
- Author
- [email protected]
- Date
- 2013-01-29 18:08:28 -0800 (Tue, 29 Jan 2013)
Log Message
[Chromium] Cannot copy text when selecting readonly (or disabled) input elements
https://bugs.webkit.org/show_bug.cgi?id=106287
Reviewed by Hajime Morita.
.:
* Source/autotools/symbols.filter:
Source/WebCore:
When an input element is disabled or readonly, its inner element is not editable. So its rootEditableElement
does not exist. In WebViewImpl::caretOrSelectionRange, if rootEditableElement does not exist, it uses
a document element. However, the inner element and document element have a different tree scope, the selection range
cannot be gotten correctly.
We should use ShadowRoot instead of document so that we can stay in the same tree scope.
* WebCore.exp.in:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::rootEditableElementOrTreeScopeRootNode): Added. Returns ShadowRoot so that we can
stay in the same tree scope.
(WebCore):
* editing/FrameSelection.h:
(FrameSelection):
* editing/TextIterator.cpp:
(WebCore::TextIterator::getLocationAndLengthFromRange):
* editing/TextIterator.h:
(TextIterator):
Source/WebKit/chromium:
When an input element is disabled or readonly, its inner element is not editable. So its rootEditableElement
does not exist. In WebViewImpl::caretOrSelectionRange, if rootEditableElement does not exist, it uses
a document element. However, the inner element and document element have a different tree scope, selection range
cannot be gotten correctly.
We should use ShadowRoot instead of document so that we can stay in the same tree scope.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::caretOrSelectionRange):
* tests/WebViewTest.cpp:
* tests/data/selection_disabled.html: Added.
* tests/data/selection_readonly.html: Added.
Source/WebKit/win:
* WebKit.vcproj/WebKitExports.def.in:
Modified Paths
Added Paths
Diff
Modified: trunk/ChangeLog (141195 => 141196)
--- trunk/ChangeLog 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/ChangeLog 2013-01-30 02:08:28 UTC (rev 141196)
@@ -1,3 +1,12 @@
+2013-01-29 Shinya Kawanaka <[email protected]>
+
+ [Chromium] Cannot copy text when selecting readonly (or disabled) input elements
+ https://bugs.webkit.org/show_bug.cgi?id=106287
+
+ Reviewed by Hajime Morita.
+
+ * Source/autotools/symbols.filter:
+
2013-01-29 Laszlo Gombos <[email protected]>
[CMake] Add minimum version information for tool dependencies
Modified: trunk/Source/WebCore/ChangeLog (141195 => 141196)
--- trunk/Source/WebCore/ChangeLog 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/ChangeLog 2013-01-30 02:08:28 UTC (rev 141196)
@@ -1,3 +1,29 @@
+2013-01-29 Shinya Kawanaka <[email protected]>
+
+ [Chromium] Cannot copy text when selecting readonly (or disabled) input elements
+ https://bugs.webkit.org/show_bug.cgi?id=106287
+
+ Reviewed by Hajime Morita.
+
+ When an input element is disabled or readonly, its inner element is not editable. So its rootEditableElement
+ does not exist. In WebViewImpl::caretOrSelectionRange, if rootEditableElement does not exist, it uses
+ a document element. However, the inner element and document element have a different tree scope, the selection range
+ cannot be gotten correctly.
+
+ We should use ShadowRoot instead of document so that we can stay in the same tree scope.
+
+ * WebCore.exp.in:
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::rootEditableElementOrTreeScopeRootNode): Added. Returns ShadowRoot so that we can
+ stay in the same tree scope.
+ (WebCore):
+ * editing/FrameSelection.h:
+ (FrameSelection):
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::getLocationAndLengthFromRange):
+ * editing/TextIterator.h:
+ (TextIterator):
+
2013-01-29 Kent Tamura <[email protected]>
INPUT_MULTIPLE_FIELDS_UI: The content should not overflow the <input> boundary
Modified: trunk/Source/WebCore/WebCore.exp.in (141195 => 141196)
--- trunk/Source/WebCore/WebCore.exp.in 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/WebCore.exp.in 2013-01-30 02:08:28 UTC (rev 141196)
@@ -197,7 +197,7 @@
__ZN7WebCore12TextEncodingC1ERKN3WTF6StringE
__ZN7WebCore12TextIterator11rangeLengthEPKNS_5RangeEb
__ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib
-__ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERmS6_
+__ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_4NodeEPKNS_5RangeERmS6_
__ZN7WebCore12TextIterator7advanceEv
__ZN7WebCore12TextIterator8subrangeEPNS_5RangeEii
__ZN7WebCore12TextIteratorC1EPKNS_5RangeENS_20TextIteratorBehaviorE
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (141195 => 141196)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2013-01-30 02:08:28 UTC (rev 141196)
@@ -125,6 +125,16 @@
return selectionRoot ? selectionRoot : m_frame->document()->documentElement();
}
+Node* FrameSelection::rootEditableElementOrTreeScopeRootNode() const
+{
+ Element* selectionRoot = m_selection.rootEditableElement();
+ if (selectionRoot)
+ return selectionRoot;
+
+ Node* node = m_selection.base().containerNode();
+ return node ? node->treeScope()->rootNode() : 0;
+}
+
Element* FrameSelection::rootEditableElementRespectingShadowTree() const
{
Element* selectionRoot = m_selection.rootEditableElement();
Modified: trunk/Source/WebCore/editing/FrameSelection.h (141195 => 141196)
--- trunk/Source/WebCore/editing/FrameSelection.h 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/editing/FrameSelection.h 2013-01-30 02:08:28 UTC (rev 141196)
@@ -134,6 +134,7 @@
Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
Element* rootEditableElementOrDocumentElement() const;
+ Node* rootEditableElementOrTreeScopeRootNode() const;
Element* rootEditableElementRespectingShadowTree() const;
bool rendererIsEditable() const { return m_selection.rendererIsEditable(); }
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (141195 => 141196)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2013-01-30 02:08:28 UTC (rev 141196)
@@ -2523,7 +2523,7 @@
return resultRange.release();
}
-bool TextIterator::getLocationAndLengthFromRange(Element* scope, const Range* range, size_t& location, size_t& length)
+bool TextIterator::getLocationAndLengthFromRange(Node* scope, const Range* range, size_t& location, size_t& length)
{
location = notFound;
length = 0;
Modified: trunk/Source/WebCore/editing/TextIterator.h (141195 => 141196)
--- trunk/Source/WebCore/editing/TextIterator.h 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebCore/editing/TextIterator.h 2013-01-30 02:08:28 UTC (rev 141196)
@@ -102,7 +102,7 @@
static int rangeLength(const Range*, bool spacesForReplacedElements = false);
static PassRefPtr<Range> rangeFromLocationAndLength(ContainerNode* scope, int rangeLocation, int rangeLength, bool spacesForReplacedElements = false);
- static bool getLocationAndLengthFromRange(Element* scope, const Range*, size_t& location, size_t& length);
+ static bool getLocationAndLengthFromRange(Node* scope, const Range*, size_t& location, size_t& length);
static PassRefPtr<Range> subrange(Range* entireRange, int characterOffset, int characterCount);
private:
Modified: trunk/Source/WebKit/chromium/ChangeLog (141195 => 141196)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-01-30 02:08:28 UTC (rev 141196)
@@ -1,3 +1,23 @@
+2013-01-29 Shinya Kawanaka <[email protected]>
+
+ [Chromium] Cannot copy text when selecting readonly (or disabled) input elements
+ https://bugs.webkit.org/show_bug.cgi?id=106287
+
+ Reviewed by Hajime Morita.
+
+ When an input element is disabled or readonly, its inner element is not editable. So its rootEditableElement
+ does not exist. In WebViewImpl::caretOrSelectionRange, if rootEditableElement does not exist, it uses
+ a document element. However, the inner element and document element have a different tree scope, selection range
+ cannot be gotten correctly.
+
+ We should use ShadowRoot instead of document so that we can stay in the same tree scope.
+
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::caretOrSelectionRange):
+ * tests/WebViewTest.cpp:
+ * tests/data/selection_disabled.html: Added.
+ * tests/data/selection_readonly.html: Added.
+
2013-01-29 Tom Sepez <[email protected]>
[v8] Enable binding integrity on linux
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (141195 => 141196)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2013-01-30 02:08:28 UTC (rev 141196)
@@ -2537,7 +2537,7 @@
if (!range)
return false;
- if (TextIterator::getLocationAndLengthFromRange(selection->rootEditableElementOrDocumentElement(), range.get(), *location, *length))
+ if (TextIterator::getLocationAndLengthFromRange(selection->rootEditableElementOrTreeScopeRootNode(), range.get(), *location, *length))
return true;
return false;
}
Modified: trunk/Source/WebKit/chromium/tests/WebViewTest.cpp (141195 => 141196)
--- trunk/Source/WebKit/chromium/tests/WebViewTest.cpp 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebKit/chromium/tests/WebViewTest.cpp 2013-01-30 02:08:28 UTC (rev 141196)
@@ -652,4 +652,52 @@
}
#endif
+TEST_F(WebViewTest, SelectionOnDisabledInput)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("selection_disabled.html"));
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selection_disabled.html", true);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ std::string testWord = "This text should be selected.";
+
+ WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data()));
+
+ size_t location;
+ size_t length;
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+
+ EXPECT_TRUE(webViewImpl->caretOrSelectionRange(&location, &length));
+ EXPECT_EQ(location, 0UL);
+ EXPECT_EQ(length, testWord.length());
+
+ webView->close();
}
+
+TEST_F(WebViewTest, SelectionOnReadOnlyInput)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("selection_readonly.html"));
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "selection_readonly.html", true);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ std::string testWord = "This text should be selected.";
+
+ WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ EXPECT_EQ(testWord, std::string(frame->selectionAsText().utf8().data()));
+
+ size_t location;
+ size_t length;
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+
+ EXPECT_TRUE(webViewImpl->caretOrSelectionRange(&location, &length));
+ EXPECT_EQ(location, 0UL);
+ EXPECT_EQ(length, testWord.length());
+
+ webView->close();
+}
+
+}
Added: trunk/Source/WebKit/chromium/tests/data/selection_disabled.html (0 => 141196)
--- trunk/Source/WebKit/chromium/tests/data/selection_disabled.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/selection_disabled.html 2013-01-30 02:08:28 UTC (rev 141196)
@@ -0,0 +1,5 @@
+<input id="disabled-input" type="text" value="This text should be selected." disabled>
+<script>
+var input = document.getElementById('disabled-input');
+input.select();
+</script>
Added: trunk/Source/WebKit/chromium/tests/data/selection_readonly.html (0 => 141196)
--- trunk/Source/WebKit/chromium/tests/data/selection_readonly.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/selection_readonly.html 2013-01-30 02:08:28 UTC (rev 141196)
@@ -0,0 +1,5 @@
+<input id="readonly-input" type="text" value="This text should be selected." readonly>
+<script>
+var input = document.getElementById('readonly-input');
+input.select();
+</script>
Modified: trunk/Source/WebKit/win/ChangeLog (141195 => 141196)
--- trunk/Source/WebKit/win/ChangeLog 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebKit/win/ChangeLog 2013-01-30 02:08:28 UTC (rev 141196)
@@ -1,3 +1,12 @@
+2013-01-29 Shinya Kawanaka <[email protected]>
+
+ [Chromium] Cannot copy text when selecting readonly (or disabled) input elements
+ https://bugs.webkit.org/show_bug.cgi?id=106287
+
+ Reviewed by Hajime Morita.
+
+ * WebKit.vcproj/WebKitExports.def.in:
+
2013-01-29 Elliott Sprehn <[email protected]>
Refactor ShadowRoot exception handling
Modified: trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in (141195 => 141196)
--- trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in 2013-01-30 02:08:28 UTC (rev 141196)
@@ -192,7 +192,7 @@
?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ
- ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVElement@2@PBVRange@2@AAI2@Z
+ ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVNode@2@PBVRange@2@AAI2@Z
?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@@WTF@@ABV34@@Z
?inputTag@HTMLNames@WebCore@@3VQualifiedName@2@B
#if ENABLE(INSPECTOR)
@@ -580,7 +580,7 @@
?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ
- ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVElement@2@PBVRange@2@AAI2@Z
+ ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVNode@2@PBVRange@2@AAI2@Z
?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@@WTF@@ABV34@@Z
?inputTag@HTMLNames@WebCore@@3VQualifiedName@2@B
#if ENABLE(INSPECTOR)
@@ -966,7 +966,7 @@
?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ
- ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVElement@2@PBVRange@2@AAI2@Z
+ ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVNode@2@PBVRange@2@AAI2@Z
?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@@WTF@@ABV34@@Z
?inputTag@HTMLNames@WebCore@@3VQualifiedName@2@B
#if ENABLE(INSPECTOR)
@@ -1356,7 +1356,7 @@
?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ
?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ
- ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVElement@2@PBVRange@2@AAI2@Z
+ ?getLocationAndLengthFromRange@TextIterator@WebCore@@SA_NPAVNode@2@PBVRange@2@AAI2@Z
?getReferencedFilePaths@FormController@WebCore@@SA?AV?$Vector@VString@WTF@@$0A@@WTF@@ABV34@@Z
?inputTag@HTMLNames@WebCore@@3VQualifiedName@2@B
#if ENABLE(INSPECTOR)
Modified: trunk/Source/autotools/symbols.filter (141195 => 141196)
--- trunk/Source/autotools/symbols.filter 2013-01-30 02:05:22 UTC (rev 141195)
+++ trunk/Source/autotools/symbols.filter 2013-01-30 02:08:28 UTC (rev 141196)
@@ -57,8 +57,7 @@
_ZN7WebCore11HistoryItem16setDocumentStateERKN3WTF6VectorINS1_6StringELm0EEE;
_ZN7WebCore11MemoryCache14resourceForURLERKNS_4KURLE;
_ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib;
-_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERjS6_;
-_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERmS6_;
+_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_4NodeEPKNS_5RangeERmS6_;
_ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE;
_ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE;
_ZN7WebCore14ClientRectListC1ERKN3WTF6VectorINS_9FloatQuadELj0EEE;