• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007, The Android Open Source Project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *  * Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef CachedRoot_H
27 #define CachedRoot_H
28 
29 #include "CachedFrame.h"
30 #include "IntRect.h"
31 #include "SkPicture.h"
32 #include "SkRegion.h"
33 #include "wtf/Vector.h"
34 
35 class SkRect;
36 
37 namespace WebCore {
38     class LayerAndroid;
39 }
40 
41 namespace android {
42 
43 class CachedHistory;
44 class CachedNode;
45 class FindCanvas;
46 
47 class CachedRoot : public CachedFrame {
48 public:
49     bool adjustForScroll(BestData* , Direction , WebCore::IntPoint* scrollPtr,
50         bool findClosest);
baseUncovered()51     const SkRegion& baseUncovered() const { return mBaseUncovered; }
52     int checkForCenter(int x, int y) const;
53     void checkForJiggle(int* ) const;
54     bool checkRings(SkPicture* , const WTF::Vector<WebCore::IntRect>& rings,
55         const WebCore::IntRect& bounds) const;
56     WebCore::IntPoint cursorLocation() const;
documentHeight()57     int documentHeight() { return mContents.height(); }
documentWidth()58     int documentWidth() { return mContents.width(); }
59     void draw(FindCanvas& ) const;
60     const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** ,
61         int* x, int* y, bool checkForHidden) const;
focusBounds()62     const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
63     WebCore::IntPoint focusLocation() const;
64     int getAndResetSelectionEnd();
65     int getAndResetSelectionStart();
66     int getBlockLeftEdge(int x, int y, float scale) const;
67     void getSimulatedMousePosition(WebCore::IntPoint* ) const;
68     void init(WebCore::Frame* , CachedHistory* );
69     bool innerDown(const CachedNode* , BestData* ) const;
70     bool innerLeft(const CachedNode* , BestData* ) const;
71     void innerMove(const CachedNode* ,BestData* bestData, Direction ,
72         WebCore::IntPoint* scroll, bool firstCall);
73     bool innerRight(const CachedNode* , BestData* ) const;
74     bool innerUp(const CachedNode* , BestData* ) const;
75     WebCore::String imageURI(int x, int y) const;
76     bool maskIfHidden(BestData* ) const;
77     const CachedNode* moveCursor(Direction , const CachedFrame** , WebCore::IntPoint* scroll);
78     /**
79      * Find the next textfield/textarea
80      * @param start         The textfield/textarea to search from.
81      * @param framePtr      If non-zero, returns CachedFrame* containing result.
82      * @return CachedNode*  Next textfield/textarea or null (0) if none.
83      */
84     const CachedNode* nextTextField(const CachedNode* start,
85         const CachedFrame** framePtr) const;
86     SkPicture* pictureAt(int x, int y) const;
87     void reset();
rootHistory()88     CachedHistory* rootHistory() const { return mHistory; }
rootLayer()89     const WebCore::LayerAndroid* rootLayer() const { return mRootLayer; }
90     bool scrollDelta(WebCore::IntRect& cursorRingBounds, Direction , int* delta);
scrolledBounds()91     const WebCore::IntRect& scrolledBounds() const { return mScrolledBounds; }
92     void setCursor(CachedFrame* , CachedNode* );
93     void setCursorCache(int scrollX, int scrollY) const; // compute cached state used to find next cursor
94     void setCachedFocus(CachedFrame* , CachedNode* );
setFocusBounds(const WebCore::IntRect & r)95     void setFocusBounds(const WebCore::IntRect& r) { mFocusBounds = r; }
setTextGeneration(int textGeneration)96     void setTextGeneration(int textGeneration) { mTextGeneration = textGeneration; }
setMaxScroll(int x,int y)97     void setMaxScroll(int x, int y) { mMaxXScroll = x; mMaxYScroll = y; }
setPicture(SkPicture * picture)98     void setPicture(SkPicture* picture) { mPicture = picture; }
setRootLayer(WebCore::LayerAndroid * layer)99     void setRootLayer(WebCore::LayerAndroid* layer) { mRootLayer = layer; }
setScrollOnly(bool state)100     void setScrollOnly(bool state) { mScrollOnly = state; }
setSelection(int start,int end)101     void setSelection(int start, int end) { mSelectionStart = start; mSelectionEnd = end; }
setupScrolledBounds()102     void setupScrolledBounds() const { mScrolledBounds = mViewBounds; }
setVisibleRect(const WebCore::IntRect & r)103     void setVisibleRect(const WebCore::IntRect& r) { mViewBounds = r; }
textGeneration()104     int textGeneration() const { return mTextGeneration; }
width()105     int width() const { return mPicture ? mPicture->width() : 0; }
106 private:
107     friend class CachedFrame;
108     CachedHistory* mHistory;
109     SkPicture* mPicture;
110     WebCore::LayerAndroid* mRootLayer;
111     WebCore::IntRect mFocusBounds; // dom text input focus node bounds
112     mutable WebCore::IntRect mScrolledBounds; // view bounds + amount visible as result of scroll
113     int mTextGeneration;
114     int mMaxXScroll;
115     int mMaxYScroll;
116     // These two are ONLY used when the tree is rebuilt and the focus is a textfield/area
117     int mSelectionStart;
118     int mSelectionEnd;
119     // these four set up as cache for use by frameDown/Up/Left/Right etc
120     mutable WebCore::IntRect mCursorBounds;
121     mutable const CachedNode* mCursor;
122     mutable SkRegion mBaseUncovered;
123     bool mScrollOnly;
124 #if DUMP_NAV_CACHE
125 public:
126     class Debug {
127 public:
128         CachedRoot* base() const;
129         void print() const;
130     } mDebug;
131 #endif
132 };
133 
134 }
135 
136 #endif
137