Changeset 171320 in webkit


Ignore:
Timestamp:
Jul 21, 2014 4:44:33 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Turn off position:fixed behavior when the keyboard is up
https://bugs.webkit.org/show_bug.cgi?id=132537

Reviewed by Benjamin Poulain.

Source/WebCore:

Export RenderObject::localToContainerPoint().

  • WebCore.exp.in:

Source/WebKit2:

Make interaction with form elements inside position:fixed less terrible by re-laying out
fixed elements relative to the document while we have an assisted node. This ensures
that all parts of a position:fixed are accessible (e.g. inputs on the right side
of a fixed-width top bar).

  • Shared/AssistedNodeInformation.cpp: Add a flag for being inside postion:fixed,

and encode/decode it.
(WebKit::AssistedNodeInformation::encode):
(WebKit::AssistedNodeInformation::decode):

  • Shared/AssistedNodeInformation.h:

(WebKit::AssistedNodeInformation::AssistedNodeInformation):

  • UIProcess/PageClient.h: Add isAssistingNode().
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::isAssistingNode):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::computeCustomFixedPositionRect): If we have an assisted
node, just use the document rect as the custom fixed position rect.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getAssistedNodeInformation): Get the selection rect first,
since we have to fix it up for position:fixed. If the element is inside fixed
position in the main frame, re-set the fixed position rect to the document rect
(which forces a layout), re-fetch elementRect, then set it back. This ensures
that the UI process gets an elementRect which it can zoom to correctly.

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171316 r171320  
     12014-07-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Turn off position:fixed behavior when the keyboard is up
     4        https://bugs.webkit.org/show_bug.cgi?id=132537
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Export RenderObject::localToContainerPoint().
     9
     10        * WebCore.exp.in:
     11
    1122014-07-21  Jer Noble  <jer.noble@apple.com>
    213
  • trunk/Source/WebCore/WebCore.exp.in

    r171314 r171320  
    16141614__ZNK7WebCore12RenderObject16repaintRectangleERKNS_10LayoutRectEb
    16151615__ZNK7WebCore12RenderObject20localToContainerQuadERKNS_9FloatQuadEPKNS_22RenderLayerModelObjectEjPb
     1616__ZNK7WebCore12RenderObject21localToContainerPointERKNS_10FloatPointEPKNS_22RenderLayerModelObjectEjPb
    16161617__ZNK7WebCore12RenderObject23absoluteBoundingBoxRectEb
    16171618__ZNK7WebCore12RenderObject39pixelSnappedAbsoluteClippedOverflowRectEv
  • trunk/Source/WebKit2/ChangeLog

    r171317 r171320  
     12014-07-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Turn off position:fixed behavior when the keyboard is up
     4        https://bugs.webkit.org/show_bug.cgi?id=132537
     5
     6        Reviewed by Benjamin Poulain.
     7       
     8        Make interaction with form elements inside position:fixed less terrible by re-laying out
     9        fixed elements relative to the document while we have an assisted node. This ensures
     10        that all parts of a position:fixed are accessible (e.g. inputs on the right side
     11        of a fixed-width top bar).
     12       
     13        * Shared/AssistedNodeInformation.cpp: Add a flag for being inside postion:fixed,
     14        and encode/decode it.
     15        (WebKit::AssistedNodeInformation::encode):
     16        (WebKit::AssistedNodeInformation::decode):
     17        * Shared/AssistedNodeInformation.h:
     18        (WebKit::AssistedNodeInformation::AssistedNodeInformation):
     19        * UIProcess/PageClient.h: Add isAssistingNode().
     20        * UIProcess/ios/PageClientImplIOS.h:
     21        * UIProcess/ios/PageClientImplIOS.mm:
     22        (WebKit::PageClientImpl::isAssistingNode):
     23        * UIProcess/ios/WebPageProxyIOS.mm:
     24        (WebKit::WebPageProxy::computeCustomFixedPositionRect): If we have an assisted
     25        node, just use the document rect as the custom fixed position rect.
     26        * WebProcess/WebPage/ios/WebPageIOS.mm:
     27        (WebKit::WebPage::getAssistedNodeInformation): Get the selection rect first,
     28        since we have to fix it up for position:fixed. If the element is inside fixed
     29        position in the main frame, re-set the fixed position rect to the document rect
     30        (which forces a layout), re-fetch elementRect, then set it back. This ensures
     31        that the UI process gets an elementRect which it can zoom to correctly.
     32
    1332014-07-21  Timothy Horton  <timothy_horton@apple.com>
    234
  • trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp

    r170321 r171320  
    8080    encoder << isReadOnly;
    8181    encoder << allowsUserScaling;
     82    encoder << insideFixedPosition;
    8283    encoder << value;
    8384    encoder << valueAsNumber;
     
    135136        return false;
    136137
     138    if (!decoder.decode(result.insideFixedPosition))
     139        return false;
     140
    137141    if (!decoder.decode(result.value))
    138142        return false;
  • trunk/Source/WebKit2/Shared/AssistedNodeInformation.h

    r170321 r171320  
    103103        , isReadOnly(false)
    104104        , allowsUserScaling(false)
     105        , insideFixedPosition(false)
    105106        , autocapitalizeType(WebAutocapitalizeTypeDefault)
    106107        , elementType(InputType::None)
     
    121122    bool isReadOnly;
    122123    bool allowsUserScaling;
     124    bool insideFixedPosition;
    123125    WebAutocapitalizeType autocapitalizeType;
    124126    InputType elementType;
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r171154 r171320  
    260260    virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
    261261    virtual void stopAssistingNode() = 0;
     262    virtual bool isAssistingNode() = 0;
    262263    virtual void selectionDidChange() = 0;
    263264    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r171154 r171320  
    120120    virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
    121121    virtual void stopAssistingNode() override;
     122    virtual bool isAssistingNode() override;
    122123    virtual void selectionDidChange() override;
    123124    virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r171154 r171320  
    531531}
    532532
     533bool PageClientImpl::isAssistingNode()
     534{
     535    return [m_contentView isAssistingNode];
     536}
     537
    533538void PageClientImpl::stopAssistingNode()
    534539{
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r171203 r171320  
    3838#import "WKInspectorNodeSearchGestureRecognizer.h"
    3939#import "WKWebViewConfiguration.h"
     40#import "WKWebViewInternal.h"
    4041#import "WKWebViewPrivate.h"
    4142#import "WebEvent.h"
     
    25492550        break;
    25502551    }
     2552   
     2553    if (information.insideFixedPosition)
     2554        [_webView _updateVisibleContentRects];
     2555
    25512556    [self reloadInputViews];
    25522557    [self _displayFormNodeInputView];
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r171154 r171320  
    221221    FloatRect documentRect = FloatRect(FloatPoint(), contentsSize);
    222222
     223    if (m_pageClient.isAssistingNode())
     224        return documentRect;
     225
    223226    if (constraint == UnobscuredRectConstraint::ConstrainedToDocumentRect)
    224227        constrainedUnobscuredRect.intersect(documentRect);
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r171280 r171320  
    19901990    layoutIfNeeded();
    19911991
     1992    // FIXME: This should return the selection rect, but when this is called at focus time
     1993    // we don't have a selection yet. Using the last interaction location is a reasonable approximation for now.
     1994    // FIXME: should the selection rect always be inside the elementRect?
     1995    information.selectionRect = IntRect(m_lastInteractionLocation, IntSize(1, 1));
     1996
    19921997    if (RenderObject* renderer = m_assistedNode->renderer()) {
    1993         information.elementRect = m_page->focusController().focusedOrMainFrame().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
     1998        Frame& elementFrame = m_page->focusController().focusedOrMainFrame();
     1999        information.elementRect = elementFrame.view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
    19942000        information.nodeFontSize = renderer->style().fontDescription().computedSize();
     2001
     2002        bool inFixed = false;
     2003        renderer->localToContainerPoint(FloatPoint(), nullptr, 0, &inFixed);
     2004        information.insideFixedPosition = inFixed;
     2005       
     2006        if (inFixed && elementFrame.isMainFrame()) {
     2007            FrameView* frameView = elementFrame.view();
     2008            IntRect currentFixedPositionRect = frameView->customFixedPositionLayoutRect();
     2009            frameView->setCustomFixedPositionLayoutRect(frameView->renderView()->documentRect());
     2010            information.elementRect = frameView->contentsToRootView(renderer->absoluteBoundingBoxRect());
     2011            frameView->setCustomFixedPositionLayoutRect(currentFixedPositionRect);
     2012           
     2013            if (!information.elementRect.contains(information.selectionRect))
     2014                information.selectionRect.setLocation(information.elementRect.location());
     2015        }
    19952016    } else
    19962017        information.elementRect = IntRect();
    1997     // FIXME: This should return the selection rect, but when this is called at focus time
    1998     // we don't have a selection yet. Using the last interaction location is a reasonable approximation for now.
    1999     information.selectionRect = IntRect(m_lastInteractionLocation, IntSize(1, 1));
     2018
    20002019    information.minimumScaleFactor = m_viewportConfiguration.minimumScale();
    20012020    information.maximumScaleFactor = m_viewportConfiguration.maximumScale();
Note: See TracChangeset for help on using the changeset viewer.