2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebInputElement_h
32 #define WebInputElement_h
34 #include "WebFormControlElement.h"
36 #if BLINK_IMPLEMENTATION
37 namespace WebCore { class HTMLInputElement; }
42 class WebElementCollection;
44 // Provides readonly access to some properties of a DOM input element node.
45 class WebInputElement : public WebFormControlElement {
47 WebInputElement() : WebFormControlElement() { }
48 WebInputElement(const WebInputElement& element) : WebFormControlElement(element) { }
50 WebInputElement& operator=(const WebInputElement& element)
52 WebFormControlElement::assign(element);
55 void assign(const WebInputElement& element) { WebFormControlElement::assign(element); }
57 // This returns true for all of textfield-looking types such as text,
58 // password, search, email, url, and number.
59 BLINK_EXPORT bool isTextField() const;
60 // This returns true only for type=text.
61 BLINK_EXPORT bool isText() const;
62 BLINK_EXPORT bool isPasswordField() const;
63 BLINK_EXPORT bool isImageButton() const;
64 BLINK_EXPORT bool isRadioButton() const;
65 BLINK_EXPORT bool isCheckbox() const;
66 BLINK_EXPORT int maxLength() const;
67 BLINK_EXPORT void setActivatedSubmit(bool);
68 BLINK_EXPORT int size() const;
69 BLINK_EXPORT void setChecked(bool, bool sendEvents = false);
70 // Sets the value inside the text field without being sanitized.
71 // Can't be used if a renderer doesn't exist or on a non text field type.
72 // Caret will be moved to the end.
73 BLINK_EXPORT void setEditingValue(const WebString&);
74 BLINK_EXPORT bool isValidValue(const WebString&) const;
75 BLINK_EXPORT bool isChecked() const;
76 BLINK_EXPORT bool isMultiple() const;
78 BLINK_EXPORT WebElementCollection dataListOptions() const;
80 // Return the localized value for this input type.
81 BLINK_EXPORT WebString localizeValue(const WebString&) const;
83 // Exposes the default value of the maxLength attribute.
84 BLINK_EXPORT static int defaultMaxLength();
86 BLINK_EXPORT WebElement decorationElementFor(void*);
87 BLINK_EXPORT WebElement passwordGeneratorButtonElement() const;
89 // If true, forces the text of the element to be visible.
90 BLINK_EXPORT void setShouldRevealPassword(bool value);
92 #if BLINK_IMPLEMENTATION
93 WebInputElement(const PassRefPtrWillBeRawPtr<WebCore::HTMLInputElement>&);
94 WebInputElement& operator=(const PassRefPtrWillBeRawPtr<WebCore::HTMLInputElement>&);
95 operator PassRefPtrWillBeRawPtr<WebCore::HTMLInputElement>() const;
99 BLINK_EXPORT WebInputElement* toWebInputElement(WebElement*);
101 inline const WebInputElement* toWebInputElement(const WebElement* element)
103 return toWebInputElement(const_cast<WebElement*>(element));