1635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/* 2d0825bca7fe65beaee391d30da42e937db621564Steve Block * Copyright (C) 2010 Google Inc. All rights reserved. 3cad810f21b803229eb11403f9209855525a25d57Steve Block * Copyright (C) 2011 Apple Inc. All rights reserved. 48f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * 5635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Redistribution and use in source and binary forms, with or without 6635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * modification, are permitted provided that the following conditions are 7635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * met: 88f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * 9635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions of source code must retain the above copyright 10635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer. 11635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions in binary form must reproduce the above 12635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * copyright notice, this list of conditions and the following disclaimer 13635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * in the documentation and/or other materials provided with the 14635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * distribution. 15635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Neither the name of Google Inc. nor the names of its 16635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * contributors may be used to endorse or promote products derived from 17635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * this software without specific prior written permission. 18d0825bca7fe65beaee391d30da42e937db621564Steve Block * 19635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */ 31635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 32bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#ifndef InputType_h 33bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#define InputType_h 345e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 35bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#include <wtf/Forward.h> 36ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch#include <wtf/FastAllocBase.h> 37dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include <wtf/Noncopyable.h> 38cad810f21b803229eb11403f9209855525a25d57Steve Block#include <wtf/RefPtr.h> 39cad810f21b803229eb11403f9209855525a25d57Steve Block#include <wtf/Vector.h> 40635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 41635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Projectnamespace WebCore { 42635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 43cad810f21b803229eb11403f9209855525a25d57Steve Blockclass BeforeTextInsertedEvent; 44a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochclass DateComponents; 456b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brennerclass Event; 46cad810f21b803229eb11403f9209855525a25d57Steve Blockclass FileList; 47e14391e94c850b8bd03680c23b38978db68687a8John Reckclass FormDataList; 48cad810f21b803229eb11403f9209855525a25d57Steve Blockclass HTMLFormElement; 49bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenclass HTMLInputElement; 506b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brennerclass KeyboardEvent; 516b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brennerclass MouseEvent; 52e14391e94c850b8bd03680c23b38978db68687a8John Reckclass RenderArena; 53e14391e94c850b8bd03680c23b38978db68687a8John Reckclass RenderObject; 54e14391e94c850b8bd03680c23b38978db68687a8John Reckclass RenderStyle; 55cad810f21b803229eb11403f9209855525a25d57Steve Blockclass WheelEvent; 56cad810f21b803229eb11403f9209855525a25d57Steve Block 576fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) 586fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdochclass TouchEvent; 596fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch#endif 606fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch 61cad810f21b803229eb11403f9209855525a25d57Steve Blocktypedef int ExceptionCode; 62cad810f21b803229eb11403f9209855525a25d57Steve Block 63cad810f21b803229eb11403f9209855525a25d57Steve Blockstruct ClickHandlingState { 64ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch WTF_MAKE_FAST_ALLOCATED; 65ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochpublic: 66cad810f21b803229eb11403f9209855525a25d57Steve Block bool checked; 67cad810f21b803229eb11403f9209855525a25d57Steve Block bool indeterminate; 68cad810f21b803229eb11403f9209855525a25d57Steve Block RefPtr<HTMLInputElement> checkedRadioButton; 69cad810f21b803229eb11403f9209855525a25d57Steve Block}; 70dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 71e14391e94c850b8bd03680c23b38978db68687a8John Reck// An InputType object represents the type-specific part of an HTMLInputElement. 72e14391e94c850b8bd03680c23b38978db68687a8John Reck// Do not expose instances of InputType and classes derived from it to classes 73e14391e94c850b8bd03680c23b38978db68687a8John Reck// other than HTMLInputElement. 74ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochclass InputType { 75ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch WTF_MAKE_NONCOPYABLE(InputType); WTF_MAKE_FAST_ALLOCATED; 76dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockpublic: 77cad810f21b803229eb11403f9209855525a25d57Steve Block static PassOwnPtr<InputType> create(HTMLInputElement*, const String&); 78bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen static PassOwnPtr<InputType> createText(HTMLInputElement*); 79bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen virtual ~InputType(); 80dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 81cad810f21b803229eb11403f9209855525a25d57Steve Block virtual const AtomicString& formControlType() const = 0; 82cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canChangeFromAnotherType() const; 83cad810f21b803229eb11403f9209855525a25d57Steve Block 84e14391e94c850b8bd03680c23b38978db68687a8John Reck // Type query functions 85e14391e94c850b8bd03680c23b38978db68687a8John Reck 86cad810f21b803229eb11403f9209855525a25d57Steve Block // Any time we are using one of these functions it's best to refactor 87cad810f21b803229eb11403f9209855525a25d57Steve Block // to add a virtual function to allow the input type object to do the 88cad810f21b803229eb11403f9209855525a25d57Steve Block // work instead, or at least make a query function that asks a higher 89cad810f21b803229eb11403f9209855525a25d57Steve Block // level question. These functions make the HTMLInputElement class 90cad810f21b803229eb11403f9209855525a25d57Steve Block // inflexible because it's harder to add new input types if there is 91cad810f21b803229eb11403f9209855525a25d57Steve Block // scattered code with special cases for various types. 92cad810f21b803229eb11403f9209855525a25d57Steve Block 93cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isCheckbox() const; 94cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isEmailField() const; 95cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isFileUpload() const; 96cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isHiddenType() const; 97cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isImageButton() const; 98cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isNumberField() const; 99cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isPasswordField() const; 100cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isRadioButton() const; 101cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isRangeControl() const; 102cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isSearchField() const; 103cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isSubmitButton() const; 104cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isTelephoneField() const; 105cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isTextButton() const; 106bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen virtual bool isTextField() const; 107bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen virtual bool isTextType() const; 108cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isURLField() const; 109dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 110e14391e94c850b8bd03680c23b38978db68687a8John Reck // Form value functions 111e14391e94c850b8bd03680c23b38978db68687a8John Reck 112e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual bool saveFormControlState(String&) const; 113e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual void restoreFormControlState(const String&) const; 114e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual bool isFormDataAppendable() const; 115e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual bool appendFormData(FormDataList&, bool multipart) const; 116e14391e94c850b8bd03680c23b38978db68687a8John Reck 117e14391e94c850b8bd03680c23b38978db68687a8John Reck // DOM property functions 118e14391e94c850b8bd03680c23b38978db68687a8John Reck 119cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool getTypeSpecificValue(String&); // Checked first, before internal storage or the value attribute. 120cad810f21b803229eb11403f9209855525a25d57Steve Block virtual String fallbackValue(); // Checked last, if both internal storage and value attribute are missing. 121cad810f21b803229eb11403f9209855525a25d57Steve Block virtual String defaultValue(); // Checked after even fallbackValue, only when the valueWithDefault function is called. 122a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double valueAsDate() const; 123a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void setValueAsDate(double, ExceptionCode&) const; 124a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double valueAsNumber() const; 125a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void setValueAsNumber(double, ExceptionCode&) const; 126a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 127e14391e94c850b8bd03680c23b38978db68687a8John Reck // Validation functions 128a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 129a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool supportsValidation() const; 130a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool typeMismatchFor(const String&) const; 131a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Type check for the current input value. We do nothing for some types 132a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // though typeMismatchFor() does something for them because of value 133a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // sanitization. 134a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool typeMismatch() const; 135a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool supportsRequired() const; 136a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool valueMissing(const String&) const; 137bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen virtual bool patternMismatch(const String&) const; 138a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool rangeUnderflow(const String&) const; 139a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool rangeOverflow(const String&) const; 140cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool supportsRangeLimitation() const; 141f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch virtual double defaultValueForStepUp() const; 142a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double minimum() const; 143a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double maximum() const; 144cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool stepMismatch(const String&, double step) const; 145a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double stepBase() const; 1466b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner virtual double stepBaseWithDecimalPlaces(unsigned*) const; 147a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double defaultStep() const; 148a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double stepScaleFactor() const; 149a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool parsedStepValueShouldBeInteger() const; 150cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool scaledStepValueShouldBeInteger() const; 1516b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner virtual double acceptableError(double) const; 1526b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner virtual String typeMismatchText() const; 1534576aa36e9a9671459299c7963ac95aa94beaea9Shimeng (Simon) Wang virtual String valueMissingText() const; 154cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canSetStringValue() const; 1552fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual String visibleValue() const; 15681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch virtual String convertFromVisibleValue(const String&) const; 157cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isAcceptableValue(const String&); 15881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch // Returing the null string means "use the default value." 159cad810f21b803229eb11403f9209855525a25d57Steve Block virtual String sanitizeValue(const String&); 160cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool hasUnacceptableValue(); 1616b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner 1626b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // Event handlers 163cad810f21b803229eb11403f9209855525a25d57Steve Block 164cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleClickEvent(MouseEvent*); 165ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch virtual void handleMouseDownEvent(MouseEvent*); 166cad810f21b803229eb11403f9209855525a25d57Steve Block virtual PassOwnPtr<ClickHandlingState> willDispatchClick(); 167cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void didDispatchClick(Event*, const ClickHandlingState&); 168cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleDOMActivateEvent(Event*); 169cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeydownEvent(KeyboardEvent*); 170cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeypressEvent(KeyboardEvent*); 171cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeyupEvent(KeyboardEvent*); 172cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*); 173cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleWheelEvent(WheelEvent*); 174cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void forwardEvent(Event*); 1756fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch 176f2e2233332c5b4a4b584c0a10b8bac10b6122acfGeorge Mount#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) 177f2e2233332c5b4a4b584c0a10b8bac10b6122acfGeorge Mount virtual void handleTouchStartEvent(TouchEvent*); 178f2e2233332c5b4a4b584c0a10b8bac10b6122acfGeorge Mount#endif 179f2e2233332c5b4a4b584c0a10b8bac10b6122acfGeorge Mount 180cad810f21b803229eb11403f9209855525a25d57Steve Block // Helpers for event handlers. 181f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch virtual bool shouldSubmitImplicitly(Event*); 182cad810f21b803229eb11403f9209855525a25d57Steve Block virtual PassRefPtr<HTMLFormElement> formForSubmission() const; 183cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isKeyboardFocusable() const; 184cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldUseInputMethod() const; 185cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleBlurEvent(); 186cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void accessKeyAction(bool sendToAnyElement); 187cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canBeSuccessfulSubmitButton(); 188a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 18965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 19065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch // Shadow tree handling 19165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 19265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch virtual void createShadowSubtree(); 19365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch void destroyShadowSubtree(); 19465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 195e14391e94c850b8bd03680c23b38978db68687a8John Reck // Miscellaneous functions 196e14391e94c850b8bd03680c23b38978db68687a8John Reck 197cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool rendererIsNeeded(); 198e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 199cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void attach(); 200cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void minOrMaxAttributeChanged(); 201cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void altAttributeChanged(); 202cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void srcAttributeChanged(); 2032fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void valueChanged(); 204cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void willMoveToNewOwnerDocument(); 205cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectAlignAttribute(); 206cad810f21b803229eb11403f9209855525a25d57Steve Block virtual FileList* files(); 2072fc2651226baac27029e38c9d6ef883fa32084dbSteve Block // Should return true if the corresponding renderer for a type can display a suggested value. 208cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canSetSuggestedValue(); 209cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldSendChangeEventAfterCheckedChanged(); 210cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canSetValue(const String&); 211cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool storesValueSeparateFromAttribute(); 212cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void setFileList(const Vector<String>& paths); 213cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldResetOnDocumentActivation(); 214cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectListAttribute(); 215cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectSpeechAttribute(); 216cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isEnumeratable(); 217cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isCheckable(); 218cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool hasSpinButton(); 219cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectHeightAndWidthAttributes(); 220e14391e94c850b8bd03680c23b38978db68687a8John Reck 221a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Parses the specified string for the type, and return 222a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // the double value for the parsing result if the parsing 223a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // succeeds; Returns defaultValue otherwise. This function can 224a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // return NaN or Infinity only if defaultValue is NaN or Infinity. 225a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double parseToDouble(const String&, double defaultValue) const; 226cad810f21b803229eb11403f9209855525a25d57Steve Block 2276b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // Parses the specified string for the type as parseToDouble() does. 2286b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // In addition, it stores the number of digits after the decimal point 2296b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // into *decimalPlaces. 230cad810f21b803229eb11403f9209855525a25d57Steve Block virtual double parseToDoubleWithDecimalPlaces(const String&, double defaultValue, unsigned* decimalPlaces) const; 231cad810f21b803229eb11403f9209855525a25d57Steve Block 232a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Parses the specified string for this InputType, and returns true if it 233a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // is successfully parsed. An instance pointed by the DateComponents* 234a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // parameter will have parsed values and be modified even if the parsing 235a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // fails. The DateComponents* parameter may be 0. 236a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool parseToDateComponents(const String&, DateComponents*) const; 237cad810f21b803229eb11403f9209855525a25d57Steve Block 238a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Create a string representation of the specified double value for the 239a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // input type. If NaN or Infinity is specified, this returns an empty 240a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // string. This should not be called for types without valueAsNumber. 241a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual String serialize(double) const; 242e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 243bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenprotected: 244bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen InputType(HTMLInputElement* element) : m_element(element) { } 245bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen HTMLInputElement* element() const { return m_element; } 246f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch void dispatchSimulatedClickIfActive(KeyboardEvent*) const; 247a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // We can't make this a static const data member because VC++ doesn't like it. 248a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch static double defaultStepBase() { return 0.0; } 249e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 250dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockprivate: 251bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen // Raw pointer because the HTMLInputElement object owns this InputType object. 252bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen HTMLInputElement* m_element; 253dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}; 254635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 255bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsennamespace InputTypeNames { 256bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 257bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& button(); 258bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& checkbox(); 259bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& color(); 260bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& date(); 261bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& datetime(); 262bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& datetimelocal(); 263bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& email(); 264bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& file(); 265bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& hidden(); 266bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& image(); 267bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& isindex(); 268bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& month(); 269bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& number(); 270bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& password(); 271bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& radio(); 272bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& range(); 273bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& reset(); 274bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& search(); 275bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& submit(); 276bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& telephone(); 277bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& text(); 278bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& time(); 279bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& url(); 280bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& week(); 281bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 282bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen} // namespace WebCore::InputTypeNames 283bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 284635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} // namespace WebCore 2855e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 2865e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block#endif 287