Fix the gap when using the IME (Bug:2453748)

The problem was that layers may have a different size than their corresponding element,
but we used the layer's size instead of the element's to compute the fixed position.
The fix asks for the element visible overflow size (needed, some children may be outside the bounds of the element itself).
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index be275a8..a72d31b 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -230,7 +230,13 @@
             top = convertLength(view->style()->top());
             right = convertLength(view->style()->right());
             bottom = convertLength(view->style()->bottom());
-            m_contentLayer->setFixedPosition(left, top, right, bottom);
+            // We need to pass the size of the element to compute the final fixed
+            // position -- we can't use the layer's size as it could possibly differs.
+            // We also have to use the visible overflow and not just the size,
+            // as some child elements could be overflowing.
+            int w = view->rightVisibleOverflow() - view->leftVisibleOverflow();
+            int h = view->bottomVisibleOverflow() - view->topVisibleOverflow();
+            m_contentLayer->setFixedPosition(left, top, right, bottom, w, h);
         }
     }
 }
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 59533be..c21c9b3 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -85,6 +85,8 @@
     m_fixedTop = layer.m_fixedTop;
     m_fixedRight = layer.m_fixedRight;
     m_fixedBottom = layer.m_fixedBottom;
+    m_fixedWidth = layer.m_fixedWidth;
+    m_fixedHeight = layer.m_fixedHeight;
 
     m_recordingPicture = layer.m_recordingPicture;
     SkSafeRef(m_recordingPicture);
@@ -282,12 +284,12 @@
         if (m_fixedLeft.defined())
             x = dx + m_fixedLeft.calcFloatValue(w);
         else if (m_fixedRight.defined())
-            x = dx + w - m_fixedRight.calcFloatValue(w) - getSize().width();
+            x = dx + w - m_fixedRight.calcFloatValue(w) - m_fixedWidth;
 
         if (m_fixedTop.defined())
             y = dy + m_fixedTop.calcFloatValue(h);
         else if (m_fixedBottom.defined())
-            y = dy + h - m_fixedBottom.calcFloatValue(h) - getSize().height();
+            y = dy + h - m_fixedBottom.calcFloatValue(h) - m_fixedHeight;
 
         this->setPosition(x, y);
         matrix.reset();
@@ -306,13 +308,8 @@
 
     // now apply it to our children
     int count = this->countChildren();
-    if (count > 0) {
-        SkRect tmp = viewport;
-        // adjust the viewport by our (the parent) position
-        tmp.offset(-this->getPosition());
-        for (int i = 0; i < count; i++) {
-            this->getChild(i)->updatePositions(tmp);
-        }
+    for (int i = 0; i < count; i++) {
+        this->getChild(i)->updatePositions(viewport);
     }
 }
 
@@ -487,6 +484,8 @@
     writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop);
     writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight);
     writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom);
+    writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth);
+    writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight);
 
     if (countChildren()) {
         writeln(file, indentLevel + 1, "children = [");
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 23c785f..83d728f 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -88,11 +88,18 @@
         rect.offset(m_translation.fX, m_translation.fY);
         return rect;
     }
-    void setFixedPosition(SkLength left, SkLength top, SkLength right, SkLength bottom) {
+    void setFixedPosition(SkLength left,   // CSS left property
+                          SkLength top,    // CSS top property
+                          SkLength right,  // CSS right property
+                          SkLength bottom, // CSS bottom property
+                          int width,       // visible overflow width
+                          int height) {    // visible overflow height
         m_fixedLeft = left;
         m_fixedTop = top;
         m_fixedRight = right;
         m_fixedBottom = bottom;
+        m_fixedWidth = width;
+        m_fixedHeight = height;
         m_isFixed = true;
     }
 
@@ -160,6 +167,9 @@
     SkLength m_fixedTop;
     SkLength m_fixedRight;
     SkLength m_fixedBottom;
+    int m_fixedWidth;
+    int m_fixedHeight;
+
     SkPoint m_translation;
     SkPoint m_scale;
     SkScalar m_angleTransform;