Changeset 225837 in webkit
- Timestamp:
- Dec 12, 2017 8:05:33 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225836 r225837 1 2017-12-12 Zalan Bujtas <zalan@apple.com> 2 3 is<HTMLTextFormControlElement> reports the input type. 4 https://bugs.webkit.org/show_bug.cgi?id=180721 5 <rdar://problem/36005123> 6 7 Reviewed by Ryosuke Niwa. 8 9 This patch ensures that is<HTMLTextFormControlElement> consistently returns true even 10 when the input type changes from text to non-text (checkbox etc). 11 12 * accessibility/AccessibilityObject.cpp: 13 (WebCore::AccessibilityObject::selectText): 14 * dom/Element.h: 15 (WebCore::Element::isTextFormControlElement const): 16 (WebCore::Element::isTextField const): 17 (WebCore::Element::isTextFormControl const): Deleted. 18 * editing/Editor.cpp: 19 (WebCore::Editor::selectionForCommand): 20 (WebCore::Editor::setBaseWritingDirection): 21 (WebCore::findFirstMarkable): 22 * editing/FrameSelection.cpp: 23 (WebCore::FrameSelection::selectAll): 24 * html/FormController.cpp: 25 (WebCore::FormController::formElementsCharacterCount const): 26 * html/HTMLElement.cpp: 27 (WebCore::HTMLElement::directionality const): 28 * html/HTMLInputElement.h: 29 * html/HTMLTextAreaElement.h: 30 * html/HTMLTextFormControlElement.cpp: 31 (WebCore::HTMLTextFormControlElement::didEditInnerTextValue): 32 (WebCore::HTMLTextFormControlElement::selectedText const): 33 (WebCore::HTMLTextFormControlElement::setSelectionRange): 34 (WebCore::HTMLTextFormControlElement::selectionStart const): 35 (WebCore::HTMLTextFormControlElement::computeSelectionStart const): 36 (WebCore::HTMLTextFormControlElement::selectionEnd const): 37 (WebCore::HTMLTextFormControlElement::computeSelectionEnd const): 38 (WebCore::HTMLTextFormControlElement::selectionDirection const): 39 (WebCore::HTMLTextFormControlElement::computeSelectionDirection const): 40 (WebCore::HTMLTextFormControlElement::selection const): 41 (WebCore::HTMLTextFormControlElement::selectionChanged): 42 (WebCore::HTMLTextFormControlElement::lastChangeWasUserEdit const): 43 (WebCore::HTMLTextFormControlElement::setInnerTextValue): 44 (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const): 45 (WebCore::enclosingTextFormControl): 46 * html/HTMLTextFormControlElement.h: 47 (isType): 48 * rendering/HitTestResult.cpp: 49 (WebCore::HitTestResult::isOverTextInsideFormControlElement const): 50 1 51 2017-12-12 Dean Jackson <dino@apple.com> 2 52 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r225511 r225837 829 829 if (RefPtr<Range> closestStringRange = rangeClosestToRange(selectedStringRange.get(), WTFMove(closestAfterStringRange), WTFMove(closestBeforeStringRange))) { 830 830 // If the search started within a text control, ensure that the result is inside that element. 831 if (element() && element()->isTextF ormControl()) {831 if (element() && element()->isTextField()) { 832 832 if (!closestStringRange->startContainer().isDescendantOrShadowDescendantOf(element()) || !closestStringRange->endContainer().isDescendantOrShadowDescendantOf(element())) 833 833 return String(); -
trunk/Source/WebCore/cssjit/SelectorCompiler.cpp
r221788 r225837 3345 3345 static bool makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown(const Element* element, SelectorChecker::CheckingContext* checkingContext) 3346 3346 { 3347 if (is<HTMLTextFormControlElement>(*element) ) {3347 if (is<HTMLTextFormControlElement>(*element) && element->isTextField()) { 3348 3348 if (checkingContext->resolvingMode == SelectorChecker::Mode::ResolvingStyle) 3349 3349 checkingContext->styleRelations.append({ *element, Style::Relation::Unique, 1 }); -
trunk/Source/WebCore/dom/Element.h
r225223 r225837 437 437 virtual bool isFormControlElement() const { return false; } 438 438 virtual bool isSpinButtonElement() const { return false; } 439 virtual bool isTextFormControl() const { return false; } 439 virtual bool isTextFormControlElement() const { return false; } 440 virtual bool isTextField() const { return false; } 440 441 virtual bool isOptionalFormControl() const { return false; } 441 442 virtual bool isRequiredFormControl() const { return false; } -
trunk/Source/WebCore/editing/Editor.cpp
r225429 r225837 244 244 // If the target is a text control, and the current selection is outside of its shadow tree, 245 245 // then use the saved selection for that text control. 246 if (is< HTMLTextFormControlElement>(event->target())) {246 if (is<Element>(event->target()) && downcast<Element>(*event->target()).isTextField()) { 247 247 auto& target = downcast<HTMLTextFormControlElement>(*event->target()); 248 248 auto start = selection.start(); … … 1722 1722 1723 1723 Element* focusedElement = document().focusedElement(); 1724 if ( is<HTMLTextFormControlElement>(focusedElement)) {1724 if (focusedElement && focusedElement->isTextField()) { 1725 1725 if (direction == NaturalWritingDirection) 1726 1726 return; … … 3627 3627 if (node->renderer()->isTextOrLineBreak()) 3628 3628 return node; 3629 if (is< HTMLTextFormControlElement>(*node))3629 if (is<Element>(*node) && downcast<Element>(*node).isTextField()) 3630 3630 node = downcast<HTMLTextFormControlElement>(*node).visiblePositionForIndex(1).deepEquivalent().deprecatedNode(); 3631 3631 else if (node->firstChild()) -
trunk/Source/WebCore/editing/FrameSelection.cpp
r225117 r225837 1923 1923 } else { 1924 1924 if (m_selection.isNone() && focusedElement) { 1925 if ( is<HTMLTextFormControlElement>(*focusedElement)) {1925 if (focusedElement->isTextField()) { 1926 1926 downcast<HTMLTextFormControlElement>(*focusedElement).select(); 1927 1927 return; -
trunk/Source/WebCore/html/FormController.cpp
r225037 r225837 346 346 unsigned count = 0; 347 347 for (auto& element : m_formElementsWithState) { 348 if (element->isTextF ormControl())348 if (element->isTextField()) 349 349 count += element->saveFormControlState()[0].length(); 350 350 } -
trunk/Source/WebCore/html/HTMLElement.cpp
r224390 r225837 794 794 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const 795 795 { 796 if (is <HTMLTextFormControlElement>(*this)) {796 if (isTextField()) { 797 797 HTMLTextFormControlElement& textElement = downcast<HTMLTextFormControlElement>(const_cast<HTMLElement&>(*this)); 798 798 bool hasStrongDirectionality; … … 807 807 // Skip bdi, script, style and text form controls. 808 808 if (equalLettersIgnoringASCIICase(node->nodeName(), "bdi") || node->hasTagName(scriptTag) || node->hasTagName(styleTag) 809 || (is<Element>(*node) && downcast<Element>(*node).isTextF ormControl())) {809 || (is<Element>(*node) && downcast<Element>(*node).isTextField())) { 810 810 node = NodeTraversal::nextSkippingChildren(*node, this); 811 811 continue; -
trunk/Source/WebCore/html/HTMLInputElement.h
r225680 r225837 98 98 99 99 bool isRadioButton() const; 100 WEBCORE_EXPORT bool isTextField() const ;100 WEBCORE_EXPORT bool isTextField() const final; 101 101 WEBCORE_EXPORT bool isSearchField() const; 102 102 bool isInputTypeHidden() const; … … 371 371 void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) final; 372 372 bool shouldUseInputMethod() final; 373 374 bool isTextFormControl() const final { return isTextField(); }375 373 376 374 bool canTriggerImplicitSubmission() const final { return isTextField(); } -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r224316 r225837 103 103 void restoreFormControlState(const FormControlState&) final; 104 104 105 bool isTextF ormControl() const final { return true; }105 bool isTextField() const final { return true; } 106 106 107 107 void childrenChanged(const ChildChange&) final; -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r224320 r225837 108 108 void HTMLTextFormControlElement::didEditInnerTextValue() 109 109 { 110 if (!isTextF ormControl())110 if (!isTextField()) 111 111 return; 112 112 … … 199 199 String HTMLTextFormControlElement::selectedText() const 200 200 { 201 if (!isTextF ormControl())201 if (!isTextField()) 202 202 return String(); 203 203 return value().substring(selectionStart(), selectionEnd() - selectionStart()); … … 285 285 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction, const AXTextStateChangeIntent& intent) 286 286 { 287 if (!isTextF ormControl())287 if (!isTextField()) 288 288 return; 289 289 … … 344 344 int HTMLTextFormControlElement::selectionStart() const 345 345 { 346 if (!isTextF ormControl())346 if (!isTextField()) 347 347 return 0; 348 348 if (document().focusedElement() != this && hasCachedSelection()) … … 354 354 int HTMLTextFormControlElement::computeSelectionStart() const 355 355 { 356 ASSERT(isTextF ormControl());356 ASSERT(isTextField()); 357 357 RefPtr<Frame> frame = document().frame(); 358 358 if (!frame) … … 364 364 int HTMLTextFormControlElement::selectionEnd() const 365 365 { 366 if (!isTextF ormControl())366 if (!isTextField()) 367 367 return 0; 368 368 if (document().focusedElement() != this && hasCachedSelection()) … … 373 373 int HTMLTextFormControlElement::computeSelectionEnd() const 374 374 { 375 ASSERT(isTextF ormControl());375 ASSERT(isTextField()); 376 376 RefPtr<Frame> frame = document().frame(); 377 377 if (!frame) … … 402 402 const AtomicString& HTMLTextFormControlElement::selectionDirection() const 403 403 { 404 if (!isTextF ormControl())404 if (!isTextField()) 405 405 return directionString(SelectionHasNoDirection); 406 406 if (document().focusedElement() != this && hasCachedSelection()) … … 412 412 TextFieldSelectionDirection HTMLTextFormControlElement::computeSelectionDirection() const 413 413 { 414 ASSERT(isTextF ormControl());414 ASSERT(isTextField()); 415 415 RefPtr<Frame> frame = document().frame(); 416 416 if (!frame) … … 434 434 RefPtr<Range> HTMLTextFormControlElement::selection() const 435 435 { 436 if (!renderer() || !isTextF ormControl() || !hasCachedSelection())436 if (!renderer() || !isTextField() || !hasCachedSelection()) 437 437 return nullptr; 438 438 … … 480 480 void HTMLTextFormControlElement::selectionChanged(bool shouldFireSelectEvent) 481 481 { 482 if (!isTextF ormControl())482 if (!isTextField()) 483 483 return; 484 484 … … 520 520 bool HTMLTextFormControlElement::lastChangeWasUserEdit() const 521 521 { 522 if (!isTextF ormControl())522 if (!isTextField()) 523 523 return false; 524 524 return m_lastChangeWasUserEdit; … … 553 553 return; 554 554 555 ASSERT(isTextF ormControl());555 ASSERT(isTextField()); 556 556 String previousValue = innerTextValueFrom(*innerText); 557 557 bool textIsChanged = value != previousValue; … … 686 686 // FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer. 687 687 // While we have no evidence this has ever been a practical problem, it would be best to fix it some day. 688 if (!isTextF ormControl())688 if (!isTextField()) 689 689 return value(); 690 690 … … 740 740 return nullptr; 741 741 RefPtr<Element> ancestor = container->shadowHost(); 742 return ancestor && is<HTMLTextFormControlElement>(*ancestor) ? downcast<HTMLTextFormControlElement>(ancestor.get()) : nullptr;742 return ancestor && ancestor->isTextField() ? downcast<HTMLTextFormControlElement>(ancestor.get()) : nullptr; 743 743 } 744 744 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r224740 r225837 133 133 TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); } 134 134 135 bool isTextFormControlElement() const final { return true; } 136 135 137 int computeSelectionStart() const; 136 138 int computeSelectionEnd() const; … … 170 172 171 173 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTextFormControlElement) 172 static bool isType(const WebCore::Element& element) { return element.isTextFormControl (); }174 static bool isType(const WebCore::Element& element) { return element.isTextFormControlElement(); } 173 175 static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); } 174 176 static bool isType(const WebCore::EventTarget& target) { return is<WebCore::Node>(target) && isType(downcast<WebCore::Node>(target)); } -
trunk/Source/WebCore/rendering/HitTestResult.cpp
r225117 r225837 573 573 return false; 574 574 575 if (!is< HTMLTextFormControlElement>(*node))575 if (!is<Element>(*node) || !downcast<Element>(*node).isTextField()) 576 576 return false; 577 577
Note: See TracChangeset
for help on using the changeset viewer.