minor fixes to layer nav

- get rid of the FloatPoint interface in LayerAndroid;
use (x, y) instead
- make CachedFrame a friend of CachedRoot and CacheBuilder
a friend of CachedNode so they alone can access private fields.
- assume the LayerAndroid picture can sometimes be null.
If it is, use the main page's picture instead.

http://b/2369549
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 8fb335e..44f19c2 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -205,16 +205,16 @@
         getChild(i)->clipInner(region, m_haveClip ? localBounds : local);
 }
 
-const LayerAndroid* LayerAndroid::find(FloatPoint pos) const
+const LayerAndroid* LayerAndroid::find(int x, int y) const
 {
     for (int i = 0; i < countChildren(); i++) {
-        const LayerAndroid* found = getChild(i)->find(pos);
+        const LayerAndroid* found = getChild(i)->find(x, y);
         if (found)
             return found;
     }
     SkRect localBounds;
     bounds(&localBounds);
-    if (localBounds.contains(pos))
+    if (localBounds.contains(x, y))
         return this;
     return 0;
 }
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index deb51bc..841eeb8 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -19,7 +19,6 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "FloatPoint.h"
 #include "RefPtr.h"
 #include "SkColor.h"
 #include "SkLayer.h"
@@ -54,7 +53,6 @@
     void setIsRootLayer(bool isRootLayer) { m_isRootLayer = isRootLayer; }
 
     virtual void draw(SkCanvas*, const SkRect* viewPort);
-//    GraphicsContext* paintContext();
     bool prepareContext(bool force = false);
     void startRecording();
     void stopRecording();
@@ -74,7 +72,7 @@
     void bounds(SkRect* ) const;
     bool calcPosition(const SkRect* viewPort, SkMatrix*);
     void clipArea(SkTDArray<SkRect>* region) const;
-    const LayerAndroid* find(FloatPoint position) const;
+    const LayerAndroid* find(int x, int y) const;
     const LayerAndroid* findById(int uniqueID) const;
     LayerAndroid* getChild(int index) const { return
         static_cast<LayerAndroid*>(m_children[index]); }
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 62c2771..f0000cf 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -1112,7 +1112,7 @@
                 IntRect(0, 0, INT_MAX, INT_MAX);
             if (ConstructTextRects((WebCore::Text*) node, walk.mStart, 
                     (WebCore::Text*) walk.mFinalNode, walk.mEnd, globalOffsetX,
-                    globalOffsetY, &bounds, clip, cachedNode.cursorRingsPtr()) == false)
+                    globalOffsetY, &bounds, clip, &cachedNode.mCursorRing) == false)
                 continue;
             absBounds = bounds;
             cachedNode.setBounds(bounds);
@@ -1204,9 +1204,9 @@
         cachedNode.init(node);
         if (computeCursorRings == false) {
             cachedNode.setBounds(bounds);
-            cachedNode.cursorRingsPtr()->append(bounds);
-        } else if (ConstructPartRects(node, bounds, cachedNode.boundsPtr(), 
-                globalOffsetX, globalOffsetY, cachedNode.cursorRingsPtr()) == false)
+            cachedNode.mCursorRing.append(bounds);
+        } else if (ConstructPartRects(node, bounds, &cachedNode.mBounds,
+                globalOffsetX, globalOffsetY, &cachedNode.mCursorRing) == false)
             continue;
     keepTextNode:
         IntRect clip = hasClip ? bounds : absBounds;
@@ -1316,7 +1316,7 @@
             lastNode->hasTagName(HTMLNames::bodyTag) ||
             lastNode->hasTagName(HTMLNames::formTag)) {
         lastCached->setBounds(IntRect(0, 0, 0, 0));
-        lastCached->cursorRingsPtr()->clear();
+        lastCached->mCursorRing.clear();
         lastCached->setNavableRects();
         return false;
     }
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index de407c8..b1f4193 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -144,7 +144,7 @@
 {
     if (testData.mNode->tabIndex() != bestData.mNode->tabIndex()) {
         if (testData.mNode->tabIndex() < bestData.mNode->tabIndex()
-                || (mRoot->cursor() && mRoot->cursor()->tabIndex() < bestData.mNode->tabIndex())) {
+                || (mRoot->mCursor && mRoot->mCursor->tabIndex() < bestData.mNode->tabIndex())) {
             testData.mNode->setCondition(CachedNode::HIGHER_TAB_INDEX);
             return REJECT_TEST;
         }
@@ -640,7 +640,7 @@
                 *bestData = testData;
         }
     } while ((test = test->traverseNextNode()) != limit);
-    ASSERT(mRoot->cursor() == NULL || bestData->mNode != mRoot->cursor());
+    ASSERT(mRoot->mCursor == NULL || bestData->mNode != mRoot->mCursor);
     // does the best contain something (or, is it contained by an area which is not the cursor?)
         // if so, is the conainer/containee should have been chosen, but wasn't -- so there's a better choice
         // in the doc list prior to this choice
@@ -680,7 +680,7 @@
                 *bestData = testData;
         }
     } while ((test = test->traverseNextNode()) != limit);  // FIXME ??? left and up should use traversePreviousNode to choose reverse document order
-    ASSERT(mRoot->cursor() == NULL || bestData->mNode != mRoot->cursor());
+    ASSERT(mRoot->mCursor == NULL || bestData->mNode != mRoot->mCursor);
     return bestData->mNode;
 }
 
@@ -708,20 +708,20 @@
 //        return REJECT_TEST;
 //    }
 //
-    if (test == mRoot->cursor()) {
+    if (test == mRoot->mCursor) {
         testData.mNode->setCondition(CachedNode::NOT_CURSOR_NODE);
         return REJECT_TEST;
     }
-//    if (test->bounds().contains(mRoot->cursorBounds())) {
+//    if (test->bounds().contains(mRoot->mCursorBounds)) {
 //        testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR);
 //        return REJECT_TEST;
 //    }
-    void* par = mRoot->cursor() ? mRoot->cursor()->parentGroup() : NULL;
+    void* par = mRoot->mCursor ? mRoot->mCursor->parentGroup() : NULL;
     testData.mCursorChild = par ? test->parentGroup() == par : false;
     if (bestData->mNode == NULL)
         return TEST_IS_BEST;
-    if (mRoot->cursor() && testData.mNode->parentIndex() != bestData->mNode->parentIndex()) {
-        int cursorParentIndex = mRoot->cursor()->parentIndex();
+    if (mRoot->mCursor && testData.mNode->parentIndex() != bestData->mNode->parentIndex()) {
+        int cursorParentIndex = mRoot->mCursor->parentIndex();
         if (cursorParentIndex >= 0) {
             if (bestData->mNode->parentIndex() == cursorParentIndex)
                 return REJECT_TEST;
@@ -759,8 +759,8 @@
 int CachedFrame::framePartCommon(BestData& testData,
     const CachedNode* test, BestData* bestData) const
 {
-    if (mRoot->cursor()
-            && testData.bounds().contains(mRoot->cursorBounds())
+    if (mRoot->mCursor
+            && testData.bounds().contains(mRoot->mCursorBounds)
             && !test->wantsKeyEvents()) {
         testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_CURSOR);
         return REJECT_TEST;
@@ -809,7 +809,7 @@
                 *bestData = testData;
         }
     } while ((test = test->traverseNextNode()) != limit);
-    ASSERT(mRoot->cursor() == NULL || bestData->mNode != mRoot->cursor());
+    ASSERT(mRoot->mCursor == NULL || bestData->mNode != mRoot->mCursor);
     return bestData->mNode;
 }
 
@@ -845,7 +845,7 @@
                 *bestData = testData;
         }
     } while ((test = test->traverseNextNode()) != limit);  // FIXME ??? left and up should use traversePreviousNode to choose reverse document order
-    ASSERT(mRoot->cursor() == NULL || bestData->mNode != mRoot->cursor());
+    ASSERT(mRoot->mCursor == NULL || bestData->mNode != mRoot->mCursor);
     return bestData->mNode;
 }
 
@@ -965,7 +965,7 @@
     if (node->isInLayer())
         return layer(node)->picture(mRoot->rootLayer());
 #endif
-    return mRoot->getPicture();
+    return mRoot->mPicture;
 }
 
 void CachedFrame::resetClippedOut()
diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp
index 9406db1..e5040ea 100644
--- a/WebKit/android/nav/CachedNode.cpp
+++ b/WebKit/android/nav/CachedNode.cpp
@@ -361,7 +361,7 @@
     DEBUG_PRINT_RECT(mBounds);
     DEBUG_PRINT_RECT(mHitBounds);
     DEBUG_PRINT_RECT(mOriginalAbsoluteBounds);
-    const WTF::Vector<WebCore::IntRect>* rects = b->cursorRingsPtr();
+    const WTF::Vector<WebCore::IntRect>* rects = &b->mCursorRing;
     size_t size = rects->size();
     DUMP_NAV_LOGD("// IntRect cursorRings={ // size=%d\n", size);
     for (size_t i = 0; i < size; i++) {
diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h
index 825eab7..a5fc0da 100644
--- a/WebKit/android/nav/CachedNode.h
+++ b/WebKit/android/nav/CachedNode.h
@@ -88,7 +88,6 @@
     }
 
     WebCore::IntRect bounds(const CachedFrame* ) const;
-    WebCore::IntRect* boundsPtr() { return &mBounds; } // CacheBuilder only
     int childFrameIndex() const { return isFrame() ? mDataIndex : -1; }
     void clearCondition() const { mCondition = NOT_REJECTED; }
     void clearCursor(CachedFrame* );
@@ -97,8 +96,6 @@
     bool clip(const WebCore::IntRect& );
     bool clippedOut() { return mClippedOut; }
     WebCore::IntRect cursorRingBounds(const CachedFrame* ) const;
-    // cursorRingsPtr() only for CacheBuilder since it points to raw data
-    WTF::Vector<WebCore::IntRect>* cursorRingsPtr() { return &mCursorRing; }
     void cursorRings(const CachedFrame* , WTF::Vector<WebCore::IntRect>* ) const;
     bool disabled() const { return mDisabled; }
     const CachedNode* document() const { return &this[-mIndex]; }
@@ -172,6 +169,7 @@
     bool useHitBounds() const { return mUseHitBounds; }
     bool wantsKeyEvents() const { return isTextInput() || isPlugin(); }
 private:
+    friend class CacheBuilder;
     WebCore::String mExport;
     WebCore::IntRect mBounds;
     WebCore::IntRect mHitBounds;
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index d81d764..60b151d 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -1273,9 +1273,12 @@
 {
 #if USE(ACCELERATED_COMPOSITING)
     if (mRootLayer) {
-        const LayerAndroid* layer = mRootLayer->find(FloatPoint(x, y));
-        if (layer)
-            return layer->picture();
+        const LayerAndroid* layer = mRootLayer->find(x, y);
+        if (layer) {
+            SkPicture* picture = layer->picture();
+            if (picture)
+                return picture;
+        }
     }
 #endif
     return mPicture;
diff --git a/WebKit/android/nav/CachedRoot.h b/WebKit/android/nav/CachedRoot.h
index e4461d1..ae1530f 100644
--- a/WebKit/android/nav/CachedRoot.h
+++ b/WebKit/android/nav/CachedRoot.h
@@ -54,8 +54,6 @@
     bool checkRings(SkPicture* , const WTF::Vector<WebCore::IntRect>& rings,
         const WebCore::IntRect& bounds) const;
     WebCore::IntPoint cursorLocation() const;
-    const WebCore::IntRect& cursorBounds() const { return mCursorBounds; } // should only be called by CachedFrame
-    const CachedNode* cursor() const { return mCursor; } // should only be called by CachedFrame
     int documentHeight() { return mContents.height(); }
     int documentWidth() { return mContents.width(); }
     void draw(FindCanvas& ) const;
@@ -63,7 +61,6 @@
         int* x, int* y, bool checkForHidden) const;
     const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
     WebCore::IntPoint focusLocation() const;
-    SkPicture* getPicture() const { return mPicture; } // should only be called by CachedFrame
     int getAndResetSelectionEnd();
     int getAndResetSelectionStart();
     int getBlockLeftEdge(int x, int y, float scale) const;
@@ -99,6 +96,7 @@
     int textGeneration() const { return mTextGeneration; }
     int width() const { return mPicture ? mPicture->width() : 0; }
 private:
+    friend class CachedFrame;
     CachedHistory* mHistory;
     SkPicture* mPicture;
     WebCore::LayerAndroid* mRootLayer;
diff --git a/WebKit/android/nav/FindCanvas.cpp b/WebKit/android/nav/FindCanvas.cpp
index 15a8001..ef7b96c 100644
--- a/WebKit/android/nav/FindCanvas.cpp
+++ b/WebKit/android/nav/FindCanvas.cpp
@@ -476,7 +476,7 @@
     MatchInfo matchInfo;
     mMatches->append(matchInfo);
     LOGD("%s region=%p pict=%p layer=%d", __FUNCTION__,
-        region, mWorkingPicture, mLayerId);
+        &region, mWorkingPicture, mLayerId);
     mMatches->last().set(region, mWorkingPicture, mLayerId);
 }