WebCore/rendering/RenderTextControlSingleLine.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
       
     3  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Library General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Library General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Library General Public License
       
    16  * along with this library; see the file COPYING.LIB.  If not, write to
       
    17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18  * Boston, MA 02110-1301, USA.
       
    19  *
       
    20  */
       
    21 
       
    22 #ifndef RenderTextControlSingleLine_h
       
    23 #define RenderTextControlSingleLine_h
       
    24 
       
    25 #include "PopupMenuClient.h"
       
    26 #include "RenderTextControl.h"
       
    27 #include "Timer.h"
       
    28 
       
    29 namespace WebCore {
       
    30 
       
    31 class InputElement;
       
    32 class InputFieldSpeechButtonElement;
       
    33 class SearchFieldCancelButtonElement;
       
    34 class SearchFieldResultsButtonElement;
       
    35 class SearchPopupMenu;
       
    36 class SpinButtonElement;
       
    37 class TextControlInnerElement;
       
    38 
       
    39 class RenderTextControlSingleLine : public RenderTextControl, private PopupMenuClient {
       
    40 public:
       
    41     RenderTextControlSingleLine(Node*, bool);
       
    42     virtual ~RenderTextControlSingleLine();
       
    43 
       
    44     bool placeholderIsVisible() const { return m_placeholderVisible; }
       
    45     bool placeholderShouldBeVisible() const;
       
    46 
       
    47     void addSearchResult();
       
    48     void stopSearchEventTimer();
       
    49 
       
    50     bool popupIsVisible() const { return m_searchPopupIsVisible; }
       
    51     void showPopup();
       
    52     void hidePopup();
       
    53 
       
    54     void forwardEvent(Event*);
       
    55 
       
    56     void capsLockStateMayHaveChanged();
       
    57 
       
    58     // Decoration width outside of the text field.
       
    59     int decorationWidthRight() const;
       
    60 
       
    61 private:
       
    62     int preferredDecorationWidthRight() const;
       
    63     virtual bool hasControlClip() const;
       
    64     virtual IntRect controlClipRect(int tx, int ty) const;
       
    65     virtual bool isTextField() const { return true; }
       
    66 
       
    67     virtual void subtreeHasChanged();
       
    68     virtual void paint(PaintInfo&, int tx, int ty);
       
    69     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
       
    70     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
       
    71     virtual void layout();
       
    72 
       
    73     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
       
    74 
       
    75     virtual void autoscroll();
       
    76 
       
    77     // Subclassed to forward to our inner div.
       
    78     virtual int scrollLeft() const;
       
    79     virtual int scrollTop() const;
       
    80     virtual int scrollWidth() const;
       
    81     virtual int scrollHeight() const;
       
    82     virtual void setScrollLeft(int);
       
    83     virtual void setScrollTop(int);
       
    84     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f, Node** stopNode = 0);
       
    85 
       
    86     int textBlockWidth() const;
       
    87     virtual float getAvgCharWidth(AtomicString family);
       
    88     virtual int preferredContentWidth(float charWidth) const;
       
    89     virtual void adjustControlHeightBasedOnLineHeight(int lineHeight);
       
    90 
       
    91     void createSubtreeIfNeeded();
       
    92     virtual void updateFromElement();
       
    93     virtual void cacheSelection(int start, int end);
       
    94     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
       
    95 
       
    96     virtual RenderStyle* textBaseStyle() const;
       
    97     virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const;
       
    98     PassRefPtr<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
       
    99     PassRefPtr<RenderStyle> createResultsButtonStyle(const RenderStyle* startStyle) const;
       
   100     PassRefPtr<RenderStyle> createCancelButtonStyle(const RenderStyle* startStyle) const;
       
   101     PassRefPtr<RenderStyle> createInnerSpinButtonStyle() const;
       
   102     PassRefPtr<RenderStyle> createOuterSpinButtonStyle() const;
       
   103 #if ENABLE(INPUT_SPEECH)
       
   104     PassRefPtr<RenderStyle> createSpeechButtonStyle(const RenderStyle* startStyle) const;
       
   105 #endif
       
   106 
       
   107     void updateCancelButtonVisibility() const;
       
   108     EVisibility visibilityForCancelButton() const;
       
   109     const AtomicString& autosaveName() const;
       
   110 
       
   111     void startSearchEventTimer();
       
   112     void searchEventTimerFired(Timer<RenderTextControlSingleLine>*);
       
   113 
       
   114     // PopupMenuClient methods
       
   115     virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
       
   116     virtual void selectionChanged(unsigned, bool) {}
       
   117     virtual void selectionCleared() {}
       
   118     virtual String itemText(unsigned listIndex) const;
       
   119     virtual String itemLabel(unsigned listIndex) const;
       
   120     virtual String itemToolTip(unsigned) const { return String(); }
       
   121     virtual String itemAccessibilityText(unsigned) const { return String(); }
       
   122     virtual bool itemIsEnabled(unsigned listIndex) const;
       
   123     virtual PopupMenuStyle itemStyle(unsigned listIndex) const;
       
   124     virtual PopupMenuStyle menuStyle() const;
       
   125     virtual int clientInsetLeft() const;
       
   126     virtual int clientInsetRight() const;
       
   127     virtual int clientPaddingLeft() const;
       
   128     virtual int clientPaddingRight() const;
       
   129     virtual int listSize() const;
       
   130     virtual int selectedIndex() const;
       
   131     virtual void popupDidHide();
       
   132     virtual bool itemIsSeparator(unsigned listIndex) const;
       
   133     virtual bool itemIsLabel(unsigned listIndex) const;
       
   134     virtual bool itemIsSelected(unsigned listIndex) const;
       
   135     virtual bool shouldPopOver() const { return false; }
       
   136     virtual bool valueShouldChangeOnHotTrack() const { return false; }
       
   137     virtual void setTextFromItem(unsigned listIndex);
       
   138     virtual FontSelector* fontSelector() const;
       
   139     virtual HostWindow* hostWindow() const;
       
   140     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize);
       
   141 
       
   142     InputElement* inputElement() const;
       
   143 
       
   144     bool m_searchPopupIsVisible;
       
   145     bool m_shouldDrawCapsLockIndicator;
       
   146 
       
   147     RefPtr<TextControlInnerElement> m_innerBlock;
       
   148     RefPtr<SearchFieldResultsButtonElement> m_resultsButton;
       
   149     RefPtr<SearchFieldCancelButtonElement> m_cancelButton;
       
   150     RefPtr<TextControlInnerElement> m_innerSpinButton;
       
   151     RefPtr<TextControlInnerElement> m_outerSpinButton;
       
   152 #if ENABLE(INPUT_SPEECH)
       
   153     RefPtr<InputFieldSpeechButtonElement> m_speechButton;
       
   154 #endif
       
   155 
       
   156     Timer<RenderTextControlSingleLine> m_searchEventTimer;
       
   157     RefPtr<SearchPopupMenu> m_searchPopup;
       
   158     Vector<String> m_recentSearches;
       
   159 };
       
   160 
       
   161 inline RenderTextControlSingleLine* toRenderTextControlSingleLine(RenderObject* object)
       
   162 { 
       
   163     ASSERT(!object || object->isTextField());
       
   164     return static_cast<RenderTextControlSingleLine*>(object);
       
   165 }
       
   166 
       
   167 // This will catch anyone doing an unnecessary cast.
       
   168 void toRenderTextControlSingleLine(const RenderTextControlSingleLine*);
       
   169 
       
   170 }
       
   171 
       
   172 #endif