Diff
Modified: trunk/LayoutTests/ChangeLog (261064 => 261065)
--- trunk/LayoutTests/ChangeLog 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/LayoutTests/ChangeLog 2020-05-03 20:53:22 UTC (rev 261065)
@@ -1,3 +1,23 @@
+2020-05-03 Daniel Bates <[email protected]>
+
+ Sometimes cannot find <textarea> in list of editable elements
+ https://bugs.webkit.org/show_bug.cgi?id=211348
+ <rdar://problem/62231067>
+
+ Reviewed by Simon Fraser.
+
+ Update some existing test results and add some more tests.
+
+ * editing/editable-region/hit-test-textarea-empty-space-expected.txt: Added.
+ * editing/editable-region/hit-test-textarea-empty-space.html: Added.
+ * editing/editable-region/overflow-scroll-text-field-and-contenteditable-expected.txt:
+ * editing/editable-region/search-field-basic-expected.txt: Copied from LayoutTests/editing/editable-region/input-basic-expected.txt.
+ * editing/editable-region/search-field-basic.html: Copied from LayoutTests/editing/editable-region/input-basic.html.
+ * editing/editable-region/text-field-basic-expected.txt: Copied from LayoutTests/editing/editable-region/input-basic-expected.txt.
+ * editing/editable-region/text-field-basic.html: Copied from LayoutTests/editing/editable-region/input-basic.html.
+ * editing/editable-region/textarea-basic-expected.txt: Renamed from LayoutTests/editing/editable-region/input-basic-expected.txt.
+ * editing/editable-region/textarea-basic.html: Renamed from LayoutTests/editing/editable-region/input-basic.html.
+
2020-05-03 Simon Fraser <[email protected]>
Unreviewed test cleanup.
Added: trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space-expected.txt (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,10 @@
+Tests that the <textarea> is hit even though the rect is over an empty portion of it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS (x = 100, y = 200, width = 50, height = 50) contains editable elements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space.html (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space.html (rev 0)
+++ trunk/LayoutTests/editing/editable-region/hit-test-textarea-empty-space.html 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<style>
+#test-container {
+ position: absolute;
+ top: 100px;
+ left: 100px;
+ border: 1px solid black;
+ width: 200px;
+ height: 200px;
+}
+</style>
+</head>
+<body>
+<div id="test-container">
+ <textarea style="width: 200px; height: 200px">Hello</textarea>
+</div>
+<script>
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+async function runTest()
+{
+ if (!window.testRunner) {
+ testFailed("Must be run in WebKitTestRunner.");
+ return;
+ }
+
+ let testContainer = document.getElementById("test-container");
+ let textarea = document.querySelector("textarea");
+ // Textarea is positioned relative to test-container. So, use container's offsets.
+ await shouldHaveEditableElementsInRect(testContainer.offsetLeft, testContainer.offsetTop + 100, 50, 50);
+
+ document.body.removeChild(testContainer);
+ finishJSTest();
+}
+
+description("Tests that the <textarea> is hit even though the rect is over an empty portion of it.");
+runTest();
+</script>
+</body>
+</html>
Deleted: trunk/LayoutTests/editing/editable-region/input-basic-expected.txt (261064 => 261065)
--- trunk/LayoutTests/editing/editable-region/input-basic-expected.txt 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/LayoutTests/editing/editable-region/input-basic-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -1,20 +0,0 @@
-
-(GraphicsLayer
- (anchor 0.00 0.00)
- (bounds 800.00 600.00)
- (children 1
- (GraphicsLayer
- (bounds 800.00 600.00)
- (contentsOpaque 1)
- (drawsContent 1)
- (backgroundColor #FFFFFF)
- (event region
- (rect (0,0) width=800 height=600)
- (editable region
- (rect (16,13) width=123 height=14)
- )
- )
- )
- )
-)
-
Deleted: trunk/LayoutTests/editing/editable-region/input-basic.html (261064 => 261065)
--- trunk/LayoutTests/editing/editable-region/input-basic.html 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/LayoutTests/editing/editable-region/input-basic.html 2020-05-03 20:53:22 UTC (rev 261065)
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<input type="text">
-<pre id="results"></pre>
-<script>
-if (window.testRunner)
- testRunner.dumpAsText();
-if (window.internals)
- results.textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
-</script>
-</body>
-</html>
Modified: trunk/LayoutTests/editing/editable-region/overflow-scroll-text-field-and-contenteditable-expected.txt (261064 => 261065)
--- trunk/LayoutTests/editing/editable-region/overflow-scroll-text-field-and-contenteditable-expected.txt 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/LayoutTests/editing/editable-region/overflow-scroll-text-field-and-contenteditable-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -11,7 +11,7 @@
(event region
(rect (0,0) width=800 height=600)
(editable region
- (rect (17,206) width=123 height=14)
+ (rect (11,203) width=136 height=22)
(rect (19,451) width=275 height=35)
)
)
Copied: trunk/LayoutTests/editing/editable-region/search-field-basic-expected.txt (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic-expected.txt) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/search-field-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/editable-region/search-field-basic-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,20 @@
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=600)
+ (editable region
+ (rect (16,13) width=123 height=14)
+ )
+ )
+ )
+ )
+)
+
Copied: trunk/LayoutTests/editing/editable-region/search-field-basic.html (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic.html) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/search-field-basic.html (rev 0)
+++ trunk/LayoutTests/editing/editable-region/search-field-basic.html 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<input type="search">
+<pre id="results"></pre>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+if (window.internals)
+ results.textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+</script>
+</body>
+</html>
Copied: trunk/LayoutTests/editing/editable-region/text-field-basic-expected.txt (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic-expected.txt) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/text-field-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/editable-region/text-field-basic-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,20 @@
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=600)
+ (editable region
+ (rect (10,10) width=136 height=22)
+ )
+ )
+ )
+ )
+)
+
Copied: trunk/LayoutTests/editing/editable-region/text-field-basic.html (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic.html) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/text-field-basic.html (rev 0)
+++ trunk/LayoutTests/editing/editable-region/text-field-basic.html 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<input type="text">
+<pre id="results"></pre>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+if (window.internals)
+ results.textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+</script>
+</body>
+</html>
Copied: trunk/LayoutTests/editing/editable-region/textarea-basic-expected.txt (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic-expected.txt) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/textarea-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/editable-region/textarea-basic-expected.txt 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,20 @@
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=600)
+ (editable region
+ (rect (11,11) width=149 height=32)
+ )
+ )
+ )
+ )
+)
+
Copied: trunk/LayoutTests/editing/editable-region/textarea-basic.html (from rev 261064, trunk/LayoutTests/editing/editable-region/input-basic.html) (0 => 261065)
--- trunk/LayoutTests/editing/editable-region/textarea-basic.html (rev 0)
+++ trunk/LayoutTests/editing/editable-region/textarea-basic.html 2020-05-03 20:53:22 UTC (rev 261065)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<textarea></textarea>
+<pre id="results"></pre>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+if (window.internals)
+ results.textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (261064 => 261065)
--- trunk/Source/WebCore/ChangeLog 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/Source/WebCore/ChangeLog 2020-05-03 20:53:22 UTC (rev 261065)
@@ -1,3 +1,39 @@
+2020-05-03 Daniel Bates <[email protected]>
+
+ Sometimes cannot find <textarea> in list of editable elements
+ https://bugs.webkit.org/show_bug.cgi?id=211348
+ <rdar://problem/62231067>
+
+ Reviewed by Simon Fraser.
+
+ When building the editable region add the bounds of the text control to the region instead
+ of the bounds of its inner text element even though it is the latter that is actually editable.
+ Using the bounds of the text control is more in line with a user's expectation for the editable
+ portion of a text control: the entire control. So, do that.
+
+ Tests: editing/editable-region/hit-test-textarea-empty-space.html
+ editing/editable-region/search-field-basic.html
+ editing/editable-region/text-field-basic.html
+ editing/editable-region/textarea-basic.html
+
+ * rendering/EventRegion.cpp:
+ (WebCore::EventRegionContext::unite):
+ (WebCore::EventRegion::unite):
+ Add a new bool as to whether to override the user-modify check and just assume that the region
+ is for something editable. This is needed because the form control (e.g. the <input> or <textarea>
+ aka the shadow host element) isn't actually editable itself. Its inner text element is editable.
+ RenderBlock::paintObject() will pass true for this override when event region painting such a
+ control and the control's inner text element is editable so that the controls bounds are added to
+ the editable region.
+ * rendering/EventRegion.h: Add a bool, defaulting to false to keep the current behavior. While
+ I am here remove some unneeded WEBCORE_EXPORT attributions.
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::paintObject): Pass a value for the override argument. It will be true
+ if this block is actually a text control and its inner text element is editable. Otherwise, it
+ will be false. There is also no longer a need to descend into the children of a text control
+ because I only care to record the bounds of the control itself as editable, not its inner text
+ element.
+
2020-05-03 Zalan Bujtas <[email protected]>
[LFC][TFC] Turns horizontal space distribution into a generic space distribution
Modified: trunk/Source/WebCore/rendering/EventRegion.cpp (261064 => 261065)
--- trunk/Source/WebCore/rendering/EventRegion.cpp 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/Source/WebCore/rendering/EventRegion.cpp 2020-05-03 20:53:22 UTC (rev 261065)
@@ -71,10 +71,10 @@
m_clipStack.removeLast();
}
-void EventRegionContext::unite(const Region& region, const RenderStyle& style)
+void EventRegionContext::unite(const Region& region, const RenderStyle& style, bool overrideUserModifyIsEditable)
{
if (m_transformStack.isEmpty() && m_clipStack.isEmpty()) {
- m_eventRegion.unite(region, style);
+ m_eventRegion.unite(region, style, overrideUserModifyIsEditable);
return;
}
@@ -83,7 +83,7 @@
if (!m_clipStack.isEmpty())
transformedAndClippedRegion.intersect(m_clipStack.last());
- m_eventRegion.unite(transformedAndClippedRegion, style);
+ m_eventRegion.unite(transformedAndClippedRegion, style, overrideUserModifyIsEditable);
}
bool EventRegionContext::contains(const IntRect& rect) const
@@ -107,7 +107,7 @@
return m_region == other.m_region;
}
-void EventRegion::unite(const Region& region, const RenderStyle& style)
+void EventRegion::unite(const Region& region, const RenderStyle& style, bool overrideUserModifyIsEditable)
{
m_region.unite(region);
@@ -114,8 +114,10 @@
uniteTouchActions(region, style.effectiveTouchActions());
#if ENABLE(EDITABLE_REGION)
- if (style.userModify() != UserModify::ReadOnly)
+ if (overrideUserModifyIsEditable || style.userModify() != UserModify::ReadOnly)
m_editableRegion.unite(region);
+#else
+ UNUSED_PARAM(overrideUserModifyIsEditable);
#endif
}
Modified: trunk/Source/WebCore/rendering/EventRegion.h (261064 => 261065)
--- trunk/Source/WebCore/rendering/EventRegion.h 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/Source/WebCore/rendering/EventRegion.h 2020-05-03 20:53:22 UTC (rev 261065)
@@ -46,7 +46,7 @@
void pushClip(const IntRect&);
void popClip();
- void unite(const Region&, const RenderStyle&);
+ void unite(const Region&, const RenderStyle&, bool overrideUserModifyIsEditable = false);
bool contains(const IntRect&) const;
private:
@@ -65,8 +65,8 @@
WEBCORE_EXPORT bool operator==(const EventRegion&) const;
- WEBCORE_EXPORT void unite(const Region&, const RenderStyle&);
- WEBCORE_EXPORT void translate(const IntSize&);
+ void unite(const Region&, const RenderStyle&, bool overrideUserModifyIsEditable = false);
+ void translate(const IntSize&);
bool contains(const IntPoint& point) const { return m_region.contains(point); }
bool contains(const IntRect& rect) const { return m_region.contains(rect); }
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (261064 => 261065)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2020-05-03 18:23:39 UTC (rev 261064)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2020-05-03 20:53:22 UTC (rev 261065)
@@ -35,6 +35,7 @@
#include "FrameView.h"
#include "GraphicsContext.h"
#include "HTMLNames.h"
+#include "HTMLTextFormControlElement.h"
#include "HitTestLocation.h"
#include "HitTestResult.h"
#include "ImageBuffer.h"
@@ -63,6 +64,7 @@
#include "RenderSVGResourceClipper.h"
#include "RenderSVGRoot.h"
#include "RenderTableCell.h"
+#include "RenderTextControl.h"
#include "RenderTextFragment.h"
#include "RenderTheme.h"
#include "RenderTreeBuilder.h"
@@ -1247,7 +1249,7 @@
if (visibleToHitTesting()) {
auto borderRegion = approximateAsRegion(style().getRoundedBorderFor(borderRect));
- paintInfo.eventRegionContext->unite(borderRegion, style());
+ paintInfo.eventRegionContext->unite(borderRegion, style(), isTextControl() && downcast<RenderTextControl>(*this).textFormControlElement().isInnerTextElementEditable());
}
bool needsTraverseDescendants = hasVisualOverflow() || containsFloats() || !paintInfo.eventRegionContext->contains(enclosingIntRect(borderRect)) || view().needsEventRegionUpdateForNonCompositedFrame();
@@ -1255,7 +1257,11 @@
needsTraverseDescendants |= document().mayHaveElementsWithNonAutoTouchAction();
#endif
#if ENABLE(EDITABLE_REGION)
- needsTraverseDescendants |= document().mayHaveEditableElements();
+ // We treat the entire text control as editable to match users' expectation even
+ // though it's actually the inner text element of the control that is editable.
+ // So, no need to traverse to find the inner text element in this case.
+ if (!isTextControl())
+ needsTraverseDescendants |= document().mayHaveEditableElements();
#endif
if (!needsTraverseDescendants)
return;