Home | History | Annotate | Download | only in nav
      1 /*
      2  * Copyright 2009, 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 CachedInput_h
     27 #define CachedInput_h
     28 
     29 #include "CachedDebug.h"
     30 #include "HTMLInputElement.h"
     31 #include "PlatformString.h"
     32 
     33 namespace android {
     34 
     35 class CachedInput {
     36 public:
     37     CachedInput() {
     38         // Initiaized to 0 in its array, so nothing to do in the
     39         // constructor
     40     }
     41 
     42     enum Type {
     43         NONE = -1,
     44         NORMAL_TEXT_FIELD = 0,
     45         TEXT_AREA = 1,
     46         PASSWORD = 2,
     47         SEARCH = 3,
     48         EMAIL = 4,
     49         NUMBER = 5,
     50         TELEPHONE = 6,
     51         URL = 7
     52     };
     53 
     54     bool autoComplete() const { return mAutoComplete; }
     55     void* formPointer() const { return mForm; }
     56     void init();
     57     void setTypeFromElement(WebCore::HTMLInputElement*);
     58     Type getType() const { return mType; }
     59     bool isRtlText() const { return mIsRtlText; }
     60     bool isTextField() const { return mIsTextField; }
     61     bool isTextArea() const { return mIsTextArea; }
     62     int lineHeight() const { return mLineHeight; }
     63     int maxLength() const { return mMaxLength; };
     64     const WTF::String& name() const { return mName; }
     65     int paddingBottom() const { return mPaddingBottom; }
     66     int paddingLeft() const { return mPaddingLeft; }
     67     int paddingRight() const { return mPaddingRight; }
     68     int paddingTop() const { return mPaddingTop; }
     69     void setAutoComplete(bool autoComplete) { mAutoComplete = autoComplete; }
     70     void setFormPointer(void* form) { mForm = form; }
     71     void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; }
     72     void setIsTextField(bool isTextField) { mIsTextField = isTextField; }
     73     void setIsTextArea(bool isTextArea) { mIsTextArea = isTextArea; }
     74     void setLineHeight(int height) { mLineHeight = height; }
     75     void setMaxLength(int maxLength) { mMaxLength = maxLength; }
     76     void setName(const WTF::String& name) { mName = name; }
     77     void setPaddingBottom(int bottom) { mPaddingBottom = bottom; }
     78     void setPaddingLeft(int left) { mPaddingLeft = left; }
     79     void setPaddingRight(int right) { mPaddingRight = right; }
     80     void setPaddingTop(int top) { mPaddingTop = top; }
     81     void setSpellcheck(bool spellcheck) { mSpellcheck = spellcheck; }
     82     void setTextSize(float textSize) { mTextSize = textSize; }
     83     bool spellcheck() const { return mSpellcheck; }
     84     float textSize() const { return mTextSize; }
     85 
     86 private:
     87 
     88     void* mForm;
     89     int mLineHeight;
     90     int mMaxLength;
     91     WTF::String mName;
     92     int mPaddingBottom;
     93     int mPaddingLeft;
     94     int mPaddingRight;
     95     int mPaddingTop;
     96     float mTextSize;
     97     Type mType;
     98     bool mAutoComplete : 1;
     99     bool mSpellcheck : 1;
    100     bool mIsRtlText : 1;
    101     bool mIsTextField : 1;
    102     bool mIsTextArea : 1;
    103 #if DUMP_NAV_CACHE
    104 public:
    105     class Debug {
    106 public:
    107         CachedInput* base() const;
    108         void print() const;
    109     } mDebug;
    110 #endif
    111 };
    112 
    113 }
    114 
    115 #endif
    116