Changeset 70511 in webkit
- Timestamp:
- Oct 25, 2010 7:27:22 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 30 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/CMakeLists.txt
r70300 r70511 950 950 951 951 html/AsyncImageResizer.cpp 952 html/BaseButtonInputType.cpp 953 html/BaseCheckableInputType.cpp 952 954 html/BaseDateAndTimeInputType.cpp 953 955 html/BaseTextInputType.cpp -
trunk/WebCore/ChangeLog
r70509 r70511 1 2010-10-25 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Refactor HTMLInputElement: Move createRender(), appendFormData(), 6 saveFormControlState() and restoreFormControlState() to InputTypes. 7 https://bugs.webkit.org/show_bug.cgi?id=47834 8 9 This change adds BaseButtonInputType and BaseCheckableInputType. They 10 are super classes of some concrete InputType classes. 11 12 No new tests. Just a code refactoring. 13 14 * CMakeLists.txt: Add BaseButtonInputType and BaseCheckableInputType files. 15 * GNUmakefile.am: ditto. 16 * WebCore.gypi: ditto. 17 * WebCore.pro: ditto. 18 * WebCore.vcproj/WebCore.vcproj: ditto. 19 * WebCore.xcodeproj/project.pbxproj: ditto. 20 * html/BaseButtonInputType.cpp: Added. 21 (WebCore::BaseButtonInputType::appendFormData): 22 (WebCore::BaseButtonInputType::createRenderer): 23 * html/BaseButtonInputType.h: Added. 24 (WebCore::BaseButtonInputType::BaseButtonInputType): 25 * html/BaseCheckableInputType.cpp: Added. 26 (WebCore::BaseCheckableInputType::saveFormControlState): 27 (WebCore::BaseCheckableInputType::restoreFormControlState): 28 (WebCore::BaseCheckableInputType::appendFormData): 29 * html/BaseCheckableInputType.h: Added. 30 (WebCore::BaseCheckableInputType::BaseCheckableInputType): 31 * html/ButtonInputType.h: Change the super class. 32 (WebCore::ButtonInputType::ButtonInputType): 33 * html/CheckboxInputType.h: Change the super class. 34 (WebCore::CheckboxInputType::CheckboxInputType): 35 * html/FileInputType.cpp: 36 (WebCore::FileInputType::appendFormData): 37 (WebCore::FileInputType::createRenderer): 38 * html/FileInputType.h: Change the super class. 39 (WebCore::FileInputType::FileInputType): 40 * html/HTMLFormControlElement.h: 41 Make placeholderShouldBeVisible() public for access from TextFieldInputType. 42 * html/HTMLInputElement.cpp: 43 (WebCore::HTMLInputElement::saveFormControlState): 44 (WebCore::HTMLInputElement::restoreFormControlState): 45 (WebCore::HTMLInputElement::createRenderer): 46 (WebCore::HTMLInputElement::appendFormData): 47 * html/HTMLInputElement.h: 48 Add the following functions for ImageInputType and SubmitInputType. 49 (WebCore::HTMLInputElement::xPosition): 50 (WebCore::HTMLInputElement::yPosition): 51 * html/HiddenInputType.cpp: 52 (WebCore::HiddenInputType::createRenderer): 53 * html/HiddenInputType.h: 54 * html/ImageInputType.cpp: 55 (WebCore::ImageInputType::isFormDataAppendable): 56 (WebCore::ImageInputType::appendFormData): 57 (WebCore::ImageInputType::createRenderer): 58 * html/ImageInputType.h: Change the super class. 59 (WebCore::ImageInputType::ImageInputType): 60 * html/InputType.cpp: 61 (WebCore::InputType::saveFormControlState): 62 (WebCore::InputType::restoreFormControlState): 63 (WebCore::InputType::isFormDataAppendable): 64 (WebCore::InputType::appendFormData): 65 (WebCore::InputType::createRenderer): 66 * html/InputType.h: 67 * html/PasswordInputType.cpp: 68 (WebCore::PasswordInputType::saveFormControlState): 69 (WebCore::PasswordInputType::restoreFormControlState): 70 * html/PasswordInputType.h: 71 * html/RadioInputType.h: Change the super class. 72 (WebCore::RadioInputType::RadioInputType): 73 * html/RangeInputType.cpp: 74 (WebCore::RangeInputType::createRenderer): 75 * html/RangeInputType.h: 76 * html/ResetInputType.h: 77 (WebCore::ResetInputType::ResetInputType): 78 * html/SubmitInputType.cpp: 79 (WebCore::SubmitInputType::appendFormData): 80 * html/SubmitInputType.h: Change the super class. 81 (WebCore::SubmitInputType::SubmitInputType): 82 * html/TextFieldInputType.cpp: 83 (WebCore::TextFieldInputType::createRenderer): 84 * html/TextFieldInputType.h: 85 1 86 2010-10-25 Simon Fraser <simon.fraser@apple.com> 2 87 -
trunk/WebCore/GNUmakefile.am
r70490 r70511 1454 1454 WebCore/html/AsyncImageResizer.cpp \ 1455 1455 WebCore/html/AsyncImageResizer.h \ 1456 WebCore/html/BaseButtonInputType.cpp \ 1457 WebCore/html/BaseButtonInputType.h \ 1458 WebCore/html/BaseCheckableInputType.cpp \ 1459 WebCore/html/BaseCheckableInputType.h \ 1456 1460 WebCore/html/BaseDateAndTimeInputType.cpp \ 1457 1461 WebCore/html/BaseDateAndTimeInputType.h \ -
trunk/WebCore/WebCore.gypi
r70490 r70511 1544 1544 'html/AsyncImageResizer.cpp', 1545 1545 'html/AsyncImageResizer.h', 1546 'html/BaseButtonInputType.cpp', 1547 'html/BaseButtonInputType.h', 1548 'html/BaseCheckableInputType.cpp', 1549 'html/BaseCheckableInputType.h', 1546 1550 'html/BaseDateAndTimeInputType.cpp', 1547 1551 'html/BaseDateAndTimeInputType.h', -
trunk/WebCore/WebCore.pro
r70490 r70511 840 840 history/PageCache.cpp \ 841 841 html/AsyncImageResizer.cpp \ 842 html/BaseButtonInputType.cpp \ 843 html/BaseCheckableInputType.cpp \ 842 844 html/BaseDateAndTimeInputType.cpp \ 843 845 html/BaseTextInputType.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r70410 r70511 48008 48008 </File> 48009 48009 <File 48010 RelativePath="..\html\BaseButtonInputType.cpp" 48011 > 48012 </File> 48013 <File 48014 RelativePath="..\html\BaseButtonInputType.h" 48015 > 48016 </File> 48017 <File 48018 RelativePath="..\html\BaseCheckableInputType.cpp" 48019 > 48020 </File> 48021 <File 48022 RelativePath="..\html\BaseCheckableInputType.h" 48023 > 48024 </File> 48025 <File 48010 48026 RelativePath="..\html\BaseDateAndTimeInputType.cpp" 48011 48027 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r70490 r70511 858 858 379919971200DDF400EA041C /* WOFFFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 379919951200DDF400EA041C /* WOFFFileFormat.h */; }; 859 859 379919B21200DE5000EA041C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 379919B11200DE5000EA041C /* libz.dylib */; }; 860 379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */; }; 861 379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */; }; 862 379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */; }; 863 379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */; }; 860 864 37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 861 865 37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACCE620DA2AA960089E602 /* FontDescription.cpp */; }; … … 6901 6905 379919951200DDF400EA041C /* WOFFFileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOFFFileFormat.h; sourceTree = "<group>"; }; 6902 6906 379919B11200DE5000EA041C /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; }; 6907 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseButtonInputType.cpp; sourceTree = "<group>"; }; 6908 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseButtonInputType.h; sourceTree = "<group>"; }; 6909 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseCheckableInputType.cpp; sourceTree = "<group>"; }; 6910 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseCheckableInputType.h; sourceTree = "<group>"; }; 6903 6911 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontRenderingMode.h; sourceTree = "<group>"; }; 6904 6912 37ACCE620DA2AA960089E602 /* FontDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescription.cpp; sourceTree = "<group>"; }; … … 14568 14576 B0149E7911A4B21500196A7B /* AsyncImageResizer.cpp */, 14569 14577 B0149E7A11A4B21500196A7B /* AsyncImageResizer.h */, 14578 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */, 14579 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */, 14580 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */, 14581 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */, 14570 14582 F59C95FD1255B23F000623C0 /* BaseDateAndTimeInputType.cpp */, 14571 14583 F59C95FE1255B23F000623C0 /* BaseDateAndTimeInputType.h */, … … 18393 18405 BC124EE80C2641CD009E2349 /* BarInfo.h in Headers */, 18394 18406 B2C3DA220D006C1D00EF6F26 /* Base64.h in Headers */, 18407 379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */, 18408 379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */, 18395 18409 F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */, 18396 18410 F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */, … … 21524 21538 BC124EE70C2641CD009E2349 /* BarInfo.cpp in Sources */, 21525 21539 B2C3DA210D006C1D00EF6F26 /* Base64.cpp in Sources */, 21540 379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */, 21541 379E61CB126CA5C400B63E8D /* BaseCheckableInputType.cpp in Sources */, 21526 21542 F59C95FF1255B23F000623C0 /* BaseDateAndTimeInputType.cpp in Sources */, 21527 21543 F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */, -
trunk/WebCore/html/BaseButtonInputType.cpp
r70510 r70511 30 30 31 31 #include "config.h" 32 #include " ImageInputType.h"32 #include "BaseButtonInputType.h" 33 33 34 #include <wtf/PassOwnPtr.h> 34 #include "HTMLInputElement.h" 35 #include "RenderButton.h" 35 36 36 37 namespace WebCore { 37 38 38 PassOwnPtr<InputType> ImageInputType::create(HTMLInputElement* element) 39 bool BaseButtonInputType::appendFormData(FormDataList&, bool) const 39 40 { 40 return adoptPtr(new ImageInputType(element)); 41 } 42 43 const AtomicString& ImageInputType::formControlType() const 44 { 45 return InputTypeNames::image(); 46 } 47 48 bool ImageInputType::supportsValidation() const 49 { 41 // Buttons except overridden types are never successful. 50 42 return false; 51 43 } 52 44 45 RenderObject* BaseButtonInputType::createRenderer(RenderArena* arena, RenderStyle*) const 46 { 47 return new (arena) RenderButton(element()); 48 } 49 53 50 } // namespace WebCore -
trunk/WebCore/html/BaseButtonInputType.h
r70510 r70511 29 29 */ 30 30 31 #ifndef B uttonInputType_h32 #define B uttonInputType_h31 #ifndef BaseButtonInputType_h 32 #define BaseButtonInputType_h 33 33 34 34 #include "InputType.h" … … 36 36 namespace WebCore { 37 37 38 class ButtonInputType : public InputType { 39 public: 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 38 // Base of button, file, image, reset, and submit types. 39 class BaseButtonInputType : public InputType { 40 protected: 41 BaseButtonInputType(HTMLInputElement* element) : InputType(element) { } 41 42 42 43 private: 43 ButtonInputType(HTMLInputElement* element) : InputType(element) { } 44 virtual const AtomicString& formControlType() const; 45 virtual bool supportsValidation() const; 44 virtual bool appendFormData(FormDataList&, bool) const; 45 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 46 46 }; 47 47 48 48 } // namespace WebCore 49 49 50 #endif // B uttonInputType_h50 #endif // BaseButtonInputType_h -
trunk/WebCore/html/BaseCheckableInputType.cpp
r70510 r70511 30 30 31 31 #include "config.h" 32 #include " TextFieldInputType.h"32 #include "BaseCheckableInputType.h" 33 33 34 #include <wtf/text/WTFString.h> 34 #include "FormDataList.h" 35 #include "HTMLInputElement.h" 36 #include "HTMLNames.h" 37 #include "RegularExpression.h" 35 38 36 39 namespace WebCore { 37 40 38 bool TextFieldInputType::isTextField() const41 bool BaseCheckableInputType::saveFormControlState(String& result) const 39 42 { 43 result = element()->checked() ? "on" : "off"; 40 44 return true; 41 45 } 42 46 43 bool TextFieldInputType::valueMissing(const String& value) const47 void BaseCheckableInputType::restoreFormControlState(const String& state) const 44 48 { 45 return value.isEmpty(); 49 element()->setChecked(state == "on"); 50 } 51 52 bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const 53 { 54 if (!element()->checked()) 55 return false; 56 encoding.appendData(element()->name(), element()->value()); 57 return true; 46 58 } 47 59 -
trunk/WebCore/html/BaseCheckableInputType.h
r70510 r70511 29 29 */ 30 30 31 #ifndef TextFieldInputType_h32 #define TextFieldInputType_h31 #ifndef BaseCheckableInputType_h 32 #define BaseCheckableInputType_h 33 33 34 34 #include "InputType.h" … … 36 36 namespace WebCore { 37 37 38 // The class represents types of which UI contain text fields. 39 // It supports not only the types for BaseTextInputType but also type=number. 40 class TextFieldInputType : public InputType { 38 // Base of checkbox and radio types. 39 class BaseCheckableInputType : public InputType { 41 40 protected: 42 TextFieldInputType(HTMLInputElement* element) : InputType(element) { } 43 virtual bool isTextField() const; 44 virtual bool valueMissing(const String&) const; 41 BaseCheckableInputType(HTMLInputElement* element) : InputType(element) { } 42 43 private: 44 virtual bool saveFormControlState(String&) const; 45 virtual void restoreFormControlState(const String&) const; 46 virtual bool appendFormData(FormDataList&, bool) const; 45 47 }; 46 48 47 49 } // namespace WebCore 48 50 49 #endif // TextFieldInputType_h51 #endif // BaseCheckableInputType_h -
trunk/WebCore/html/ButtonInputType.h
r69445 r70511 32 32 #define ButtonInputType_h 33 33 34 #include " InputType.h"34 #include "BaseButtonInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class ButtonInputType : public InputType {38 class ButtonInputType : public BaseButtonInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 ButtonInputType(HTMLInputElement* element) : InputType(element) { }43 ButtonInputType(HTMLInputElement* element) : BaseButtonInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual bool supportsValidation() const; -
trunk/WebCore/html/CheckboxInputType.h
r69445 r70511 32 32 #define CheckboxInputType_h 33 33 34 #include " InputType.h"34 #include "BaseCheckableInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class CheckboxInputType : public InputType {38 class CheckboxInputType : public BaseCheckableInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 CheckboxInputType(HTMLInputElement* element) : InputType(element) { }43 CheckboxInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual bool valueMissing(const String&) const; -
trunk/WebCore/html/FileInputType.cpp
r69445 r70511 1 1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 4 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 7 9 * 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 13 * distribution. 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. 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 17 14 * 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. 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 * 29 20 */ 30 21 … … 32 23 #include "FileInputType.h" 33 24 25 #include "File.h" 26 #include "FileList.h" 27 #include "FormDataList.h" 28 #include "HTMLInputElement.h" 29 #include "RenderFileUploadControl.h" 34 30 #include <wtf/PassOwnPtr.h> 35 31 #include <wtf/text/WTFString.h> … … 47 43 } 48 44 45 bool FileInputType::appendFormData(FormDataList& encoding, bool multipart) const 46 { 47 FileList* fileList = element()->files(); 48 unsigned numFiles = fileList->length(); 49 if (!multipart) { 50 // Send only the basenames. 51 // 4.10.16.4 and 4.10.16.6 sections in HTML5. 52 53 // Unlike the multipart case, we have no special handling for the empty 54 // fileList because Netscape doesn't support for non-multipart 55 // submission of file inputs, and Firefox doesn't add "name=" query 56 // parameter. 57 for (unsigned i = 0; i < numFiles; ++i) 58 encoding.appendData(element()->name(), fileList->item(i)->fileName()); 59 return true; 60 } 61 62 // If no filename at all is entered, return successful but empty. 63 // Null would be more logical, but Netscape posts an empty file. Argh. 64 if (!numFiles) { 65 encoding.appendBlob(element()->name(), File::create("")); 66 return true; 67 } 68 69 for (unsigned i = 0; i < numFiles; ++i) 70 encoding.appendBlob(element()->name(), fileList->item(i)); 71 return true; 72 } 73 49 74 bool FileInputType::valueMissing(const String& value) const 50 75 { … … 52 77 } 53 78 79 RenderObject* FileInputType::createRenderer(RenderArena* arena, RenderStyle*) const 80 { 81 return new (arena) RenderFileUploadControl(element()); 82 } 83 54 84 } // namespace WebCore -
trunk/WebCore/html/FileInputType.h
r69445 r70511 32 32 #define FileInputType_h 33 33 34 #include " InputType.h"34 #include "BaseButtonInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class FileInputType : public InputType {38 class FileInputType : public BaseButtonInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 FileInputType(HTMLInputElement* element) : InputType(element) { }43 FileInputType(HTMLInputElement* element) : BaseButtonInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 virtual bool appendFormData(FormDataList&, bool) const; 45 46 virtual bool valueMissing(const String&) const; 47 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 46 48 }; 47 49 -
trunk/WebCore/html/HTMLFormControlElement.h
r69831 r70511 181 181 virtual bool supportsPlaceholder() const = 0; 182 182 String strippedPlaceholder() const; 183 bool placeholderShouldBeVisible() const; 183 184 184 185 int selectionStart(); … … 193 194 HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*); 194 195 195 bool placeholderShouldBeVisible() const;196 196 void updatePlaceholderVisibility(bool); 197 197 -
trunk/WebCore/html/HTMLInputElement.cpp
r69445 r70511 57 57 #include "MouseEvent.h" 58 58 #include "Page.h" 59 #include "RenderButton.h"60 59 #include "RenderFileUploadControl.h" 61 60 #include "RenderImage.h" 62 61 #include "RenderSlider.h" 63 #include "RenderText.h"64 62 #include "RenderTextControlSingleLine.h" 65 63 #include "RenderTheme.h" … … 530 528 bool HTMLInputElement::saveFormControlState(String& result) const 531 529 { 532 switch (deprecatedInputType()) { 533 case BUTTON: 534 case COLOR: 535 case DATE: 536 case DATETIME: 537 case DATETIMELOCAL: 538 case EMAIL: 539 case FILE: 540 case HIDDEN: 541 case IMAGE: 542 case ISINDEX: 543 case MONTH: 544 case NUMBER: 545 case RANGE: 546 case RESET: 547 case SEARCH: 548 case SUBMIT: 549 case TELEPHONE: 550 case TEXT: 551 case TIME: 552 case URL: 553 case WEEK: { 554 String currentValue = value(); 555 if (currentValue == defaultValue()) 556 return false; 557 result = currentValue; 558 return true; 559 } 560 case CHECKBOX: 561 case RADIO: 562 result = checked() ? "on" : "off"; 563 return true; 564 case PASSWORD: 565 return false; 566 } 567 ASSERT_NOT_REACHED(); 568 return false; 530 return m_inputType->saveFormControlState(result); 569 531 } 570 532 571 533 void HTMLInputElement::restoreFormControlState(const String& state) 572 534 { 573 ASSERT(deprecatedInputType() != PASSWORD); // should never save/restore password fields 574 switch (deprecatedInputType()) { 575 case BUTTON: 576 case COLOR: 577 case DATE: 578 case DATETIME: 579 case DATETIMELOCAL: 580 case EMAIL: 581 case FILE: 582 case HIDDEN: 583 case IMAGE: 584 case ISINDEX: 585 case MONTH: 586 case NUMBER: 587 case RANGE: 588 case RESET: 589 case SEARCH: 590 case SUBMIT: 591 case TELEPHONE: 592 case TEXT: 593 case TIME: 594 case URL: 595 case WEEK: 596 setValue(state); 597 break; 598 case CHECKBOX: 599 case RADIO: 600 setChecked(state == "on"); 601 break; 602 case PASSWORD: 603 break; 604 } 535 m_inputType->restoreFormControlState(state); 605 536 } 606 537 … … 797 728 } 798 729 799 RenderObject* HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *style) 800 { 801 switch (deprecatedInputType()) { 802 case BUTTON: 803 case RESET: 804 case SUBMIT: 805 return new (arena) RenderButton(this); 806 case CHECKBOX: 807 case RADIO: 808 return RenderObject::createObject(this, style); 809 case FILE: 810 return new (arena) RenderFileUploadControl(this); 811 case HIDDEN: 812 break; 813 case IMAGE: { 814 RenderImage* image = new (arena) RenderImage(this); 815 image->setImageResource(RenderImageResource::create()); 816 return image; 817 } 818 case RANGE: 819 return new (arena) RenderSlider(this); 820 case COLOR: 821 case DATE: 822 case DATETIME: 823 case DATETIMELOCAL: 824 case EMAIL: 825 case ISINDEX: 826 case MONTH: 827 case NUMBER: 828 case PASSWORD: 829 case SEARCH: 830 case TELEPHONE: 831 case TEXT: 832 case TIME: 833 case URL: 834 case WEEK: 835 return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible()); 836 } 837 ASSERT(false); 838 return 0; 730 RenderObject* HTMLInputElement::createRenderer(RenderArena* arena, RenderStyle* style) 731 { 732 return m_inputType->createRenderer(arena, style); 839 733 } 840 734 … … 913 807 bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart) 914 808 { 915 // image generates its own names, but for other types there is no form data unless there's a name 916 if (name().isEmpty() && deprecatedInputType() != IMAGE) 917 return false; 918 919 switch (deprecatedInputType()) { 920 case COLOR: 921 case DATE: 922 case DATETIME: 923 case DATETIMELOCAL: 924 case EMAIL: 925 case HIDDEN: 926 case ISINDEX: 927 case MONTH: 928 case NUMBER: 929 case PASSWORD: 930 case RANGE: 931 case SEARCH: 932 case TELEPHONE: 933 case TEXT: 934 case TIME: 935 case URL: 936 case WEEK: 937 // always successful 938 encoding.appendData(name(), value()); 939 return true; 940 941 case CHECKBOX: 942 case RADIO: 943 if (checked()) { 944 encoding.appendData(name(), value()); 945 return true; 946 } 947 break; 948 949 case BUTTON: 950 case RESET: 951 // these types of buttons are never successful 952 return false; 953 954 case IMAGE: 955 if (m_activeSubmit) { 956 encoding.appendData(name().isEmpty() ? "x" : (name() + ".x"), m_xPos); 957 encoding.appendData(name().isEmpty() ? "y" : (name() + ".y"), m_yPos); 958 if (!name().isEmpty() && !value().isEmpty()) 959 encoding.appendData(name(), value()); 960 return true; 961 } 962 break; 963 964 case SUBMIT: 965 if (m_activeSubmit) { 966 String encstr = valueWithDefault(); 967 encoding.appendData(name(), encstr); 968 return true; 969 } 970 break; 971 972 case FILE: { 973 unsigned numFiles = m_fileList->length(); 974 if (!multipart) { 975 // Send only the basenames. 976 // 4.10.16.4 and 4.10.16.6 sections in HTML5. 977 978 // Unlike the multipart case, we have no special 979 // handling for the empty fileList because Netscape 980 // doesn't support for non-multipart submission of 981 // file inputs, and Firefox doesn't add "name=" query 982 // parameter. 983 984 for (unsigned i = 0; i < numFiles; ++i) 985 encoding.appendData(name(), m_fileList->item(i)->fileName()); 986 return true; 987 } 988 989 // If no filename at all is entered, return successful but empty. 990 // Null would be more logical, but Netscape posts an empty file. Argh. 991 if (!numFiles) { 992 encoding.appendBlob(name(), File::create("")); 993 return true; 994 } 995 996 for (unsigned i = 0; i < numFiles; ++i) 997 encoding.appendBlob(name(), m_fileList->item(i)); 998 return true; 999 } 1000 } 1001 return false; 809 return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(encoding, multipart); 1002 810 } 1003 811 -
trunk/WebCore/html/HTMLInputElement.h
r69445 r70511 203 203 return document()->checkedRadioButtons(); 204 204 } 205 206 // FIXME: We should move m_xPos and m_yPos to ImageInputType class. 207 int xPosition() const { return m_xPos; } 208 int yPosition() const { return m_yPos; } 205 209 206 210 protected: -
trunk/WebCore/html/HiddenInputType.cpp
r69445 r70511 50 50 } 51 51 52 RenderObject* HiddenInputType::createRenderer(RenderArena*, RenderStyle*) const 53 { 54 ASSERT_NOT_REACHED(); 55 return 0; 56 } 57 52 58 } // namespace WebCore -
trunk/WebCore/html/HiddenInputType.h
r69445 r70511 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual bool supportsValidation() const; 46 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 46 47 }; 47 48 -
trunk/WebCore/html/ImageInputType.cpp
r69445 r70511 1 1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 4 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 7 9 * 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 13 * distribution. 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. 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 17 14 * 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. 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 * 29 20 */ 30 21 … … 32 23 #include "ImageInputType.h" 33 24 25 #include "FormDataList.h" 26 #include "HTMLInputElement.h" 27 #include "RenderImage.h" 34 28 #include <wtf/PassOwnPtr.h> 35 29 … … 46 40 } 47 41 42 bool ImageInputType::isFormDataAppendable() const 43 { 44 return true; 45 } 46 47 bool ImageInputType::appendFormData(FormDataList& encoding, bool) const 48 { 49 if (!element()->isActivatedSubmit()) 50 return false; 51 const AtomicString& name = element()->name(); 52 encoding.appendData(name.isEmpty() ? "x" : (name + ".x"), element()->xPosition()); 53 encoding.appendData(name.isEmpty() ? "y" : (name + ".y"), element()->yPosition()); 54 if (!name.isEmpty() && !element()->value().isEmpty()) 55 encoding.appendData(name, element()->value()); 56 return true; 57 } 58 48 59 bool ImageInputType::supportsValidation() const 49 60 { … … 51 62 } 52 63 64 RenderObject* ImageInputType::createRenderer(RenderArena* arena, RenderStyle*) const 65 { 66 RenderImage* image = new (arena) RenderImage(element()); 67 image->setImageResource(RenderImageResource::create()); 68 return image; 69 } 70 53 71 } // namespace WebCore -
trunk/WebCore/html/ImageInputType.h
r69445 r70511 32 32 #define ImageInputType_h 33 33 34 #include " InputType.h"34 #include "BaseButtonInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class ImageInputType : public InputType {38 class ImageInputType : public BaseButtonInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 ImageInputType(HTMLInputElement* element) : InputType(element) { }43 ImageInputType(HTMLInputElement* element) : BaseButtonInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 virtual bool isFormDataAppendable() const; 46 virtual bool appendFormData(FormDataList&, bool) const; 45 47 virtual bool supportsValidation() const; 48 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 46 49 }; 47 50 -
trunk/WebCore/html/InputType.cpp
r69445 r70511 37 37 #include "EmailInputType.h" 38 38 #include "FileInputType.h" 39 #include "FormDataList.h" 39 40 #include "HTMLInputElement.h" 40 41 #include "HiddenInputType.h" … … 47 48 #include "RangeInputType.h" 48 49 #include "RegularExpression.h" 50 #include "RenderObject.h" 49 51 #include "ResetInputType.h" 50 52 #include "SearchInputType.h" … … 123 125 } 124 126 127 bool InputType::saveFormControlState(String& result) const 128 { 129 String currentValue = element()->value(); 130 if (currentValue == element()->defaultValue()) 131 return false; 132 result = currentValue; 133 return true; 134 } 135 136 void InputType::restoreFormControlState(const String& state) const 137 { 138 element()->setValue(state); 139 } 140 141 bool InputType::isFormDataAppendable() const 142 { 143 // There is no form data unless there's a name for non-image types. 144 return !element()->name().isEmpty(); 145 } 146 147 bool InputType::appendFormData(FormDataList& encoding, bool) const 148 { 149 // Always successful. 150 encoding.appendData(element()->name(), element()->value()); 151 return true; 152 } 153 125 154 double InputType::valueAsDate() const 126 155 { … … 229 258 } 230 259 260 RenderObject* InputType::createRenderer(RenderArena*, RenderStyle* style) const 261 { 262 return RenderObject::createObject(element(), style); 263 } 264 231 265 double InputType::parseToDouble(const String&, double defaultValue) const 232 266 { -
trunk/WebCore/html/InputType.h
r69445 r70511 39 39 40 40 class DateComponents; 41 class FormDataList; 41 42 class HTMLInputElement; 43 class RenderArena; 44 class RenderObject; 45 class RenderStyle; 42 46 47 // An InputType object represents the type-specific part of an HTMLInputElement. 48 // Do not expose instances of InputType and classes derived from it to classes 49 // other than HTMLInputElement. 43 50 class InputType : public Noncopyable { 44 51 public: … … 47 54 virtual ~InputType(); 48 55 56 // Type query functions 57 49 58 virtual bool isTextField() const; 50 59 virtual bool isTextType() const; 51 60 virtual const AtomicString& formControlType() const = 0; 61 62 // Form value functions 63 64 virtual bool saveFormControlState(String&) const; 65 virtual void restoreFormControlState(const String&) const; 66 virtual bool isFormDataAppendable() const; 67 virtual bool appendFormData(FormDataList&, bool multipart) const; 68 69 // DOM property functions 52 70 53 71 virtual double valueAsDate() const; … … 56 74 virtual void setValueAsNumber(double, ExceptionCode&) const; 57 75 58 // Validation -relatedfunctions76 // Validation functions 59 77 60 78 virtual bool supportsValidation() const; … … 77 95 virtual bool parsedStepValueShouldBeInteger() const; 78 96 virtual bool scaledStepValeuShouldBeInteger() const; 97 98 // Miscellaneous functions 99 100 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 79 101 80 102 // Parses the specified string for the type, and return -
trunk/WebCore/html/PasswordInputType.cpp
r68629 r70511 32 32 #include "PasswordInputType.h" 33 33 34 #include <wtf/Assertions.h> 34 35 #include <wtf/PassOwnPtr.h> 35 36 … … 46 47 } 47 48 49 bool PasswordInputType::saveFormControlState(String&) const 50 { 51 // Should never save/restore password fields. 52 return false; 53 } 54 55 void PasswordInputType::restoreFormControlState(const String&) const 56 { 57 // Should never save/restore password fields. 58 ASSERT_NOT_REACHED(); 59 } 60 48 61 } // namespace WebCore -
trunk/WebCore/html/PasswordInputType.h
r68629 r70511 43 43 PasswordInputType(HTMLInputElement* element) : BaseTextInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 virtual bool saveFormControlState(String&) const; 46 virtual void restoreFormControlState(const String&) const; 45 47 }; 46 48 -
trunk/WebCore/html/RadioInputType.h
r69445 r70511 32 32 #define RadioInputType_h 33 33 34 #include " InputType.h"34 #include "BaseCheckableInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class RadioInputType : public InputType {38 class RadioInputType : public BaseCheckableInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 RadioInputType(HTMLInputElement* element) : InputType(element) { }43 RadioInputType(HTMLInputElement* element) : BaseCheckableInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual bool valueMissing(const String&) const; -
trunk/WebCore/html/RangeInputType.cpp
r69446 r70511 35 35 #include "HTMLNames.h" 36 36 #include "HTMLParserIdioms.h" 37 #include "RenderSlider.h" 37 38 #include <limits> 38 39 #include <wtf/MathExtras.h> … … 127 128 } 128 129 130 RenderObject* RangeInputType::createRenderer(RenderArena* arena, RenderStyle*) const 131 { 132 return new (arena) RenderSlider(element()); 133 } 134 129 135 double RangeInputType::parseToDouble(const String& src, double defaultValue) const 130 136 { -
trunk/WebCore/html/RangeInputType.h
r69446 r70511 54 54 virtual double defaultStep() const; 55 55 virtual double stepScaleFactor() const; 56 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 56 57 virtual double parseToDouble(const String&, double) const; 57 58 virtual String serialize(double) const; -
trunk/WebCore/html/ResetInputType.h
r69445 r70511 32 32 #define ResetInputType_h 33 33 34 #include " InputType.h"34 #include "BaseButtonInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class ResetInputType : public InputType {38 class ResetInputType : public BaseButtonInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 ResetInputType(HTMLInputElement* element) : InputType(element) { }43 ResetInputType(HTMLInputElement* element) : BaseButtonInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 45 virtual bool supportsValidation() const; -
trunk/WebCore/html/SubmitInputType.cpp
r69445 r70511 32 32 #include "SubmitInputType.h" 33 33 34 #include "FormDataList.h" 35 #include "HTMLInputElement.h" 34 36 #include <wtf/PassOwnPtr.h> 35 37 … … 46 48 } 47 49 50 bool SubmitInputType::appendFormData(FormDataList& encoding, bool) const 51 { 52 if (!element()->isActivatedSubmit()) 53 return false; 54 encoding.appendData(element()->name(), element()->valueWithDefault()); 55 return true; 56 } 57 48 58 bool SubmitInputType::supportsValidation() const 49 59 { -
trunk/WebCore/html/SubmitInputType.h
r69445 r70511 32 32 #define SubmitInputType_h 33 33 34 #include " InputType.h"34 #include "BaseButtonInputType.h" 35 35 36 36 namespace WebCore { 37 37 38 class SubmitInputType : public InputType {38 class SubmitInputType : public BaseButtonInputType { 39 39 public: 40 40 static PassOwnPtr<InputType> create(HTMLInputElement*); 41 41 42 42 private: 43 SubmitInputType(HTMLInputElement* element) : InputType(element) { }43 SubmitInputType(HTMLInputElement* element) : BaseButtonInputType(element) { } 44 44 virtual const AtomicString& formControlType() const; 45 virtual bool appendFormData(FormDataList&, bool) const; 45 46 virtual bool supportsValidation() const; 46 47 }; -
trunk/WebCore/html/TextFieldInputType.cpp
r69445 r70511 32 32 #include "TextFieldInputType.h" 33 33 34 #include "HTMLInputElement.h" 35 #include "RenderTextControlSingleLine.h" 34 36 #include <wtf/text/WTFString.h> 35 37 … … 46 48 } 47 49 50 RenderObject* TextFieldInputType::createRenderer(RenderArena* arena, RenderStyle*) const 51 { 52 return new (arena) RenderTextControlSingleLine(element(), element()->placeholderShouldBeVisible()); 53 } 54 48 55 } // namespace WebCore -
trunk/WebCore/html/TextFieldInputType.h
r69445 r70511 43 43 virtual bool isTextField() const; 44 44 virtual bool valueMissing(const String&) const; 45 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 45 46 }; 46 47
Note: See TracChangeset
for help on using the changeset viewer.