| 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2009, 2015 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 | #pragma once |
| 24 | |
| 25 | #include "PopupMenuClient.h" |
| 26 | #include "RenderTextControlSingleLine.h" |
| 27 | #include "SearchPopupMenu.h" |
| 28 | |
| 29 | namespace WebCore { |
| 30 | |
| 31 | class HTMLInputElement; |
| 32 | |
| 33 | class RenderSearchField final : public RenderTextControlSingleLine, private PopupMenuClient { |
| 34 | WTF_MAKE_ISO_ALLOCATED(RenderSearchField); |
| 35 | public: |
| 36 | RenderSearchField(HTMLInputElement&, RenderStyle&&); |
| 37 | virtual ~RenderSearchField(); |
| 38 | |
| 39 | void updateCancelButtonVisibility() const; |
| 40 | |
| 41 | void addSearchResult(); |
| 42 | void stopSearchEventTimer(); |
| 43 | |
| 44 | bool () const { return m_searchPopupIsVisible; } |
| 45 | void (); |
| 46 | void (); |
| 47 | |
| 48 | private: |
| 49 | bool isSearchField() const final { return true; } |
| 50 | |
| 51 | void willBeDestroyed() override; |
| 52 | LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const override; |
| 53 | void updateFromElement() override; |
| 54 | Visibility visibilityForCancelButton() const; |
| 55 | const AtomicString& autosaveName() const; |
| 56 | |
| 57 | // PopupMenuClient methods |
| 58 | void valueChanged(unsigned listIndex, bool fireEvents = true) override; |
| 59 | void selectionChanged(unsigned, bool) override { } |
| 60 | void selectionCleared() override { } |
| 61 | String itemText(unsigned listIndex) const override; |
| 62 | String itemLabel(unsigned listIndex) const override; |
| 63 | String itemIcon(unsigned listIndex) const override; |
| 64 | String itemToolTip(unsigned) const override { return String(); } |
| 65 | String itemAccessibilityText(unsigned) const override { return String(); } |
| 66 | bool itemIsEnabled(unsigned listIndex) const override; |
| 67 | PopupMenuStyle itemStyle(unsigned listIndex) const override; |
| 68 | PopupMenuStyle () const override; |
| 69 | int clientInsetLeft() const override; |
| 70 | int clientInsetRight() const override; |
| 71 | LayoutUnit clientPaddingLeft() const override; |
| 72 | LayoutUnit clientPaddingRight() const override; |
| 73 | int listSize() const override; |
| 74 | int selectedIndex() const override; |
| 75 | void () override; |
| 76 | bool itemIsSeparator(unsigned listIndex) const override; |
| 77 | bool itemIsLabel(unsigned listIndex) const override; |
| 78 | bool itemIsSelected(unsigned listIndex) const override; |
| 79 | bool shouldPopOver() const override { return false; } |
| 80 | bool valueShouldChangeOnHotTrack() const override { return false; } |
| 81 | void setTextFromItem(unsigned listIndex) override; |
| 82 | FontSelector* fontSelector() const override; |
| 83 | HostWindow* hostWindow() const override; |
| 84 | Ref<Scrollbar> createScrollbar(ScrollableArea&, ScrollbarOrientation, ScrollbarControlSize) override; |
| 85 | |
| 86 | HTMLElement* resultsButtonElement() const; |
| 87 | HTMLElement* cancelButtonElement() const; |
| 88 | |
| 89 | bool ; |
| 90 | RefPtr<SearchPopupMenu> ; |
| 91 | Vector<RecentSearch> m_recentSearches; |
| 92 | }; |
| 93 | |
| 94 | } // namespace WebCore |
| 95 | |
| 96 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSearchField, isSearchField()) |
| 97 | |