InputType.h revision 6fbaea61d241814b015fd7e022796e68d8ef3e8e
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; 155cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isAcceptableValue(const String&); 156cad810f21b803229eb11403f9209855525a25d57Steve Block virtual String sanitizeValue(const String&); 157cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool hasUnacceptableValue(); 1586b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner 1596b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // Event handlers 160cad810f21b803229eb11403f9209855525a25d57Steve Block 161cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleClickEvent(MouseEvent*); 162ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch virtual void handleMouseDownEvent(MouseEvent*); 163cad810f21b803229eb11403f9209855525a25d57Steve Block virtual PassOwnPtr<ClickHandlingState> willDispatchClick(); 164cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void didDispatchClick(Event*, const ClickHandlingState&); 165cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleDOMActivateEvent(Event*); 166cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeydownEvent(KeyboardEvent*); 167cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeypressEvent(KeyboardEvent*); 168cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleKeyupEvent(KeyboardEvent*); 169cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*); 170cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleWheelEvent(WheelEvent*); 171cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void forwardEvent(Event*); 1726fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch 1736fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) 1746fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch virtual void handleTouchStartEvent(TouchEvent*); 1756fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch#endif 1766fbaea61d241814b015fd7e022796e68d8ef3e8eBen Murdoch 177cad810f21b803229eb11403f9209855525a25d57Steve Block // Helpers for event handlers. 178f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch virtual bool shouldSubmitImplicitly(Event*); 179cad810f21b803229eb11403f9209855525a25d57Steve Block virtual PassRefPtr<HTMLFormElement> formForSubmission() const; 180cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isKeyboardFocusable() const; 181cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldUseInputMethod() const; 182cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void handleBlurEvent(); 183cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void accessKeyAction(bool sendToAnyElement); 184cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canBeSuccessfulSubmitButton(); 185a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 18665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 18765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch // Shadow tree handling 18865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 18965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch virtual void createShadowSubtree(); 19065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch void destroyShadowSubtree(); 19165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 192e14391e94c850b8bd03680c23b38978db68687a8John Reck // Miscellaneous functions 193e14391e94c850b8bd03680c23b38978db68687a8John Reck 194cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool rendererIsNeeded(); 195e14391e94c850b8bd03680c23b38978db68687a8John Reck virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 196cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void attach(); 197cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void minOrMaxAttributeChanged(); 198cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void altAttributeChanged(); 199cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void srcAttributeChanged(); 200cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void willMoveToNewOwnerDocument(); 201cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectAlignAttribute(); 202cad810f21b803229eb11403f9209855525a25d57Steve Block virtual FileList* files(); 203cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canSetSuggestedValue(); 204cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldSendChangeEventAfterCheckedChanged(); 205cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool canSetValue(const String&); 206cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool storesValueSeparateFromAttribute(); 207cad810f21b803229eb11403f9209855525a25d57Steve Block virtual void setFileList(const Vector<String>& paths); 208cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldResetOnDocumentActivation(); 209cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectListAttribute(); 210cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectSpeechAttribute(); 211cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isEnumeratable(); 212cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool isCheckable(); 213cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool hasSpinButton(); 214cad810f21b803229eb11403f9209855525a25d57Steve Block virtual bool shouldRespectHeightAndWidthAttributes(); 215e14391e94c850b8bd03680c23b38978db68687a8John Reck 216a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Parses the specified string for the type, and return 217a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // the double value for the parsing result if the parsing 218a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // succeeds; Returns defaultValue otherwise. This function can 219a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // return NaN or Infinity only if defaultValue is NaN or Infinity. 220a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual double parseToDouble(const String&, double defaultValue) const; 221cad810f21b803229eb11403f9209855525a25d57Steve Block 2226b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // Parses the specified string for the type as parseToDouble() does. 2236b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // In addition, it stores the number of digits after the decimal point 2246b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner // into *decimalPlaces. 225cad810f21b803229eb11403f9209855525a25d57Steve Block virtual double parseToDoubleWithDecimalPlaces(const String&, double defaultValue, unsigned* decimalPlaces) const; 226cad810f21b803229eb11403f9209855525a25d57Steve Block 227a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Parses the specified string for this InputType, and returns true if it 228a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // is successfully parsed. An instance pointed by the DateComponents* 229a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // parameter will have parsed values and be modified even if the parsing 230a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // fails. The DateComponents* parameter may be 0. 231a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual bool parseToDateComponents(const String&, DateComponents*) const; 232cad810f21b803229eb11403f9209855525a25d57Steve Block 233a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Create a string representation of the specified double value for the 234a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // input type. If NaN or Infinity is specified, this returns an empty 235a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // string. This should not be called for types without valueAsNumber. 236a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual String serialize(double) const; 237e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 238bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenprotected: 239bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen InputType(HTMLInputElement* element) : m_element(element) { } 240bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen HTMLInputElement* element() const { return m_element; } 241f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch void dispatchSimulatedClickIfActive(KeyboardEvent*) const; 242a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // We can't make this a static const data member because VC++ doesn't like it. 243a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch static double defaultStepBase() { return 0.0; } 244e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 245dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockprivate: 246bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen // Raw pointer because the HTMLInputElement object owns this InputType object. 247bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen HTMLInputElement* m_element; 248dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}; 249635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 250bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsennamespace InputTypeNames { 251bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 252bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& button(); 253bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& checkbox(); 254bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& color(); 255bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& date(); 256bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& datetime(); 257bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& datetimelocal(); 258bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& email(); 259bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& file(); 260bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& hidden(); 261bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& image(); 262bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& isindex(); 263bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& month(); 264bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& number(); 265bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& password(); 266bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& radio(); 267bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& range(); 268bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& reset(); 269bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& search(); 270bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& submit(); 271bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& telephone(); 272bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& text(); 273bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& time(); 274bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& url(); 275bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenconst AtomicString& week(); 276bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 277bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen} // namespace WebCore::InputTypeNames 278bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 279635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project} // namespace WebCore 2805e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 2815e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block#endif 282