Changeset 90849 in webkit
- Timestamp:
- Jul 12, 2011 2:20:35 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r90832 r90849 775 775 html/HTMLTableSectionElement.cpp 776 776 html/HTMLTextAreaElement.cpp 777 html/HTMLTextFormControlElement.cpp 777 778 html/HTMLTitleElement.cpp 778 779 html/HTMLUListElement.cpp -
trunk/Source/WebCore/ChangeLog
r90847 r90849 1 2011-07-12 Ryosuke Niwa <rniwa@webkit.org> 2 3 Isolate HTMLTextFormControlElement into a separate file 4 https://bugs.webkit.org/show_bug.cgi?id=64381 5 6 Reviewed by Dimitri Glazkov. 7 8 Extracted HTMLTextFormControlElement.h and HTMLTextFormControlElement.cpp out of 9 HTMLFormControlElement.h and HTMLFormControlElement.cpp. 10 11 Also moved defaultEventHandler from HTMLFormControlElementWithState to HTMLTextFormControlElement 12 because it was specific to HTMLTextFormControlElement, and replaced all references to 13 HTMLFormControlElementWithState in HTMLInputElement and HTMLTextAreaElement by ones to 14 HTMLTextFormControlElement. 15 16 * CMakeLists.txt: 17 * GNUmakefile.list.am: 18 * WebCore.gypi: 19 * WebCore.pro: 20 * WebCore.vcproj/WebCore.vcproj: 21 * WebCore.xcodeproj/project.pbxproj: 22 * editing/TextIterator.cpp: 23 * editing/htmlediting.cpp: 24 * html/HTMLElementsAllInOne.cpp: 25 * html/HTMLFormControlElement.cpp: 26 (WebCore::HTMLFormControlElement::isFocusable): 27 * html/HTMLFormControlElement.h: 28 * html/HTMLInputElement.cpp: 29 (WebCore::HTMLInputElement::isKeyboardFocusable): 30 (WebCore::HTMLInputElement::isMouseFocusable): 31 (WebCore::HTMLInputElement::updateFocusAppearance): 32 (WebCore::HTMLInputElement::canStartSelection): 33 (WebCore::HTMLInputElement::parseMappedAttribute): 34 (WebCore::HTMLInputElement::finishParsingChildren): 35 (WebCore::HTMLInputElement::rendererIsNeeded): 36 (WebCore::HTMLInputElement::attach): 37 (WebCore::HTMLInputElement::detach): 38 (WebCore::HTMLInputElement::copyNonAttributeProperties): 39 (WebCore::HTMLInputElement::defaultEventHandler): 40 (WebCore::HTMLInputElement::willMoveToNewOwnerDocument): 41 (WebCore::HTMLInputElement::didMoveToNewOwnerDocument): 42 (WebCore::HTMLInputElement::addSubresourceAttributeURLs): 43 (WebCore::HTMLInputElement::recalcWillValidate): 44 * html/HTMLInputElement.h: 45 * html/HTMLTextAreaElement.cpp: 46 (WebCore::HTMLTextAreaElement::defaultEventHandler): 47 * html/HTMLTextAreaElement.h: 48 * html/HTMLTextFormControlElement.cpp: Copied from Source/WebCore/html/HTMLFormControlElement.cpp. 49 (WebCore::HTMLTextFormControlElement::defaultEventHandler): 50 * html/HTMLTextFormControlElement.h: Copied from Source/WebCore/html/HTMLFormControlElement.h. 51 1 52 2011-07-12 Sheriff Bot <webkit.review.bot@gmail.com> 2 53 -
trunk/Source/WebCore/GNUmakefile.list.am
r90832 r90849 1777 1777 Source/WebCore/html/HTMLTextAreaElement.cpp \ 1778 1778 Source/WebCore/html/HTMLTextAreaElement.h \ 1779 Source/WebCore/html/HTMLTextFormControlElement.cpp \ 1780 Source/WebCore/html/HTMLTextFormControlElement.h \ 1779 1781 Source/WebCore/html/HTMLTitleElement.cpp \ 1780 1782 Source/WebCore/html/HTMLTitleElement.h \ -
trunk/Source/WebCore/WebCore.gypi
r90842 r90849 620 620 'html/HTMLTablePartElement.h', 621 621 'html/HTMLTextAreaElement.h', 622 'html/HTMLTextFormControlElement.h', 622 623 'html/InputType.h', 623 624 'html/VoidCallback.h', … … 3021 3022 'html/HTMLTableSectionElement.h', 3022 3023 'html/HTMLTextAreaElement.cpp', 3024 'html/HTMLTextFormControlElement.cpp', 3023 3025 'html/HTMLTitleElement.cpp', 3024 3026 'html/HTMLTitleElement.h', -
trunk/Source/WebCore/WebCore.pro
r90832 r90849 733 733 html/HTMLTableSectionElement.cpp \ 734 734 html/HTMLTextAreaElement.cpp \ 735 html/HTMLTextFormControlElement.cpp \ 735 736 html/HTMLTitleElement.cpp \ 736 737 html/HTMLUListElement.cpp \ … … 1726 1727 html/HTMLTableSectionElement.h \ 1727 1728 html/HTMLTextAreaElement.h \ 1729 html/HTMLTextFormControlElement.h \ 1728 1730 html/HTMLTitleElement.h \ 1729 1731 html/HTMLTrackElement.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r90832 r90849 56919 56919 </File> 56920 56920 <File 56921 RelativePath="..\html\HTMLTextFormControlElement.cpp" 56922 > 56923 <FileConfiguration 56924 Name="Debug|Win32" 56925 ExcludedFromBuild="true" 56926 > 56927 <Tool 56928 Name="VCCLCompilerTool" 56929 /> 56930 </FileConfiguration> 56931 <FileConfiguration 56932 Name="Release|Win32" 56933 ExcludedFromBuild="true" 56934 > 56935 <Tool 56936 Name="VCCLCompilerTool" 56937 /> 56938 </FileConfiguration> 56939 <FileConfiguration 56940 Name="Debug_Cairo_CFLite|Win32" 56941 ExcludedFromBuild="true" 56942 > 56943 <Tool 56944 Name="VCCLCompilerTool" 56945 /> 56946 </FileConfiguration> 56947 <FileConfiguration 56948 Name="Release_Cairo_CFLite|Win32" 56949 ExcludedFromBuild="true" 56950 > 56951 <Tool 56952 Name="VCCLCompilerTool" 56953 /> 56954 </FileConfiguration> 56955 <FileConfiguration 56956 Name="Debug_All|Win32" 56957 ExcludedFromBuild="true" 56958 > 56959 <Tool 56960 Name="VCCLCompilerTool" 56961 /> 56962 </FileConfiguration> 56963 <FileConfiguration 56964 Name="Production|Win32" 56965 ExcludedFromBuild="true" 56966 > 56967 <Tool 56968 Name="VCCLCompilerTool" 56969 /> 56970 </FileConfiguration> 56971 </File> 56972 <File 56973 RelativePath="..\html\HTMLTextFormControlElement.h" 56974 > 56975 </File> 56976 <File 56921 56977 RelativePath="..\html\HTMLTitleElement.cpp" 56922 56978 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r90832 r90849 3218 3218 9BAB6C6D12550631001626D4 /* EditingStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */; }; 3219 3219 9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3220 9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3221 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */; }; 3220 3222 9BD0BF9312A42BF50072FD43 /* ScopedEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */; }; 3221 3223 9BD0BF9412A42BF50072FD43 /* ScopedEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */; }; … … 9741 9743 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditingStyle.cpp; sourceTree = "<group>"; }; 9742 9744 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritingDirection.h; sourceTree = "<group>"; }; 9745 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTextFormControlElement.h; sourceTree = "<group>"; }; 9746 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFormControlElement.cpp; sourceTree = "<group>"; }; 9743 9747 9BD0BF9112A42BF50072FD43 /* ScopedEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedEventQueue.h; sourceTree = "<group>"; }; 9744 9748 9BD0BF9212A42BF50072FD43 /* ScopedEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedEventQueue.cpp; sourceTree = "<group>"; }; … … 12716 12720 isa = PBXGroup; 12717 12721 children = ( 12722 00CA93B413C6697C00F7FE95 /* NewXMLDocumentParser.cpp */, 12723 00CA93B113C6691600F7FE95 /* NewXMLDocumentParser.h */, 12718 12724 00B9318113BA867F0035A948 /* XMLDocumentParser.cpp */, 12719 12725 00B9318213BA867F0035A948 /* XMLDocumentParser.h */, … … 12721 12727 00B9318513BA867F0035A948 /* XMLDocumentParserScope.cpp */, 12722 12728 00B9318613BA867F0035A948 /* XMLDocumentParserScope.h */, 12723 00CA93B113C6691600F7FE95 /* NewXMLDocumentParser.h */,12724 00CA93B413C6697C00F7FE95 /* NewXMLDocumentParser.cpp */,12725 12729 ); 12726 12730 path = parser; … … 13687 13691 isa = PBXGroup; 13688 13692 children = ( 13693 41815C1B138319630057AAA4 /* js */, 13689 13694 B1AD4E7713A12A7200846B27 /* track */, 13695 B1AD4E4B13A12A0B00846B27 /* CueIndex.cpp */, 13696 B1AD4E4C13A12A0B00846B27 /* CueIndex.h */, 13690 13697 B1AD4E7113A12A4600846B27 /* CueLoader.cpp */, 13691 13698 B1AD4E7213A12A4600846B27 /* CueLoader.h */, 13692 B1AD4E4B13A12A0B00846B27 /* CueIndex.cpp */, 13693 B1AD4E4C13A12A0B00846B27 /* CueIndex.h */, 13699 417DA4CF13734326007C57FB /* Internals.cpp */, 13700 417DA4CE13734326007C57FB /* Internals.h */, 13701 41813F9113818AD60057AAA4 /* Internals.idl */, 13694 13702 B1AD4E4D13A12A0B00846B27 /* LoadableTextTrack.cpp */, 13695 13703 B1AD4E4E13A12A0B00846B27 /* LoadableTextTrack.h */, … … 13702 13710 B1AD4E5913A12A0B00846B27 /* TextTrackCueList.cpp */, 13703 13711 B1AD4E5A13A12A0B00846B27 /* TextTrackCueList.h */, 13704 41815C1B138319630057AAA4 /* js */,13705 417DA4CF13734326007C57FB /* Internals.cpp */,13706 417DA4CE13734326007C57FB /* Internals.h */,13707 41813F9113818AD60057AAA4 /* Internals.idl */,13708 13712 ); 13709 13713 path = testing; … … 14316 14320 isa = PBXGroup; 14317 14321 children = ( 14318 CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */,14319 CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */,14320 CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */,14321 CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */,14322 CD8203081395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h */,14323 CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */,14324 14322 51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */, 14325 14323 65A640F00533BB1F0085E777 /* BlockExceptions.h */, … … 14386 14384 E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */, 14387 14385 E1A3162C134BC32D007C9A4F /* WebNSAttributedStringExtras.mm */, 14386 CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */, 14387 CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */, 14388 CD8203081395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h */, 14389 CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */, 14390 CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */, 14391 CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */, 14388 14392 935C477209AC4D7700A6AAB4 /* WheelEventMac.mm */, 14389 14393 9380F47709A11ACC001FDB34 /* WidgetMac.mm */, … … 16224 16228 A81369BA097374F500D74463 /* HTMLTextAreaElement.h */, 16225 16229 A80E7E160A1A7CCB007FB8C5 /* HTMLTextAreaElement.idl */, 16230 9BC6C21A13CCC97B008E0337 /* HTMLTextFormControlElement.cpp */, 16231 9BC6C21913CCC97B008E0337 /* HTMLTextFormControlElement.h */, 16226 16232 A871DC1D0A15205700B12A68 /* HTMLTitleElement.cpp */, 16227 16233 A871DC1C0A15205700B12A68 /* HTMLTitleElement.h */, … … 17453 17459 08B35B16127B6A88005314DD /* SVGAnimatedNumberList.h */, 17454 17460 B22277ED0D00BF1F0071B782 /* SVGAnimatedNumberList.idl */, 17461 431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */, 17455 17462 431A2F9A13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h */, 17456 431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */,17457 17463 0863951313B5FE5700BB344D /* SVGAnimatedPath.cpp */, 17458 17464 0863951413B5FE5700BB344D /* SVGAnimatedPath.h */, 17465 43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */, 17459 17466 43B9336713B261B1004584BF /* SVGAnimatedPointList.h */, 17460 43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */,17461 17467 431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */, 17462 17468 08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */, … … 18101 18107 087E0AF513606D0B00FA4BA8 /* SVGGlyph.h */, 18102 18108 930FC6891072B9280045293E /* TextRenderingMode.h */, 18109 376DCCE013B4F966002EBEFC /* TextRun.cpp */, 18103 18110 A824B4640E2EF2EA0081A7B7 /* TextRun.h */, 18104 376DCCE013B4F966002EBEFC /* TextRun.cpp */,18105 18111 37C28A6710F659CC008C7813 /* TypesettingFeatures.h */, 18106 18112 E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */, … … 18734 18740 089582530E857A7E00F82C83 /* ImageLoader.cpp */, 18735 18741 089582540E857A7E00F82C83 /* ImageLoader.h */, 18736 984264EF12D5280A000D88A4 /* LinkLoaderClient.h */,18737 18742 98CE4325129E00BD005821DC /* LinkLoader.cpp */, 18738 18743 98CE4329129E00E5005821DC /* LinkLoader.h */, 18744 984264EF12D5280A000D88A4 /* LinkLoaderClient.h */, 18739 18745 93E227DC0AF589AD00D48324 /* MainResourceLoader.cpp */, 18740 18746 656D37290ADBA5DE00A4554D /* MainResourceLoader.h */, … … 20184 20190 49EECDE310503C2400099FAB /* ArrayBuffer.h in Headers */, 20185 20191 49EECDE010503C2400099FAB /* ArrayBufferView.h in Headers */, 20192 FD5686CA13AC180200B69C68 /* AsyncAudioDecoder.h in Headers */, 20186 20193 2EF1BFF7121CB0BD00C27627 /* AsyncFileStream.h in Headers */, 20187 20194 89D08DA012228451001241DF /* AsyncFileSystem.h in Headers */, … … 20195 20202 FD315FF712B0267600C1A359 /* AudioBasicProcessorNode.h in Headers */, 20196 20203 FD315FF912B0267600C1A359 /* AudioBuffer.h in Headers */, 20204 FD5686CC13AC181400B69C68 /* AudioBufferCallback.h in Headers */, 20197 20205 FD315FFC12B0267600C1A359 /* AudioBufferSourceNode.h in Headers */, 20198 20206 FD31607C12B026F700C1A359 /* AudioBus.h in Headers */, … … 20428 20436 6565815109D13043000E61D7 /* CSSValueKeywords.h in Headers */, 20429 20437 A80E6CE90A1989CA007FB8C5 /* CSSValueList.h in Headers */, 20438 B1AD4E5D13A12A0B00846B27 /* CueIndex.h in Headers */, 20439 B1AD4E7413A12A4600846B27 /* CueLoader.h in Headers */, 20440 B1AD4E7C13A12A7200846B27 /* CueParser.h in Headers */, 20441 B1AD4E7D13A12A7200846B27 /* CueParserPrivate.h in Headers */, 20430 20442 93F1992F08245E59001E9ABC /* Cursor.h in Headers */, 20431 20443 BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */, … … 21406 21418 A871DB250A150BD600B12A68 /* HTMLTableSectionElement.h in Headers */, 21407 21419 A81369D6097374F600D74463 /* HTMLTextAreaElement.h in Headers */, 21420 9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */, 21408 21421 A871DC280A15205700B12A68 /* HTMLTitleElement.h in Headers */, 21409 21422 977B3878122883E900B81FF8 /* HTMLTokenizer.h in Headers */, … … 21509 21522 4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */, 21510 21523 82AB1774125C826700C5069D /* InspectorStyleSheet.h in Headers */, 21524 82889B4D13C62392009A6156 /* InspectorStyleTextEditor.h in Headers */, 21511 21525 754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */, 21512 21526 4F3289B611A42AAB005ABE7E /* InspectorValues.h in Headers */, … … 21547 21561 65DF31DB09D1C123000BE325 /* JSAttr.h in Headers */, 21548 21562 FDA15E9E12B03EE1003A583A /* JSAudioBuffer.h in Headers */, 21563 FDF7E9C413AC21DB00A51EAC /* JSAudioBufferCallback.h in Headers */, 21549 21564 FDA15EA012B03EE1003A583A /* JSAudioBufferSourceNode.h in Headers */, 21550 21565 FDA15EA212B03EE1003A583A /* JSAudioChannelMerger.h in Headers */, … … 22060 22075 85EC9AFB0A71A2C600EEEAED /* Language.h in Headers */, 22061 22076 2D9066070BE141D400956998 /* LayoutState.h in Headers */, 22077 BACF290113B2A0D500781F90 /* LayoutTypes.h in Headers */, 22062 22078 512DD8F50D91E6AF000F89EE /* LegacyWebArchive.h in Headers */, 22063 22079 BCE65BEB0EACDF16007E4533 /* Length.h in Headers */, … … 22072 22088 84730D911248F0B300D3A9C9 /* LightSource.h in Headers */, 22073 22089 B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */, 22090 A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */, 22074 22091 AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */, 22075 22092 89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */, … … 22077 22094 98CE432A129E00E5005821DC /* LinkLoader.h in Headers */, 22078 22095 984264F112D5280A000D88A4 /* LinkLoaderClient.h in Headers */, 22096 985BB96E13A94058007A0B69 /* LinkRelAttribute.h in Headers */, 22097 B1AD4E5F13A12A0B00846B27 /* LoadableTextTrack.h in Headers */, 22079 22098 656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */, 22080 22099 7EE6846912D26E3800E79415 /* LoaderRunLoopCF.h in Headers */, … … 22155 22174 93309DFC099E64920056E581 /* MoveSelectionCommand.h in Headers */, 22156 22175 B12D234213560282002A28D4 /* MultipleTrackList.h in Headers */, 22176 B1AD4E6313A12A0B00846B27 /* MutableTextTrack.h in Headers */, 22157 22177 85031B4A0A44EFC700F992E0 /* MutationEvent.h in Headers */, 22158 22178 A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */, … … 22534 22554 B2AFFC940D00A5DF0030074D /* ShapeArabic.h in Headers */, 22535 22555 1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */, 22556 97B1F02F13B025D200F5103F /* SharedBufferChunkReader.h in Headers */, 22536 22557 498770EB1242C535002226BA /* SharedGraphicsContext3D.h in Headers */, 22537 22558 93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */, … … 22624 22645 BC5EB67F0E81D4A700B25965 /* StyleDashboardRegion.h in Headers */, 22625 22646 A8C4A7FD09D563270003AC8D /* StyledElement.h in Headers */, 22647 BC5EB8B90E8201BD00B25965 /* StyleDeprecatedFlexibleBoxData.h in Headers */, 22626 22648 AA4C3A770B2B1679002334A2 /* StyleElement.h in Headers */, 22627 BC5EB8B90E8201BD00B25965 /* StyleDeprecatedFlexibleBoxData.h in Headers */,22628 22649 BCEF444A0E6745E0001C1287 /* StyleGeneratedImage.h in Headers */, 22629 22650 BCEF43CF0E673DA1001C1287 /* StyleImage.h in Headers */, … … 22649 22670 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */, 22650 22671 97C078501165D5BE003A32EF /* SuffixTree.h in Headers */, 22672 087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */, 22651 22673 62C1217D11AB9E77003C462C /* SuspendableTimer.h in Headers */, 22652 22674 B22279740D00BF220071B782 /* SVGAElement.h in Headers */, … … 22656 22678 087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */, 22657 22679 085797091278394C00A8EC5F /* SVGAnimatedBoolean.h in Headers */, 22680 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */, 22658 22681 08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */, 22659 22682 71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */, … … 22664 22687 08B35B13127B6A7C005314DD /* SVGAnimatedNumber.h in Headers */, 22665 22688 08B35B17127B6A88005314DD /* SVGAnimatedNumberList.h in Headers */, 22689 431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */, 22690 0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */, 22666 22691 089A8E07128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h in Headers */, 22692 43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */, 22667 22693 08FE0BC5127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h in Headers */, 22668 22694 088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */, … … 22683 22709 B22279980D00BF220071B782 /* SVGAnimationElement.h in Headers */, 22684 22710 439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */, 22711 08FB3F8413BC754C0099FC18 /* SVGAttributeToPropertyMap.h in Headers */, 22685 22712 B222799C0D00BF220071B782 /* SVGCircleElement.h in Headers */, 22686 22713 B222799F0D00BF220071B782 /* SVGClipPathElement.h in Headers */, … … 22807 22834 B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */, 22808 22835 088A0E0A126EF1DB00978F7A /* SVGProperty.h in Headers */, 22836 081DD49C13BA1A6000DC7627 /* SVGPropertyInfo.h in Headers */, 22809 22837 088A0E0B126EF1DB00978F7A /* SVGPropertyTearOff.h in Headers */, 22810 22838 088A0E0C126EF1DB00978F7A /* SVGPropertyTraits.h in Headers */, … … 22910 22938 A824B4650E2EF2EA0081A7B7 /* TextRun.h in Headers */, 22911 22939 B2C3DA4B0D006C1D00EF6F26 /* TextStream.h in Headers */, 22940 B1AD4E6713A12A0B00846B27 /* TextTrack.h in Headers */, 22941 B1AD4E6913A12A0B00846B27 /* TextTrackCue.h in Headers */, 22942 B1AD4E6B13A12A0B00846B27 /* TextTrackCueList.h in Headers */, 22912 22943 498770F11242C535002226BA /* Texture.h in Headers */, 22913 22944 97BC84A512370DC8000C6161 /* TextViewSourceParser.h in Headers */, … … 23093 23124 977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */, 23094 23125 FD537353137B651800008DCE /* ZeroPole.h in Headers */, 23095 985BB96E13A94058007A0B69 /* LinkRelAttribute.h in Headers */,23096 FD5686CA13AC180200B69C68 /* AsyncAudioDecoder.h in Headers */,23097 FD5686CC13AC181400B69C68 /* AudioBufferCallback.h in Headers */,23098 FDF7E9C413AC21DB00A51EAC /* JSAudioBufferCallback.h in Headers */,23099 B1AD4E5D13A12A0B00846B27 /* CueIndex.h in Headers */,23100 B1AD4E5F13A12A0B00846B27 /* LoadableTextTrack.h in Headers */,23101 B1AD4E6313A12A0B00846B27 /* MutableTextTrack.h in Headers */,23102 B1AD4E6713A12A0B00846B27 /* TextTrack.h in Headers */,23103 B1AD4E6913A12A0B00846B27 /* TextTrackCue.h in Headers */,23104 B1AD4E6B13A12A0B00846B27 /* TextTrackCueList.h in Headers */,23105 B1AD4E7413A12A4600846B27 /* CueLoader.h in Headers */,23106 B1AD4E7C13A12A7200846B27 /* CueParser.h in Headers */,23107 B1AD4E7D13A12A7200846B27 /* CueParserPrivate.h in Headers */,23108 97B1F02F13B025D200F5103F /* SharedBufferChunkReader.h in Headers */,23109 BACF290113B2A0D500781F90 /* LayoutTypes.h in Headers */,23110 43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */,23111 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */,23112 087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */,23113 0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */,23114 431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */,23115 A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */,23116 081DD49C13BA1A6000DC7627 /* SVGPropertyInfo.h in Headers */,23117 08FB3F8413BC754C0099FC18 /* SVGAttributeToPropertyMap.h in Headers */,23118 82889B4D13C62392009A6156 /* InspectorStyleTextEditor.h in Headers */,23119 23126 ); 23120 23127 runOnlyForDeploymentPostprocessing = 0; … … 23478 23485 49EECDE210503C2400099FAB /* ArrayBuffer.cpp in Sources */, 23479 23486 49EECDDF10503C2400099FAB /* ArrayBufferView.cpp in Sources */, 23487 FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */, 23480 23488 89D08D9F12228451001241DF /* AsyncFileSystem.cpp in Sources */, 23481 23489 A8C4A80E09D563270003AC8D /* Attr.cpp in Sources */, … … 23673 23681 1ABA76CB11D20E57004C201C /* CSSValueKeywords.cpp in Sources */, 23674 23682 A80E6CE40A1989CA007FB8C5 /* CSSValueList.cpp in Sources */, 23683 B1AD4E5C13A12A0B00846B27 /* CueIndex.cpp in Sources */, 23684 B1AD4E7313A12A4600846B27 /* CueLoader.cpp in Sources */, 23685 B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */, 23675 23686 E11AF15111B9A1A300805103 /* Cursor.cpp in Sources */, 23676 23687 93F19A2608245E59001E9ABC /* CursorMac.mm in Sources */, … … 24306 24317 A871DB260A150BD600B12A68 /* HTMLTableSectionElement.cpp in Sources */, 24307 24318 A81369D7097374F600D74463 /* HTMLTextAreaElement.cpp in Sources */, 24319 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */, 24308 24320 A871DC290A15205700B12A68 /* HTMLTitleElement.cpp in Sources */, 24309 24321 977B3877122883E900B81FF8 /* HTMLTokenizer.cpp in Sources */, … … 24343 24355 1A71D57B0F33819000F9CE4E /* IdentifierRep.cpp in Sources */, 24344 24356 B275356F0B053814002CE64F /* Image.cpp in Sources */, 24357 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */, 24345 24358 B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */, 24346 24359 2292B27C1356669400CF11EF /* ImageBufferDataCG.cpp in Sources */, … … 24393 24406 4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */, 24394 24407 82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */, 24408 82889B4C13C62392009A6156 /* InspectorStyleTextEditor.cpp in Sources */, 24395 24409 754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */, 24396 24410 4F3289B511A42AAB005ABE7E /* InspectorValues.cpp in Sources */, … … 24427 24441 BC2ED6BC0C6BD2F000920BFF /* JSAttrCustom.cpp in Sources */, 24428 24442 FDA15E9D12B03EE1003A583A /* JSAudioBuffer.cpp in Sources */, 24443 FDF7E9C313AC21DB00A51EAC /* JSAudioBufferCallback.cpp in Sources */, 24429 24444 FDA15E9F12B03EE1003A583A /* JSAudioBufferSourceNode.cpp in Sources */, 24430 24445 FDEAAAF312B02EE400DCF33B /* JSAudioBufferSourceNodeCustom.cpp in Sources */, … … 25067 25082 A7AD2F870EC89D07008AB002 /* LinkHash.cpp in Sources */, 25068 25083 98CE4326129E00BD005821DC /* LinkLoader.cpp in Sources */, 25084 985BB96D13A94058007A0B69 /* LinkRelAttribute.cpp in Sources */, 25085 B1AD4E5E13A12A0B00846B27 /* LoadableTextTrack.cpp in Sources */, 25069 25086 656D37330ADBA5DE00A4554D /* LoaderNSURLExtras.mm in Sources */, 25070 25087 7EE6846812D26E3800E79415 /* LoaderRunLoopCF.cpp in Sources */, … … 25139 25156 93309DFB099E64920056E581 /* MoveSelectionCommand.cpp in Sources */, 25140 25157 B12D234113560282002A28D4 /* MultipleTrackList.cpp in Sources */, 25158 B1AD4E6213A12A0B00846B27 /* MutableTextTrack.cpp in Sources */, 25141 25159 85031B490A44EFC700F992E0 /* MutationEvent.cpp in Sources */, 25142 25160 BCF34A3711A231CD00C71804 /* NamedNodeMap.cpp in Sources */, … … 25431 25449 1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */, 25432 25450 512DD8E30D91E2B4000F89EE /* SharedBufferCF.cpp in Sources */, 25451 97B1F02E13B025CA00F5103F /* SharedBufferChunkReader.cpp in Sources */, 25433 25452 1A4A95520B4EDCFF002D8C3C /* SharedBufferMac.mm in Sources */, 25434 25453 498770EA1242C535002226BA /* SharedGraphicsContext3D.cpp in Sources */, … … 25511 25530 BCEF447A0E6747D0001C1287 /* StyleCachedImage.cpp in Sources */, 25512 25531 A8C4A7FE09D563270003AC8D /* StyledElement.cpp in Sources */, 25532 BC5EB8B80E8201BD00B25965 /* StyleDeprecatedFlexibleBoxData.cpp in Sources */, 25513 25533 AA4C3A760B2B1679002334A2 /* StyleElement.cpp in Sources */, 25514 BC5EB8B80E8201BD00B25965 /* StyleDeprecatedFlexibleBoxData.cpp in Sources */,25515 25534 BCEF447D0E674806001C1287 /* StyleGeneratedImage.cpp in Sources */, 25516 25535 BC2273030E82F1E600E7F975 /* StyleInheritedData.cpp in Sources */, … … 25531 25550 7E37EF2E1339208800B29250 /* SubresourceLoaderCF.cpp in Sources */, 25532 25551 93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */, 25552 087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */, 25533 25553 62C1217C11AB9E77003C462C /* SuspendableTimer.cpp in Sources */, 25534 25554 B22279730D00BF220071B782 /* SVGAElement.cpp in Sources */, … … 25536 25556 B22279760D00BF220071B782 /* SVGAngle.cpp in Sources */, 25537 25557 B22279790D00BF220071B782 /* SVGAnimateColorElement.cpp in Sources */, 25558 4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */, 25559 431A308813B8F978007791E4 /* SVGAnimatedBoolean.cpp in Sources */, 25560 43A625F913B3304000AC94B8 /* SVGAnimatedColor.cpp in Sources */, 25561 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */, 25538 25562 4381763B13A697D4007D1187 /* SVGAnimatedLength.cpp in Sources */, 25563 431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */, 25564 43A0F0B113AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp in Sources */, 25565 4331AC7813B6870000A9E5AE /* SVGAnimatedNumberList.cpp in Sources */, 25566 431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */, 25567 08B5F25513B5FFF2002959EC /* SVGAnimatedPath.cpp in Sources */, 25568 43B9336A13B261B1004584BF /* SVGAnimatedPointList.cpp in Sources */, 25569 431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */, 25570 43142E7A13B1E97700F1C871 /* SVGAnimatedRect.cpp in Sources */, 25571 43A6266713B3D11000AC94B8 /* SVGAnimatedString.cpp in Sources */, 25572 43A0F0B613ACCCFF00A5F0A7 /* SVGAnimatedType.cpp in Sources */, 25539 25573 B222798F0D00BF220071B782 /* SVGAnimateElement.cpp in Sources */, 25540 25574 B22279920D00BF220071B782 /* SVGAnimateMotionElement.cpp in Sources */, 25541 25575 B22279940D00BF220071B782 /* SVGAnimateTransformElement.cpp in Sources */, 25542 25576 B22279970D00BF220071B782 /* SVGAnimationElement.cpp in Sources */, 25577 08FB17C113BC7E9100040086 /* SVGAttributeToPropertyMap.cpp in Sources */, 25543 25578 B222799B0D00BF220071B782 /* SVGCircleElement.cpp in Sources */, 25544 25579 B222799E0D00BF220071B782 /* SVGClipPathElement.cpp in Sources */, … … 25706 25741 93309E1B099E64920056E581 /* TextIterator.cpp in Sources */, 25707 25742 93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */, 25743 376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */, 25708 25744 B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */, 25745 B1AD4E6613A12A0B00846B27 /* TextTrack.cpp in Sources */, 25746 B1AD4E6813A12A0B00846B27 /* TextTrackCue.cpp in Sources */, 25747 B1AD4E6A13A12A0B00846B27 /* TextTrackCueList.cpp in Sources */, 25709 25748 498770F01242C535002226BA /* Texture.cpp in Sources */, 25710 25749 97BC84A412370DC8000C6161 /* TextViewSourceParser.cpp in Sources */, … … 25857 25896 977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */, 25858 25897 FD537352137B651800008DCE /* ZeroPole.cpp in Sources */, 25859 985BB96D13A94058007A0B69 /* LinkRelAttribute.cpp in Sources */,25860 FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */,25861 FDF7E9C313AC21DB00A51EAC /* JSAudioBufferCallback.cpp in Sources */,25862 B1AD4E5C13A12A0B00846B27 /* CueIndex.cpp in Sources */,25863 B1AD4E5E13A12A0B00846B27 /* LoadableTextTrack.cpp in Sources */,25864 B1AD4E6213A12A0B00846B27 /* MutableTextTrack.cpp in Sources */,25865 B1AD4E6613A12A0B00846B27 /* TextTrack.cpp in Sources */,25866 B1AD4E6813A12A0B00846B27 /* TextTrackCue.cpp in Sources */,25867 B1AD4E6A13A12A0B00846B27 /* TextTrackCueList.cpp in Sources */,25868 B1AD4E7313A12A4600846B27 /* CueLoader.cpp in Sources */,25869 B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */,25870 4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */,25871 43A0F0B113AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp in Sources */,25872 43A0F0B613ACCCFF00A5F0A7 /* SVGAnimatedType.cpp in Sources */,25873 97B1F02E13B025CA00F5103F /* SharedBufferChunkReader.cpp in Sources */,25874 43142E7A13B1E97700F1C871 /* SVGAnimatedRect.cpp in Sources */,25875 43B9336A13B261B1004584BF /* SVGAnimatedPointList.cpp in Sources */,25876 43A625F913B3304000AC94B8 /* SVGAnimatedColor.cpp in Sources */,25877 43A6266713B3D11000AC94B8 /* SVGAnimatedString.cpp in Sources */,25878 087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,25879 08B5F25513B5FFF2002959EC /* SVGAnimatedPath.cpp in Sources */,25880 376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,25881 4331AC7813B6870000A9E5AE /* SVGAnimatedNumberList.cpp in Sources */,25882 431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */,25883 431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */,25884 431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */,25885 431A308813B8F978007791E4 /* SVGAnimatedBoolean.cpp in Sources */,25886 08FB17C113BC7E9100040086 /* SVGAttributeToPropertyMap.cpp in Sources */,25887 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */,25888 82889B4C13C62392009A6156 /* InspectorStyleTextEditor.cpp in Sources */,25889 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */,25890 25898 ); 25891 25899 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/editing/TextIterator.cpp
r90775 r90849 31 31 #include "Frame.h" 32 32 #include "HTMLElement.h" 33 #include "HTML FormControlElement.h"33 #include "HTMLTextFormControlElement.h" 34 34 #include "HTMLNames.h" 35 35 #include "htmlediting.h" -
trunk/Source/WebCore/editing/htmlediting.cpp
r90098 r90849 32 32 #include "HTMLDivElement.h" 33 33 #include "HTMLElementFactory.h" 34 #include "HTML FormControlElement.h"34 #include "HTMLTextFormControlElement.h" 35 35 #include "HTMLInterchange.h" 36 36 #include "HTMLLIElement.h" -
trunk/Source/WebCore/html/HTMLElementsAllInOne.cpp
r84991 r90849 103 103 #include "HTMLTableSectionElement.cpp" 104 104 #include "HTMLTextAreaElement.cpp" 105 #include "HTMLTextFormControlElement.cpp" 105 106 #include "HTMLTitleElement.cpp" 106 107 #include "HTMLUListElement.cpp" -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r90775 r90849 27 27 28 28 #include "Attribute.h" 29 #include "Chrome.h"30 #include "ChromeClient.h"31 29 #include "Document.h" 32 #include "DocumentParser.h"33 30 #include "ElementRareData.h" 34 31 #include "Event.h" … … 40 37 #include "HTMLNames.h" 41 38 #include "LabelsNodeList.h" 42 #include "Page.h"43 39 #include "RenderBox.h" 44 #include "RenderTextControl.h"45 40 #include "RenderTheme.h" 46 41 #include "ScriptEventListener.h" 47 42 #include "ValidationMessage.h" 48 43 #include "ValidityState.h" 49 #include <limits>50 44 #include <wtf/Vector.h> 51 #include <wtf/unicode/CharacterNames.h>52 45 53 46 namespace WebCore { … … 283 276 bool HTMLFormControlElement::isFocusable() const 284 277 { 285 if (!renderer() || 286 !renderer()->isBox() || toRenderBox(renderer())->size().isEmpty()) 278 if (!renderer() || !renderer()->isBox() || toRenderBox(renderer())->size().isEmpty()) 287 279 return false; 288 280 // HTMLElement::isFocusable handles visibility and calls suportsFocus which … … 553 545 } 554 546 555 void HTMLFormControlElementWithState::defaultEventHandler(Event* event)556 {557 if (event->type() == eventNames().webkitEditableContentChangedEvent && renderer() && renderer()->isTextControl()) {558 toRenderTextControl(renderer())->subtreeHasChanged();559 return;560 }561 562 HTMLFormControlElement::defaultEventHandler(event);563 }564 565 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form)566 : HTMLFormControlElementWithState(tagName, doc, form)567 , m_cachedSelectionStart(-1)568 , m_cachedSelectionEnd(-1)569 {570 }571 572 HTMLTextFormControlElement::~HTMLTextFormControlElement()573 {574 }575 576 void HTMLTextFormControlElement::insertedIntoDocument()577 {578 HTMLFormControlElement::insertedIntoDocument();579 String initialValue = value();580 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue);581 }582 583 void HTMLTextFormControlElement::dispatchFocusEvent()584 {585 if (supportsPlaceholder())586 updatePlaceholderVisibility(false);587 handleFocusEvent();588 HTMLFormControlElementWithState::dispatchFocusEvent();589 }590 591 void HTMLTextFormControlElement::dispatchBlurEvent()592 {593 if (supportsPlaceholder())594 updatePlaceholderVisibility(false);595 handleBlurEvent();596 HTMLFormControlElementWithState::dispatchBlurEvent();597 }598 599 String HTMLTextFormControlElement::strippedPlaceholder() const600 {601 // According to the HTML5 specification, we need to remove CR and LF from602 // the attribute value.603 const AtomicString& attributeValue = getAttribute(placeholderAttr);604 if (!attributeValue.contains(newlineCharacter) && !attributeValue.contains(carriageReturn))605 return attributeValue;606 607 Vector<UChar> stripped;608 unsigned length = attributeValue.length();609 stripped.reserveCapacity(length);610 for (unsigned i = 0; i < length; ++i) {611 UChar character = attributeValue[i];612 if (character == newlineCharacter || character == carriageReturn)613 continue;614 stripped.append(character);615 }616 return String::adopt(stripped);617 }618 619 static bool isNotLineBreak(UChar ch) { return ch != newlineCharacter && ch != carriageReturn; }620 621 bool HTMLTextFormControlElement::isPlaceholderEmpty() const622 {623 const AtomicString& attributeValue = getAttribute(placeholderAttr);624 return attributeValue.string().find(isNotLineBreak) == notFound;625 }626 627 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const628 {629 return supportsPlaceholder()630 && isEmptyValue()631 && isEmptySuggestedValue()632 && !isPlaceholderEmpty()633 && (document()->focusedNode() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()));634 }635 636 void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)637 {638 if (supportsPlaceholder() && renderer())639 toRenderTextControl(renderer())->updatePlaceholderVisibility(placeholderShouldBeVisible(), placeholderValueChanged);640 }641 642 RenderTextControl* HTMLTextFormControlElement::textRendererAfterUpdateLayout()643 {644 if (!isTextFormControl())645 return 0;646 document()->updateLayoutIgnorePendingStylesheets();647 return toRenderTextControl(renderer());648 }649 650 void HTMLTextFormControlElement::setSelectionStart(int start)651 {652 setSelectionRange(start, max(start, selectionEnd()));653 }654 655 void HTMLTextFormControlElement::setSelectionEnd(int end)656 {657 setSelectionRange(min(end, selectionStart()), end);658 }659 660 void HTMLTextFormControlElement::select()661 {662 setSelectionRange(0, numeric_limits<int>::max());663 }664 665 String HTMLTextFormControlElement::selectedText() const666 {667 // FIXME: We should be able to extract selected contents even if there were no renderer.668 if (!renderer() || renderer()->isTextControl())669 return String();670 671 RenderTextControl* textControl = toRenderTextControl(renderer());672 return textControl->text().substring(selectionStart(), selectionEnd() - selectionStart());673 }674 675 void HTMLTextFormControlElement::dispatchFormControlChangeEvent()676 {677 if (m_textAsOfLastFormControlChangeEvent != value()) {678 HTMLElement::dispatchChangeEvent();679 setTextAsOfLastFormControlChangeEvent(value());680 }681 setChangedSinceLastFormControlChangeEvent(false);682 }683 684 static inline bool hasVisibleTextArea(RenderTextControl* textControl, HTMLElement* innerText)685 {686 ASSERT(textControl);687 return textControl->style()->visibility() != HIDDEN && innerText && innerText->renderer() && innerText->renderBox()->height();688 }689 690 void HTMLTextFormControlElement::setSelectionRange(int start, int end)691 {692 document()->updateLayoutIgnorePendingStylesheets();693 694 if (!renderer() || !renderer()->isTextControl())695 return;696 697 end = max(end, 0);698 start = min(max(start, 0), end);699 700 RenderTextControl* control = toRenderTextControl(renderer());701 if (!hasVisibleTextArea(control, innerTextElement())) {702 cacheSelection(start, end);703 return;704 }705 VisiblePosition startPosition = control->visiblePositionForIndex(start);706 VisiblePosition endPosition;707 if (start == end)708 endPosition = startPosition;709 else710 endPosition = control->visiblePositionForIndex(end);711 712 // startPosition and endPosition can be null position for example when713 // "-webkit-user-select: none" style attribute is specified.714 if (startPosition.isNotNull() && endPosition.isNotNull()) {715 ASSERT(startPosition.deepEquivalent().deprecatedNode()->shadowAncestorNode() == this716 && endPosition.deepEquivalent().deprecatedNode()->shadowAncestorNode() == this);717 }718 VisibleSelection newSelection = VisibleSelection(startPosition, endPosition);719 720 if (Frame* frame = document()->frame())721 frame->selection()->setSelection(newSelection);722 }723 724 int HTMLTextFormControlElement::selectionStart() const725 {726 if (!isTextFormControl())727 return 0;728 if (document()->focusedNode() != this && hasCachedSelectionStart())729 return m_cachedSelectionStart;730 731 return computeSelectionStart();732 }733 734 int HTMLTextFormControlElement::computeSelectionStart() const735 {736 Frame* frame = document()->frame();737 if (!frame)738 return 0;739 740 return RenderTextControl::indexForVisiblePosition(innerTextElement(), frame->selection()->start());741 }742 743 int HTMLTextFormControlElement::selectionEnd() const744 {745 if (!isTextFormControl())746 return 0;747 if (document()->focusedNode() != this && hasCachedSelectionEnd())748 return m_cachedSelectionEnd;749 return computeSelectionEnd();750 }751 752 int HTMLTextFormControlElement::computeSelectionEnd() const753 {754 Frame* frame = document()->frame();755 if (!frame)756 return 0;757 758 return RenderTextControl::indexForVisiblePosition(innerTextElement(), frame->selection()->end());759 }760 761 static inline void setContainerAndOffsetForRange(Node* node, int offset, Node*& containerNode, int& offsetInContainer)762 {763 if (node->isTextNode()) {764 containerNode = node;765 offsetInContainer = offset;766 } else {767 containerNode = node->parentNode();768 offsetInContainer = node->nodeIndex() + offset;769 }770 }771 772 PassRefPtr<Range> HTMLTextFormControlElement::selection() const773 {774 if (!renderer() || !isTextFormControl() || !hasCachedSelectionStart() || !hasCachedSelectionEnd())775 return 0;776 777 int start = m_cachedSelectionStart;778 int end = m_cachedSelectionEnd;779 780 ASSERT(start <= end);781 HTMLElement* innerText = innerTextElement();782 if (!innerText)783 return 0;784 785 if (!innerText->firstChild())786 return Range::create(document(), innerText, 0, innerText, 0);787 788 int offset = 0;789 Node* startNode = 0;790 Node* endNode = 0;791 for (Node* node = innerText->firstChild(); node; node = node->traverseNextNode(innerText)) {792 ASSERT(!node->firstChild());793 ASSERT(node->isTextNode() || node->hasTagName(brTag));794 int length = node->isTextNode() ? lastOffsetInNode(node) : 1;795 796 if (offset <= start && start <= offset + length)797 setContainerAndOffsetForRange(node, start - offset, startNode, start);798 799 if (offset <= end && end <= offset + length) {800 setContainerAndOffsetForRange(node, end - offset, endNode, end);801 break;802 }803 804 offset += length;805 }806 807 if (!startNode || !endNode)808 return 0;809 810 return Range::create(document(), startNode, start, endNode, end);811 }812 813 void HTMLTextFormControlElement::restoreCachedSelection()814 {815 setSelectionRange(m_cachedSelectionStart, m_cachedSelectionEnd);816 }817 818 void HTMLTextFormControlElement::selectionChanged(bool userTriggered)819 {820 if (!renderer() || !isTextFormControl())821 return;822 823 // selectionStart() or selectionEnd() will return cached selection when this node doesn't have focus824 cacheSelection(computeSelectionStart(), computeSelectionEnd());825 826 if (Frame* frame = document()->frame()) {827 if (frame->selection()->isRange() && userTriggered)828 dispatchEvent(Event::create(eventNames().selectEvent, true, false));829 }830 }831 832 void HTMLTextFormControlElement::parseMappedAttribute(Attribute* attr)833 {834 if (attr->name() == placeholderAttr)835 updatePlaceholderVisibility(true);836 else if (attr->name() == onselectAttr)837 setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr));838 else if (attr->name() == onchangeAttr)839 setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr));840 else841 HTMLFormControlElementWithState::parseMappedAttribute(attr);842 }843 844 547 } // namespace Webcore -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r90775 r90849 32 32 class FormDataList; 33 33 class HTMLFormElement; 34 class RenderTextControl;35 34 class ValidationMessage; 36 35 class ValidityState; 37 class VisibleSelection;38 36 39 37 // HTMLFormControlElement is the default implementation of FormAssociatedElement, … … 180 178 virtual void willMoveToNewOwnerDocument(); 181 179 virtual void didMoveToNewOwnerDocument(); 182 virtual void defaultEventHandler(Event*);183 180 184 181 private: … … 186 183 }; 187 184 188 // FIXME: Give this class its own header file.189 class HTMLTextFormControlElement : public HTMLFormControlElementWithState {190 public:191 // Common flag for HTMLInputElement::tooLong() and HTMLTextAreaElement::tooLong().192 enum NeedsToCheckDirtyFlag {CheckDirtyFlag, IgnoreDirtyFlag};193 194 virtual ~HTMLTextFormControlElement();195 196 virtual void insertedIntoDocument();197 198 // The derived class should return true if placeholder processing is needed.199 virtual bool supportsPlaceholder() const = 0;200 String strippedPlaceholder() const;201 bool placeholderShouldBeVisible() const;202 203 int selectionStart() const;204 int selectionEnd() const;205 void setSelectionStart(int);206 void setSelectionEnd(int);207 void select();208 void setSelectionRange(int start, int end);209 PassRefPtr<Range> selection() const;210 String selectedText() const;211 212 virtual void dispatchFormControlChangeEvent();213 214 virtual int maxLength() const = 0;215 virtual String value() const = 0;216 217 virtual HTMLElement* innerTextElement() const = 0;218 219 void cacheSelection(int start, int end)220 {221 m_cachedSelectionStart = start;222 m_cachedSelectionEnd = end;223 }224 225 void selectionChanged(bool userTriggered);226 227 protected:228 HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);229 230 void updatePlaceholderVisibility(bool);231 232 virtual void parseMappedAttribute(Attribute*);233 234 void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }235 236 void restoreCachedSelection();237 bool hasCachedSelectionStart() const { return m_cachedSelectionStart >= 0; }238 bool hasCachedSelectionEnd() const { return m_cachedSelectionEnd >= 0; }239 240 private:241 int computeSelectionStart() const;242 int computeSelectionEnd() const;243 244 virtual void dispatchFocusEvent();245 virtual void dispatchBlurEvent();246 247 bool isPlaceholderEmpty() const;248 249 // Returns true if user-editable value is empty. Used to check placeholder visibility.250 virtual bool isEmptyValue() const = 0;251 // Returns true if suggested value is empty. Used to check placeholder visibility.252 virtual bool isEmptySuggestedValue() const { return true; }253 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().254 virtual void handleFocusEvent() { }255 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().256 virtual void handleBlurEvent() { }257 258 RenderTextControl* textRendererAfterUpdateLayout();259 260 String m_textAsOfLastFormControlChangeEvent;261 262 int m_cachedSelectionStart;263 int m_cachedSelectionEnd;264 };265 266 // This function returns 0 when node is an input element and not a text field.267 inline HTMLTextFormControlElement* toTextFormControl(Node* node)268 {269 return (node && node->isElementNode() && static_cast<Element*>(node)->isTextFormControl()) ? static_cast<HTMLTextFormControlElement*>(node) : 0;270 }271 272 185 } // namespace 273 186 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r90809 r90849 457 457 { 458 458 if (isTextField()) 459 return HTML FormControlElementWithState::isFocusable();460 return HTML FormControlElementWithState::isKeyboardFocusable(event) && m_inputType->isKeyboardFocusable();459 return HTMLTextFormControlElement::isFocusable(); 460 return HTMLTextFormControlElement::isKeyboardFocusable(event) && m_inputType->isKeyboardFocusable(); 461 461 } 462 462 … … 464 464 { 465 465 if (isTextField()) 466 return HTML FormControlElementWithState::isFocusable();467 return HTML FormControlElementWithState::isMouseFocusable();466 return HTMLTextFormControlElement::isFocusable(); 467 return HTMLTextFormControlElement::isMouseFocusable(); 468 468 } 469 469 … … 478 478 document()->frame()->selection()->revealSelection(); 479 479 } else 480 HTML FormControlElementWithState::updateFocusAppearance(restorePreviousSelection);480 HTMLTextFormControlElement::updateFocusAppearance(restorePreviousSelection); 481 481 } 482 482 … … 630 630 if (!isTextField()) 631 631 return false; 632 return HTML FormControlElementWithState::canStartSelection();632 return HTMLTextFormControlElement::canStartSelection(); 633 633 } 634 634 … … 667 667 m_name = attr->value(); 668 668 checkedRadioButtons().addButton(this); 669 HTML FormControlElementWithState::parseMappedAttribute(attr);669 HTMLTextFormControlElement::parseMappedAttribute(attr); 670 670 } else if (attr->name() == autocompleteAttr) { 671 671 if (equalIgnoringCase(attr->value(), "off")) { … … 778 778 { 779 779 m_parsingInProgress = false; 780 HTML FormControlElementWithState::finishParsingChildren();780 HTMLTextFormControlElement::finishParsingChildren(); 781 781 if (!m_stateRestored) { 782 782 bool checked = hasAttribute(checkedAttr); … … 789 789 bool HTMLInputElement::rendererIsNeeded(const NodeRenderingContext& context) 790 790 { 791 return m_inputType->rendererIsNeeded() && HTML FormControlElementWithState::rendererIsNeeded(context);791 return m_inputType->rendererIsNeeded() && HTMLTextFormControlElement::rendererIsNeeded(context); 792 792 } 793 793 … … 804 804 updateType(); 805 805 806 HTML FormControlElementWithState::attach();806 HTMLTextFormControlElement::attach(); 807 807 808 808 m_inputType->attach(); … … 816 816 void HTMLInputElement::detach() 817 817 { 818 HTML FormControlElementWithState::detach();818 HTMLTextFormControlElement::detach(); 819 819 setFormControlValueMatchesRenderer(false); 820 820 } … … 937 937 m_isIndeterminate = sourceElement->m_isIndeterminate; 938 938 939 HTML FormControlElementWithState::copyNonAttributeProperties(source);939 HTMLTextFormControlElement::copyNonAttributeProperties(source); 940 940 } 941 941 … … 1151 1151 bool callBaseClassEarly = isTextField() && (evt->type() == eventNames().keydownEvent || evt->type() == eventNames().keypressEvent); 1152 1152 if (callBaseClassEarly) { 1153 HTML FormControlElementWithState::defaultEventHandler(evt);1153 HTMLTextFormControlElement::defaultEventHandler(evt); 1154 1154 if (evt->defaultHandled()) 1155 1155 return; … … 1217 1217 1218 1218 if (!callBaseClassEarly && !evt->defaultHandled()) 1219 HTML FormControlElementWithState::defaultEventHandler(evt);1219 HTMLTextFormControlElement::defaultEventHandler(evt); 1220 1220 } 1221 1221 … … 1390 1390 document()->checkedRadioButtons().removeButton(this); 1391 1391 1392 HTML FormControlElementWithState::willMoveToNewOwnerDocument();1392 HTMLTextFormControlElement::willMoveToNewOwnerDocument(); 1393 1393 } 1394 1394 … … 1397 1397 registerForActivationCallbackIfNeeded(); 1398 1398 1399 HTML FormControlElementWithState::didMoveToNewOwnerDocument();1399 HTMLTextFormControlElement::didMoveToNewOwnerDocument(); 1400 1400 } 1401 1401 1402 1402 void HTMLInputElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 1403 1403 { 1404 HTML FormControlElementWithState::addSubresourceAttributeURLs(urls);1404 HTMLTextFormControlElement::addSubresourceAttributeURLs(urls); 1405 1405 1406 1406 addSubresourceURL(urls, src()); … … 1409 1409 bool HTMLInputElement::recalcWillValidate() const 1410 1410 { 1411 return m_inputType->supportsValidation() && HTML FormControlElementWithState::recalcWillValidate();1411 return m_inputType->supportsValidation() && HTMLTextFormControlElement::recalcWillValidate(); 1412 1412 } 1413 1413 -
trunk/Source/WebCore/html/HTMLInputElement.h
r90591 r90849 25 25 #define HTMLInputElement_h 26 26 27 #include "HTML FormControlElement.h"27 #include "HTMLTextFormControlElement.h" 28 28 29 29 namespace WebCore { -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r90775 r90849 240 240 handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event)); 241 241 242 HTML FormControlElementWithState::defaultEventHandler(event);242 HTMLTextFormControlElement::defaultEventHandler(event); 243 243 } 244 244 -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r90775 r90849 25 25 #define HTMLTextAreaElement_h 26 26 27 #include "HTML FormControlElement.h"27 #include "HTMLTextFormControlElement.h" 28 28 29 29 namespace WebCore { -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r90802 r90849 24 24 25 25 #include "config.h" 26 #include "HTML FormControlElement.h"26 #include "HTMLTextFormControlElement.h" 27 27 28 28 #include "Attribute.h" 29 #include "Chrome.h"30 #include "ChromeClient.h"31 29 #include "Document.h" 32 #include "DocumentParser.h"33 #include "ElementRareData.h"34 30 #include "Event.h" 35 #include "EventHandler.h"36 31 #include "EventNames.h" 37 32 #include "Frame.h" … … 39 34 #include "HTMLInputElement.h" 40 35 #include "HTMLNames.h" 41 #include "LabelsNodeList.h"42 #include "Page.h"43 36 #include "RenderBox.h" 44 37 #include "RenderTextControl.h" 45 38 #include "RenderTheme.h" 46 39 #include "ScriptEventListener.h" 47 #include "ValidationMessage.h"48 #include "ValidityState.h"49 #include <limits>50 40 #include <wtf/Vector.h> 51 #include <wtf/unicode/CharacterNames.h>52 41 53 42 namespace WebCore { … … 55 44 using namespace HTMLNames; 56 45 using namespace std; 57 58 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)59 : HTMLElement(tagName, document)60 , FormAssociatedElement(form)61 , m_disabled(false)62 , m_readOnly(false)63 , m_required(false)64 , m_valueMatchesRenderer(false)65 , m_willValidateInitialized(false)66 , m_willValidate(true)67 , m_isValid(true)68 , m_wasChangedSinceLastFormControlChangeEvent(false)69 {70 if (!this->form())71 setForm(findFormAncestor());72 if (this->form())73 this->form()->registerFormElement(this);74 }75 76 HTMLFormControlElement::~HTMLFormControlElement()77 {78 if (form())79 form()->removeFormElement(this);80 }81 82 void HTMLFormControlElement::detach()83 {84 m_validationMessage = nullptr;85 HTMLElement::detach();86 }87 88 bool HTMLFormControlElement::formNoValidate() const89 {90 return fastHasAttribute(formnovalidateAttr);91 }92 93 void HTMLFormControlElement::parseMappedAttribute(Attribute* attr)94 {95 if (attr->name() == disabledAttr) {96 bool oldDisabled = m_disabled;97 m_disabled = !attr->isNull();98 if (oldDisabled != m_disabled) {99 setNeedsStyleRecalc();100 if (renderer() && renderer()->style()->hasAppearance())101 renderer()->theme()->stateChanged(renderer(), EnabledState);102 }103 } else if (attr->name() == readonlyAttr) {104 bool oldReadOnly = m_readOnly;105 m_readOnly = !attr->isNull();106 if (oldReadOnly != m_readOnly) {107 setNeedsStyleRecalc();108 if (renderer() && renderer()->style()->hasAppearance())109 renderer()->theme()->stateChanged(renderer(), ReadOnlyState);110 }111 } else if (attr->name() == requiredAttr) {112 bool oldRequired = m_required;113 m_required = !attr->isNull();114 if (oldRequired != m_required) {115 setNeedsValidityCheck();116 setNeedsStyleRecalc(); // Updates for :required :optional classes.117 }118 } else119 HTMLElement::parseMappedAttribute(attr);120 setNeedsWillValidateCheck();121 }122 123 static bool shouldAutofocus(HTMLFormControlElement* element)124 {125 if (!element->autofocus())126 return false;127 if (!element->renderer())128 return false;129 if (element->document()->ignoreAutofocus())130 return false;131 if (element->isReadOnlyFormControl())132 return false;133 134 // FIXME: Should this set of hasTagName checks be replaced by a135 // virtual member function?136 if (element->hasTagName(inputTag))137 return !static_cast<HTMLInputElement*>(element)->isInputTypeHidden();138 if (element->hasTagName(selectTag))139 return true;140 if (element->hasTagName(keygenTag))141 return true;142 if (element->hasTagName(buttonTag))143 return true;144 if (element->hasTagName(textareaTag))145 return true;146 147 return false;148 }149 150 static void focusPostAttach(Node* element, unsigned)151 {152 static_cast<Element*>(element)->focus();153 element->deref();154 }155 156 void HTMLFormControlElement::attach()157 {158 ASSERT(!attached());159 160 suspendPostAttachCallbacks();161 162 HTMLElement::attach();163 164 // The call to updateFromElement() needs to go after the call through165 // to the base class's attach() because that can sometimes do a close166 // on the renderer.167 if (renderer())168 renderer()->updateFromElement();169 170 if (shouldAutofocus(this)) {171 ref();172 queuePostAttachCallback(focusPostAttach, this);173 }174 175 resumePostAttachCallbacks();176 }177 178 void HTMLFormControlElement::willMoveToNewOwnerDocument()179 {180 FormAssociatedElement::willMoveToNewOwnerDocument();181 HTMLElement::willMoveToNewOwnerDocument();182 }183 184 void HTMLFormControlElement::insertedIntoTree(bool deep)185 {186 FormAssociatedElement::insertedIntoTree();187 if (!form())188 document()->checkedRadioButtons().addButton(this);189 190 HTMLElement::insertedIntoTree(deep);191 }192 193 void HTMLFormControlElement::removedFromTree(bool deep)194 {195 FormAssociatedElement::removedFromTree();196 HTMLElement::removedFromTree(deep);197 }198 199 void HTMLFormControlElement::insertedIntoDocument()200 {201 HTMLElement::insertedIntoDocument();202 FormAssociatedElement::insertedIntoDocument();203 }204 205 void HTMLFormControlElement::removedFromDocument()206 {207 HTMLElement::removedFromDocument();208 FormAssociatedElement::removedFromDocument();209 }210 211 const AtomicString& HTMLFormControlElement::formControlName() const212 {213 const AtomicString& name = fastGetAttribute(nameAttr);214 return name.isNull() ? emptyAtom : name;215 }216 217 void HTMLFormControlElement::setName(const AtomicString& value)218 {219 setAttribute(nameAttr, value);220 }221 222 bool HTMLFormControlElement::wasChangedSinceLastFormControlChangeEvent() const223 {224 return m_wasChangedSinceLastFormControlChangeEvent;225 }226 227 void HTMLFormControlElement::setChangedSinceLastFormControlChangeEvent(bool changed)228 {229 m_wasChangedSinceLastFormControlChangeEvent = changed;230 }231 232 void HTMLFormControlElement::dispatchFormControlChangeEvent()233 {234 HTMLElement::dispatchChangeEvent();235 setChangedSinceLastFormControlChangeEvent(false);236 }237 238 void HTMLFormControlElement::dispatchFormControlInputEvent()239 {240 setChangedSinceLastFormControlChangeEvent(true);241 HTMLElement::dispatchInputEvent();242 }243 244 void HTMLFormControlElement::setDisabled(bool b)245 {246 setAttribute(disabledAttr, b ? "" : 0);247 }248 249 bool HTMLFormControlElement::autofocus() const250 {251 return hasAttribute(autofocusAttr);252 }253 254 bool HTMLFormControlElement::required() const255 {256 return m_required;257 }258 259 static void updateFromElementCallback(Node* node, unsigned)260 {261 ASSERT_ARG(node, node->isElementNode());262 ASSERT_ARG(node, static_cast<Element*>(node)->isFormControlElement());263 ASSERT(node->renderer());264 if (RenderObject* renderer = node->renderer())265 renderer->updateFromElement();266 }267 268 void HTMLFormControlElement::recalcStyle(StyleChange change)269 {270 HTMLElement::recalcStyle(change);271 272 // updateFromElement() can cause the selection to change, and in turn273 // trigger synchronous layout, so it must not be called during style recalc.274 if (renderer())275 queuePostAttachCallback(updateFromElementCallback, this);276 }277 278 bool HTMLFormControlElement::supportsFocus() const279 {280 return !m_disabled;281 }282 283 bool HTMLFormControlElement::isFocusable() const284 {285 if (!renderer() ||286 !renderer()->isBox() || toRenderBox(renderer())->size().isEmpty())287 return false;288 // HTMLElement::isFocusable handles visibility and calls suportsFocus which289 // will cover the disabled case.290 return HTMLElement::isFocusable();291 }292 293 bool HTMLFormControlElement::isKeyboardFocusable(KeyboardEvent* event) const294 {295 if (isFocusable())296 if (document()->frame())297 return document()->frame()->eventHandler()->tabsToAllFormControls(event);298 return false;299 }300 301 bool HTMLFormControlElement::isMouseFocusable() const302 {303 #if PLATFORM(GTK) || PLATFORM(QT)304 return HTMLElement::isMouseFocusable();305 #else306 return false;307 #endif308 }309 310 short HTMLFormControlElement::tabIndex() const311 {312 // Skip the supportsFocus check in HTMLElement.313 return Element::tabIndex();314 }315 316 bool HTMLFormControlElement::recalcWillValidate() const317 {318 // FIXME: Should return false if this element has a datalist element as an319 // ancestor. See HTML5 4.10.10 'The datalist element.'320 return !m_disabled && !m_readOnly;321 }322 323 bool HTMLFormControlElement::willValidate() const324 {325 if (!m_willValidateInitialized) {326 m_willValidateInitialized = true;327 m_willValidate = recalcWillValidate();328 } else {329 // If the following assertion fails, setNeedsWillValidateCheck() is not330 // called correctly when something which changes recalcWillValidate() result331 // is updated.332 ASSERT(m_willValidate == recalcWillValidate());333 }334 return m_willValidate;335 }336 337 void HTMLFormControlElement::setNeedsWillValidateCheck()338 {339 // We need to recalculate willValidte immediately because willValidate340 // change can causes style change.341 bool newWillValidate = recalcWillValidate();342 if (m_willValidateInitialized && m_willValidate == newWillValidate)343 return;344 m_willValidateInitialized = true;345 m_willValidate = newWillValidate;346 setNeedsStyleRecalc();347 if (!m_willValidate)348 hideVisibleValidationMessage();349 }350 351 String HTMLFormControlElement::validationMessage()352 {353 return validity()->validationMessage();354 }355 356 void HTMLFormControlElement::updateVisibleValidationMessage()357 {358 Page* page = document()->page();359 if (!page)360 return;361 String message;362 if (renderer() && willValidate()) {363 message = validationMessage().stripWhiteSpace();364 // HTML5 specification doesn't ask UA to show the title attribute value365 // with the validationMessage. However, this behavior is same as Opera366 // and the specification describes such behavior as an example.367 const AtomicString& title = getAttribute(titleAttr);368 if (!message.isEmpty() && !title.isEmpty()) {369 message.append('\n');370 message.append(title);371 }372 }373 if (message.isEmpty()) {374 hideVisibleValidationMessage();375 return;376 }377 if (!m_validationMessage) {378 m_validationMessage = ValidationMessage::create(this);379 m_validationMessage->setMessage(message);380 } else {381 // Call setMessage() even if m_validationMesage->message() == message382 // because the existing message might be to be hidden.383 m_validationMessage->setMessage(message);384 }385 }386 387 void HTMLFormControlElement::hideVisibleValidationMessage()388 {389 if (m_validationMessage)390 m_validationMessage->requestToHideMessage();391 }392 393 String HTMLFormControlElement::visibleValidationMessage() const394 {395 return m_validationMessage ? m_validationMessage->message() : String();396 }397 398 bool HTMLFormControlElement::checkValidity(Vector<RefPtr<FormAssociatedElement> >* unhandledInvalidControls)399 {400 if (!willValidate() || isValidFormControlElement())401 return true;402 // An event handler can deref this object.403 RefPtr<HTMLFormControlElement> protector(this);404 RefPtr<Document> originalDocument(document());405 bool needsDefaultAction = dispatchEvent(Event::create(eventNames().invalidEvent, false, true));406 if (needsDefaultAction && unhandledInvalidControls && inDocument() && originalDocument == document())407 unhandledInvalidControls->append(this);408 return false;409 }410 411 bool HTMLFormControlElement::isValidFormControlElement()412 {413 // If the following assertion fails, setNeedsValidityCheck() is not called414 // correctly when something which changes validity is updated.415 ASSERT(m_isValid == validity()->valid());416 return m_isValid;417 }418 419 void HTMLFormControlElement::setNeedsValidityCheck()420 {421 bool newIsValid = validity()->valid();422 if (willValidate() && newIsValid != m_isValid) {423 // Update style for pseudo classes such as :valid :invalid.424 setNeedsStyleRecalc();425 }426 m_isValid = newIsValid;427 428 // Updates only if this control already has a validtion message.429 if (!visibleValidationMessage().isEmpty()) {430 // Calls updateVisibleValidationMessage() even if m_isValid is not431 // changed because a validation message can be chagned.432 updateVisibleValidationMessage();433 }434 }435 436 void HTMLFormControlElement::setCustomValidity(const String& error)437 {438 validity()->setCustomErrorMessage(error);439 }440 441 void HTMLFormControlElement::dispatchBlurEvent()442 {443 HTMLElement::dispatchBlurEvent();444 hideVisibleValidationMessage();445 }446 447 HTMLFormElement* HTMLFormControlElement::virtualForm() const448 {449 return FormAssociatedElement::form();450 }451 452 bool HTMLFormControlElement::isDefaultButtonForForm() const453 {454 return isSuccessfulSubmitButton() && form() && form()->defaultButton() == this;455 }456 457 void HTMLFormControlElement::attributeChanged(Attribute* attr, bool preserveDecls)458 {459 if (attr->name() == formAttr) {460 formAttributeChanged();461 if (!form())462 document()->checkedRadioButtons().addButton(this);463 } else464 HTMLElement::attributeChanged(attr, preserveDecls);465 }466 467 bool HTMLFormControlElement::isLabelable() const468 {469 // FIXME: Add meterTag and outputTag to the list once we support them.470 return hasTagName(buttonTag) || hasTagName(inputTag) || hasTagName(keygenTag)471 #if ENABLE(METER_TAG)472 || hasTagName(meterTag)473 #endif474 #if ENABLE(PROGRESS_TAG)475 || hasTagName(progressTag)476 #endif477 || hasTagName(selectTag) || hasTagName(textareaTag);478 }479 480 PassRefPtr<NodeList> HTMLFormControlElement::labels()481 {482 if (!isLabelable())483 return 0;484 if (!document())485 return 0;486 487 NodeRareData* data = Node::ensureRareData();488 if (!data->nodeLists()) {489 data->setNodeLists(NodeListsNodeData::create());490 treeScope()->addNodeListCache();491 }492 493 if (data->nodeLists()->m_labelsNodeListCache)494 return data->nodeLists()->m_labelsNodeListCache;495 496 RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);497 data->nodeLists()->m_labelsNodeListCache = list.get();498 return list.release();499 }500 501 HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)502 : HTMLFormControlElement(tagName, doc, f)503 {504 document()->registerFormElementWithState(this);505 }506 507 HTMLFormControlElementWithState::~HTMLFormControlElementWithState()508 {509 document()->unregisterFormElementWithState(this);510 }511 512 void HTMLFormControlElementWithState::willMoveToNewOwnerDocument()513 {514 document()->unregisterFormElementWithState(this);515 HTMLFormControlElement::willMoveToNewOwnerDocument();516 }517 518 void HTMLFormControlElementWithState::didMoveToNewOwnerDocument()519 {520 document()->registerFormElementWithState(this);521 HTMLFormControlElement::didMoveToNewOwnerDocument();522 }523 524 bool HTMLFormControlElementWithState::shouldAutocomplete() const525 {526 if (!form())527 return true;528 return form()->shouldAutocomplete();529 }530 531 bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const532 {533 // We don't save/restore control state in a form with autocomplete=off.534 return attached() && shouldAutocomplete();535 }536 537 void HTMLFormControlElementWithState::finishParsingChildren()538 {539 HTMLFormControlElement::finishParsingChildren();540 541 // We don't save state of a control with shouldSaveAndRestoreFormControlState()=false.542 // But we need to skip restoring process too because a control in another543 // form might have the same pair of name and type and saved its state.544 if (!shouldSaveAndRestoreFormControlState())545 return;546 547 Document* doc = document();548 if (doc->hasStateForNewFormElements()) {549 String state;550 if (doc->takeStateForFormElement(name().impl(), type().impl(), state))551 restoreFormControlState(state);552 }553 }554 555 void HTMLFormControlElementWithState::defaultEventHandler(Event* event)556 {557 if (event->type() == eventNames().webkitEditableContentChangedEvent && renderer() && renderer()->isTextControl()) {558 toRenderTextControl(renderer())->subtreeHasChanged();559 return;560 }561 562 HTMLFormControlElement::defaultEventHandler(event);563 }564 46 565 47 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form) … … 595 77 handleBlurEvent(); 596 78 HTMLFormControlElementWithState::dispatchBlurEvent(); 79 } 80 81 void HTMLTextFormControlElement::defaultEventHandler(Event* event) 82 { 83 if (event->type() == eventNames().webkitEditableContentChangedEvent && renderer() && renderer()->isTextControl()) { 84 toRenderTextControl(renderer())->subtreeHasChanged(); 85 return; 86 } 87 88 HTMLFormControlElementWithState::defaultEventHandler(event); 597 89 } 598 90 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r90802 r90849 22 22 */ 23 23 24 #ifndef HTML FormControlElement_h25 #define HTML FormControlElement_h24 #ifndef HTMLTextFormControlElement_h 25 #define HTMLTextFormControlElement_h 26 26 27 #include "FormAssociatedElement.h" 28 #include "HTMLElement.h" 27 #include "HTMLFormControlElement.h" 29 28 30 29 namespace WebCore { 31 30 32 class FormDataList;33 class HTMLFormElement;34 31 class RenderTextControl; 35 class ValidationMessage;36 class ValidityState;37 class VisibleSelection;38 32 39 // HTMLFormControlElement is the default implementation of FormAssociatedElement,40 // and form-associated element implementations should use HTMLFormControlElement41 // unless there is a special reason.42 class HTMLFormControlElement : public HTMLElement, public FormAssociatedElement {43 public:44 virtual ~HTMLFormControlElement();45 46 HTMLFormElement* form() const { return FormAssociatedElement::form(); }47 48 bool formNoValidate() const;49 50 virtual void reset() { }51 52 virtual bool formControlValueMatchesRenderer() const { return m_valueMatchesRenderer; }53 virtual void setFormControlValueMatchesRenderer(bool b) { m_valueMatchesRenderer = b; }54 55 virtual bool wasChangedSinceLastFormControlChangeEvent() const;56 virtual void setChangedSinceLastFormControlChangeEvent(bool);57 58 virtual void dispatchFormControlChangeEvent();59 virtual void dispatchFormControlInputEvent();60 61 virtual bool disabled() const { return m_disabled; }62 void setDisabled(bool);63 64 virtual bool isFocusable() const;65 virtual bool isEnumeratable() const { return false; }66 67 // Determines whether or not a control will be automatically focused.68 virtual bool autofocus() const;69 70 bool required() const;71 72 const AtomicString& type() const { return formControlType(); }73 74 void setName(const AtomicString& name);75 76 virtual bool isEnabledFormControl() const { return !disabled(); }77 virtual bool isReadOnlyFormControl() const { return readOnly(); }78 79 virtual bool isRadioButton() const { return false; }80 virtual bool canTriggerImplicitSubmission() const { return false; }81 82 // Override in derived classes to get the encoded name=value pair for submitting.83 // Return true for a successful control (see HTML4-17.13.2).84 virtual bool appendFormData(FormDataList&, bool) { return false; }85 86 virtual bool isSuccessfulSubmitButton() const { return false; }87 virtual bool isActivatedSubmit() const { return false; }88 virtual void setActivatedSubmit(bool) { }89 90 virtual bool willValidate() const;91 String validationMessage();92 void updateVisibleValidationMessage();93 void hideVisibleValidationMessage();94 bool checkValidity(Vector<RefPtr<FormAssociatedElement> >* unhandledInvalidControls = 0);95 // This must be called when a validation constraint or control value is changed.96 void setNeedsValidityCheck();97 void setCustomValidity(const String&);98 99 bool isLabelable() const;100 PassRefPtr<NodeList> labels();101 102 bool readOnly() const { return m_readOnly; }103 104 virtual void attributeChanged(Attribute*, bool preserveDecls = false);105 106 using TreeShared<ContainerNode>::ref;107 using TreeShared<ContainerNode>::deref;108 109 protected:110 HTMLFormControlElement(const QualifiedName& tagName, Document*, HTMLFormElement*);111 112 virtual void parseMappedAttribute(Attribute*);113 virtual void attach();114 virtual void insertedIntoTree(bool deep);115 virtual void removedFromTree(bool deep);116 virtual void insertedIntoDocument();117 virtual void removedFromDocument();118 virtual void willMoveToNewOwnerDocument();119 120 virtual bool supportsFocus() const;121 virtual bool isKeyboardFocusable(KeyboardEvent*) const;122 virtual bool isMouseFocusable() const;123 124 virtual void recalcStyle(StyleChange);125 126 virtual void dispatchBlurEvent();127 virtual void detach();128 129 // This must be called any time the result of willValidate() has changed.130 void setNeedsWillValidateCheck();131 virtual bool recalcWillValidate() const;132 133 private:134 virtual const AtomicString& formControlName() const;135 virtual const AtomicString& formControlType() const = 0;136 137 virtual void refFormAssociatedElement() { ref(); }138 virtual void derefFormAssociatedElement() { deref(); }139 140 virtual bool isFormControlElement() const { return true; }141 142 virtual short tabIndex() const;143 144 virtual HTMLFormElement* virtualForm() const;145 virtual bool isDefaultButtonForForm() const;146 virtual bool isValidFormControlElement();147 String visibleValidationMessage() const;148 149 OwnPtr<ValidationMessage> m_validationMessage;150 bool m_disabled : 1;151 bool m_readOnly : 1;152 bool m_required : 1;153 bool m_valueMatchesRenderer : 1;154 155 // The initial value of m_willValidate depends on the derived class. We can't156 // initialize it with a virtual function in the constructor. m_willValidate157 // is not deterministic as long as m_willValidateInitialized is false.158 mutable bool m_willValidateInitialized: 1;159 mutable bool m_willValidate : 1;160 161 // Cache of validity()->valid().162 // But "candidate for constraint validation" doesn't affect m_isValid.163 bool m_isValid : 1;164 165 bool m_wasChangedSinceLastFormControlChangeEvent : 1;166 };167 168 // FIXME: Give this class its own header file.169 class HTMLFormControlElementWithState : public HTMLFormControlElement {170 public:171 virtual ~HTMLFormControlElementWithState();172 173 virtual bool canContainRangeEndPoint() const { return false; }174 175 protected:176 HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);177 178 virtual bool shouldAutocomplete() const;179 virtual void finishParsingChildren();180 virtual void willMoveToNewOwnerDocument();181 virtual void didMoveToNewOwnerDocument();182 virtual void defaultEventHandler(Event*);183 184 private:185 virtual bool shouldSaveAndRestoreFormControlState() const;186 };187 188 // FIXME: Give this class its own header file.189 33 class HTMLTextFormControlElement : public HTMLFormControlElementWithState { 190 34 public: … … 238 82 bool hasCachedSelectionEnd() const { return m_cachedSelectionEnd >= 0; } 239 83 84 virtual void defaultEventHandler(Event*); 85 240 86 private: 241 87 int computeSelectionStart() const;
Note: See TracChangeset
for help on using the changeset viewer.