Title: [171320] trunk/Source
Revision
171320
Author
[email protected]
Date
2014-07-21 16:44:33 -0700 (Mon, 21 Jul 2014)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171319 => 171320)


--- trunk/Source/WebCore/ChangeLog	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebCore/ChangeLog	2014-07-21 23:44:33 UTC (rev 171320)
@@ -1,3 +1,14 @@
+2014-07-21  Simon Fraser  <[email protected]>
+
+        [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.
+
+        Export RenderObject::localToContainerPoint().
+
+        * WebCore.exp.in:
+
 2014-07-21  Jer Noble  <[email protected]>
 
         [MSE] YouTube video decode error when variant-switching

Modified: trunk/Source/WebCore/WebCore.exp.in (171319 => 171320)


--- trunk/Source/WebCore/WebCore.exp.in	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-07-21 23:44:33 UTC (rev 171320)
@@ -1613,6 +1613,7 @@
 __ZNK7WebCore12RenderObject15localToAbsoluteERKNS_10FloatPointEj
 __ZNK7WebCore12RenderObject16repaintRectangleERKNS_10LayoutRectEb
 __ZNK7WebCore12RenderObject20localToContainerQuadERKNS_9FloatQuadEPKNS_22RenderLayerModelObjectEjPb
+__ZNK7WebCore12RenderObject21localToContainerPointERKNS_10FloatPointEPKNS_22RenderLayerModelObjectEjPb
 __ZNK7WebCore12RenderObject23absoluteBoundingBoxRectEb
 __ZNK7WebCore12RenderObject39pixelSnappedAbsoluteClippedOverflowRectEv
 __ZNK7WebCore12RenderObject7childAtEj

Modified: trunk/Source/WebKit2/ChangeLog (171319 => 171320)


--- trunk/Source/WebKit2/ChangeLog	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-21 23:44:33 UTC (rev 171320)
@@ -1,3 +1,35 @@
+2014-07-21  Simon Fraser  <[email protected]>
+
+        [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.
+        
+        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.
+
 2014-07-21  Timothy Horton  <[email protected]>
 
         Random crashes on the Web Thread due to Timers firing on the wrong thread in the UI process

Modified: trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp (171319 => 171320)


--- trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp	2014-07-21 23:44:33 UTC (rev 171320)
@@ -79,6 +79,7 @@
     encoder << isMultiSelect;
     encoder << isReadOnly;
     encoder << allowsUserScaling;
+    encoder << insideFixedPosition;
     encoder << value;
     encoder << valueAsNumber;
     encoder << title;
@@ -134,6 +135,9 @@
     if (!decoder.decode(result.allowsUserScaling))
         return false;
 
+    if (!decoder.decode(result.insideFixedPosition))
+        return false;
+
     if (!decoder.decode(result.value))
         return false;
 

Modified: trunk/Source/WebKit2/Shared/AssistedNodeInformation.h (171319 => 171320)


--- trunk/Source/WebKit2/Shared/AssistedNodeInformation.h	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/Shared/AssistedNodeInformation.h	2014-07-21 23:44:33 UTC (rev 171320)
@@ -102,6 +102,7 @@
         , isMultiSelect(false)
         , isReadOnly(false)
         , allowsUserScaling(false)
+        , insideFixedPosition(false)
         , autocapitalizeType(WebAutocapitalizeTypeDefault)
         , elementType(InputType::None)
         , selectedIndex(-1)
@@ -120,6 +121,7 @@
     bool isMultiSelect;
     bool isReadOnly;
     bool allowsUserScaling;
+    bool insideFixedPosition;
     WebAutocapitalizeType autocapitalizeType;
     InputType elementType;
     String formAction;

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (171319 => 171320)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2014-07-21 23:44:33 UTC (rev 171320)
@@ -259,6 +259,7 @@
 
     virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
     virtual void stopAssistingNode() = 0;
+    virtual bool isAssistingNode() = 0;
     virtual void selectionDidChange() = 0;
     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (171319 => 171320)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2014-07-21 23:44:33 UTC (rev 171320)
@@ -119,6 +119,7 @@
 
     virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override;
     virtual void stopAssistingNode() override;
+    virtual bool isAssistingNode() override;
     virtual void selectionDidChange() override;
     virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) override;
     virtual void positionInformationDidChange(const InteractionInformationAtPosition&) override;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (171319 => 171320)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-07-21 23:44:33 UTC (rev 171320)
@@ -530,6 +530,11 @@
     [m_contentView _startAssistingNode:nodeInformation userIsInteracting:userIsInteracting blurPreviousNode:blurPreviousNode userObject:userObject];
 }
 
+bool PageClientImpl::isAssistingNode()
+{
+    return [m_contentView isAssistingNode];
+}
+
 void PageClientImpl::stopAssistingNode()
 {
     [m_contentView _stopAssistingNode];

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (171319 => 171320)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2014-07-21 23:44:33 UTC (rev 171320)
@@ -37,6 +37,7 @@
 #import "WKFormSelectControl.h"
 #import "WKInspectorNodeSearchGestureRecognizer.h"
 #import "WKWebViewConfiguration.h"
+#import "WKWebViewInternal.h"
 #import "WKWebViewPrivate.h"
 #import "WebEvent.h"
 #import "WebIOSEventFactory.h"
@@ -2548,6 +2549,10 @@
         [self _startAssistingKeyboard];
         break;
     }
+    
+    if (information.insideFixedPosition)
+        [_webView _updateVisibleContentRects];
+
     [self reloadInputViews];
     [self _displayFormNodeInputView];
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (171319 => 171320)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2014-07-21 23:44:33 UTC (rev 171320)
@@ -220,6 +220,9 @@
     FloatSize contentsSize = m_pageClient.contentsSize();
     FloatRect documentRect = FloatRect(FloatPoint(), contentsSize);
 
+    if (m_pageClient.isAssistingNode())
+        return documentRect;
+
     if (constraint == UnobscuredRectConstraint::ConstrainedToDocumentRect)
         constrainedUnobscuredRect.intersect(documentRect);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (171319 => 171320)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-07-21 23:10:44 UTC (rev 171319)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-07-21 23:44:33 UTC (rev 171320)
@@ -1989,14 +1989,33 @@
 {
     layoutIfNeeded();
 
+    // FIXME: This should return the selection rect, but when this is called at focus time
+    // we don't have a selection yet. Using the last interaction location is a reasonable approximation for now.
+    // FIXME: should the selection rect always be inside the elementRect?
+    information.selectionRect = IntRect(m_lastInteractionLocation, IntSize(1, 1));
+
     if (RenderObject* renderer = m_assistedNode->renderer()) {
-        information.elementRect = m_page->focusController().focusedOrMainFrame().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
+        Frame& elementFrame = m_page->focusController().focusedOrMainFrame();
+        information.elementRect = elementFrame.view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
         information.nodeFontSize = renderer->style().fontDescription().computedSize();
+
+        bool inFixed = false;
+        renderer->localToContainerPoint(FloatPoint(), nullptr, 0, &inFixed);
+        information.insideFixedPosition = inFixed;
+        
+        if (inFixed && elementFrame.isMainFrame()) {
+            FrameView* frameView = elementFrame.view();
+            IntRect currentFixedPositionRect = frameView->customFixedPositionLayoutRect();
+            frameView->setCustomFixedPositionLayoutRect(frameView->renderView()->documentRect());
+            information.elementRect = frameView->contentsToRootView(renderer->absoluteBoundingBoxRect());
+            frameView->setCustomFixedPositionLayoutRect(currentFixedPositionRect);
+            
+            if (!information.elementRect.contains(information.selectionRect))
+                information.selectionRect.setLocation(information.elementRect.location());
+        }
     } else
         information.elementRect = IntRect();
-    // FIXME: This should return the selection rect, but when this is called at focus time
-    // we don't have a selection yet. Using the last interaction location is a reasonable approximation for now.
-    information.selectionRect = IntRect(m_lastInteractionLocation, IntSize(1, 1));
+
     information.minimumScaleFactor = m_viewportConfiguration.minimumScale();
     information.maximumScaleFactor = m_viewportConfiguration.maximumScale();
     information.allowsUserScaling = m_viewportConfiguration.allowsUserScaling();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to