Title: [257749] trunk/Source
- Revision
- 257749
- Author
- [email protected]
- Date
- 2020-03-02 16:59:09 -0800 (Mon, 02 Mar 2020)
Log Message
Annotate editable elements with hit test order
https://bugs.webkit.org/show_bug.cgi?id=208463
<rdar://problem/59962843>
Reviewed by Wenson Hsieh.
Source/WebCore:
Until <rdar://problem/59737118> is fixed, annotate editable elements with their hit test order
towards fixing <rdar://problem/59602885>.
* dom/ElementContext.h:
(WebCore::ElementContext::encode const):
(WebCore::ElementContext::decode):
Encode and decode the optional hit test order.
Source/WebKit:
Until <rdar://problem/59737118> is fixed, annotate editable elements with their hit test
order towards fixing <rdar://problem/59602885>. Only element contexts created as a result
of calling WebPage::textInputContextsInRect() have a meaningful hit test order.
Note that the hit test order of an element can only be meaningfully compared to the hit test
order of other elements returned in the same invocation of WebPage::textInputContextsInRect().
That is, the hit test order is not render tree-unique. So, the same element returned by two
different invocations of WebPage::textInputContextsInRect() cannot be compared to any other
element outside of the list it was returned in even if its order is the same in both lists.
* UIProcess/API/Cocoa/_WKTextInputContext.mm:
(-[_WKTextInputContext _hitTestOrder]): Added. If the context does not have a hit test order
(e.g. returned form WebPage::contextForElement()) then I chose to return 0 – treat it as the
frontmost element.
* UIProcess/API/Cocoa/_WKTextInputContextInternal.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::textInputContextsInRect): Assign each element's hit test order. Following
r257722 the elements are already ordered by hit test order (frontmost to backmost). So, we can
simply assign monotonically increasing numbers.
(WebKit::WebPage::contextForElement const): Pass WTF::nullopt for the hit test order as I do
not have a need to support hit test order for individual elements.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (257748 => 257749)
--- trunk/Source/WebCore/ChangeLog 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebCore/ChangeLog 2020-03-03 00:59:09 UTC (rev 257749)
@@ -1,3 +1,19 @@
+2020-03-02 Daniel Bates <[email protected]>
+
+ Annotate editable elements with hit test order
+ https://bugs.webkit.org/show_bug.cgi?id=208463
+ <rdar://problem/59962843>
+
+ Reviewed by Wenson Hsieh.
+
+ Until <rdar://problem/59737118> is fixed, annotate editable elements with their hit test order
+ towards fixing <rdar://problem/59602885>.
+
+ * dom/ElementContext.h:
+ (WebCore::ElementContext::encode const):
+ (WebCore::ElementContext::decode):
+ Encode and decode the optional hit test order.
+
2020-03-02 Ross Kirsling <[email protected]>
Unreviewed restabilization of non-unified build.
Modified: trunk/Source/WebCore/dom/ElementContext.h (257748 => 257749)
--- trunk/Source/WebCore/dom/ElementContext.h 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebCore/dom/ElementContext.h 2020-03-03 00:59:09 UTC (rev 257749)
@@ -35,6 +35,10 @@
struct ElementContext {
FloatRect boundingRect;
+ // Lower ordinal means the element is visually closer to a person's face.
+ // FIXME: Remove this once <rdar://problem/59737118> is fixed.
+ Optional<unsigned> hitTestOrder;
+
PageIdentifier webPageIdentifier;
DocumentIdentifier documentIdentifier;
ElementIdentifier elementIdentifier;
@@ -58,6 +62,7 @@
template<class Encoder>
void ElementContext::encode(Encoder& encoder) const
{
+ encoder << hitTestOrder;
encoder << boundingRect;
encoder << webPageIdentifier;
encoder << documentIdentifier;
@@ -69,6 +74,9 @@
{
ElementContext context;
+ if (!decoder.decode(context.hitTestOrder))
+ return WTF::nullopt;
+
if (!decoder.decode(context.boundingRect))
return WTF::nullopt;
Modified: trunk/Source/WebKit/ChangeLog (257748 => 257749)
--- trunk/Source/WebKit/ChangeLog 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebKit/ChangeLog 2020-03-03 00:59:09 UTC (rev 257749)
@@ -1,3 +1,33 @@
+2020-03-02 Daniel Bates <[email protected]>
+
+ Annotate editable elements with hit test order
+ https://bugs.webkit.org/show_bug.cgi?id=208463
+ <rdar://problem/59962843>
+
+ Reviewed by Wenson Hsieh.
+
+ Until <rdar://problem/59737118> is fixed, annotate editable elements with their hit test
+ order towards fixing <rdar://problem/59602885>. Only element contexts created as a result
+ of calling WebPage::textInputContextsInRect() have a meaningful hit test order.
+
+ Note that the hit test order of an element can only be meaningfully compared to the hit test
+ order of other elements returned in the same invocation of WebPage::textInputContextsInRect().
+ That is, the hit test order is not render tree-unique. So, the same element returned by two
+ different invocations of WebPage::textInputContextsInRect() cannot be compared to any other
+ element outside of the list it was returned in even if its order is the same in both lists.
+
+ * UIProcess/API/Cocoa/_WKTextInputContext.mm:
+ (-[_WKTextInputContext _hitTestOrder]): Added. If the context does not have a hit test order
+ (e.g. returned form WebPage::contextForElement()) then I chose to return 0 – treat it as the
+ frontmost element.
+ * UIProcess/API/Cocoa/_WKTextInputContextInternal.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::textInputContextsInRect): Assign each element's hit test order. Following
+ r257722 the elements are already ordered by hit test order (frontmost to backmost). So, we can
+ simply assign monotonically increasing numbers.
+ (WebKit::WebPage::contextForElement const): Pass WTF::nullopt for the hit test order as I do
+ not have a need to support hit test order for individual elements.
+
2020-03-02 Said Abou-Hallawa <[email protected]>
Implement canvas remote rendering
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContext.mm (257748 => 257749)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContext.mm 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContext.mm 2020-03-03 00:59:09 UTC (rev 257749)
@@ -54,6 +54,12 @@
return _textInputContext.boundingRect;
}
+- (NSUInteger)_hitTestOrder
+{
+ // All elements that do not have a hit test order are considered frontmost.
+ return _textInputContext.hitTestOrder.valueOr(0);
+}
+
- (const WebCore::ElementContext&)_textInputContext
{
return _textInputContext;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContextInternal.h (257748 => 257749)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContextInternal.h 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKTextInputContextInternal.h 2020-03-03 00:59:09 UTC (rev 257749)
@@ -35,4 +35,7 @@
- (const WebCore::ElementContext&)_textInputContext;
+// Lower ordinal means the element is visually closer to a person's face.
+@property (nonatomic, readonly) NSUInteger _hitTestOrder;
+
@end
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (257748 => 257749)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-03 00:57:09 UTC (rev 257748)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-03 00:59:09 UTC (rev 257749)
@@ -6879,6 +6879,7 @@
void WebPage::textInputContextsInRect(WebCore::FloatRect searchRect, CompletionHandler<void(const Vector<WebCore::ElementContext>&)>&& completionHandler)
{
+ unsigned count = 1; // Zero is reserved for _WKTextInputContext objects that do not have a hit test order.
auto contexts = m_page->editableElementsInRect(searchRect).map([&] (const auto& element) {
auto& document = element->document();
@@ -6887,6 +6888,7 @@
context.documentIdentifier = document.identifier();
context.elementIdentifier = document.identifierForElement(element);
context.boundingRect = element->clientRect();
+ context.hitTestOrder = count++;
return context;
});
completionHandler(contexts);
@@ -6934,7 +6936,7 @@
if (!frame)
return WTF::nullopt;
- return WebCore::ElementContext { element.clientRect(), m_identifier, document.identifier(), document.identifierForElement(element) };
+ return WebCore::ElementContext { element.clientRect(), WTF::nullopt, m_identifier, document.identifier(), document.identifierForElement(element) };
}
void WebPage::startTextManipulations(Vector<WebCore::TextManipulationController::ExclusionRule>&& exclusionRules, CompletionHandler<void()>&& completionHandler)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes