WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
29937
caretRangeFromPoint() returns wrong result for text in <textarea>
https://bugs.webkit.org/show_bug.cgi?id=29937
Summary
caretRangeFromPoint() returns wrong result for text in <textarea>
Xiaomei Ji
Reported
2009-09-30 15:21:59 PDT
Created
attachment 40403
[details]
test case 1. Open the attached HTML page. 2. Type in "this is a test" in the textarea. 3. click anywhere in above text. observe the result 4. nodeType is always "element" node, and offset is always equals 3. The following code in Document::caretRangeFromPoint() changed the node type from TextNode to ElementNode, and the offset is set as the node index. Node* shadowAncestorNode = node->shadowAncestorNode(); if (shadowAncestorNode != node) { unsigned offset = shadowAncestorNode->nodeIndex(); Node* container = shadowAncestorNode->parentNode(); return Range::create(this, container, offset, container, offset); } What is the purpose of shadowAncestorNode()? Should the above code piece be changed to the following? (related to issue 29249) Node::NodeType type = node->nodeType(); if (type != Node::CDATA_SECTION_NODE && type != Node::COMMENT_NODE && type != Node::TEXT_NODE) return NULL;
Attachments
test case
(757 bytes, text/html)
2009-09-30 15:21 PDT
,
Xiaomei Ji
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2009-09-30 15:30:52 PDT
I don't believe this can work. Typing into a text area does not alter the DOM, so this would return shadow content which is an implementation detail.
Xiaomei Ji
Comment 2
2009-09-30 15:53:02 PDT
(In reply to
comment #1
)
> I don't believe this can work. Typing into a text area does not alter the DOM, > so this would return shadow content which is an implementation detail.
I tried to change the above code piece, after I type in "this is a test" in the textarea, mouse clicking shows the same/similar result as mouse clicking in the paragraph above the textarea (the actual containing nodes are different though). Typing into textarea does not alter DOM, but why need shadowAncestorNode() to change the hit-test node (and offset) if hit in textarea node? Sorry I did not get much idea on what shadowAncestorNode() does and why it is needed.
Sam Weinig
Comment 3
2009-09-30 16:06:10 PDT
shadowAncestorNode() tells us if we are in a shadow tree, which is an implementation detail of how we represent certain form controls. To the user, clicking in a textarea is just like clicking on an opaque replaced element. The important take away is that stuff in the textarea cannot be made visible in this fashion.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug