<attachment> shouldn't use "user-select: all"
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2015 00:33:07 +0000 (00:33 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2015 00:33:07 +0000 (00:33 +0000)
commite761f183cc811c09238ce571d77650573d7046c5
treeec9bef9a88fea671faf504ea8784434c9a0f6f3f
parent2853d9db76b2e6393f54ebacf0392250e0d2d241
<attachment> shouldn't use "user-select: all"
https://bugs.webkit.org/show_bug.cgi?id=142453

Reviewed by Darin Adler.

It turns out that "user-select: all" is rife with bugs; in lieu of fixing them
all (at least for now), let's not use "user-select: all" in the default stylesheet
for <attachment>. It's really overkill anyway, since <attachment> can't have children.
The only "user-select: all" behavior we actually want is select-on-click.
So, we'll implement that in a slightly different way.

Tests: fast/attachment/attachment-select-on-click-inside-user-select-all.html
       fast/attachment/attachment-select-on-click.html

* css/html.css:
(attachment):
No more "user-select: all".

(attachment:focus): Deleted.
We stopped using attachment focus a while back and forgot to remove this.

* dom/Node.h:
(WebCore::Node::shouldSelectOnMouseDown):
Add a virtual function that Node subclasses can override to indicate they
should be selected on mouse down.

* html/HTMLAttachmentElement.h:
Override the aforementioned virtual function; <attachment> should always
be selected on mouse down.

* page/EventHandler.cpp:
(WebCore::nodeToSelectOnMouseDownForNode):
Determine which node should be selected when a mousedown hits the given node.
If there's any "user-select: all", we go with the outermost "user-select: all".
Otherwise, we give the node a chance to say that it wants to be selected itself.

(WebCore::expandSelectionToRespectSelectOnMouseDown):
Rename this function, it's not just about "user-select: all" anymore.
Make use of nodeToSelectOnMouseDownForNode.

(WebCore::EventHandler::selectClosestWordFromHitTestResult):
(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent):
(WebCore::EventHandler::handleMousePressEventTripleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::expandSelectionToRespectUserSelectAll): Deleted.
Adjust to the new names.

* fast/attachment/attachment-select-on-click-inside-user-select-all.html: Added.
* fast/attachment/attachment-select-on-click.html: Added.
* platform/mac/fast/attachment/attachment-select-on-click-expected.png: Added.
* platform/mac/fast/attachment/attachment-select-on-click-expected.txt: Added.
* platform/mac/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.png: Added.
* platform/mac/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.txt: Added.
* platform/mac-mavericks/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.txt: Added.
* platform/mac-mavericks/fast/attachment/attachment-select-on-click-expected.txt: Added.
Add two tests. One, for the basic functionality of clicking on an
<attachment> to select it. The second, to test that clicking on an
<attachment> inside a larger "user-select: all" element still selects
the whole "user-select: all" element.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/attachment/attachment-select-on-click-inside-user-select-all.html [new file with mode: 0644]
LayoutTests/fast/attachment/attachment-select-on-click.html [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/fast/attachment/attachment-select-on-click-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-select-on-click-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-select-on-click-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-select-on-click-inside-user-select-all-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/html.css
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLAttachmentElement.h
Source/WebCore/page/EventHandler.cpp