Title: [239756] trunk/Source/WebCore
- Revision
- 239756
- Author
- timothy_hor...@apple.com
- Date
- 2019-01-08 17:09:06 -0800 (Tue, 08 Jan 2019)
Log Message
Editable images sometimes don't become focused when tapped
https://bugs.webkit.org/show_bug.cgi?id=193259
<rdar://problem/47038424>
Reviewed by Wenson Hsieh.
Often when tapping an editable image inside an editable text area, the
text area's selection will change instead of focusing the editable image.
No new tests; I have had no luck writing a test that reliably failed
beforehand (the "sometimes" is a problem).
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::defaultEventHandler):
* html/HTMLImageElement.h:
Override mousedown on editable images, focus the image, and prevent
the default behavior.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (239755 => 239756)
--- trunk/Source/WebCore/ChangeLog 2019-01-09 00:56:35 UTC (rev 239755)
+++ trunk/Source/WebCore/ChangeLog 2019-01-09 01:09:06 UTC (rev 239756)
@@ -1,3 +1,23 @@
+2019-01-08 Tim Horton <timothy_hor...@apple.com>
+
+ Editable images sometimes don't become focused when tapped
+ https://bugs.webkit.org/show_bug.cgi?id=193259
+ <rdar://problem/47038424>
+
+ Reviewed by Wenson Hsieh.
+
+ Often when tapping an editable image inside an editable text area, the
+ text area's selection will change instead of focusing the editable image.
+
+ No new tests; I have had no luck writing a test that reliably failed
+ beforehand (the "sometimes" is a problem).
+
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::defaultEventHandler):
+ * html/HTMLImageElement.h:
+ Override mousedown on editable images, focus the image, and prevent
+ the default behavior.
+
2019-01-08 Jiewen Tan <jiewen_...@apple.com>
[WebAuthN] Support U2F HID Authenticators on macOS
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (239755 => 239756)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2019-01-09 00:56:35 UTC (rev 239755)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2019-01-09 01:09:06 UTC (rev 239756)
@@ -31,6 +31,7 @@
#include "EditableImageReference.h"
#include "Editor.h"
#include "ElementIterator.h"
+#include "EventNames.h"
#include "FrameView.h"
#include "HTMLAnchorElement.h"
#include "HTMLAttachmentElement.h"
@@ -46,6 +47,7 @@
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "NodeTraversal.h"
+#include "PlatformMouseEvent.h"
#include "RenderImage.h"
#include "RenderView.h"
#include "RuntimeEnabledFeatures.h"
@@ -839,4 +841,14 @@
Element::copyNonAttributePropertiesFromElement(source);
}
+void HTMLImageElement::defaultEventHandler(Event& event)
+{
+ if (hasEditableImageAttribute() && event.type() == eventNames().mousedownEvent && is<MouseEvent>(event) && downcast<MouseEvent>(event).button() == LeftButton) {
+ focus();
+ event.setDefaultHandled();
+ return;
+ }
+ HTMLElement::defaultEventHandler(event);
}
+
+}
Modified: trunk/Source/WebCore/html/HTMLImageElement.h (239755 => 239756)
--- trunk/Source/WebCore/html/HTMLImageElement.h 2019-01-09 00:56:35 UTC (rev 239755)
+++ trunk/Source/WebCore/html/HTMLImageElement.h 2019-01-09 01:09:06 UTC (rev 239756)
@@ -121,6 +121,8 @@
WEBCORE_EXPORT GraphicsLayer::EmbeddedViewID editableImageViewID() const;
WEBCORE_EXPORT bool hasEditableImageAttribute() const;
+ void defaultEventHandler(Event&) final;
+
protected:
HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes