CachedRoot.h revision a2aaeda3cab40ff823fc40ebff51b828d1a9bc1c
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 "wtf/Vector.h" 33 34class SkRect; 35 36namespace android { 37 38class CachedHistory; 39class CachedNode; 40 41class CachedRoot : public CachedFrame { 42public: 43 bool adjustForScroll(BestData* , Direction , WebCore::IntPoint* scrollPtr, 44 bool findClosest); 45 int checkForCenter(int x, int y) const; 46 void checkForJiggle(int* ) const; 47 bool checkRings(const WTF::Vector<WebCore::IntRect>& rings, 48 const WebCore::IntRect& bounds) const; 49 WebCore::IntPoint cursorLocation() const; 50 int documentHeight() { return mContents.height(); } 51 int documentWidth() { return mContents.width(); } 52 const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** , 53 int* x, int* y, bool checkForHidden) const; 54 const WebCore::IntRect& focusBounds() const { return mFocusBounds; } 55 WebCore::IntPoint focusLocation() const; 56 SkPicture* getPicture() { return mPicture; } 57 int getAndResetSelectionEnd(); 58 int getAndResetSelectionStart(); 59 int getBlockLeftEdge(int x, int y, float scale) const; 60 void getSimulatedMousePosition(WebCore::IntPoint* ) const; 61 void init(WebCore::Frame* , CachedHistory* ); 62 bool innerDown(const CachedNode* , BestData* ) const; 63 bool innerLeft(const CachedNode* , BestData* ) const; 64 void innerMove(const CachedNode* ,BestData* bestData, Direction , 65 WebCore::IntPoint* scroll, bool firstCall); 66 bool innerRight(const CachedNode* , BestData* ) const; 67 bool innerUp(const CachedNode* , BestData* ) const; 68 WebCore::String imageURI(int x, int y) const; 69 bool maskIfHidden(BestData* ) const; 70 const CachedNode* moveCursor(Direction , const CachedFrame** , WebCore::IntPoint* scroll); 71 void reset(); 72 CachedHistory* rootHistory() const { return mHistory; } 73 bool scrollDelta(WebCore::IntRect& cursorRingBounds, Direction , int* delta); 74 const WebCore::IntRect& scrolledBounds() const { return mScrolledBounds; } 75 void setCursor(CachedFrame* , CachedNode* ); 76 void setCachedFocus(CachedFrame* , CachedNode* ); 77 void setFocusBounds(const WebCore::IntRect& r) { mFocusBounds = r; } 78 void setTextGeneration(int textGeneration) { mTextGeneration = textGeneration; } 79 void setMaxScroll(int x, int y) { mMaxXScroll = x; mMaxYScroll = y; } 80 void setPicture(SkPicture* picture) { mPicture = picture; } 81 void setScrollOnly(bool state) { mScrollOnly = state; } 82 void setSelection(int start, int end) { mSelectionStart = start; mSelectionEnd = end; } 83 void setupScrolledBounds() const { mScrolledBounds = mViewBounds; } 84 void setVisibleRect(const WebCore::IntRect& r) { mViewBounds = r; } 85 int textGeneration() const { return mTextGeneration; } 86 int width() const { return mPicture ? mPicture->width() : 0; } 87private: 88 CachedHistory* mHistory; 89 SkPicture* mPicture; 90 WebCore::IntRect mFocusBounds; // dom text input focus node bounds 91 mutable WebCore::IntRect mScrolledBounds; // view bounds + amount visible as result of scroll 92 int mTextGeneration; 93 int mMaxXScroll; 94 int mMaxYScroll; 95 // These two are ONLY used when the tree is rebuilt and the focus is a textfield/area 96 int mSelectionStart; 97 int mSelectionEnd; 98 bool mScrollOnly; 99#if DUMP_NAV_CACHE 100public: 101 class Debug { 102public: 103 CachedRoot* base() const; 104 void print() const; 105 } mDebug; 106#endif 107}; 108 109} 110 111#endif 112