Diff
Modified: trunk/Source/WebCore/ChangeLog (225836 => 225837)
--- trunk/Source/WebCore/ChangeLog 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/ChangeLog 2017-12-13 04:05:33 UTC (rev 225837)
@@ -1,3 +1,53 @@
+2017-12-12 Zalan Bujtas <za...@apple.com>
+
+ is<HTMLTextFormControlElement> reports the input type.
+ https://bugs.webkit.org/show_bug.cgi?id=180721
+ <rdar://problem/36005123>
+
+ Reviewed by Ryosuke Niwa.
+
+ This patch ensures that is<HTMLTextFormControlElement> consistently returns true even
+ when the input type changes from text to non-text (checkbox etc).
+
+ * accessibility/AccessibilityObject.cpp:
+ (WebCore::AccessibilityObject::selectText):
+ * dom/Element.h:
+ (WebCore::Element::isTextFormControlElement const):
+ (WebCore::Element::isTextField const):
+ (WebCore::Element::isTextFormControl const): Deleted.
+ * editing/Editor.cpp:
+ (WebCore::Editor::selectionForCommand):
+ (WebCore::Editor::setBaseWritingDirection):
+ (WebCore::findFirstMarkable):
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::selectAll):
+ * html/FormController.cpp:
+ (WebCore::FormController::formElementsCharacterCount const):
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::directionality const):
+ * html/HTMLInputElement.h:
+ * html/HTMLTextAreaElement.h:
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::HTMLTextFormControlElement::didEditInnerTextValue):
+ (WebCore::HTMLTextFormControlElement::selectedText const):
+ (WebCore::HTMLTextFormControlElement::setSelectionRange):
+ (WebCore::HTMLTextFormControlElement::selectionStart const):
+ (WebCore::HTMLTextFormControlElement::computeSelectionStart const):
+ (WebCore::HTMLTextFormControlElement::selectionEnd const):
+ (WebCore::HTMLTextFormControlElement::computeSelectionEnd const):
+ (WebCore::HTMLTextFormControlElement::selectionDirection const):
+ (WebCore::HTMLTextFormControlElement::computeSelectionDirection const):
+ (WebCore::HTMLTextFormControlElement::selection const):
+ (WebCore::HTMLTextFormControlElement::selectionChanged):
+ (WebCore::HTMLTextFormControlElement::lastChangeWasUserEdit const):
+ (WebCore::HTMLTextFormControlElement::setInnerTextValue):
+ (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
+ (WebCore::enclosingTextFormControl):
+ * html/HTMLTextFormControlElement.h:
+ (isType):
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::isOverTextInsideFormControlElement const):
+
2017-12-12 Dean Jackson <d...@apple.com>
Unify some WebGL sources
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (225836 => 225837)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -828,7 +828,7 @@
// Determine which candidate is closest to the selection and perform the activity.
if (RefPtr<Range> closestStringRange = rangeClosestToRange(selectedStringRange.get(), WTFMove(closestAfterStringRange), WTFMove(closestBeforeStringRange))) {
// If the search started within a text control, ensure that the result is inside that element.
- if (element() && element()->isTextFormControl()) {
+ if (element() && element()->isTextField()) {
if (!closestStringRange->startContainer().isDescendantOrShadowDescendantOf(element()) || !closestStringRange->endContainer().isDescendantOrShadowDescendantOf(element()))
return String();
}
Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (225836 => 225837)
--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -3344,7 +3344,7 @@
static bool makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown(const Element* element, SelectorChecker::CheckingContext* checkingContext)
{
- if (is<HTMLTextFormControlElement>(*element)) {
+ if (is<HTMLTextFormControlElement>(*element) && element->isTextField()) {
if (checkingContext->resolvingMode == SelectorChecker::Mode::ResolvingStyle)
checkingContext->styleRelations.append({ *element, Style::Relation::Unique, 1 });
return downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
Modified: trunk/Source/WebCore/dom/Element.h (225836 => 225837)
--- trunk/Source/WebCore/dom/Element.h 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/dom/Element.h 2017-12-13 04:05:33 UTC (rev 225837)
@@ -436,7 +436,8 @@
virtual bool isFormControlElement() const { return false; }
virtual bool isSpinButtonElement() const { return false; }
- virtual bool isTextFormControl() const { return false; }
+ virtual bool isTextFormControlElement() const { return false; }
+ virtual bool isTextField() const { return false; }
virtual bool isOptionalFormControl() const { return false; }
virtual bool isRequiredFormControl() const { return false; }
virtual bool isInRange() const { return false; }
Modified: trunk/Source/WebCore/editing/Editor.cpp (225836 => 225837)
--- trunk/Source/WebCore/editing/Editor.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/editing/Editor.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -243,7 +243,7 @@
return selection;
// If the target is a text control, and the current selection is outside of its shadow tree,
// then use the saved selection for that text control.
- if (is<HTMLTextFormControlElement>(event->target())) {
+ if (is<Element>(event->target()) && downcast<Element>(*event->target()).isTextField()) {
auto& target = downcast<HTMLTextFormControlElement>(*event->target());
auto start = selection.start();
if (start.isNull() || &target != enclosingTextFormControl(start)) {
@@ -1721,7 +1721,7 @@
#endif
Element* focusedElement = document().focusedElement();
- if (is<HTMLTextFormControlElement>(focusedElement)) {
+ if (focusedElement && focusedElement->isTextField()) {
if (direction == NaturalWritingDirection)
return;
@@ -3626,7 +3626,7 @@
return nullptr;
if (node->renderer()->isTextOrLineBreak())
return node;
- if (is<HTMLTextFormControlElement>(*node))
+ if (is<Element>(*node) && downcast<Element>(*node).isTextField())
node = downcast<HTMLTextFormControlElement>(*node).visiblePositionForIndex(1).deepEquivalent().deprecatedNode();
else if (node->firstChild())
node = node->firstChild();
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (225836 => 225837)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -1922,7 +1922,7 @@
selectStartTarget = root.get();
} else {
if (m_selection.isNone() && focusedElement) {
- if (is<HTMLTextFormControlElement>(*focusedElement)) {
+ if (focusedElement->isTextField()) {
downcast<HTMLTextFormControlElement>(*focusedElement).select();
return;
}
Modified: trunk/Source/WebCore/html/FormController.cpp (225836 => 225837)
--- trunk/Source/WebCore/html/FormController.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/FormController.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -345,7 +345,7 @@
{
unsigned count = 0;
for (auto& element : m_formElementsWithState) {
- if (element->isTextFormControl())
+ if (element->isTextField())
count += element->saveFormControlState()[0].length();
}
return count;
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (225836 => 225837)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -793,7 +793,7 @@
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const
{
- if (is<HTMLTextFormControlElement>(*this)) {
+ if (isTextField()) {
HTMLTextFormControlElement& textElement = downcast<HTMLTextFormControlElement>(const_cast<HTMLElement&>(*this));
bool hasStrongDirectionality;
UCharDirection textDirection = textElement.value().defaultWritingDirection(&hasStrongDirectionality);
@@ -806,7 +806,7 @@
while (node) {
// Skip bdi, script, style and text form controls.
if (equalLettersIgnoringASCIICase(node->nodeName(), "bdi") || node->hasTagName(scriptTag) || node->hasTagName(styleTag)
- || (is<Element>(*node) && downcast<Element>(*node).isTextFormControl())) {
+ || (is<Element>(*node) && downcast<Element>(*node).isTextField())) {
node = NodeTraversal::nextSkippingChildren(*node, this);
continue;
}
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (225836 => 225837)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2017-12-13 04:05:33 UTC (rev 225837)
@@ -97,7 +97,7 @@
bool isTextButton() const;
bool isRadioButton() const;
- WEBCORE_EXPORT bool isTextField() const;
+ WEBCORE_EXPORT bool isTextField() const final;
WEBCORE_EXPORT bool isSearchField() const;
bool isInputTypeHidden() const;
WEBCORE_EXPORT bool isPasswordField() const;
@@ -371,8 +371,6 @@
void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) final;
bool shouldUseInputMethod() final;
- bool isTextFormControl() const final { return isTextField(); }
-
bool canTriggerImplicitSubmission() const final { return isTextField(); }
const AtomicString& formControlType() const final;
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (225836 => 225837)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.h 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h 2017-12-13 04:05:33 UTC (rev 225837)
@@ -102,7 +102,7 @@
FormControlState saveFormControlState() const final;
void restoreFormControlState(const FormControlState&) final;
- bool isTextFormControl() const final { return true; }
+ bool isTextField() const final { return true; }
void childrenChanged(const ChildChange&) final;
void parseAttribute(const QualifiedName&, const AtomicString&) final;
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (225836 => 225837)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -107,7 +107,7 @@
void HTMLTextFormControlElement::didEditInnerTextValue()
{
- if (!isTextFormControl())
+ if (!isTextField())
return;
LOG(Editing, "HTMLTextFormControlElement %p didEditInnerTextValue", this);
@@ -198,7 +198,7 @@
String HTMLTextFormControlElement::selectedText() const
{
- if (!isTextFormControl())
+ if (!isTextField())
return String();
return value().substring(selectionStart(), selectionEnd() - selectionStart());
}
@@ -284,7 +284,7 @@
void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction, const AXTextStateChangeIntent& intent)
{
- if (!isTextFormControl())
+ if (!isTextField())
return;
end = std::max(end, 0);
@@ -343,7 +343,7 @@
int HTMLTextFormControlElement::selectionStart() const
{
- if (!isTextFormControl())
+ if (!isTextField())
return 0;
if (document().focusedElement() != this && hasCachedSelection())
return m_cachedSelectionStart;
@@ -353,7 +353,7 @@
int HTMLTextFormControlElement::computeSelectionStart() const
{
- ASSERT(isTextFormControl());
+ ASSERT(isTextField());
RefPtr<Frame> frame = document().frame();
if (!frame)
return 0;
@@ -363,7 +363,7 @@
int HTMLTextFormControlElement::selectionEnd() const
{
- if (!isTextFormControl())
+ if (!isTextField())
return 0;
if (document().focusedElement() != this && hasCachedSelection())
return m_cachedSelectionEnd;
@@ -372,7 +372,7 @@
int HTMLTextFormControlElement::computeSelectionEnd() const
{
- ASSERT(isTextFormControl());
+ ASSERT(isTextField());
RefPtr<Frame> frame = document().frame();
if (!frame)
return 0;
@@ -401,7 +401,7 @@
const AtomicString& HTMLTextFormControlElement::selectionDirection() const
{
- if (!isTextFormControl())
+ if (!isTextField())
return directionString(SelectionHasNoDirection);
if (document().focusedElement() != this && hasCachedSelection())
return directionString(cachedSelectionDirection());
@@ -411,7 +411,7 @@
TextFieldSelectionDirection HTMLTextFormControlElement::computeSelectionDirection() const
{
- ASSERT(isTextFormControl());
+ ASSERT(isTextField());
RefPtr<Frame> frame = document().frame();
if (!frame)
return SelectionHasNoDirection;
@@ -433,7 +433,7 @@
RefPtr<Range> HTMLTextFormControlElement::selection() const
{
- if (!renderer() || !isTextFormControl() || !hasCachedSelection())
+ if (!renderer() || !isTextField() || !hasCachedSelection())
return nullptr;
int start = m_cachedSelectionStart;
@@ -479,7 +479,7 @@
void HTMLTextFormControlElement::selectionChanged(bool shouldFireSelectEvent)
{
- if (!isTextFormControl())
+ if (!isTextField())
return;
// FIXME: Don't re-compute selection start and end if this function was called inside setSelectionRange.
@@ -519,7 +519,7 @@
bool HTMLTextFormControlElement::lastChangeWasUserEdit() const
{
- if (!isTextFormControl())
+ if (!isTextField())
return false;
return m_lastChangeWasUserEdit;
}
@@ -552,7 +552,7 @@
if (!innerText)
return;
- ASSERT(isTextFormControl());
+ ASSERT(isTextField());
String previousValue = innerTextValueFrom(*innerText);
bool textIsChanged = value != previousValue;
if (textIsChanged || !innerText->hasChildNodes()) {
@@ -685,7 +685,7 @@
{
// FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer.
// While we have no evidence this has ever been a practical problem, it would be best to fix it some day.
- if (!isTextFormControl())
+ if (!isTextField())
return value();
auto innerText = innerTextElement();
@@ -739,7 +739,7 @@
if (!container)
return nullptr;
RefPtr<Element> ancestor = container->shadowHost();
- return ancestor && is<HTMLTextFormControlElement>(*ancestor) ? downcast<HTMLTextFormControlElement>(ancestor.get()) : nullptr;
+ return ancestor && ancestor->isTextField() ? downcast<HTMLTextFormControlElement>(ancestor.get()) : nullptr;
}
static const Element* parentHTMLElement(const Element* element)
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (225836 => 225837)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2017-12-13 04:05:33 UTC (rev 225837)
@@ -132,6 +132,8 @@
private:
TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); }
+ bool isTextFormControlElement() const final { return true; }
+
int computeSelectionStart() const;
int computeSelectionEnd() const;
TextFieldSelectionDirection computeSelectionDirection() const;
@@ -169,7 +171,7 @@
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTextFormControlElement)
- static bool isType(const WebCore::Element& element) { return element.isTextFormControl(); }
+ static bool isType(const WebCore::Element& element) { return element.isTextFormControlElement(); }
static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
static bool isType(const WebCore::EventTarget& target) { return is<WebCore::Node>(target) && isType(downcast<WebCore::Node>(target)); }
SPECIALIZE_TYPE_TRAITS_END()
Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (225836 => 225837)
--- trunk/Source/WebCore/rendering/HitTestResult.cpp 2017-12-13 03:51:48 UTC (rev 225836)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp 2017-12-13 04:05:33 UTC (rev 225837)
@@ -572,7 +572,7 @@
if (!node)
return false;
- if (!is<HTMLTextFormControlElement>(*node))
+ if (!is<Element>(*node) || !downcast<Element>(*node).isTextField())
return false;
Frame* frame = node->document().frame();