<attachment> should be selected immediately upon click, and be drag/copyable upon...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 00:09:09 +0000 (00:09 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 00:09:09 +0000 (00:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142114
<rdar://problem/19982520>

Reviewed by Enrica Casucci.

* css/html.css:
(attachment):
Make attachment use 'user-select: all' to act as a single click-to-select unit.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::setFocus): Deleted.
* html/HTMLAttachmentElement.h:
* rendering/RenderAttachment.cpp:
(WebCore::RenderAttachment::isFocused): Deleted.
(WebCore::RenderAttachment::focusChanged): Deleted.
* rendering/RenderAttachment.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintAttachment):
Remove focus-related code; instead of focusing the element upon click,
we get a selection including just the <attachment>, and everything
behaves much more consistently (copy works, drag works, etc.).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180794 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/html.css
Source/WebCore/html/HTMLAttachmentElement.cpp
Source/WebCore/html/HTMLAttachmentElement.h
Source/WebCore/rendering/RenderAttachment.cpp
Source/WebCore/rendering/RenderAttachment.h
Source/WebCore/rendering/RenderThemeMac.mm

index edfc2e0..5d60b06 100644 (file)
@@ -1,3 +1,28 @@
+2015-02-27  Timothy Horton  <timothy_horton@apple.com>
+
+        <attachment> should be selected immediately upon click, and be drag/copyable upon click
+        https://bugs.webkit.org/show_bug.cgi?id=142114
+        <rdar://problem/19982520>
+
+        Reviewed by Enrica Casucci.
+
+        * css/html.css:
+        (attachment):
+        Make attachment use 'user-select: all' to act as a single click-to-select unit.
+
+        * html/HTMLAttachmentElement.cpp:
+        (WebCore::HTMLAttachmentElement::setFocus): Deleted.
+        * html/HTMLAttachmentElement.h:
+        * rendering/RenderAttachment.cpp:
+        (WebCore::RenderAttachment::isFocused): Deleted.
+        (WebCore::RenderAttachment::focusChanged): Deleted.
+        * rendering/RenderAttachment.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintAttachment):
+        Remove focus-related code; instead of focusing the element upon click,
+        we get a selection including just the <attachment>, and everything
+        behaves much more consistently (copy works, drag works, etc.).
+
 2015-02-27  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [iOS] Some MathML tests crash in RenderMathMLOperator::advanceForGlyph() or boundsForGlyph()
index 636aac4..0564230 100644 (file)
@@ -1195,6 +1195,7 @@ applet, embed, object, img {
 #if defined(ENABLE_ATTACHMENT_ELEMENT) && ENABLE_ATTACHMENT_ELEMENT
 attachment {
     -webkit-appearance: attachment;
+    -webkit-user-select: all;
 }
 
 attachment:focus {
index 061afb9..2cf4c09 100644 (file)
@@ -72,20 +72,6 @@ void HTMLAttachmentElement::setFile(File* file)
     downcast<RenderAttachment>(*renderer).representedFileChanged();
 }
 
-void HTMLAttachmentElement::setFocus(bool shouldBeFocused)
-{
-    if (focused() == shouldBeFocused)
-        return;
-    
-    HTMLElement::setFocus(shouldBeFocused);
-    
-    auto* renderer = this->renderer();
-    if (!is<RenderAttachment>(renderer))
-        return;
-    
-    downcast<RenderAttachment>(*renderer).focusChanged();
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
index cdf77f5..7fc338c 100644 (file)
@@ -37,7 +37,6 @@ class File;
 class HTMLAttachmentElement final : public HTMLElement {
 public:
     static Ref<HTMLAttachmentElement> create(const QualifiedName&, Document&);
-    virtual bool canContainRangeEndPoint() const override { return false; }
     File* file() const;
     void setFile(File*);
 
@@ -47,8 +46,7 @@ private:
 
     virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&) override;
 
-    virtual bool isFocusable() const override { return true; }
-    virtual void setFocus(bool shouldBeFocused) override;
+    virtual bool canContainRangeEndPoint() const override { return false; }
     
     RefPtr<File> m_file;
 };
index cf99a44..cdda217 100644 (file)
@@ -57,11 +57,6 @@ bool RenderAttachment::isSelected() const
     return selectionRange && selectionRange->intersectsNode(&nodeForNonAnonymous(), ASSERT_NO_EXCEPTION);
 }
 
-bool RenderAttachment::isFocused() const
-{
-    return frame().selection().isFocusedAndActive() && document().focusedElement() == &attachmentElement();
-}
-
 void RenderAttachment::layout()
 {
     setIntrinsicSize(document().page()->theme().attachmentIntrinsicSize(*this));
@@ -69,11 +64,6 @@ void RenderAttachment::layout()
     RenderReplaced::layout();
 }
 
-void RenderAttachment::focusChanged()
-{
-    repaint();
-}
-
 void RenderAttachment::representedFileChanged()
 {
     setNeedsLayout();
index b68a09a..2fae7fb 100644 (file)
@@ -40,10 +40,9 @@ public:
 
     HTMLAttachmentElement& attachmentElement() const;
 
-    void focusChanged();
     void representedFileChanged();
 
-    bool isSelectedOrFocused() const { return isSelected() || isFocused(); }
+    bool isSelected() const;
 
 private:
     void element() const = delete;
@@ -54,9 +53,6 @@ private:
 
     virtual void layout() override;
 
-    bool isSelected() const;
-    bool isFocused() const;
-
     virtual int baselinePosition(FontBaseline, bool, LineDirectionMode, LinePositionMode) const;
 };
 
index 397f753..3e541f9 100644 (file)
@@ -2251,7 +2251,7 @@ bool RenderThemeMac::paintAttachment(const RenderObject& renderer, const PaintIn
     context.translate(toFloatSize(paintRect.location()));
     context.translate(FloatSize((layout.attachmentRect.width() - attachmentIconBackgroundSize) / 2, 0));
 
-    bool useSelectedStyle = attachment.isSelectedOrFocused();
+    bool useSelectedStyle = attachment.isSelected();
 
     if (useSelectedStyle)
         paintAttachmentIconBackground(attachment, context, layout);