VERIFIED FIXED7152
REGRESSION: Select All does not highlight table if it's last in the document
https://bugs.webkit.org/show_bug.cgi?id=7152
Summary REGRESSION: Select All does not highlight table if it's last in the document
mitz
Reported 2006-02-08 22:55:20 PST
The page footer is not included in the selection when you do Select All in the Enter Bug form.
Attachments
Test case reduction (327 bytes, text/html)
2006-02-11 00:20 PST, jonathanjohnsson
no flags
one way to fix this (4.35 KB, patch)
2006-02-19 12:26 PST, Darin Adler
justin.garcia: review-
patch (18.85 KB, patch)
2006-03-26 21:25 PST, Justin Garcia
mjs: review+
jonathanjohnsson
Comment 1 2006-02-11 00:20:52 PST
Created attachment 6404 [details] Test case reduction First, just a note that it's just visually that "select all" doesn't select everything, since copying the text after hitting cmd+a gets everything (even the "unselected" part) into the clipboard. In the reduction, removing "display: table;" from the div makes it (visually) selectable again.
mitz
Comment 2 2006-02-11 00:55:39 PST
(In reply to comment #1) Another great reduction and a good observation! It is also sufficient to add text after the last div in order to make the div highlight correctly.
mitz
Comment 3 2006-02-11 13:28:47 PST
Based on testing nightly builds, I think this is a regression from r12358, which was a fix for a bunch of editing bugs, including <rdar://problem/4259845> Table editing in design mode is broken.
David Harrison
Comment 4 2006-02-13 20:49:05 PST
This happens even not in design mode.
Darin Adler
Comment 5 2006-02-19 10:50:01 PST
Even though this happens outside of editing, it's in the editing-related code to set up selections.
Darin Adler
Comment 6 2006-02-19 11:24:17 PST
Here's what it looks like to me. The problem is caused by the fact that there is a visible position after the table, represented as the <div> element of the table with offset 1 (meaning "past the text node inside"). This shows up as the "deep equivalent" of the position, but RenderCanvas::setSelection can't deal with a selection end node that is a node with children that also need to be selected. It expects to see only positions that are "deep equivalents". In the case of this document, that means that the position needs to be at the end of a text node, not in a parent node with an offset past that text node. I think the long term direction may be to correct functions like RenderCanvas::setSelection to deal with endpoints like these, but it's not clear to me yet what the short term solution should be.
Darin Adler
Comment 7 2006-02-19 11:26:10 PST
I see now where the regression came from. Position::inRenderedContent now returns true both before and after tables: if (isTableElement(node()) || editingIgnoresContent(node())) return offset() == 0 || offset() == maxDeepOffset(node()); While I see the sense in this, it does mean that VisiblePosition::deepEquivalent is now returning offsets that aren't really "deep" in the old sense.
Darin Adler
Comment 8 2006-02-19 12:26:01 PST
Created attachment 6614 [details] one way to fix this
Maciej Stachowiak
Comment 9 2006-02-20 00:39:26 PST
Looks like an ok short-term fix, although I will let hyatt, harrison or justing comment. I also wish this kind of code about updating the selection display could be on SelectionController.
Justin Garcia
Comment 10 2006-02-20 14:00:18 PST
Comment on attachment 6614 [details] one way to fix this + while (endNode && endOffset != 0 && !offsetInCharacters(endNode->nodeType())) { + if (NodeImpl* child = startNode->childNode(endOffset)) { + endNode = child; + endOffset = 0; Don't you want to use endNode instead of startNode here? + if (startNode && !isAtomicNode(startNode)) + if (NodeImpl* child = startNode->childNode(startOffset)) { + startNode = child; + startOffset = 0; + } This would only descend one level, why not continue descending until you hit an atomic node, like you did to fix up the end position? The descent that you did could leave you at a node that doesn't have a renderer. What you'd need to do is descend to an atomic position, create a visible position with that, then pull out that VPs deepEquivalent and give that to RenderCanvas::setSelection. But I think that we should fix RenderCanvas::setSelection.
Justin Garcia
Comment 11 2006-02-20 17:38:40 PST
Comment on attachment 6614 [details] one way to fix this r-'ing, i'm going to work on this.
Alice Liu
Comment 12 2006-03-20 08:44:19 PST
Justin Garcia
Comment 13 2006-03-26 21:25:39 PST
Darin Adler
Comment 14 2006-03-26 22:54:20 PST
Comment on attachment 7322 [details] patch The operation called nextInPreOrder here is called traverseNextNode in the DOM tree. And the one called nextInPreOrderAfterChildren here is called traversNextSibling, and previousInPreOrder is traversePreviousNode. I suggest using the same terminology here.
Justin Garcia
Comment 15 2006-03-26 23:10:58 PST
> (From update of attachment 7322 [details] [edit]) > The operation called nextInPreOrder here is called traverseNextNode in the DOM > tree. And the one called nextInPreOrderAfterChildren here is called > traversNextSibling, and previousInPreOrder is traversePreviousNode. "Traverse" is a verb but the traverseX functions don't change the node, so I was thinking of changing them to match these. What do you think?
Justin Garcia
Comment 16 2006-03-26 23:12:06 PST
(In reply to comment #15) > > (From update of attachment 7322 [details] [edit] [edit]) > > The operation called nextInPreOrder here is called traverseNextNode in the DOM > > tree. And the one called nextInPreOrderAfterChildren here is called > > traversNextSibling, and previousInPreOrder is traversePreviousNode. > > "Traverse" is a verb but the traverseX functions don't change the node, so I > was thinking of changing them to match these. What do you think? I also think these are better since they tell what kind of traversal they do.
Maciej Stachowiak
Comment 17 2006-03-28 02:24:13 PST
Comment on attachment 7322 [details] patch + (WebCore::RenderObject::nextInPreOrder): Renamed from nextRenderer, cleaned up the logic a little. + (WebCore::RenderObject::nextInPreOrderAfterChildren): Added, like Node::traverseNextSibling. Might be good to call these traverseNext[Renderer] and traverseNextSibling for naming consistency with the Node ones. + (WebCore::RenderObject::previousInPreOrder): Renamed from previousRenderer. Likewise, traversePrevious[Renderer] On the other hand, maybe your new names are more clear and should be used for Node as well. +RenderObject* objectAfterPosition(RenderObject* object, unsigned offset) I would call this rendererAfterPosition or something. Other than the naming nitpicks, r=me
Justin Garcia
Comment 18 2006-03-28 03:29:21 PST
> On the other hand, maybe your new names are more clear and should be used for > Node as well. I think I want to rename traverseX to match these. > > +RenderObject* objectAfterPosition(RenderObject* object, unsigned offset) > > I would call this rendererAfterPosition or something. OK.
Darin Adler
Comment 19 2006-03-28 10:44:28 PST
(In reply to comment #15) > "Traverse" is a verb but the traverseX functions don't change the node, so I > was thinking of changing them to match these. What do you think? I think you're right!
mitz
Comment 20 2006-03-31 01:09:28 PST
Verified in r13594 nightly
Note You need to log in before you can comment on or make changes to this bug.