Changeset 229982 in webkit


Ignore:
Timestamp:
Mar 26, 2018 12:09:33 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[Extra zoom mode] Add plumbing for next and previous focusable element rects
https://bugs.webkit.org/show_bug.cgi?id=184016
Work towards <rdar://problem/38758727>

Reviewed by Tim Horton.

When building up AssistedNodeInformation, we currently compute the element rect of the current focused element,
as well as flags indicating whether or not there are next or previous focusable elements. For
<rdar://problem/38758727>, we additionally send the rects of the next or previous focusable elements as well.

  • Shared/AssistedNodeInformation.cpp:

(WebKit::AssistedNodeInformation::encode const):
(WebKit::AssistedNodeInformation::decode):

IPC support for nextNodeRect and previousNodeRect.

  • Shared/AssistedNodeInformation.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::elementRectInRootViewCoordinates):

Add a helper to compute an element's rect in root view coordinates. We use this to compute the rects of the
current focused element as well as those of the next and previous elements, if any.

(WebKit::WebPage::getAssistedNodeInformation):
(WebKit::hasAssistableElement): Deleted.

Since we need the next or previous focusable element to get its rect, we don't need this helper anymore.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r229979 r229982  
     12018-03-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Add plumbing for next and previous focusable element rects
     4        https://bugs.webkit.org/show_bug.cgi?id=184016
     5        Work towards <rdar://problem/38758727>
     6
     7        Reviewed by Tim Horton.
     8
     9        When building up AssistedNodeInformation, we currently compute the element rect of the current focused element,
     10        as well as flags indicating whether or not there are next or previous focusable elements. For
     11        <rdar://problem/38758727>, we additionally send the rects of the next or previous focusable elements as well.
     12
     13        * Shared/AssistedNodeInformation.cpp:
     14        (WebKit::AssistedNodeInformation::encode const):
     15        (WebKit::AssistedNodeInformation::decode):
     16
     17        IPC support for nextNodeRect and previousNodeRect.
     18
     19        * Shared/AssistedNodeInformation.h:
     20        * WebProcess/WebPage/ios/WebPageIOS.mm:
     21        (WebKit::elementRectInRootViewCoordinates):
     22
     23        Add a helper to compute an element's rect in root view coordinates. We use this to compute the rects of the
     24        current focused element as well as those of the next and previous elements, if any.
     25
     26        (WebKit::WebPage::getAssistedNodeInformation):
     27        (WebKit::hasAssistableElement): Deleted.
     28
     29        Since we need the next or previous focusable element to get its rect, we don't need this helper anymore.
     30
    1312018-03-26  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit/Shared/AssistedNodeInformation.cpp

    r229783 r229982  
    7171    encoder << nodeFontSize;
    7272    encoder << hasNextNode;
     73    encoder << nextNodeRect;
    7374    encoder << hasPreviousNode;
     75    encoder << previousNodeRect;
    7476    encoder << isAutocorrect;
    7577    encoder << isRTL;
     
    118120        return false;
    119121
     122    if (!decoder.decode(result.nextNodeRect))
     123        return false;
     124
    120125    if (!decoder.decode(result.hasPreviousNode))
     126        return false;
     127
     128    if (!decoder.decode(result.previousNodeRect))
    121129        return false;
    122130
  • trunk/Source/WebKit/Shared/AssistedNodeInformation.h

    r229783 r229982  
    9595    double nodeFontSize { 0 };
    9696    bool hasNextNode { false };
     97    WebCore::IntRect nextNodeRect;
    9798    bool hasPreviousNode { false };
     99    WebCore::IntRect previousNodeRect;
    98100    bool isAutocorrect { false };
    99101    bool isRTL { false };
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r229783 r229982  
    26922692}
    26932693
    2694 static inline bool hasAssistableElement(Node* startNode, Page& page, bool isForward)
    2695 {
    2696     return nextAssistableElement(startNode, page, isForward);
    2697 }
    2698 
    26992694void WebPage::focusNextAssistedNode(bool isForward, CallbackID callbackID)
    27002695{
     
    27072702}
    27082703
     2704static IntRect elementRectInRootViewCoordinates(const Node& node, const Frame& frame)
     2705{
     2706    auto* view = frame.view();
     2707    if (!view)
     2708        return { };
     2709
     2710    auto* renderer = node.renderer();
     2711    if (!renderer)
     2712        return { };
     2713
     2714    return view->contentsToRootView(renderer->absoluteBoundingBoxRect());
     2715}
     2716
    27092717void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
    27102718{
     
    27172725    if (RenderObject* renderer = m_assistedNode->renderer()) {
    27182726        Frame& elementFrame = m_page->focusController().focusedOrMainFrame();
    2719         information.elementRect = elementFrame.view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
     2727        information.elementRect = elementRectInRootViewCoordinates(*m_assistedNode, elementFrame);
    27202728        information.nodeFontSize = renderer->style().fontDescription().computedSize();
    27212729
     
    27472755    information.allowsUserScaling = m_viewportConfiguration.allowsUserScaling();
    27482756    information.allowsUserScalingIgnoringAlwaysScalable = m_viewportConfiguration.allowsUserScalingIgnoringAlwaysScalable();
    2749     information.hasNextNode = hasAssistableElement(m_assistedNode.get(), *m_page, true);
    2750     information.hasPreviousNode = hasAssistableElement(m_assistedNode.get(), *m_page, false);
     2757    if (auto* nextElement = nextAssistableElement(m_assistedNode.get(), *m_page, true)) {
     2758        if (auto* frame = nextElement->document().frame())
     2759            information.nextNodeRect = elementRectInRootViewCoordinates(*nextElement, *frame);
     2760        information.hasNextNode = true;
     2761    }
     2762    if (auto* previousElement = nextAssistableElement(m_assistedNode.get(), *m_page, false)) {
     2763        if (auto* frame = previousElement->document().frame())
     2764            information.previousNodeRect = elementRectInRootViewCoordinates(*previousElement, *frame);
     2765        information.hasPreviousNode = true;
     2766    }
    27512767    information.assistedNodeIdentifier = m_currentAssistedNodeIdentifier;
    27522768
Note: See TracChangeset for help on using the changeset viewer.