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 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 * 21 */ 22 23#ifndef RenderSearchField_h 24#define RenderSearchField_h 25 26#include "PopupMenuClient.h" 27#include "RenderTextControlSingleLine.h" 28 29namespace WebCore { 30 31class HTMLInputElement; 32class SearchPopupMenu; 33 34class RenderSearchField final : public RenderTextControlSingleLine, private PopupMenuClient { 35public: 36 RenderSearchField(HTMLInputElement&, PassRef<RenderStyle>); 37 virtual ~RenderSearchField(); 38 39 void updateCancelButtonVisibility() const; 40 41 void addSearchResult(); 42 void stopSearchEventTimer(); 43 44 bool popupIsVisible() const { return m_searchPopupIsVisible; } 45 void showPopup(); 46 void hidePopup(); 47 48private: 49 virtual void centerContainerIfNeeded(RenderBox*) const override; 50 virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const override; 51 virtual LayoutUnit computeLogicalHeightLimit() const override; 52 virtual void updateFromElement() override; 53 EVisibility visibilityForCancelButton() const; 54 const AtomicString& autosaveName() const; 55 56 // PopupMenuClient methods 57 virtual void valueChanged(unsigned listIndex, bool fireEvents = true) override; 58 virtual void selectionChanged(unsigned, bool) override { } 59 virtual void selectionCleared() override { } 60 virtual String itemText(unsigned listIndex) const override; 61 virtual String itemLabel(unsigned listIndex) const override; 62 virtual String itemIcon(unsigned listIndex) const override; 63 virtual String itemToolTip(unsigned) const override { return String(); } 64 virtual String itemAccessibilityText(unsigned) const override { return String(); } 65 virtual bool itemIsEnabled(unsigned listIndex) const override; 66 virtual PopupMenuStyle itemStyle(unsigned listIndex) const override; 67 virtual PopupMenuStyle menuStyle() const override; 68 virtual int clientInsetLeft() const override; 69 virtual int clientInsetRight() const override; 70 virtual LayoutUnit clientPaddingLeft() const override; 71 virtual LayoutUnit clientPaddingRight() const override; 72 virtual int listSize() const override; 73 virtual int selectedIndex() const override; 74 virtual void popupDidHide() override; 75 virtual bool itemIsSeparator(unsigned listIndex) const override; 76 virtual bool itemIsLabel(unsigned listIndex) const override; 77 virtual bool itemIsSelected(unsigned listIndex) const override; 78 virtual bool shouldPopOver() const override { return false; } 79 virtual bool valueShouldChangeOnHotTrack() const override { return false; } 80 virtual void setTextFromItem(unsigned listIndex) override; 81 virtual FontSelector* fontSelector() const override; 82 virtual HostWindow* hostWindow() const override; 83 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize) override; 84 85 HTMLElement* resultsButtonElement() const; 86 HTMLElement* cancelButtonElement() const; 87 88 bool m_searchPopupIsVisible; 89 RefPtr<SearchPopupMenu> m_searchPopup; 90 Vector<String> m_recentSearches; 91}; 92 93RENDER_OBJECT_TYPE_CASTS(RenderSearchField, isTextField()) 94 95} 96 97#endif 98