Changeset 181408 in webkit
- Timestamp:
- Mar 11, 2015 3:01:01 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181404 r181408 1 2015-03-10 Sam Weinig <sam@webkit.org> 2 3 Allow adding a button in input elements for auto fill related functionality 4 <rdar://problem/19782066> 5 https://bugs.webkit.org/show_bug.cgi?id=142564 6 7 Reviewed by Anders Carlsson. 8 9 * fast/forms/input-auto-fill-button-expected.txt: Added. 10 * fast/forms/input-auto-fill-button.html: Added. 11 1 12 2015-03-11 Ryosuke Niwa <rniwa@webkit.org> 2 13 -
trunk/Source/WebCore/CMakeLists.txt
r181371 r181408 1747 1747 html/parser/XSSAuditorDelegate.cpp 1748 1748 1749 html/shadow/AutoFillButtonElement.cpp 1749 1750 html/shadow/ContentDistributor.cpp 1750 1751 html/shadow/DetailsMarkerControl.cpp -
trunk/Source/WebCore/ChangeLog
r181407 r181408 1 2015-03-10 Sam Weinig <sam@webkit.org> 2 3 Allow adding a button in input elements for auto fill related functionality 4 <rdar://problem/19782066> 5 https://bugs.webkit.org/show_bug.cgi?id=142564 6 7 Reviewed by Anders Carlsson. 8 9 Test: fast/forms/input-auto-fill-button.html 10 11 - Adds a new button that can be shown in <input> elements - AutoFillButtonElement. 12 - Makes the spelling of AutoFill consistent throughout WebCore and WebKit (except 13 where not feasible due to exported API/SPI). 14 15 * CMakeLists.txt: 16 * WebCore.vcxproj/WebCore.vcxproj: 17 * WebCore.vcxproj/WebCore.vcxproj.filters: 18 * WebCore.xcodeproj/project.pbxproj: 19 Add new files. 20 21 * css/html.css: 22 (input::-webkit-auto-fill-button): 23 (input::-webkit-auto-fill-button:hover): 24 (input::-webkit-auto-fill-button:active): 25 Add default style rules for the AutoFill button based on the ones 26 used for caps lock indicator. 27 28 * html/HTMLInputElement.cpp: 29 (WebCore::HTMLInputElement::HTMLInputElement): 30 (WebCore::HTMLInputElement::autoFillButtonElement): 31 (WebCore::HTMLInputElement::reset): 32 (WebCore::HTMLInputElement::setValueFromRenderer): 33 (WebCore::HTMLInputElement::setAutoFilled): 34 (WebCore::HTMLInputElement::setShowAutoFillButton): 35 (WebCore::HTMLInputElement::setAutofilled): Deleted. 36 * html/HTMLInputElement.h: 37 (WebCore::HTMLInputElement::isAutoFilled): 38 (WebCore::HTMLInputElement::showAutoFillButton): 39 (WebCore::HTMLInputElement::isAutofilled): Deleted. 40 Add new bit to represent whether the AutoFill button should be shown 41 or not. By default it is not shown, and the client must enable it. 42 43 * html/InputType.cpp: 44 (WebCore::InputType::updateAutoFillButton): 45 * html/InputType.h: 46 (WebCore::InputType::autoFillButtonElement): 47 Add new virtual methods for updating and accessing the AutoFill button. 48 49 * html/TextFieldInputType.cpp: 50 (WebCore::TextFieldInputType::createShadowSubtree): 51 (WebCore::TextFieldInputType::autoFillButtonElement): 52 (WebCore::TextFieldInputType::destroyShadowSubtree): 53 (WebCore::TextFieldInputType::updatePlaceholderText): 54 (WebCore::TextFieldInputType::shouldDrawAutoFillButton): 55 (WebCore::TextFieldInputType::autoFillButtonElementWasClicked): 56 (WebCore::TextFieldInputType::createContainer): 57 (WebCore::TextFieldInputType::createAutoFillButton): 58 (WebCore::TextFieldInputType::updateAutoFillButton): 59 * html/TextFieldInputType.h: 60 Add support for adding the AutoFill to the shadow DOM of textfields. The implementation 61 is slightly different than for the caps lock indicator, because I didn't want to force 62 the creation of a container for all <input> elements just in case an AutoFill button was 63 added. Instead, if an AutoFill button is added, the container is created on the fly and 64 the existing DOM is updated to move into it. Once a container is created, it is never 65 removed. 66 67 * html/shadow/AutoFillButtonElement.cpp: Added. 68 (WebCore::AutoFillButtonElement::create): 69 (WebCore::AutoFillButtonElement::AutoFillButtonElement): 70 (WebCore::AutoFillButtonElement::defaultEventHandler): 71 * html/shadow/AutoFillButtonElement.h: Added. 72 Add div subclass that swallows the click event and forwards it to the ChromeClient. 73 74 * page/ChromeClient.h: 75 Add handleAutoFillButtonClick client function to inform WebKit that the AutoFill 76 button was clicked. 77 78 * testing/Internals.cpp: 79 (WebCore::Internals::setAutofilled): 80 (WebCore::Internals::setShowAutoFillButton): 81 * testing/Internals.h: 82 * testing/Internals.idl: 83 Expose a new internals.setShowAutoFillButton() function to allow testing 84 of the AutoFill button from layout tests. 85 86 * accessibility/AccessibilityObject.cpp: 87 (WebCore::AccessibilityObject::isValueAutofilled): 88 * css/SelectorCheckerTestFunctions.h: 89 (WebCore::isAutofilled): 90 * css/StyleResolver.cpp: 91 (WebCore::StyleResolver::canShareStyleWithControl): 92 Update for new spelling of AutoFill. 93 1 94 2015-03-11 Geoffrey Garen <ggaren@apple.com> 2 95 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r181190 r181408 16209 16209 <ClCompile Include="..\html\parser\XSSAuditor.cpp" /> 16210 16210 <ClCompile Include="..\html\parser\XSSAuditorDelegate.cpp" /> 16211 <ClCompile Include="..\html\shadow\AutoFillButtonElement.cpp" /> 16211 16212 <ClCompile Include="..\html\shadow\ContentDistributor.cpp" /> 16212 16213 <ClCompile Include="..\html\shadow\DetailsMarkerControl.cpp" /> … … 20971 20972 <ClInclude Include="..\html\parser\XSSAuditor.h" /> 20972 20973 <ClInclude Include="..\html\parser\XSSAuditorDelegate.h" /> 20974 <ClInclude Include="..\html\shadow\AutoFillButtonElement.h" /> 20973 20975 <ClInclude Include="..\html\shadow\ContentDistributor.h" /> 20974 20976 <ClInclude Include="..\html\shadow\DetailsMarkerControl.h" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r181190 r181408 4111 4111 <Filter>html\parser</Filter> 4112 4112 </ClCompile> 4113 <ClCompile Include="..\html\shadow\AutoFillButtonElement.cpp"> 4114 <Filter>html\shadow</Filter> 4115 </ClCompile> 4113 4116 <ClCompile Include="..\html\shadow\ContentDistributor.cpp"> 4114 4117 <Filter>html\shadow</Filter> … … 11274 11277 <ClInclude Include="..\html\parser\XSSAuditorDelegate.h"> 11275 11278 <Filter>html\parser</Filter> 11279 </ClInclude> 11280 <ClInclude Include="..\html\shadow\AutoFillButtonElement.h"> 11281 <Filter>html\shadow</Filter> 11276 11282 </ClInclude> 11277 11283 <ClInclude Include="..\html\shadow\ContentDistributor.h"> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r181371 r181408 2474 2474 7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; }; 2475 2475 7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; }; 2476 7C1E97271A9F9834007BF0FB /* AutoFillButtonElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */; }; 2477 7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */; }; 2476 2478 7C2BDD3D17C7F98C0038FF15 /* JSDOMGlobalObjectTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */; }; 2477 2479 7C2BDD3E17C7F98C0038FF15 /* JSDOMGlobalObjectTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */; }; … … 9694 9696 7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; }; 9695 9697 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; }; 9698 7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoFillButtonElement.cpp; sourceTree = "<group>"; }; 9699 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoFillButtonElement.h; sourceTree = "<group>"; }; 9696 9700 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObjectTask.cpp; sourceTree = "<group>"; }; 9697 9701 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObjectTask.h; sourceTree = "<group>"; }; … … 15685 15689 children = ( 15686 15690 51C4AA5118B28357007BFE9B /* mac */, 15691 7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */, 15692 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */, 15687 15693 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */, 15688 15694 57B791A014C6A62900F202D1 /* ContentDistributor.h */, … … 26191 26197 0FEA3E84191B31BF000F1B55 /* ScrollingStateOverflowScrollingNode.h in Headers */, 26192 26198 931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */, 26199 7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */, 26193 26200 0FB8890F167D30160010CDA5 /* ScrollingStateStickyNode.h in Headers */, 26194 26201 931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */, … … 27801 27808 85BA4D0E0AA688680088052D /* DOMHTMLDivElement.mm in Sources */, 27802 27809 85BA4D100AA688680088052D /* DOMHTMLDListElement.mm in Sources */, 27810 7C1E97271A9F9834007BF0FB /* AutoFillButtonElement.cpp in Sources */, 27803 27811 85BCBC140ABBA87D00381160 /* DOMHTMLDocument.mm in Sources */, 27804 27812 85DF2EEE0AA387CB00AD64C5 /* DOMHTMLElement.mm in Sources */, -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r180621 r181408 2029 2029 return false; 2030 2030 2031 return downcast<HTMLInputElement>(*node).isAuto filled();2031 return downcast<HTMLInputElement>(*node).isAutoFilled(); 2032 2032 } 2033 2033 -
trunk/Source/WebCore/bindings/objc/DOMHTML.mm
r177559 r181408 183 183 - (BOOL)_isAutofilled 184 184 { 185 return core(self)->isAuto filled();185 return core(self)->isAutoFilled(); 186 186 } 187 187 … … 191 191 // This allows WebKit to obey the -webkit-autofill pseudo style, which 192 192 // changes the background color. 193 core(self)->setAuto filled(filled);193 core(self)->setAutoFilled(filled); 194 194 } 195 195 #endif // PLATFORM(IOS) -
trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h
r181197 r181408 46 46 if (is<HTMLFormControlElement>(*element)) { 47 47 if (const HTMLInputElement* inputElement = element->toInputElement()) 48 return inputElement->isAuto filled();48 return inputElement->isAutoFilled(); 49 49 } 50 50 return false; -
trunk/Source/WebCore/css/StyleResolver.cpp
r180554 r181408 507 507 return false; 508 508 509 if (thisInputElement->isAuto filled() != otherInputElement->isAutofilled())509 if (thisInputElement->isAutoFilled() != otherInputElement->isAutoFilled()) 510 510 return false; 511 511 if (thisInputElement->shouldAppearChecked() != otherInputElement->shouldAppearChecked()) -
trunk/Source/WebCore/css/html.css
r181094 r181408 545 545 } 546 546 547 input::-webkit-auto-fill-button { 548 content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="black" d="M12,0H4C1.8,0,0,1.8,0,4v8c0,2.2,1.8,4,4,4h8c2.2,0,4-1.8,4-4V4C16,1.8,14.2,0,12,0z M9.6,7.1l0,1.2l-1,1L9.4,10l-0.7,0.7 l0.7,0.7l-0.7,0.7l0.7,0.7l-1.2,1.2c-0.2,0.2-0.3,0.2-0.5,0l-1-1l0-6C5.7,6.6,5.1,5.6,5.1,4.5c0-1.6,1.3-3,3-3c1.7,0,3,1.3,3,3 C11.1,5.6,10.5,6.6,9.6,7.1z"/><circle fill="black" cx="8.1" cy="3.6" r="1"/></svg>'); 549 align-self:stretch; 550 opacity: .4; 551 -webkit-flex: none; 552 -webkit-user-select: none; 553 } 554 555 input::-webkit-auto-fill-button:hover { 556 opacity: .85; 557 } 558 559 input::-webkit-auto-fill-button:active { 560 opacity: 1; 561 } 562 547 563 input::-webkit-caps-lock-indicator { 548 564 -webkit-appearance: caps-lock-indicator; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r181358 r181408 110 110 , m_isActivatedSubmit(false) 111 111 , m_autocomplete(Uninitialized) 112 , m_isAutofilled(false) 112 , m_isAutoFilled(false) 113 , m_showAutoFillButton(false) 113 114 #if ENABLE(DATALIST_ELEMENT) 114 115 , m_hasNonEmptyList(false) … … 203 204 { 204 205 return m_inputType->capsLockIndicatorElement(); 206 } 207 208 HTMLElement* HTMLInputElement::autoFillButtonElement() const 209 { 210 return m_inputType->autoFillButtonElement(); 205 211 } 206 212 … … 836 842 setValue(String()); 837 843 838 setAuto filled(false);844 setAutoFilled(false); 839 845 setChecked(fastHasAttribute(checkedAttr)); 840 846 m_reflectsCheckedAttribute = true; … … 1057 1063 updateValidity(); 1058 1064 1059 // Clear auto fill flag (and yellow background) on user edit.1060 setAuto filled(false);1065 // Clear auto fill flag (and yellow background) on user edit. 1066 setAutoFilled(false); 1061 1067 } 1062 1068 … … 1290 1296 } 1291 1297 1292 void HTMLInputElement::setAuto filled(bool autofilled)1293 { 1294 if (auto filled == m_isAutofilled)1298 void HTMLInputElement::setAutoFilled(bool autoFilled) 1299 { 1300 if (autoFilled == m_isAutoFilled) 1295 1301 return; 1296 1302 1297 m_isAuto filled = autofilled;1303 m_isAutoFilled = autoFilled; 1298 1304 setNeedsStyleRecalc(); 1305 } 1306 1307 void HTMLInputElement::setShowAutoFillButton(bool showAutoFillButton) 1308 { 1309 if (showAutoFillButton == m_showAutoFillButton) 1310 return; 1311 1312 m_showAutoFillButton = showAutoFillButton; 1313 m_inputType->updateAutoFillButton(); 1299 1314 } 1300 1315 -
trunk/Source/WebCore/html/HTMLInputElement.h
r181169 r181408 152 152 HTMLElement* sliderTrackElement() const; 153 153 virtual HTMLElement* placeholderElement() const override final; 154 WEBCORE_EXPORT HTMLElement* autoFillButtonElement() const; 154 155 155 156 bool checked() const { return m_isChecked; } … … 236 237 bool multiple() const; 237 238 238 bool isAutofilled() const { return m_isAutofilled; } 239 WEBCORE_EXPORT void setAutofilled(bool = true); 239 bool isAutoFilled() const { return m_isAutoFilled; } 240 WEBCORE_EXPORT void setAutoFilled(bool = true); 241 242 bool showAutoFillButton() const { return m_showAutoFillButton; } 243 WEBCORE_EXPORT void setShowAutoFillButton(bool); 240 244 241 245 FileList* files(); … … 429 433 bool m_isActivatedSubmit : 1; 430 434 unsigned m_autocomplete : 2; // AutoCompleteSetting 431 bool m_isAutofilled : 1; 435 bool m_isAutoFilled : 1; 436 bool m_showAutoFillButton : 1; 432 437 #if ENABLE(DATALIST_ELEMENT) 433 438 bool m_hasNonEmptyList : 1; -
trunk/Source/WebCore/html/InputType.cpp
r180490 r181408 490 490 } 491 491 492 void InputType::capsLockStateMayHaveChanged()493 {494 }495 496 492 void InputType::createShadowSubtree() 497 493 { … … 926 922 927 923 void InputType::requiredAttributeChanged() 924 { 925 } 926 927 void InputType::capsLockStateMayHaveChanged() 928 { 929 } 930 931 void InputType::updateAutoFillButton() 928 932 { 929 933 } -
trunk/Source/WebCore/html/InputType.h
r180490 r181408 216 216 virtual void blur(); 217 217 218 virtual void capsLockStateMayHaveChanged();219 220 218 // Shadow tree handling 221 219 … … 228 226 virtual HTMLElement* innerSpinButtonElement() const { return nullptr; } 229 227 virtual HTMLElement* capsLockIndicatorElement() const { return nullptr; } 228 virtual HTMLElement* autoFillButtonElement() const { return nullptr; } 230 229 virtual HTMLElement* resultsButtonElement() const { return nullptr; } 231 230 virtual HTMLElement* cancelButtonElement() const { return nullptr; } … … 276 275 virtual void readonlyAttributeChanged(); 277 276 virtual void requiredAttributeChanged(); 277 virtual void capsLockStateMayHaveChanged(); 278 virtual void updateAutoFillButton(); 278 279 virtual String defaultToolTip() const; 279 280 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r180490 r181408 35 35 #include "BeforeTextInsertedEvent.h" 36 36 #include "Chrome.h" 37 #include "ChromeClient.h" 37 38 #include "Editor.h" 38 39 #include "FormDataList.h" … … 256 257 ASSERT(!m_innerBlock); 257 258 ASSERT(!m_innerSpinButton); 259 ASSERT(!m_capsLockIndicator); 260 ASSERT(!m_autoFillButton); 258 261 259 262 Document& document = element().document(); … … 263 266 264 267 m_innerText = TextControlInnerTextElement::create(document); 268 265 269 if (!createsContainer) { 266 270 element().userAgentShadowRoot()->appendChild(m_innerText, IGNORE_EXCEPTION); … … 269 273 } 270 274 271 ShadowRoot* shadowRoot = element().userAgentShadowRoot(); 272 m_container = TextControlInnerContainer::create(document); 273 m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral)); 274 shadowRoot->appendChild(m_container, IGNORE_EXCEPTION); 275 276 m_innerBlock = TextControlInnerElement::create(document); 277 m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION); 278 m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION); 279 275 createContainer(); 280 276 updatePlaceholderText(); 281 277 … … 294 290 m_container->appendChild(m_capsLockIndicator, IGNORE_EXCEPTION); 295 291 } 292 293 updateAutoFillButton(); 296 294 } 297 295 … … 320 318 { 321 319 return m_capsLockIndicator.get(); 320 } 321 322 HTMLElement* TextFieldInputType::autoFillButtonElement() const 323 { 324 return m_autoFillButton.get(); 322 325 } 323 326 … … 337 340 m_innerSpinButton = nullptr; 338 341 m_capsLockIndicator = nullptr; 342 m_autoFillButton = nullptr; 339 343 m_container = nullptr; 340 344 } … … 457 461 m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); 458 462 element().userAgentShadowRoot()->insertBefore(m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION); 463 459 464 } 460 465 m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION); … … 564 569 } 565 570 571 bool TextFieldInputType::shouldDrawAutoFillButton() const 572 { 573 return element().showAutoFillButton(); 574 } 575 576 void TextFieldInputType::autoFillButtonElementWasClicked() 577 { 578 Page* page = element().document().page(); 579 if (!page) 580 return; 581 582 page->chrome().client().handleAutoFillButtonClick(element()); 583 } 584 585 void TextFieldInputType::createContainer() 586 { 587 ASSERT(!m_container); 588 589 m_container = TextControlInnerContainer::create(element().document()); 590 m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral)); 591 592 m_innerBlock = TextControlInnerElement::create(element().document()); 593 m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION); 594 m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION); 595 596 element().userAgentShadowRoot()->appendChild(m_container, IGNORE_EXCEPTION); 597 } 598 599 void TextFieldInputType::createAutoFillButton() 600 { 601 ASSERT(!m_autoFillButton); 602 603 m_autoFillButton = AutoFillButtonElement::create(element().document(), *this); 604 m_autoFillButton->setPseudo(AtomicString("-webkit-auto-fill-button", AtomicString::ConstructFromLiteral)); 605 m_container->appendChild(m_autoFillButton, IGNORE_EXCEPTION); 606 } 607 608 void TextFieldInputType::updateAutoFillButton() 609 { 610 if (shouldDrawAutoFillButton()) { 611 if (!m_container) 612 createContainer(); 613 614 if (!m_autoFillButton) 615 createAutoFillButton(); 616 617 m_autoFillButton->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock, true); 618 return; 619 } 620 621 if (m_autoFillButton) 622 m_autoFillButton->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true); 623 } 624 566 625 } // namespace WebCore -
trunk/Source/WebCore/html/TextFieldInputType.h
r180490 r181408 32 32 #define TextFieldInputType_h 33 33 34 #include "AutoFillButtonElement.h" 34 35 #include "InputType.h" 35 36 #include "SpinButtonElement.h" … … 42 43 // The class represents types of which UI contain text fields. 43 44 // It supports not only the types for BaseTextInputType but also type=number. 44 class TextFieldInputType : public InputType, protected SpinButtonElement::SpinButtonOwner {45 class TextFieldInputType : public InputType, protected SpinButtonElement::SpinButtonOwner, protected AutoFillButtonElement::AutoFillButtonOwner { 45 46 protected: 46 47 explicit TextFieldInputType(HTMLInputElement&); … … 54 55 virtual HTMLElement* innerSpinButtonElement() const override final; 55 56 virtual HTMLElement* capsLockIndicatorElement() const override final; 57 virtual HTMLElement* autoFillButtonElement() const override final; 56 58 57 59 protected: … … 97 99 virtual void subtreeHasChanged() override final; 98 100 virtual void capsLockStateMayHaveChanged() override final; 101 virtual void updateAutoFillButton() override final; 99 102 100 103 // SpinButtonElement::SpinButtonOwner functions. … … 105 108 virtual void spinButtonStepUp() override final; 106 109 110 // AutoFillButtonElement::AutoFillButtonOwner 111 virtual void autoFillButtonElementWasClicked() override final; 112 107 113 bool shouldHaveSpinButton() const; 108 114 bool shouldHaveCapsLockIndicator() const; 109 115 bool shouldDrawCapsLockIndicator() const; 116 bool shouldDrawAutoFillButton() const; 117 118 void createContainer(); 119 void createAutoFillButton(); 110 120 111 121 RefPtr<HTMLElement> m_container; … … 115 125 RefPtr<SpinButtonElement> m_innerSpinButton; 116 126 RefPtr<HTMLElement> m_capsLockIndicator; 127 RefPtr<HTMLElement> m_autoFillButton; 117 128 }; 118 129 -
trunk/Source/WebCore/page/ChromeClient.h
r180607 r181408 446 446 virtual bool shouldDispatchFakeMouseMoveEvents() const { return true; } 447 447 448 virtual void handleAutoFillButtonClick(HTMLInputElement&) { } 449 448 450 protected: 449 451 virtual ~ChromeClient() { } -
trunk/Source/WebCore/testing/Internals.cpp
r181371 r181408 1037 1037 return; 1038 1038 } 1039 inputElement->setAutofilled(enabled); 1040 } 1039 inputElement->setAutoFilled(enabled); 1040 } 1041 1042 void Internals::setShowAutoFillButton(Element* element, bool show, ExceptionCode& ec) 1043 { 1044 HTMLInputElement* inputElement = element->toInputElement(); 1045 if (!inputElement) { 1046 ec = INVALID_ACCESS_ERR; 1047 return; 1048 } 1049 inputElement->setShowAutoFillButton(show); 1050 } 1051 1041 1052 1042 1053 void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionCode& ec) -
trunk/Source/WebCore/testing/Internals.h
r181291 r181408 162 162 void setEditingValue(Element* inputElement, const String&, ExceptionCode&); 163 163 void setAutofilled(Element*, bool enabled, ExceptionCode&); 164 void setShowAutoFillButton(Element*, bool enabled, ExceptionCode&); 164 165 void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&); 165 166 -
trunk/Source/WebCore/testing/Internals.idl
r181291 r181408 117 117 [RaisesException] void setEditingValue(Element inputElement, DOMString value); 118 118 [RaisesException] void setAutofilled(Element inputElement, boolean enabled); 119 [RaisesException] void setShowAutoFillButton(Element inputElement, boolean enabled); 119 120 [RaisesException] unsigned long countMatchesForText(DOMString text, unsigned long findOptions, DOMString markMatches); 120 121 -
trunk/Source/WebKit/mac/ChangeLog
r181342 r181408 1 2015-03-10 Sam Weinig <sam@webkit.org> 2 3 Allow adding a button in input elements for auto fill related functionality 4 <rdar://problem/19782066> 5 https://bugs.webkit.org/show_bug.cgi?id=142564 6 7 Reviewed by Anders Carlsson. 8 9 * DOM/WebDOMOperations.mm: 10 (-[DOMHTMLInputElement _setAutofilled:]): 11 Update for consistent spelling of AutoFill. 12 1 13 2015-03-10 Timothy Horton <timothy_horton@apple.com> 2 14 -
trunk/Source/WebKit/mac/DOM/WebDOMOperations.mm
r179294 r181408 215 215 - (void)_setAutofilled:(BOOL)autofilled 216 216 { 217 downcast<HTMLInputElement>(core((DOMElement *)self))->setAuto filled(autofilled);217 downcast<HTMLInputElement>(core((DOMElement *)self))->setAutoFilled(autofilled); 218 218 } 219 219 -
trunk/Source/WebKit/win/DOMHTMLClasses.cpp
r179770 r181408 1346 1346 ASSERT(is<HTMLInputElement>(m_element)); 1347 1347 HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element); 1348 inputElement.setAuto filled(!!filled);1348 inputElement.setAutoFilled(!!filled); 1349 1349 return S_OK; 1350 1350 } … … 1355 1355 ASSERT(is<HTMLInputElement>(m_element)); 1356 1356 HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element); 1357 *result = inputElement.isAuto filled() ? TRUE : FALSE;1357 *result = inputElement.isAutoFilled() ? TRUE : FALSE; 1358 1358 return S_OK; 1359 1359 } -
trunk/Source/WebKit2/ChangeLog
r181400 r181408 1 2015-03-10 Sam Weinig <sam@webkit.org> 2 3 Allow adding a button in input elements for auto fill related functionality 4 <rdar://problem/19782066> 5 https://bugs.webkit.org/show_bug.cgi?id=142564 6 7 Reviewed by Anders Carlsson. 8 9 - Adds new SPI to respond to clicks on the AutoFill button (both bundle and UIProcess). 10 - Adds new SPI to enable/disable the display of the AutoFill button on an element. 11 - Adds new SPI to get the bounds of the AutoFill button. 12 - Updates spelling of AutoFill to be consistent. 13 14 * UIProcess/API/APIUIClient.h: 15 (API::UIClient::didClickAutoFillButton): 16 * UIProcess/API/C/WKPage.cpp: 17 (WKPageSetPageUIClient): 18 * UIProcess/API/C/WKPageUIClient.h: 19 * UIProcess/WebPageProxy.cpp: 20 (WebKit::WebPageProxy::handleAutoFillButtonClick): 21 * UIProcess/WebPageProxy.h: 22 * UIProcess/WebPageProxy.messages.in: 23 * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h: 24 (API::InjectedBundle::PageUIClient::didClickAutoFillButton): 25 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp: 26 (WebKit::InjectedBundlePageUIClient::didClickAutoFillButton): 27 * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h: 28 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 29 (WebKit::WebChromeClient::handleAutoFillButtonClick): 30 * WebProcess/WebCoreSupport/WebChromeClient.h: 31 * WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h: 32 Pipe the didClickAutoFillButton to the SPI layer. 33 34 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm: 35 (-[WKWebProcessPlugInNodeHandle HTMLInputElementIsAutoFilled]): 36 (-[WKWebProcessPlugInNodeHandle setHTMLInputElementIsAutoFilled:]): 37 Update for new spelling of AutoFill. 38 39 * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h: 40 * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: 41 (WKBundleNodeHandleGetHTMLInputElementAutoFilled): 42 (WKBundleNodeHandleSetHTMLInputElementAutoFilled): 43 Added. Replaces WKBundleNodeHandleGetHTMLInputElementAutofilled/WKBundleNodeHandleSetHTMLInputElementAutofilled 44 which are now deprecated due to inconsistent spelling of AutoFill. 45 46 (WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled): 47 (WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled): 48 (WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds): 49 Added. 50 51 (WKBundleNodeHandleGetHTMLInputElementAutofilled): 52 (WKBundleNodeHandleSetHTMLInputElementAutofilled): 53 Deprecated. 54 55 * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: 56 (WebKit::InjectedBundleNodeHandle::getOrCreate): 57 (WebKit::InjectedBundleNodeHandle::create): 58 (WebKit::InjectedBundleNodeHandle::InjectedBundleNodeHandle): 59 (WebKit::InjectedBundleNodeHandle::~InjectedBundleNodeHandle): 60 (WebKit::InjectedBundleNodeHandle::coreNode): 61 (WebKit::InjectedBundleNodeHandle::document): 62 (WebKit::InjectedBundleNodeHandle::elementBounds): 63 (WebKit::InjectedBundleNodeHandle::renderRect): 64 (WebKit::InjectedBundleNodeHandle::renderedImage): 65 (WebKit::InjectedBundleNodeHandle::visibleRange): 66 (WebKit::InjectedBundleNodeHandle::setHTMLInputElementValueForUser): 67 (WebKit::InjectedBundleNodeHandle::isHTMLInputElementAutoFilled): 68 (WebKit::InjectedBundleNodeHandle::setHTMLInputElementAutoFilled): 69 (WebKit::InjectedBundleNodeHandle::isHTMLInputElementAutoFillButtonEnabled): 70 (WebKit::InjectedBundleNodeHandle::setHTMLInputElementAutoFillButtonEnabled): 71 (WebKit::InjectedBundleNodeHandle::htmlInputElementAutoFillButtonBounds): 72 (WebKit::InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit): 73 (WebKit::InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit): 74 (WebKit::InjectedBundleNodeHandle::isTextField): 75 (WebKit::InjectedBundleNodeHandle::htmlTableCellElementCellAbove): 76 (WebKit::InjectedBundleNodeHandle::documentFrame): 77 (WebKit::InjectedBundleNodeHandle::htmlFrameElementContentFrame): 78 (WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame): 79 (WebKit::InjectedBundleNodeHandle::isHTMLInputElementAutofilled): Deleted. 80 (WebKit::InjectedBundleNodeHandle::setHTMLInputElementAutofilled): Deleted. 81 * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h: 82 Fix-up InjectedBundleNodeHandle to store its underlying Node in a Ref, rather than a RefPtr. 83 Add helpers to implement the new SPI for WKBundleNodeHandleRef. 84 1 85 2015-03-11 Timothy Horton <timothy_horton@apple.com> 2 86 -
trunk/Source/WebKit2/UIProcess/API/APIUIClient.h
r177699 r181408 156 156 virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) { } 157 157 #endif 158 159 virtual void didClickAutoFillButton(WebKit::WebPageProxy&, API::Object*) { } 158 160 }; 159 161 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r180411 r181408 1745 1745 m_client.isPlayingAudioDidChange(toAPI(&page), m_client.base.clientInfo); 1746 1746 } 1747 1748 virtual void didClickAutoFillButton(WebPageProxy& page, API::Object* userInfo) override 1749 { 1750 if (!m_client.didClickAutoFillButton) 1751 return; 1752 1753 m_client.didClickAutoFillButton(toAPI(&page), toAPI(userInfo), m_client.base.clientInfo); 1754 } 1747 1755 }; 1748 1756 -
trunk/Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
r177747 r181408 92 92 typedef void (*WKPageIsPlayingAudioDidChangeCallback)(WKPageRef page, const void* clientInfo); 93 93 typedef void (*WKPageDecidePolicyForUserMediaPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKUserMediaPermissionRequestRef permissionRequest, const void* clientInfo); 94 95 // Deprecated 94 typedef void (*WKPageDidClickAutoFillButtonCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo); 95 96 // Deprecated 96 97 typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo); 97 98 typedef void (*WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo); … … 446 447 // Version 5. 447 448 WKPageDecidePolicyForUserMediaPermissionRequestCallback decidePolicyForUserMediaPermissionRequest; 449 WKPageDidClickAutoFillButtonCallback didClickAutoFillButton; 448 450 } WKPageUIClientV5; 449 451 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r181317 r181408 5593 5593 } 5594 5594 5595 void WebPageProxy::handleAutoFillButtonClick(const UserData& userData) 5596 { 5597 m_uiClient->didClickAutoFillButton(*this, m_process->transformHandlesToObjects(userData.object()).get()); 5598 } 5599 5595 5600 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r181317 r181408 1385 1385 #endif 1386 1386 1387 void handleAutoFillButtonClick(const UserData&); 1388 1387 1389 PageClient& m_pageClient; 1388 1390 std::unique_ptr<API::LoaderClient> m_loaderClient; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r181023 r181408 424 424 DidPerformActionMenuHitTest(struct WebKit::ActionMenuHitTestResult result, bool forImmediateAction, WebKit::UserData userData) 425 425 #endif 426 427 HandleAutoFillButtonClick(WebKit::UserData userData); 426 428 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h
r177639 r181408 34 34 35 35 namespace WebKit { 36 class InjectedBundleNodeHandle; 36 37 class WebFrame; 37 38 class WebPage; … … 90 91 virtual void didRecognizeLongMousePress(WebKit::WebPage*, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); } 91 92 virtual void didCancelTrackingPotentialLongMousePress(WebKit::WebPage*, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); } 93 94 virtual void didClickAutoFillButton(WebKit::WebPage&, WebKit::InjectedBundleNodeHandle&, RefPtr<API::Object>&) { } 92 95 }; 93 96 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm
r166936 r181408 71 71 - (BOOL)HTMLInputElementIsAutoFilled 72 72 { 73 return _nodeHandle->isHTMLInputElementAuto filled();73 return _nodeHandle->isHTMLInputElementAutoFilled(); 74 74 } 75 75 76 76 - (void)setHTMLInputElementIsAutoFilled:(BOOL)isAutoFilled 77 77 { 78 _nodeHandle->setHTMLInputElementAuto filled(isAutoFilled);78 _nodeHandle->setHTMLInputElementAutoFilled(isAutoFilled); 79 79 } 80 80 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
r172780 r181408 81 81 } 82 82 83 bool WKBundleNodeHandleGetHTMLInputElementAuto filled(WKBundleNodeHandleRef htmlInputElementHandleRef)83 bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef) 84 84 { 85 return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAuto filled();85 return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); 86 86 } 87 87 88 void WKBundleNodeHandleSetHTMLInputElementAuto filled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled)88 void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) 89 89 { 90 toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); 90 toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); 91 } 92 93 bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef) 94 { 95 return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFillButtonEnabled(); 96 } 97 98 void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled) 99 { 100 toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(enabled); 101 } 102 103 WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandleRef) 104 { 105 return toAPI(toImpl(htmlInputElementHandleRef)->htmlInputElementAutoFillButtonBounds()); 91 106 } 92 107 … … 124 139 return toAPI(frame.release().leakRef()); 125 140 } 141 142 // Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef). 143 bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) 144 { 145 return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); 146 } 147 148 // Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool). 149 void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) 150 { 151 toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); 152 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h
r172780 r181408 53 53 /* HTMLInputElement Specific Operations */ 54 54 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); 55 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); 56 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); 55 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle); 56 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); 57 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle); 58 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle, bool enabled); 59 WK_EXPORT WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandle); 57 60 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle); 58 61 … … 72 75 WK_EXPORT WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNodeHandleRef htmlIFrameElementHandle); 73 76 77 78 /* Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef) */ 79 WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); 80 /* Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool) */ 81 WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); 82 74 83 #ifdef __cplusplus 75 84 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h
r177747 r181408 58 58 typedef void (*WKBundlePageDidRecognizeLongMousePressCallback)(WKBundlePageRef page, WKTypeRef* userData, const void *clientInfo); 59 59 typedef void (*WKBundlePageDidCancelTrackingPotentialLongMousePressCallback)(WKBundlePageRef page, WKTypeRef* userData, const void *clientInfo); 60 typedef void (*WKBundlePageDidClickAutoFillButtonCallback)(WKBundlePageRef page, WKBundleNodeHandleRef inputElement, WKTypeRef* userData, const void *clientInfo); 60 61 61 62 typedef struct WKBundlePageUIClientBase { … … 170 171 WKBundlePageDidRecognizeLongMousePressCallback didRecognizeLongMousePress; 171 172 WKBundlePageDidCancelTrackingPotentialLongMousePressCallback didCancelTrackingPotentialLongMousePress; 173 174 WKBundlePageDidClickAutoFillButtonCallback didClickAutoFillButton; 172 175 } WKBundlePageUIClientV3; 173 176 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
r174117 r181408 69 69 } 70 70 71 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object)71 RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object) 72 72 { 73 73 Node* node = JSNode::toWrapped(toJS(object)); … … 75 75 } 76 76 77 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* node)77 RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node* node) 78 78 { 79 79 if (!node) 80 return 0; 81 82 DOMHandleCache::AddResult result = domHandleCache().add(node, nullptr); 80 return nullptr; 81 82 return InjectedBundleNodeHandle::getOrCreate(*node); 83 } 84 85 Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node& node) 86 { 87 DOMHandleCache::AddResult result = domHandleCache().add(&node, nullptr); 83 88 if (!result.isNewEntry) 84 return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->value);85 86 Ref Ptr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node);87 result.iterator->value = nodeHandle. get();88 return nodeHandle .release();89 } 90 91 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::create(Node*node)92 { 93 return adoptRef( new InjectedBundleNodeHandle(node));94 } 95 96 InjectedBundleNodeHandle::InjectedBundleNodeHandle(Node *node)89 return Ref<InjectedBundleNodeHandle>(*result.iterator->value); 90 91 Ref<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node); 92 result.iterator->value = nodeHandle.ptr(); 93 return nodeHandle; 94 } 95 96 Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::create(Node& node) 97 { 98 return adoptRef(*new InjectedBundleNodeHandle(node)); 99 } 100 101 InjectedBundleNodeHandle::InjectedBundleNodeHandle(Node& node) 97 102 : m_node(node) 98 103 { … … 101 106 InjectedBundleNodeHandle::~InjectedBundleNodeHandle() 102 107 { 103 domHandleCache().remove(m_node. get());104 } 105 106 Node* InjectedBundleNodeHandle::coreNode() const107 { 108 return m_node. get();109 } 110 111 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::document()112 { 113 return getOrCreate( &m_node->document());108 domHandleCache().remove(m_node.ptr()); 109 } 110 111 Node* InjectedBundleNodeHandle::coreNode() 112 { 113 return m_node.ptr(); 114 } 115 116 Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::document() 117 { 118 return getOrCreate(m_node->document()); 114 119 } 115 120 … … 117 122 // Note: These should only be operations that are not exposed to JavaScript. 118 123 119 IntRect InjectedBundleNodeHandle::elementBounds() const120 { 121 if (!is<Element>( *m_node))124 IntRect InjectedBundleNodeHandle::elementBounds() 125 { 126 if (!is<Element>(m_node)) 122 127 return IntRect(); 123 128 124 return downcast<Element>( *m_node).boundsInRootViewSpace();129 return downcast<Element>(m_node.get()).boundsInRootViewSpace(); 125 130 } 126 131 127 IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const128 { 129 return m_node .get()->pixelSnappedRenderRect(isReplaced);132 IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) 133 { 134 return m_node->pixelSnappedRenderRect(isReplaced); 130 135 } 131 136 … … 167 172 Frame* frame = m_node->document().frame(); 168 173 if (!frame) 169 return 0;174 return nullptr; 170 175 171 176 FrameView* frameView = frame->view(); 172 177 if (!frameView) 173 return 0;178 return nullptr; 174 179 175 180 m_node->document().updateLayout(); … … 177 182 RenderObject* renderer = m_node->renderer(); 178 183 if (!renderer) 179 return 0;184 return nullptr; 180 185 181 186 LayoutRect topLevelRect; 182 187 IntRect paintingRect = snappedIntRect(renderer->paintingRootRect(topLevelRect)); 183 188 184 frameView->setNodeToDraw(m_node. get());189 frameView->setNodeToDraw(m_node.ptr()); 185 190 RefPtr<WebImage> image = imageForRect(frameView, paintingRect, options); 186 191 frameView->setNodeToDraw(0); … … 189 194 } 190 195 191 PassRefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange() const192 { 193 VisiblePosition start = firstPositionInNode(m_node. get());194 VisiblePosition end = lastPositionInNode(m_node. get());196 PassRefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange() 197 { 198 VisiblePosition start = firstPositionInNode(m_node.ptr()); 199 VisiblePosition end = lastPositionInNode(m_node.ptr()); 195 200 196 201 RefPtr<Range> range = makeRange(start, end); … … 200 205 void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value) 201 206 { 202 if (!is<HTMLInputElement>( *m_node))207 if (!is<HTMLInputElement>(m_node)) 203 208 return; 204 209 205 downcast<HTMLInputElement>( *m_node).setValueForUser(value);206 } 207 208 bool InjectedBundleNodeHandle::isHTMLInputElementAuto filled() const209 { 210 if (!is<HTMLInputElement>( *m_node))210 downcast<HTMLInputElement>(m_node.get()).setValueForUser(value); 211 } 212 213 bool InjectedBundleNodeHandle::isHTMLInputElementAutoFilled() const 214 { 215 if (!is<HTMLInputElement>(m_node)) 211 216 return false; 212 217 213 return downcast<HTMLInputElement>( *m_node).isAutofilled();214 } 215 216 void InjectedBundleNodeHandle::setHTMLInputElementAuto filled(bool filled)217 { 218 if (!is<HTMLInputElement>( *m_node))218 return downcast<HTMLInputElement>(m_node.get()).isAutoFilled(); 219 } 220 221 void InjectedBundleNodeHandle::setHTMLInputElementAutoFilled(bool filled) 222 { 223 if (!is<HTMLInputElement>(m_node)) 219 224 return; 220 225 221 downcast<HTMLInputElement>(*m_node).setAutofilled(filled); 226 downcast<HTMLInputElement>(m_node.get()).setAutoFilled(filled); 227 } 228 229 bool InjectedBundleNodeHandle::isHTMLInputElementAutoFillButtonEnabled() const 230 { 231 if (!is<HTMLInputElement>(m_node)) 232 return false; 233 234 return downcast<HTMLInputElement>(m_node.get()).showAutoFillButton(); 235 } 236 237 void InjectedBundleNodeHandle::setHTMLInputElementAutoFillButtonEnabled(bool filled) 238 { 239 if (!is<HTMLInputElement>(m_node)) 240 return; 241 242 downcast<HTMLInputElement>(m_node.get()).setShowAutoFillButton(filled); 243 } 244 245 IntRect InjectedBundleNodeHandle::htmlInputElementAutoFillButtonBounds() 246 { 247 if (!is<HTMLInputElement>(m_node)) 248 return IntRect(); 249 250 auto autoFillButton = downcast<HTMLInputElement>(m_node.get()).autoFillButtonElement(); 251 if (!autoFillButton) 252 return IntRect(); 253 254 return autoFillButton->boundsInRootViewSpace(); 222 255 } 223 256 224 257 bool InjectedBundleNodeHandle::htmlInputElementLastChangeWasUserEdit() 225 258 { 226 if (!is<HTMLInputElement>( *m_node))227 return false; 228 229 return downcast<HTMLInputElement>( *m_node).lastChangeWasUserEdit();259 if (!is<HTMLInputElement>(m_node)) 260 return false; 261 262 return downcast<HTMLInputElement>(m_node.get()).lastChangeWasUserEdit(); 230 263 } 231 264 232 265 bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit() 233 266 { 234 if (!is<HTMLTextAreaElement>( *m_node))235 return false; 236 237 return downcast<HTMLTextAreaElement>( *m_node).lastChangeWasUserEdit();267 if (!is<HTMLTextAreaElement>(m_node)) 268 return false; 269 270 return downcast<HTMLTextAreaElement>(m_node.get()).lastChangeWasUserEdit(); 238 271 } 239 272 240 273 bool InjectedBundleNodeHandle::isTextField() const 241 274 { 242 return is<HTMLInputElement>(*m_node) && downcast<HTMLInputElement>(*m_node).isText(); 275 if (!is<HTMLInputElement>(m_node)) 276 return false; 277 278 return downcast<HTMLInputElement>(m_node.get()).isText(); 243 279 } 244 280 245 281 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove() 246 282 { 247 if (! m_node->hasTagName(tdTag))248 return nullptr; 249 250 return getOrCreate( static_cast<HTMLTableCellElement&>(*m_node).cellAbove());283 if (!is<HTMLTableCellElement>(m_node)) 284 return nullptr; 285 286 return getOrCreate(downcast<HTMLTableCellElement>(m_node.get()).cellAbove()); 251 287 } 252 288 … … 256 292 return nullptr; 257 293 258 Frame* frame = static_cast<Document*>(m_node.get())->frame();294 Frame* frame = downcast<Document>(m_node.get()).frame(); 259 295 if (!frame) 260 296 return nullptr; … … 265 301 PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame() 266 302 { 267 if (! m_node->hasTagName(frameTag))268 return nullptr; 269 270 Frame* frame = static_cast<HTMLFrameElement*>(m_node.get())->contentFrame();303 if (!is<HTMLFrameElement>(m_node)) 304 return nullptr; 305 306 Frame* frame = downcast<HTMLFrameElement>(m_node.get()).contentFrame(); 271 307 if (!frame) 272 308 return nullptr; … … 277 313 PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame() 278 314 { 279 if (!is<HTMLIFrameElement>( *m_node))280 return nullptr; 281 282 Frame* frame = downcast<HTMLIFrameElement>( *m_node).contentFrame();315 if (!is<HTMLIFrameElement>(m_node)) 316 return nullptr; 317 318 Frame* frame = downcast<HTMLIFrameElement>(m_node.get()).contentFrame(); 283 319 if (!frame) 284 320 return nullptr; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h
r172780 r181408 48 48 class InjectedBundleNodeHandle : public API::ObjectImpl<API::Object::Type::BundleNodeHandle> { 49 49 public: 50 static PassRefPtr<InjectedBundleNodeHandle> getOrCreate(JSContextRef, JSObjectRef); 51 static PassRefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*); 50 static RefPtr<InjectedBundleNodeHandle> getOrCreate(JSContextRef, JSObjectRef); 51 static RefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*); 52 static Ref<InjectedBundleNodeHandle> getOrCreate(WebCore::Node&); 52 53 53 54 virtual ~InjectedBundleNodeHandle(); 54 55 55 WebCore::Node* coreNode() const;56 WebCore::Node* coreNode(); 56 57 57 58 // Convenience DOM Operations 58 PassRefPtr<InjectedBundleNodeHandle> document();59 Ref<InjectedBundleNodeHandle> document(); 59 60 60 61 // Additional DOM Operations 61 62 // Note: These should only be operations that are not exposed to JavaScript. 62 WebCore::IntRect elementBounds() const;63 WebCore::IntRect renderRect(bool*) const;63 WebCore::IntRect elementBounds(); 64 WebCore::IntRect renderRect(bool*); 64 65 PassRefPtr<WebImage> renderedImage(SnapshotOptions); 65 PassRefPtr<InjectedBundleRangeHandle> visibleRange() const;66 PassRefPtr<InjectedBundleRangeHandle> visibleRange(); 66 67 void setHTMLInputElementValueForUser(const String&); 67 bool isHTMLInputElementAutofilled() const; 68 void setHTMLInputElementAutofilled(bool); 68 bool isHTMLInputElementAutoFilled() const; 69 void setHTMLInputElementAutoFilled(bool); 70 bool isHTMLInputElementAutoFillButtonEnabled() const; 71 void setHTMLInputElementAutoFillButtonEnabled(bool); 72 WebCore::IntRect htmlInputElementAutoFillButtonBounds(); 69 73 bool htmlInputElementLastChangeWasUserEdit(); 70 74 bool htmlTextAreaElementLastChangeWasUserEdit(); … … 78 82 79 83 private: 80 static PassRefPtr<InjectedBundleNodeHandle> create(WebCore::Node*);81 InjectedBundleNodeHandle(WebCore::Node *);84 static Ref<InjectedBundleNodeHandle> create(WebCore::Node&); 85 InjectedBundleNodeHandle(WebCore::Node&); 82 86 83 Ref Ptr<WebCore::Node> m_node;87 Ref<WebCore::Node> m_node; 84 88 }; 85 89 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp
r177671 r181408 29 29 #include "APISecurityOrigin.h" 30 30 #include "InjectedBundleHitTestResult.h" 31 #include "InjectedBundleNodeHandle.h" 31 32 #include "WKAPICast.h" 32 33 #include "WKBundleAPICast.h" … … 234 235 } 235 236 237 void InjectedBundlePageUIClient::didClickAutoFillButton(WebPage& page, InjectedBundleNodeHandle& nodeHandle, RefPtr<API::Object>& userData) 238 { 239 if (!m_client.didClickAutoFillButton) 240 return; 241 242 WKTypeRef userDataToPass = nullptr; 243 m_client.didClickAutoFillButton(toAPI(&page), toAPI(&nodeHandle), &userDataToPass, m_client.base.clientInfo); 244 userData = adoptRef(toImpl(userDataToPass)); 245 } 246 236 247 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h
r177639 r181408 74 74 void didRecognizeLongMousePress(WebPage*, RefPtr<API::Object>& userData) override; 75 75 void didCancelTrackingPotentialLongMousePress(WebPage*, RefPtr<API::Object>& userData) override; 76 77 void didClickAutoFillButton(WebPage&, InjectedBundleNodeHandle&, RefPtr<API::Object>& userData) override; 76 78 }; 77 79 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r181023 r181408 31 31 #include "DrawingArea.h" 32 32 #include "InjectedBundleNavigationAction.h" 33 #include "InjectedBundleNodeHandle.h" 33 34 #include "LayerTreeHost.h" 34 35 #include "NavigationActionData.h" … … 1102 1103 } 1103 1104 1105 void WebChromeClient::handleAutoFillButtonClick(HTMLInputElement& inputElement) 1106 { 1107 RefPtr<API::Object> userData; 1108 1109 // Notify the bundle client. 1110 auto nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement); 1111 m_page->injectedBundleUIClient().didClickAutoFillButton(*m_page, nodeHandle.get(), userData); 1112 1113 // Notify the UIProcess. 1114 m_page->send(Messages::WebPageProxy::HandleAutoFillButtonClick(UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); 1115 } 1116 1104 1117 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r180607 r181408 311 311 virtual bool shouldDispatchFakeMouseMoveEvents() const override; 312 312 313 virtual void handleAutoFillButtonClick(WebCore::HTMLInputElement&) override; 314 313 315 String m_cachedToolTip; 314 316 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; -
trunk/Tools/ChangeLog
r181405 r181408 1 2015-03-10 Sam Weinig <sam@webkit.org> 2 3 Allow adding a button in input elements for auto fill related functionality 4 <rdar://problem/19782066> 5 https://bugs.webkit.org/show_bug.cgi?id=142564 6 7 Reviewed by Anders Carlsson. 8 9 * WebKitTestRunner/TestController.cpp: 10 (WTR::TestController::createOtherPage): 11 (WTR::TestController::createWebViewWithOptions): 12 Update for new callback. 13 1 14 2015-03-11 Benjamin Poulain <bpoulain@apple.com> 2 15 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r181071 r181408 257 257 0, // isPlayingAudioDidChange 258 258 decidePolicyForUserMediaPermissionRequest, 259 0, // didClickAutofillButton 259 260 }; 260 261 WKPageSetPageUIClient(newPage, &otherPageUIClient.base); … … 494 495 0, // isPlayingAudioDidChange 495 496 decidePolicyForUserMediaPermissionRequest, 497 0, // didClickAutofillButton 496 498 }; 497 499 WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
Note: See TracChangeset
for help on using the changeset viewer.