Changeset 85998 in webkit
- Timestamp:
- May 6, 2011 9:24:09 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 deleted
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r85909 r85998 571 571 dom/ExceptionCode.cpp 572 572 dom/IconURL.cpp 573 dom/InputElement.cpp574 573 dom/KeyboardEvent.cpp 575 574 dom/MessageChannel.cpp -
trunk/Source/WebCore/ChangeLog
r85993 r85998 1 2011-05-06 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Eliminate WebCore/dom/InputElement.{cpp,h} 6 https://bugs.webkit.org/show_bug.cgi?id=60262 7 8 - Fold in all of the code of InputElement.{cpp,h} into HTMLInputElement 9 and TextFieldInputType. 10 - Change the return type of Node::toInputElement(): 11 InputElement* -> HTMLInputElement* 12 13 No new tests. This change should not change the existing behaviour. 14 15 * CMakeLists.txt: Remove InpuntElement.cpp and/or InputElement.h. 16 * GNUmakefile.list.am: ditto. 17 * WebCore.exp.in: Add symbols of functions exposed to WebKit. 18 * WebCore.gypi: Remove InpuntElement.cpp and/or InputElement.h. 19 * WebCore.pro: ditto. 20 * WebCore.vcproj/WebCore.vcproj: ditto. 21 * WebCore.xcodeproj/project.pbxproj: ditto. 22 * accessibility/AXObjectCache.cpp: 23 (WebCore::AXObjectCache::textMarkerDataForVisiblePosition): 24 Follow the return type change of Node::toInputElement(). 25 * accessibility/AccessibilityRenderObject.cpp: 26 (WebCore::AccessibilityRenderObject::isPasswordField): ditto. 27 (WebCore::AccessibilityRenderObject::isIndeterminate): ditto. 28 (WebCore::AccessibilityRenderObject::isNativeCheckboxOrRadio): ditto. 29 (WebCore::AccessibilityRenderObject::isChecked): ditto. 30 * css/CSSStyleSelector.cpp: 31 (WebCore::CSSStyleSelector::canShareStyleWithElement): ditto. 32 (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): ditto. 33 * dom/CheckedRadioButtons.cpp: 34 (WebCore::CheckedRadioButtons::removeButton): ditto. 35 * dom/DOMAllInOne.cpp: Remove InputElement.h. 36 * dom/InputElement.cpp: Removed. 37 * dom/InputElement.h: Removed. 38 * dom/Node.cpp: 39 (WebCore::Node::toInputElement): 40 Change the return type from InputElement* to HTMLInputElement*. 41 * dom/Node.h: ditto. 42 * html/HTMLInputElement.cpp: 43 (WebCore::HTMLInputElement::HTMLInputElement): 44 (WebCore::HTMLInputElement::formControlName): 45 (WebCore::HTMLInputElement::tooLong): 46 (WebCore::HTMLInputElement::updateFocusAppearance): 47 (WebCore::HTMLInputElement::aboutToUnload): 48 (WebCore::HTMLInputElement::handleFocusEvent): 49 (WebCore::HTMLInputElement::handleBlurEvent): 50 (WebCore::HTMLInputElement::updateType): 51 (WebCore::HTMLInputElement::parseMappedAttribute): 52 (WebCore::HTMLInputElement::size): 53 (WebCore::HTMLInputElement::copyNonAttributeProperties): 54 (WebCore::HTMLInputElement::value): 55 (WebCore::HTMLInputElement::suggestedValue): 56 (WebCore::HTMLInputElement::setSuggestedValue): 57 (WebCore::HTMLInputElement::setValue): 58 (WebCore::HTMLInputElement::setValueFromRenderer): 59 (WebCore::HTMLInputElement::setFileListFromRenderer): 60 (WebCore::HTMLInputElement::setDefaultName): 61 (WebCore::HTMLInputElement::maxLength): 62 (WebCore::HTMLInputElement::cacheSelection): 63 (WebCore::formatCodes): Moved from InputElement. 64 (WebCore::cursorPositionToMaskIndex): ditto. 65 (WebCore::HTMLInputElement::isConformToInputMask): ditto. 66 (WebCore::HTMLInputElement::validateInputMask): ditto. 67 (WebCore::HTMLInputElement::setWapInputFormat): ditto. 68 (WebCore::HTMLInputElement::notifyFormStateChanged): ditto. 69 (WebCore::HTMLInputElement::parseMaxLengthAttribute): ditto. 70 (WebCore::HTMLInputElement::updateValueIfNeeded):ditto. 71 * html/HTMLInputElement.h: 72 - Add data members which were defined in InputElementData. 73 - Make some functions public because the public interface InputElement is removed. 74 - Make some functions non-virtual because they don't override 75 corresponding virtual functions of InputElement anymore. 76 (WebCore::HTMLInputElement::toInputElement): 77 Follow the return type change of Node::toInputElement(). 78 (WebCore::HTMLInputElement::isIndeterminate): 79 (WebCore::HTMLInputElement::isAutofilled): 80 (WebCore::HTMLInputElement::supportsMaxLength): 81 (WebCore::HTMLInputElement::cachedSelectionStart): 82 (WebCore::HTMLInputElement::cachedSelectionEnd): 83 * html/HTMLTextAreaElement.cpp: Remove unused InputElement.h. 84 * html/InputType.cpp: 85 (WebCore::InputType::handleBeforeTextInsertedEvent): Remove the code. 86 * html/InputType.h: Update for the above. 87 * html/TextFieldInputType.cpp: 88 (WebCore::replaceEOLAndLimitLength): Moved from InputElement.cpp. 89 (WebCore::TextFieldInputType::sanitizeValue): Implement with replaceEOLAndLimitLength(). 90 (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent): 91 Move the code from InputElement::handleBeforeTextInsertedEvent(). 92 * html/TextFieldInputType.h: Update declarations. 93 * rendering/RenderTextControlSingleLine.cpp: 94 - Remove ASSERT(node()->isHTMLElement()) because it is checked in the constructor. 95 - Follow the return type change of inputElement(). 96 (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine): 97 Make sure node() is an HTMLInputElement instance. 98 (WebCore::RenderTextControlSingleLine::addSearchResult): 99 (WebCore::RenderTextControlSingleLine::stopSearchEventTimer): 100 (WebCore::RenderTextControlSingleLine::showPopup): 101 (WebCore::RenderTextControlSingleLine::hidePopup): 102 (WebCore::RenderTextControlSingleLine::subtreeHasChanged): 103 (WebCore::RenderTextControlSingleLine::updateFromElement): 104 (WebCore::RenderTextControlSingleLine::createInnerBlockStyle): 105 (WebCore::RenderTextControlSingleLine::createResultsButtonStyle): 106 (WebCore::RenderTextControlSingleLine::createCancelButtonStyle): 107 (WebCore::RenderTextControlSingleLine::createInnerSpinButtonStyle): 108 (WebCore::RenderTextControlSingleLine::createOuterSpinButtonStyle): 109 (WebCore::RenderTextControlSingleLine::createSpeechButtonStyle): 110 (WebCore::RenderTextControlSingleLine::visibilityForCancelButton): 111 (WebCore::RenderTextControlSingleLine::startSearchEventTimer): 112 (WebCore::RenderTextControlSingleLine::searchEventTimerFired): 113 (WebCore::RenderTextControlSingleLine::valueChanged): 114 (WebCore::RenderTextControlSingleLine::setTextFromItem): 115 (WebCore::RenderTextControlSingleLine::inputElement): 116 * rendering/RenderTextControlSingleLine.h: 117 Change the return type of inputElement(): InputElement* -> HTMLInputElement*. 118 * rendering/RenderTheme.cpp: 119 (WebCore::RenderTheme::isChecked): 120 Follow the return type change of Node::toInputElement(). 121 (WebCore::RenderTheme::isIndeterminate): ditto. 122 (WebCore::RenderTheme::shouldHaveSpinButton): 123 Change the parameter type: InputElement* -> HTMLInputElement*. 124 * rendering/RenderTheme.h: ditto. 125 1 126 2011-05-06 Adam Barth <abarth@webkit.org> 2 127 -
trunk/Source/WebCore/GNUmakefile.list.am
r85987 r85998 1154 1154 Source/WebCore/dom/IconURL.cpp \ 1155 1155 Source/WebCore/dom/IconURL.h \ 1156 Source/WebCore/dom/InputElement.cpp \1157 Source/WebCore/dom/InputElement.h \1158 1156 Source/WebCore/dom/HashChangeEvent.h \ 1159 1157 Source/WebCore/dom/KeyboardEvent.cpp \ -
trunk/Source/WebCore/WebCore.exp.in
r85901 r85998 446 446 __ZN7WebCore16FontPlatformDataD1Ev 447 447 __ZN7WebCore16HTMLInputElement13setAutofilledEb 448 __ZN7WebCore16HTMLInputElement15setValueForUserERKN3WTF6StringE 448 449 __ZN7WebCore16IconDatabaseBase28synchronousIconURLForPageURLERKN3WTF6StringE 449 450 __ZN7WebCore16IconDatabaseBase4openERKN3WTF6StringES4_ … … 1147 1148 __ZNK7WebCore15VisiblePosition8previousENS_27EditingBoundaryCrossingRuleE 1148 1149 __ZNK7WebCore16FontFallbackList10fontDataAtEPKNS_4FontEj 1150 __ZNK7WebCore16HTMLInputElement11isTextFieldEv 1149 1151 __ZNK7WebCore16HTMLInputElement12autoCompleteEv 1152 __ZNK7WebCore16HTMLInputElement15isPasswordFieldEv 1150 1153 __ZNK7WebCore16HTMLInputElement21lastChangeWasUserEditEv 1151 1154 __ZNK7WebCore16IconDatabaseBase12databasePathEv -
trunk/Source/WebCore/WebCore.gypi
r85909 r85998 530 530 'dom/ExceptionCode.h', 531 531 'dom/FragmentScriptingPermission.h', 532 'dom/InputElement.h',533 532 'dom/KeyboardEvent.h', 534 533 'dom/MappedAttributeEntry.h', … … 2474 2473 'dom/IconURL.cpp', 2475 2474 'dom/IconURL.h', 2476 'dom/InputElement.cpp',2477 2475 'dom/KeyboardEvent.cpp', 2478 2476 'dom/MessageChannel.cpp', -
trunk/Source/WebCore/WebCore.pro
r85944 r85998 494 494 dom/ExceptionCode.cpp \ 495 495 dom/IconURL.cpp \ 496 dom/InputElement.cpp \497 496 dom/KeyboardEvent.cpp \ 498 497 dom/MessageChannel.cpp \ … … 1471 1470 dom/ExceptionCode.h \ 1472 1471 dom/FragmentScriptingPermission.h \ 1473 dom/InputElement.h \1474 1472 dom/KeyboardEvent.h \ 1475 1473 dom/MessageChannel.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r85909 r85998 44575 44575 </File> 44576 44576 <File 44577 RelativePath="..\dom\InputElement.cpp"44578 >44579 <FileConfiguration44580 Name="Debug|Win32"44581 ExcludedFromBuild="true"44582 >44583 <Tool44584 Name="VCCLCompilerTool"44585 />44586 </FileConfiguration>44587 <FileConfiguration44588 Name="Release|Win32"44589 ExcludedFromBuild="true"44590 >44591 <Tool44592 Name="VCCLCompilerTool"44593 />44594 </FileConfiguration>44595 <FileConfiguration44596 Name="Debug_Cairo_CFLite|Win32"44597 ExcludedFromBuild="true"44598 >44599 <Tool44600 Name="VCCLCompilerTool"44601 />44602 </FileConfiguration>44603 <FileConfiguration44604 Name="Release_Cairo_CFLite|Win32"44605 ExcludedFromBuild="true"44606 >44607 <Tool44608 Name="VCCLCompilerTool"44609 />44610 </FileConfiguration>44611 <FileConfiguration44612 Name="Debug_All|Win32"44613 ExcludedFromBuild="true"44614 >44615 <Tool44616 Name="VCCLCompilerTool"44617 />44618 </FileConfiguration>44619 <FileConfiguration44620 Name="Production|Win32"44621 ExcludedFromBuild="true"44622 >44623 <Tool44624 Name="VCCLCompilerTool"44625 />44626 </FileConfiguration>44627 </File>44628 <File44629 RelativePath="..\dom\InputElement.h"44630 >44631 </File>44632 <File44633 44577 RelativePath="..\dom\KeyboardEvent.cpp" 44634 44578 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r85909 r85998 96 96 0854B0251255E4E600B9CDD0 /* SVGTextQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 0854B0131255E4E600B9CDD0 /* SVGTextQuery.h */; }; 97 97 085797091278394C00A8EC5F /* SVGAnimatedBoolean.h in Headers */ = {isa = PBXBuildFile; fileRef = 085797081278394C00A8EC5F /* SVGAnimatedBoolean.h */; settings = {ATTRIBUTES = (Private, ); }; }; 98 08591AA50F085C4E009BACB1 /* InputElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08591AA40F085C4E009BACB1 /* InputElement.h */; settings = {ATTRIBUTES = (Private, ); }; };99 98 085A15931289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; }; 100 99 085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */; }; … … 103 102 08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 104 103 086BBD0F136039C2008B15D8 /* Glyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 086BBD0E136039C2008B15D8 /* Glyph.h */; settings = {ATTRIBUTES = (Private, ); }; }; 105 08700BE70F086C5300919419 /* InputElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08700BE60F086C5300919419 /* InputElement.cpp */; };106 104 087281550F26B9B600AFC596 /* OptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281510F26B9B600AFC596 /* OptionElement.cpp */; }; 107 105 087281560F26B9B600AFC596 /* OptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 087281520F26B9B600AFC596 /* OptionElement.h */; }; … … 6459 6457 0854B0131255E4E600B9CDD0 /* SVGTextQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextQuery.h; sourceTree = "<group>"; }; 6460 6458 085797081278394C00A8EC5F /* SVGAnimatedBoolean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedBoolean.h; sourceTree = "<group>"; }; 6461 08591AA40F085C4E009BACB1 /* InputElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputElement.h; sourceTree = "<group>"; };6462 6459 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedTransformListPropertyTearOff.h; sourceTree = "<group>"; }; 6463 6460 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataBuilder.cpp; sourceTree = "<group>"; }; … … 6466 6463 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResourceStyleImage.h; sourceTree = "<group>"; }; 6467 6464 086BBD0E136039C2008B15D8 /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Glyph.h; sourceTree = "<group>"; }; 6468 08700BE60F086C5300919419 /* InputElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputElement.cpp; sourceTree = "<group>"; };6469 6465 087281510F26B9B600AFC596 /* OptionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionElement.cpp; sourceTree = "<group>"; }; 6470 6466 087281520F26B9B600AFC596 /* OptionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionElement.h; sourceTree = "<group>"; }; … … 19251 19247 8482B7441198C32E00BFB005 /* HashChangeEvent.idl */, 19252 19248 8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */, 19253 08700BE60F086C5300919419 /* InputElement.cpp */,19254 08591AA40F085C4E009BACB1 /* InputElement.h */,19255 19249 85031B2D0A44EFC700F992E0 /* KeyboardEvent.cpp */, 19256 19250 85031B2E0A44EFC700F992E0 /* KeyboardEvent.h */, … … 21156 21150 BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */, 21157 21151 BCEA485A097D93020094C9E4 /* InlineTextBox.h in Headers */, 21158 08591AA50F085C4E009BACB1 /* InputElement.h in Headers */,21159 21152 37E3524D12450C6600BAF5D9 /* InputType.h in Headers */, 21160 21153 93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */, … … 23947 23940 A8CFF5E40A155A05000A4234 /* InlineFlowBox.cpp in Sources */, 23948 23941 BCEA4859097D93020094C9E4 /* InlineTextBox.cpp in Sources */, 23949 08700BE70F086C5300919419 /* InputElement.cpp in Sources */,23950 23942 37E3524B12450C5200BAF5D9 /* InputType.cpp in Sources */, 23951 23943 93309DE9099E64920056E581 /* InsertIntoTextNodeCommand.cpp in Sources */, -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r80811 r85998 56 56 #include "HTMLAreaElement.h" 57 57 #include "HTMLImageElement.h" 58 #include "HTMLInputElement.h" 58 59 #include "HTMLNames.h" 59 60 #if ENABLE(VIDEO) 60 61 #include "MediaControlElements.h" 61 62 #endif 62 #include "InputElement.h"63 63 #include "Page.h" 64 64 #include "RenderListBox.h" … … 617 617 618 618 if (domNode->isHTMLElement()) { 619 InputElement* inputElement = domNode->toInputElement();619 HTMLInputElement* inputElement = domNode->toInputElement(); 620 620 if (inputElement && inputElement->isPasswordField()) 621 621 return; -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r85864 r85998 497 497 return false; 498 498 499 InputElement* inputElement = m_renderer->node()->toInputElement();499 HTMLInputElement* inputElement = m_renderer->node()->toInputElement(); 500 500 if (!inputElement) 501 501 return false; … … 590 590 return false; 591 591 592 InputElement* inputElement = m_renderer->node()->toInputElement();592 HTMLInputElement* inputElement = m_renderer->node()->toInputElement(); 593 593 if (!inputElement) 594 594 return false; … … 601 601 Node* elementNode = node(); 602 602 if (elementNode) { 603 InputElement* input = elementNode->toInputElement();603 HTMLInputElement* input = elementNode->toInputElement(); 604 604 if (input) 605 605 return input->isCheckbox() || input->isRadioButton(); … … 616 616 617 617 // First test for native checkedness semantics 618 InputElement* inputElement = m_renderer->node()->toInputElement();618 HTMLInputElement* inputElement = m_renderer->node()->toInputElement(); 619 619 if (inputElement) 620 620 return inputElement->isChecked(); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r85938 r85998 1070 1070 1071 1071 if (isControl) { 1072 InputElement* thisInputElement = element->toInputElement();1073 InputElement* otherInputElement = m_element->toInputElement();1072 HTMLInputElement* thisInputElement = element->toInputElement(); 1073 HTMLInputElement* otherInputElement = m_element->toInputElement(); 1074 1074 1075 1075 if (!thisInputElement || !otherInputElement) … … 2774 2774 if (!e || !e->isFormControlElement()) 2775 2775 break; 2776 if ( InputElement* inputElement = e->toInputElement())2776 if (HTMLInputElement* inputElement = e->toInputElement()) 2777 2777 return inputElement->isAutofilled(); 2778 2778 break; … … 2867 2867 // you can't be both checked and indeterminate. We will behave like WinIE behind the scenes and just 2868 2868 // obey the CSS spec here in the test for matching the pseudo. 2869 InputElement* inputElement = e->toInputElement();2869 HTMLInputElement* inputElement = e->toInputElement(); 2870 2870 if (inputElement && inputElement->isChecked() && !inputElement->isIndeterminate()) 2871 2871 return true; … … 2875 2875 if (!e || !e->isFormControlElement()) 2876 2876 break; 2877 InputElement* inputElement = e->toInputElement();2877 HTMLInputElement* inputElement = e->toInputElement(); 2878 2878 if (inputElement && inputElement->isIndeterminate()) 2879 2879 return true; -
trunk/Source/WebCore/dom/CheckedRadioButtons.cpp
r84828 r85998 78 78 return; 79 79 80 InputElement* inputElement = element->toInputElement();80 HTMLInputElement* inputElement = element->toInputElement(); 81 81 ASSERT_UNUSED(inputElement, inputElement); 82 82 ASSERT(inputElement->isChecked()); -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r85785 r85998 77 77 #include "ExceptionCode.cpp" 78 78 #include "IconURL.cpp" 79 #include "InputElement.cpp"80 79 #include "KeyboardEvent.cpp" 81 80 #include "MessageChannel.cpp" -
trunk/Source/WebCore/dom/Node.cpp
r85799 r85998 560 560 } 561 561 562 InputElement* Node::toInputElement()562 HTMLInputElement* Node::toInputElement() 563 563 { 564 564 // If one of the below ASSERTs trigger, you are calling this function -
trunk/Source/WebCore/dom/Node.h
r85650 r85998 55 55 class FloatPoint; 56 56 class Frame; 57 class InputElement;57 class HTMLInputElement; 58 58 class IntRect; 59 59 class KeyboardEvent; … … 525 525 virtual Node* toNode() { return this; } 526 526 527 virtual InputElement* toInputElement();527 virtual HTMLInputElement* toInputElement(); 528 528 529 529 virtual ScriptExecutionContext* scriptExecutionContext() const; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r85617 r85998 7 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 8 8 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 9 10 * 10 11 * This library is free software; you can redistribute it and/or … … 31 32 #include "Attribute.h" 32 33 #include "BeforeTextInsertedEvent.h" 34 #include "Chrome.h" 35 #include "ChromeClient.h" 33 36 #include "CSSPropertyNames.h" 34 37 #include "Document.h" … … 36 39 #include "ExceptionCode.h" 37 40 #include "FileList.h" 41 #include "Frame.h" 38 42 #include "HTMLCollection.h" 39 43 #include "HTMLDataListElement.h" … … 46 50 #include "LocalizedStrings.h" 47 51 #include "MouseEvent.h" 52 #include "Page.h" 48 53 #include "PlatformMouseEvent.h" 49 54 #include "RenderTextControlSingleLine.h" … … 61 66 using namespace HTMLNames; 62 67 68 // FIXME: According to HTML4, the length attribute's value can be arbitrarily 69 // large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things 70 // get rather sluggish when a text field has a larger number of characters than 71 // this, even when just clicking in the text field. 72 const int HTMLInputElement::maximumLength = 524288; 73 const int defaultSize = 20; 63 74 const int maxSavedResults = 256; 64 75 65 76 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form, bool createdByParser) 66 77 : HTMLTextFormControlElement(tagName, document, form) 78 , m_size(defaultSize) 79 , m_maxLength(maximumLength) 80 , m_cachedSelectionStart(-1) 81 , m_cachedSelectionEnd(-1) 82 #if ENABLE(WCSS) 83 , m_inputFormatMask("*m") 84 , m_maxInputCharsAllowed(maximumLength) 85 #endif 67 86 , m_maxResults(-1) 68 87 , m_isChecked(false) … … 99 118 const AtomicString& HTMLInputElement::formControlName() const 100 119 { 101 return m_ data.name();120 return m_name.isNull() ? emptyAtom : m_name; 102 121 } 103 122 … … 201 220 if (check == CheckDirtyFlag) { 202 221 // Return false for the default value even if it is longer than maxLength. 203 bool userEdited = !m_ data.value().isNull();222 bool userEdited = !m_value.isNull(); 204 223 if (!userEdited) 205 224 return false; … … 394 413 void HTMLInputElement::updateFocusAppearance(bool restorePreviousSelection) 395 414 { 396 if (isTextField()) 397 InputElement::updateFocusAppearance(m_data, this, this, restorePreviousSelection); 398 else 415 if (isTextField()) { 416 if (!restorePreviousSelection || m_cachedSelectionStart == -1) 417 select(); 418 else { 419 // Restore the cached selection. 420 WebCore::setSelectionRange(this, m_cachedSelectionStart, m_cachedSelectionEnd); 421 } 422 if (document()->frame()) 423 document()->frame()->selection()->revealSelection(); 424 } else 399 425 HTMLFormControlElementWithState::updateFocusAppearance(restorePreviousSelection); 400 426 } … … 402 428 void HTMLInputElement::aboutToUnload() 403 429 { 404 InputElement::aboutToUnload(this, this); 430 if (!isTextField() || !focused()) 431 return; 432 433 Frame* frame = document()->frame(); 434 if (!frame) 435 return; 436 437 frame->editor()->textFieldDidEndEditing(this); 405 438 } 406 439 … … 412 445 void HTMLInputElement::handleFocusEvent() 413 446 { 414 InputElement::dispatchFocusEvent(this, this); 447 if (!isTextField()) 448 return; 449 if (isPasswordField() && document()->frame()) 450 document()->setUseSecureKeyboardEntryWhenActive(true); 415 451 } 416 452 … … 418 454 { 419 455 m_inputType->handleBlurEvent(); 420 InputElement::dispatchBlurEvent(this, this); 456 457 if (!isTextField()) 458 return; 459 Frame* frame = document()->frame(); 460 if (!frame) 461 return; 462 if (isPasswordField()) 463 document()->setUseSecureKeyboardEntryWhenActive(false); 464 frame->editor()->textFieldDidEndEditing(this); 421 465 } 422 466 … … 467 511 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 468 512 469 if (didStoreValue && !willStoreValue && !m_ data.value().isNull()) {470 setAttribute(valueAttr, m_ data.value());471 m_ data.setValue(String());513 if (didStoreValue && !willStoreValue && !m_value.isNull()) { 514 setAttribute(valueAttr, m_value); 515 m_value = String(); 472 516 } 473 517 if (!didStoreValue && willStoreValue) 474 m_ data.setValue(sanitizeValue(fastGetAttribute(valueAttr)));518 m_value = sanitizeValue(fastGetAttribute(valueAttr)); 475 519 else 476 InputElement::updateValueIfNeeded(m_data, this);520 updateValueIfNeeded(); 477 521 478 522 if (neededActivationCallback) … … 503 547 504 548 setNeedsValidityCheck(); 505 InputElement::notifyFormStateChanged(this);549 notifyFormStateChanged(); 506 550 } 507 551 … … 561 605 if (attr->name() == nameAttr) { 562 606 checkedRadioButtons().removeButton(this); 563 m_ data.setName(attr->value());607 m_name = attr->value(); 564 608 checkedRadioButtons().addButton(this); 565 609 HTMLFormControlElementWithState::parseMappedAttribute(attr); … … 583 627 } else if (attr->name() == valueAttr) { 584 628 // We only need to setChanged if the form is looking at the default value right now. 585 if (m_ data.value().isNull())629 if (m_value.isNull()) 586 630 setNeedsStyleRecalc(); 587 631 setFormControlValueMatchesRenderer(false); … … 596 640 m_reflectsCheckedAttribute = true; 597 641 } 598 } else if (attr->name() == maxlengthAttr) { 599 InputElement::parseMaxLengthAttribute(m_data, this, this, attr); 600 setNeedsValidityCheck(); 601 } else if (attr->name() == sizeAttr) 602 InputElement::parseSizeAttribute(m_data, this, attr); 603 else if (attr->name() == altAttr) 642 } else if (attr->name() == maxlengthAttr) 643 parseMaxLengthAttribute(attr); 644 else if (attr->name() == sizeAttr) { 645 m_size = attr->isNull() ? defaultSize : attr->value().toInt(); 646 if (renderer()) 647 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); 648 } else if (attr->name() == altAttr) 604 649 m_inputType->altAttributeChanged(); 605 650 else if (attr->name() == srcAttr) … … 809 854 int HTMLInputElement::size() const 810 855 { 811 return m_ data.size();856 return m_size; 812 857 } 813 858 … … 816 861 const HTMLInputElement* sourceElement = static_cast<const HTMLInputElement*>(source); 817 862 818 m_ data.setValue(sourceElement->m_data.value());863 m_value = sourceElement->m_value; 819 864 setChecked(sourceElement->m_isChecked); 820 865 m_reflectsCheckedAttribute = sourceElement->m_reflectsCheckedAttribute; … … 830 875 return value; 831 876 832 value = m_ data.value();877 value = m_value; 833 878 if (!value.isNull()) 834 879 return value; … … 858 903 const String& HTMLInputElement::suggestedValue() const 859 904 { 860 return m_ data.suggestedValue();905 return m_suggestedValue; 861 906 } 862 907 … … 866 911 return; 867 912 setFormControlValueMatchesRenderer(false); 868 m_ data.setSuggestedValue(sanitizeValue(value));913 m_suggestedValue = sanitizeValue(value); 869 914 updatePlaceholderVisibility(false); 870 915 if (renderer()) … … 883 928 files()->clear(); 884 929 else { 885 m_ data.setValue(sanitizeValue(value));930 m_value = sanitizeValue(value); 886 931 if (isTextField()) 887 932 updatePlaceholderVisibility(false); … … 894 939 895 940 if (isTextField()) { 896 unsigned max = m_ data.value().length();941 unsigned max = m_value.length(); 897 942 if (document()->focusedNode() == this) 898 InputElement::updateSelectionRange(this,this, max, max);943 WebCore::setSelectionRange(this, max, max); 899 944 else 900 945 cacheSelection(max, max); 901 m_ data.setSuggestedValue(String());946 m_suggestedValue = String(); 902 947 } 903 948 m_inputType->valueChanged(); … … 915 960 setTextAsOfLastFormControlChangeEvent(value); 916 961 917 InputElement::notifyFormStateChanged(this);962 notifyFormStateChanged(); 918 963 } 919 964 … … 962 1007 ASSERT(!isFileUpload()); 963 1008 964 m_data.setSuggestedValue(String()); 965 InputElement::setValueFromRenderer(m_data, this, this, value); 1009 m_suggestedValue = String(); 1010 1011 // Renderer and our event handler are responsible for sanitizing values. 1012 ASSERT(value == sanitizeValue(value) || sanitizeValue(value).isEmpty()); 1013 1014 // Workaround for bug where trailing \n is included in the result of textContent. 1015 // The assert macro above may also be simplified to: value == constrainValue(value) 1016 // http://bugs.webkit.org/show_bug.cgi?id=9661 1017 m_value = value == "\n" ? String("") : value; 1018 1019 setFormControlValueMatchesRenderer(true); 1020 1021 // Input event is fired by the Node::defaultEventHandler for editable controls. 1022 if (!isTextField()) 1023 dispatchInputEvent(); 1024 notifyFormStateChanged(); 1025 966 1026 updatePlaceholderVisibility(false); 967 1027 setNeedsValidityCheck(); … … 976 1036 977 1037 setFormControlValueMatchesRenderer(true); 978 InputElement::notifyFormStateChanged(this);1038 notifyFormStateChanged(); 979 1039 setNeedsValidityCheck(); 980 1040 } … … 1106 1166 void HTMLInputElement::setDefaultName(const AtomicString& name) 1107 1167 { 1108 m_ data.setName(name);1168 m_name = name; 1109 1169 } 1110 1170 … … 1121 1181 int HTMLInputElement::maxLength() const 1122 1182 { 1123 return m_ data.maxLength();1183 return m_maxLength; 1124 1184 } 1125 1185 … … 1220 1280 void HTMLInputElement::cacheSelection(int start, int end) 1221 1281 { 1222 m_ data.setCachedSelectionStart(start);1223 m_ data.setCachedSelectionEnd(end);1282 m_cachedSelectionStart = start; 1283 m_cachedSelectionEnd = end; 1224 1284 } 1225 1285 … … 1445 1505 #if ENABLE(WCSS) 1446 1506 1507 static inline const AtomicString& formatCodes() 1508 { 1509 DEFINE_STATIC_LOCAL(AtomicString, codes, ("AaNnXxMm")); 1510 return codes; 1511 } 1512 1513 static unsigned cursorPositionToMaskIndex(const String& inputFormatMask, unsigned cursorPosition) 1514 { 1515 UChar mask; 1516 int index = -1; 1517 do { 1518 mask = inputFormatMask[++index]; 1519 if (mask == '\\') 1520 ++index; 1521 else if (mask == '*' || (isASCIIDigit(mask) && mask != '0')) { 1522 index = inputFormatMask.length() - 1; 1523 break; 1524 } 1525 } while (cursorPosition--); 1526 1527 return index; 1528 } 1529 1530 bool HTMLInputElement::isConformToInputMask(const String& inputChars) const 1531 { 1532 for (unsigned i = 0; i < inputChars.length(); ++i) { 1533 if (!isConformToInputMask(inputChars[i], i)) 1534 return false; 1535 } 1536 return true; 1537 } 1538 1539 bool HTMLInputElement::isConformToInputMask(UChar inChar, unsigned cursorPosition) const 1540 { 1541 if (m_inputFormatMask.isEmpty() || m_inputFormatMask == "*M" || m_inputFormatMask == "*m") 1542 return true; 1543 1544 if (cursorPosition >= m_maxInputCharsAllowed()) 1545 return false; 1546 1547 unsigned maskIndex = cursorPositionToMaskIndex(m_inputFormatMask, cursorPosition); 1548 bool ok = true; 1549 UChar mask = m_inputFormatMask[maskIndex]; 1550 // Match the inputed character with input mask 1551 switch (mask) { 1552 case 'A': 1553 ok = !isASCIIDigit(inChar) && !isASCIILower(inChar) && isASCIIPrintable(inChar); 1554 break; 1555 case 'a': 1556 ok = !isASCIIDigit(inChar) && !isASCIIUpper(inChar) && isASCIIPrintable(inChar); 1557 break; 1558 case 'N': 1559 ok = isASCIIDigit(inChar); 1560 break; 1561 case 'n': 1562 ok = !isASCIIAlpha(inChar) && isASCIIPrintable(inChar); 1563 break; 1564 case 'X': 1565 ok = !isASCIILower(inChar) && isASCIIPrintable(inChar); 1566 break; 1567 case 'x': 1568 ok = !isASCIIUpper(inChar) && isASCIIPrintable(inChar); 1569 break; 1570 case 'M': 1571 case 'm': 1572 ok = isASCIIPrintable(inChar); 1573 break; 1574 default: 1575 ok = (mask == inChar); 1576 break; 1577 } 1578 1579 return ok; 1580 } 1581 1582 String HTMLInputElement::validateInputMask(String& inputMask) 1583 { 1584 inputMask.replace("\\\\", "\\"); 1585 1586 bool isValid = true; 1587 bool hasWildcard = false; 1588 unsigned escapeCharCount = 0; 1589 unsigned maskLength = inputMask.length(); 1590 UChar formatCode; 1591 for (unsigned i = 0; i < maskLength; ++i) { 1592 formatCode = inputMask[i]; 1593 if (formatCodes().find(formatCode) == -1) { 1594 if (formatCode == '*' || (isASCIIDigit(formatCode) && formatCode != '0')) { 1595 // Validate codes which ends with '*f' or 'nf' 1596 formatCode = inputMask[++i]; 1597 if ((i + 1 != maskLength) || formatCodes().find(formatCode) == -1) { 1598 isValid = false; 1599 break; 1600 } 1601 hasWildcard = true; 1602 } else if (formatCode == '\\') { 1603 // skip over the next mask character 1604 ++i; 1605 ++escapeCharCount; 1606 } else { 1607 isValid = false; 1608 break; 1609 } 1610 } 1611 } 1612 1613 if (!isValid) 1614 return String(); 1615 // calculate the number of characters allowed to be entered by input mask 1616 unsigned allowedLength = maskLength; 1617 if (escapeCharCount) 1618 allowedLength -= escapeCharCount; 1619 1620 if (hasWildcard) { 1621 formatCode = inputMask[maskLength - 2]; 1622 if (formatCode == '*') 1623 allowedLength = m_maxInputCharsAllowed; 1624 else { 1625 unsigned leftLen = String(&formatCode).toInt(); 1626 allowedLength = leftLen + allowedLength - 2; 1627 } 1628 } 1629 1630 if (allowedLength < m_maxInputCharsAllowed) 1631 m_maxInputCharsAllowed = allowedLength; 1632 1633 return inputMask; 1634 } 1635 1447 1636 void HTMLInputElement::setWapInputFormat(String& mask) 1448 1637 { 1449 String validateMask = validateInputMask(m _data, mask);1638 String validateMask = validateInputMask(mask); 1450 1639 if (!validateMask.isEmpty()) 1451 m_ data.setInputFormatMask(validateMask);1640 m_inputFormatMask = validateMask; 1452 1641 } 1453 1642 … … 1561 1750 } 1562 1751 1563 void HTMLInputElement::handleBeforeTextInsertedEvent(Event* event) 1564 { 1565 InputElement::handleBeforeTextInsertedEvent(m_data, this, this, event); 1752 void HTMLInputElement::notifyFormStateChanged() 1753 { 1754 Frame* frame = document()->frame(); 1755 if (!frame) 1756 return; 1757 1758 if (Page* page = frame->page()) 1759 page->chrome()->client()->formStateDidChange(this); 1760 } 1761 1762 void HTMLInputElement::parseMaxLengthAttribute(Attribute* attribute) 1763 { 1764 int maxLength = attribute->isNull() ? maximumLength : attribute->value().toInt(); 1765 if (maxLength <= 0 || maxLength > maximumLength) 1766 maxLength = maximumLength; 1767 int oldMaxLength = m_maxLength; 1768 m_maxLength = maxLength; 1769 if (oldMaxLength != maxLength) 1770 updateValueIfNeeded(); 1771 setNeedsStyleRecalc(); 1772 setNeedsValidityCheck(); 1773 } 1774 1775 void HTMLInputElement::updateValueIfNeeded() 1776 { 1777 String newValue = sanitizeValue(m_value); 1778 if (newValue != m_value) 1779 setValue(newValue); 1566 1780 } 1567 1781 -
trunk/Source/WebCore/html/HTMLInputElement.h
r84695 r85998 26 26 27 27 #include "HTMLFormControlElement.h" 28 #include "InputElement.h"29 28 30 29 namespace WebCore { … … 36 35 class KURL; 37 36 38 class HTMLInputElement : public HTMLTextFormControlElement , public InputElement{37 class HTMLInputElement : public HTMLTextFormControlElement { 39 38 public: 40 39 static PassRefPtr<HTMLInputElement> create(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser); … … 43 42 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitspeechchange); 44 43 45 virtual InputElement* toInputElement() { return this; }44 virtual HTMLInputElement* toInputElement() { return this; } 46 45 47 46 bool autoComplete() const; … … 79 78 void stepDown(ExceptionCode& ec) { stepDown(1, ec); } 80 79 // stepUp()/stepDown() for user-interaction. 81 virtualbool isSteppable() const;80 bool isSteppable() const; 82 81 void stepUpFromRenderer(int); 83 82 … … 85 84 86 85 virtual bool isRadioButton() const; 87 virtualbool isTextField() const;88 virtualbool isSearchField() const;89 virtualbool isInputTypeHidden() const;90 virtualbool isPasswordField() const;91 virtualbool isCheckbox() const;92 virtualbool isRangeControl() const;86 bool isTextField() const; 87 bool isSearchField() const; 88 bool isInputTypeHidden() const; 89 bool isPasswordField() const; 90 bool isCheckbox() const; 91 bool isRangeControl() const; 93 92 94 93 // FIXME: It's highly likely that any call site calling this function should instead … … 107 106 108 107 #if ENABLE(INPUT_SPEECH) 109 virtualbool isSpeechEnabled() const;108 bool isSpeechEnabled() const; 110 109 #endif 111 110 … … 117 116 void setIndeterminate(bool); 118 117 119 virtual int size() const; 118 // isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state 119 virtual bool isChecked() const; 120 virtual bool isIndeterminate() const { return indeterminate(); } 121 122 int size() const; 120 123 121 124 void setType(const String&); 122 125 123 virtualString value() const;124 v irtual void setValue(const String&, bool sendChangeEvent = false);125 v irtual void setValueForUser(const String&);126 String value() const; 127 void setValue(const String&, bool sendChangeEvent = false); 128 void setValueForUser(const String&); 126 129 // Checks if the specified string would be a valid value. 127 130 // We should not call this for types with no string value such as CHECKBOX and RADIO. 128 131 bool isValidValue(const String&) const; 129 132 130 virtual const String& suggestedValue() const; 133 String sanitizeValue(const String&) const; 134 135 // The value which is drawn by a renderer. 136 String visibleValue() const; 137 String convertFromVisibleValue(const String&) const; 138 // Returns true if the specified string can be set as the value of HTMLInputElement. 139 bool isAcceptableValue(const String&) const; 140 141 const String& suggestedValue() const; 131 142 void setSuggestedValue(const String&); 132 143 … … 142 153 String valueWithDefault() const; 143 154 144 v irtual void setValueFromRenderer(const String&);155 void setValueFromRenderer(const String&); 145 156 void setFileListFromRenderer(const Vector<String>&); 146 157 147 158 bool canHaveSelection() const; 148 virtual void select() { HTMLTextFormControlElement::select(); }149 159 150 160 virtual bool rendererIsNeeded(RenderStyle*); … … 179 189 bool multiple() const; 180 190 181 virtualbool isAutofilled() const { return m_isAutofilled; }191 bool isAutofilled() const { return m_isAutofilled; } 182 192 void setAutofilled(bool = true); 183 193 … … 186 196 void addSearchResult(); 187 197 void onSearch(); 198 bool searchEventsShouldBeDispatched() const; 188 199 189 200 #if ENABLE(DATALIST) … … 199 210 // Otherwise, they would be private. 200 211 CheckedRadioButtons& checkedRadioButtons() const; 201 void handleBeforeTextInsertedEvent(Event*);202 212 void updateCheckedRadioButtons(); 213 #if ENABLE(WCSS) 214 bool isConformToInputMask(const String&) const; 215 #endif 203 216 204 217 bool lastChangeWasUserEdit() const; 205 218 void cacheSelection(int start, int end); 219 220 static const int maximumLength; 221 206 222 protected: 207 223 HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser); … … 224 240 virtual const AtomicString& formControlName() const; 225 241 226 // isChecked is used by the rendering tree/CSS while checked() is used by JS to determine checked state227 virtual bool isChecked() const;228 virtual bool isIndeterminate() const { return indeterminate(); }229 230 242 virtual bool isTextFormControl() const { return isTextField(); } 231 243 … … 233 245 234 246 virtual const AtomicString& formControlType() const; 235 236 virtual bool searchEventsShouldBeDispatched() const;237 247 238 248 virtual bool saveFormControlState(String& value) const; … … 262 272 virtual bool isURLAttribute(Attribute*) const; 263 273 264 virtual void cacheSelection(int start, int end);265 266 virtual String visibleValue() const;267 virtual String convertFromVisibleValue(const String&) const;268 virtual bool isAcceptableValue(const String&) const;269 virtual String sanitizeValue(const String&) const;270 274 virtual bool hasUnacceptableValue() const; 271 275 … … 281 285 void unregisterForActivationCallbackIfNeeded(); 282 286 283 virtualbool supportsMaxLength() const { return isTextType(); }287 bool supportsMaxLength() const { return isTextType(); } 284 288 bool isTextType() const; 285 289 … … 289 293 virtual void handleFocusEvent(); 290 294 virtual void handleBlurEvent(); 291 virtual int cachedSelectionStart() const { return m_ data.cachedSelectionStart(); }292 virtual int cachedSelectionEnd() const { return m_ data.cachedSelectionEnd(); }295 virtual int cachedSelectionStart() const { return m_cachedSelectionStart; } 296 virtual int cachedSelectionEnd() const { return m_cachedSelectionEnd; } 293 297 294 298 virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } … … 304 308 HTMLDataListElement* dataList() const; 305 309 #endif 306 310 void notifyFormStateChanged(); 311 void parseMaxLengthAttribute(Attribute*); 312 void updateValueIfNeeded(); 307 313 #if ENABLE(WCSS) 308 virtual InputElementData data() const { return m_data; } 309 #endif 310 311 InputElementData m_data; 314 bool isConformToInputMask(UChar, unsigned) const; 315 String validateInputMask(String&); 316 #endif 317 318 AtomicString m_name; 319 String m_value; 320 String m_suggestedValue; 321 int m_size; 322 int m_maxLength; 323 int m_cachedSelectionStart; 324 int m_cachedSelectionEnd; 325 #if ENABLE(WCSS) 326 String m_inputFormatMask; 327 unsigned m_maxInputCharsAllowed; 328 #endif 312 329 short m_maxResults; 313 330 bool m_isChecked : 1; -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r82908 r85998 40 40 #include "Frame.h" 41 41 #include "HTMLNames.h" 42 #include "InputElement.h"43 42 #include "Page.h" 44 43 #include "RenderStyle.h" -
trunk/Source/WebCore/html/InputType.cpp
r85603 r85998 327 327 } 328 328 329 void InputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) 330 { 331 element()->handleBeforeTextInsertedEvent(event); 329 void InputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) 330 { 332 331 } 333 332 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r79951 r85998 33 33 #include "TextFieldInputType.h" 34 34 35 #include "BeforeTextInsertedEvent.h" 35 36 #include "Frame.h" 36 37 #include "HTMLInputElement.h" … … 38 39 #include "RenderTextControlSingleLine.h" 39 40 #include "TextEvent.h" 41 #include "TextIterator.h" 40 42 #include "WheelEvent.h" 41 43 #include <wtf/text/WTFString.h> … … 120 122 } 121 123 124 static String replaceEOLAndLimitLength(const String& proposedValue, int maxLength) 125 { 126 String string = proposedValue; 127 string.replace("\r\n", " "); 128 string.replace('\r', ' '); 129 string.replace('\n', ' '); 130 131 unsigned newLength = numCharactersInGraphemeClusters(string, maxLength); 132 for (unsigned i = 0; i < newLength; ++i) { 133 const UChar current = string[i]; 134 if (current < ' ' && current != '\t') { 135 newLength = i; 136 break; 137 } 138 } 139 return string.left(newLength); 140 } 141 122 142 String TextFieldInputType::sanitizeValue(const String& proposedValue) 123 143 { 124 return InputElement::sanitizeValueForTextField(element(), proposedValue); 144 #if ENABLE(WCSS) 145 if (!element()->isConformToInputMask(proposedValue)) { 146 if (isConformToInputMask(element()->value())) 147 return element->value(); 148 return String(); 149 } 150 #endif 151 return replaceEOLAndLimitLength(proposedValue, HTMLInputElement::maximumLength); 152 } 153 154 void TextFieldInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) 155 { 156 // Make sure that the text to be inserted will not violate the maxLength. 157 158 // We use RenderTextControlSingleLine::text() instead of InputElement::value() 159 // because they can be mismatched by sanitizeValue() in 160 // RenderTextControlSingleLine::subtreeHasChanged() in some cases. 161 unsigned oldLength = numGraphemeClusters(toRenderTextControlSingleLine(element()->renderer())->text()); 162 163 // selectionLength represents the selection length of this text field to be 164 // removed by this insertion. 165 // If the text field has no focus, we don't need to take account of the 166 // selection length. The selection is the source of text drag-and-drop in 167 // that case, and nothing in the text field will be removed. 168 unsigned selectionLength = element()->focused() ? numGraphemeClusters(plainText(element()->document()->frame()->selection()->selection().toNormalizedRange().get())) : 0; 169 ASSERT(oldLength >= selectionLength); 170 171 // Selected characters will be removed by the next text event. 172 unsigned baseLength = oldLength - selectionLength; 173 unsigned maxLength = static_cast<unsigned>(isTextType() ? element()->maxLength() : HTMLInputElement::maximumLength); // maxLength can never be negative. 174 unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0; 175 176 // Truncate the inserted text to avoid violating the maxLength and other constraints. 177 #if ENABLE(WCSS) 178 RefPtr<Range> range = element()->document()->frame()->selection()->selection().toNormalizedRange(); 179 String candidateString = toRenderTextControlSingleLine(element()->renderer())->text(); 180 if (selectionLength) 181 candidateString.replace(range->startOffset(), range->endOffset(), event->text()); 182 else 183 candidateString.insert(event->text(), range->startOffset()); 184 if (!element()->isConformToInputMask(candidateString)) { 185 event->setText(""); 186 return; 187 } 188 #endif 189 event->setText(replaceEOLAndLimitLength(event->text(), appendableLength)); 125 190 } 126 191 -
trunk/Source/WebCore/html/TextFieldInputType.h
r77228 r85998 49 49 virtual bool isTextField() const; 50 50 virtual bool valueMissing(const String&) const; 51 virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*); 51 52 virtual void forwardEvent(Event*); 52 53 virtual bool shouldSubmitImplicitly(Event*); 53 54 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; 54 55 virtual bool shouldUseInputMethod() const; 55 virtual String sanitizeValue(const String& proposedValue);56 virtual String sanitizeValue(const String&); 56 57 virtual bool shouldRespectListAttribute(); 57 58 }; -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r85864 r85998 35 35 #include "HTMLNames.h" 36 36 #include "HitTestResult.h" 37 #include "InputElement.h"38 37 #include "LocalizedStrings.h" 39 38 #include "MouseEvent.h" … … 76 75 , m_searchPopup(0) 77 76 { 77 ASSERT(node->isHTMLElement()); 78 ASSERT(node->toInputElement()); 78 79 } 79 80 … … 107 108 void RenderTextControlSingleLine::addSearchResult() 108 109 { 109 ASSERT(node()->isHTMLElement()); 110 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 110 HTMLInputElement* input = inputElement(); 111 111 if (input->maxResults() <= 0) 112 112 return; … … 139 139 void RenderTextControlSingleLine::stopSearchEventTimer() 140 140 { 141 ASSERT(node()->isHTMLElement());142 141 m_searchEventTimer.stop(); 143 142 } … … 145 144 void RenderTextControlSingleLine::showPopup() 146 145 { 147 ASSERT(node()->isHTMLElement());148 146 if (m_searchPopupIsVisible) 149 147 return; … … 161 159 162 160 // Trim the recent searches list if the maximum size has changed since we last saved. 163 HTMLInputElement* input = static_cast<HTMLInputElement*>(node());161 HTMLInputElement* input = inputElement(); 164 162 if (static_cast<int>(m_recentSearches.size()) > input->maxResults()) { 165 163 do { … … 175 173 void RenderTextControlSingleLine::hidePopup() 176 174 { 177 ASSERT(node()->isHTMLElement());178 175 if (m_searchPopup) 179 176 m_searchPopup->popupMenu()->hide(); … … 189 186 element->setChangedSinceLastFormControlChangeEvent(true); 190 187 191 InputElement* input = inputElement();188 HTMLInputElement* input = inputElement(); 192 189 // We don't need to call sanitizeUserInputValue() function here because 193 // InputElement::handleBeforeTextInsertedEvent() has already called190 // HTMLInputElement::handleBeforeTextInsertedEvent() has already called 194 191 // sanitizeUserInputValue(). 195 192 // sanitizeValue() is needed because IME input doesn't dispatch BeforeTextInsertedEvent. … … 197 194 if (input->isAcceptableValue(value)) 198 195 input->setValueFromRenderer(input->sanitizeValue(input->convertFromVisibleValue(value))); 199 if (node()->isHTMLElement()) { 200 // Recalc for :invalid and hasUnacceptableValue() change. 201 static_cast<HTMLInputElement*>(input)->setNeedsStyleRecalc(); 202 } 196 // Recalc for :invalid and hasUnacceptableValue() change. 197 input->setNeedsStyleRecalc(); 203 198 204 199 if (m_cancelButton) … … 711 706 // flag is false. It protects an unacceptable renderer value from 712 707 // being overwritten with the DOM value. 713 if (! static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer())708 if (!inputElement()->formControlValueMatchesRenderer()) 714 709 setInnerTextValue(inputElement()->visibleValue()); 715 710 } … … 756 751 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const RenderStyle* startStyle) const 757 752 { 758 ASSERT(node()->isHTMLElement());759 760 753 RefPtr<RenderStyle> innerBlockStyle = RenderStyle::create(); 761 754 innerBlockStyle->inheritFrom(startStyle); … … 772 765 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createResultsButtonStyle(const RenderStyle* startStyle) const 773 766 { 774 ASSERT(node()->isHTMLElement()); 775 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 767 HTMLInputElement* input = inputElement(); 776 768 777 769 RefPtr<RenderStyle> resultsBlockStyle; … … 794 786 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createCancelButtonStyle(const RenderStyle* startStyle) const 795 787 { 796 ASSERT(node()->isHTMLElement());797 788 RefPtr<RenderStyle> cancelBlockStyle; 798 789 … … 812 803 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerSpinButtonStyle() const 813 804 { 814 ASSERT(node()->isHTMLElement());815 805 RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(INNER_SPIN_BUTTON); 816 806 if (!buttonStyle) … … 822 812 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createOuterSpinButtonStyle() const 823 813 { 824 ASSERT(node()->isHTMLElement());825 814 RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(OUTER_SPIN_BUTTON); 826 815 if (!buttonStyle) … … 833 822 PassRefPtr<RenderStyle> RenderTextControlSingleLine::createSpeechButtonStyle() const 834 823 { 835 ASSERT(node()->isHTMLElement());836 824 RefPtr<RenderStyle> buttonStyle = getCachedPseudoStyle(INPUT_SPEECH_BUTTON); 837 825 if (!buttonStyle) … … 859 847 EVisibility RenderTextControlSingleLine::visibilityForCancelButton() const 860 848 { 861 ASSERT(node()->isHTMLElement()); 862 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 863 return input->value().isEmpty() ? HIDDEN : VISIBLE; 849 return inputElement()->value().isEmpty() ? HIDDEN : VISIBLE; 864 850 } 865 851 … … 871 857 void RenderTextControlSingleLine::startSearchEventTimer() 872 858 { 873 ASSERT(node()->isHTMLElement());874 859 unsigned length = text().length(); 875 860 … … 877 862 if (!length) { 878 863 stopSearchEventTimer(); 879 static_cast<HTMLInputElement*>(node())->onSearch();864 inputElement()->onSearch(); 880 865 return; 881 866 } … … 888 873 void RenderTextControlSingleLine::searchEventTimerFired(Timer<RenderTextControlSingleLine>*) 889 874 { 890 ASSERT(node()->isHTMLElement()); 891 static_cast<HTMLInputElement*>(node())->onSearch(); 875 inputElement()->onSearch(); 892 876 } 893 877 … … 895 879 void RenderTextControlSingleLine::valueChanged(unsigned listIndex, bool fireEvents) 896 880 { 897 ASSERT(node()->isHTMLElement());898 881 ASSERT(static_cast<int>(listIndex) < listSize()); 899 HTMLInputElement* input = static_cast<HTMLInputElement*>(node());882 HTMLInputElement* input = inputElement(); 900 883 if (static_cast<int>(listIndex) == (listSize() - 1)) { 901 884 if (fireEvents) { … … 1031 1014 void RenderTextControlSingleLine::setTextFromItem(unsigned listIndex) 1032 1015 { 1033 ASSERT(node()->isHTMLElement()); 1034 static_cast<HTMLInputElement*>(node())->setValue(itemText(listIndex)); 1016 inputElement()->setValue(itemText(listIndex)); 1035 1017 } 1036 1018 … … 1119 1101 } 1120 1102 1121 InputElement* RenderTextControlSingleLine::inputElement() const1103 HTMLInputElement* RenderTextControlSingleLine::inputElement() const 1122 1104 { 1123 1105 return node()->toInputElement(); -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r79978 r85998 31 31 namespace WebCore { 32 32 33 class InputElement;33 class HTMLInputElement; 34 34 class InputFieldSpeechButtonElement; 35 35 class SearchFieldCancelButtonElement; … … 143 143 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollableArea*, ScrollbarOrientation, ScrollbarControlSize); 144 144 145 InputElement* inputElement() const;145 HTMLInputElement* inputElement() const; 146 146 147 147 virtual int textBlockInsetLeft() const; -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r85864 r85998 752 752 return false; 753 753 754 InputElement* inputElement = o->node()->toInputElement();754 HTMLInputElement* inputElement = o->node()->toInputElement(); 755 755 if (!inputElement) 756 756 return false; … … 764 764 return false; 765 765 766 InputElement* inputElement = o->node()->toInputElement();766 HTMLInputElement* inputElement = o->node()->toInputElement(); 767 767 if (!inputElement) 768 768 return false; … … 966 966 #endif 967 967 968 bool RenderTheme::shouldHaveSpinButton( InputElement* inputElement) const968 bool RenderTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const 969 969 { 970 970 return inputElement->isSteppable() && !inputElement->isRangeControl(); -
trunk/Source/WebCore/rendering/RenderTheme.h
r85423 r85998 37 37 38 38 class Element; 39 class HTMLInputElement; 39 40 class PopupMenu; 40 41 class RenderMenuList; … … 202 203 203 204 virtual bool shouldShowPlaceholderWhenFocused() const { return false; } 204 virtual bool shouldHaveSpinButton( InputElement*) const;205 virtual bool shouldHaveSpinButton(HTMLInputElement*) const; 205 206 206 207 protected: -
trunk/Source/WebKit/chromium/ChangeLog
r85977 r85998 1 2011-05-06 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Eliminate WebCore/dom/InputElement.{cpp,h} 6 https://bugs.webkit.org/show_bug.cgi?id=60262 7 8 * src/WebInputElement.cpp: 9 (WebKit::WebInputElement::defaultMaxLength): 10 Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength. 11 (WebKit::toWebInputElement): 12 Follow the return type change of Node::toInputElement(). 13 1 14 2011-05-06 Justin Schuh <jschuh@chromium.org> 2 15 -
trunk/Source/WebKit/chromium/src/WebInputElement.cpp
r81637 r85998 153 153 int WebInputElement::defaultMaxLength() 154 154 { 155 return HTMLInputElement:: s_maximumLength;155 return HTMLInputElement::maximumLength; 156 156 } 157 157 … … 174 174 WebInputElement* toWebInputElement(WebElement* webElement) 175 175 { 176 InputElement* inputElement = webElement->unwrap<Element>()->toInputElement();176 HTMLInputElement* inputElement = webElement->unwrap<Element>()->toInputElement(); 177 177 if (!inputElement) 178 178 return 0; 179 180 ASSERT(webElement->unwrap<Element>()->isHTMLElement());181 179 182 180 return static_cast<WebInputElement*>(webElement); -
trunk/Source/WebKit/gtk/ChangeLog
r85987 r85998 1 2011-05-06 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Eliminate WebCore/dom/InputElement.{cpp,h} 6 https://bugs.webkit.org/show_bug.cgi?id=60262 7 8 * WebCoreSupport/DumpRenderTreeSupportGtk.cpp: 9 (DumpRenderTreeSupportGtk::setAutofilled): 10 Follow the return type change of Node::toInputElement(). 11 (DumpRenderTreeSupportGtk::setValueForUser): ditto. 12 1 13 2011-05-06 Martin Robinson <mrobinson@igalia.com> 2 14 -
trunk/Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
r85925 r85998 37 37 #include "GraphicsContext.h" 38 38 #include "HTMLInputElement.h" 39 #include "InputElement.h"40 39 #include "JSDOMWindow.h" 41 40 #include "JSDocument.h" … … 761 760 if (!element) 762 761 return; 763 InputElement* inputElement = element->toInputElement();762 HTMLInputElement* inputElement = element->toInputElement(); 764 763 if (!inputElement) 765 764 return; 766 765 767 static_cast<HTMLInputElement*>(inputElement)->setAutofilled(autofilled);766 inputElement->setAutofilled(autofilled); 768 767 } 769 768 … … 774 773 if (!element) 775 774 return; 776 InputElement* inputElement = element->toInputElement();775 HTMLInputElement* inputElement = element->toInputElement(); 777 776 if (!inputElement) 778 777 return; -
trunk/Source/WebKit/qt/Api/qwebpage.cpp
r85343 r85998 1447 1447 } 1448 1448 } 1449 return QVariant( InputElement::s_maximumLength);1449 return QVariant(HTMLInputElement::maximumLength); 1450 1450 } 1451 1451 return QVariant(0); -
trunk/Source/WebKit/qt/ChangeLog
r85925 r85998 1 2011-05-06 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Eliminate WebCore/dom/InputElement.{cpp,h} 6 https://bugs.webkit.org/show_bug.cgi?id=60262 7 8 * Api/qwebpage.cpp: 9 (QWebPage::inputMethodQuery): 10 Replace InputElement::s_maximumLength with HTMLInputElement::maximumLength. 11 * WebCoreSupport/DumpRenderTreeSupportQt.cpp: 12 (DumpRenderTreeSupportQt::setAutofilled): 13 Follow the return type change of Node::toInputElement(). 14 1 15 2011-05-04 Philippe Normand <pnormand@igalia.com> 2 16 -
trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
r85925 r85998 54 54 #include "HistoryItem.h" 55 55 #include "HTMLInputElement.h" 56 #include "InputElement.h"57 56 #include "InspectorController.h" 58 57 #include "NodeList.h" … … 244 243 if (!webElement) 245 244 return; 246 InputElement* inputElement = webElement->toInputElement();245 HTMLInputElement* inputElement = webElement->toInputElement(); 247 246 if (!inputElement) 248 247 return; 249 248 250 static_cast<HTMLInputElement*>(inputElement)->setAutofilled(isAutofilled);249 inputElement->setAutofilled(isAutofilled); 251 250 } 252 251
Note: See TracChangeset
for help on using the changeset viewer.