int WebFormControlElement::selectionEnd() const { if (isHTMLInputElement(*m_private)) return constUnwrap<HTMLInputElement>()->selectionEnd(); if (isHTMLTextAreaElement(*m_private)) return constUnwrap<HTMLTextAreaElement>()->selectionEnd(); return 0; }
void WebFormControlElement::setSelectionRange(int start, int end) { if (isHTMLInputElement(*m_private)) unwrap<HTMLInputElement>()->setSelectionRange(start, end); else if (isHTMLTextAreaElement(*m_private)) unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end); }
void WebFormControlElement::setAutofillValue(const WebString& value) { // The input and change events will be sent in setValue. if (isHTMLInputElement(*m_private) || isHTMLTextAreaElement(*m_private)) { if (!focused()) unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr); unwrap<Element>()->dispatchScopedEvent( Event::createBubble(EventTypeNames::keydown)); unwrap<HTMLTextFormControlElement>()->setValue(value, DispatchInputAndChangeEvent); unwrap<Element>()->dispatchScopedEvent( Event::createBubble(EventTypeNames::keyup)); if (!focused()) unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr); } else if (isHTMLSelectElement(*m_private)) { if (!focused()) unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr); unwrap<HTMLSelectElement>()->setValue(value, true); if (!focused()) unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr); } }
void WebFormControlElement::setSelectionRange(int start, int end) { if (isHTMLInputElement(*m_private)) unwrap<HTMLInputElement>()->setSelectionRange(start, end, SelectionHasNoDirection, NotDispatchSelectEvent); else if (isHTMLTextAreaElement(*m_private)) unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end, SelectionHasNoDirection, NotDispatchSelectEvent); }
WebString WebFormControlElement::editingValue() const { if (isHTMLInputElement(*m_private)) return constUnwrap<HTMLInputElement>()->innerEditorValue(); if (isHTMLTextAreaElement(*m_private)) return constUnwrap<HTMLTextAreaElement>()->innerEditorValue(); return WebString(); }
bool InjectedBundleNodeHandle::htmlTextAreaElementLastChangeWasUserEdit() { if (!isHTMLTextAreaElement(m_node.get())) return false; return toHTMLTextAreaElement(m_node.get())->lastChangeWasUserEdit(); }
bool WebFormControlElement::autoComplete() const { if (isHTMLInputElement(*m_private)) return constUnwrap<HTMLInputElement>()->shouldAutocomplete(); if (isHTMLTextAreaElement(*m_private)) return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete(); return false; }
WebString WebFormControlElement::directionForFormData() const { if (isHTMLInputElement(*m_private)) return constUnwrap<HTMLInputElement>()->directionForFormData(); if (isHTMLTextAreaElement(*m_private)) return constUnwrap<HTMLTextAreaElement>()->directionForFormData(); return WebString(); }
void WebFormControlElement::setSuggestedValue(const WebString& value) { if (isHTMLInputElement(*m_private)) unwrap<HTMLInputElement>()->setSuggestedValue(value); else if (isHTMLTextAreaElement(*m_private)) unwrap<HTMLTextAreaElement>()->setSuggestedValue(value); else if (isHTMLSelectElement(*m_private)) unwrap<HTMLSelectElement>()->setSuggestedValue(value); }
void WebFormControlElement::setValue(const WebString& value, bool sendEvents) { if (isHTMLInputElement(*m_private)) unwrap<HTMLInputElement>()->setValue(value, sendEvents ? DispatchInputAndChangeEvent : DispatchNoEvent); else if (isHTMLTextAreaElement(*m_private)) unwrap<HTMLTextAreaElement>()->setValue(value, sendEvents ? DispatchInputAndChangeEvent : DispatchNoEvent); else if (isHTMLSelectElement(*m_private)) unwrap<HTMLSelectElement>()->setValue(value, sendEvents); }
WebString WebFormControlElement::suggestedValue() const { if (isHTMLInputElement(*m_private)) return constUnwrap<HTMLInputElement>()->suggestedValue(); if (isHTMLTextAreaElement(*m_private)) return constUnwrap<HTMLTextAreaElement>()->suggestedValue(); if (isHTMLSelectElement(*m_private)) return constUnwrap<HTMLSelectElement>()->suggestedValue(); return WebString(); }
static bool isNonTextAreaFormControl(const LayoutObject* layoutObject) { const Node* node = layoutObject ? layoutObject->node() : nullptr; if (!node || !node->isElementNode()) return false; const Element* element = toElement(node); return (element->isFormControlElement() && !isHTMLTextAreaElement(element)); }
void WebEditorClient::textDidChangeInTextArea(Element* element) { if (!isHTMLTextAreaElement(element)) return; WebFrame* webFrame = WebFrame::fromCoreFrame(*element->document().frame()); ASSERT(webFrame); m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, toHTMLTextAreaElement(element), webFrame); }
void WebEditorClient::textDidChangeInTextArea(Element* element) { if (!isHTMLTextAreaElement(element)) return; WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(element->document().frame()->loader().client()); WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; ASSERT(webFrame); m_page->injectedBundleFormClient().textDidChangeInTextArea(m_page, toHTMLTextAreaElement(element), webFrame); }
bool WebFrame::containsAnyFormControls() const { if (!m_coreFrame) return false; Document* document = m_coreFrame->document(); if (!document) return false; for (Node* node = document->documentElement(); node; node = NodeTraversal::next(node)) { if (!node->isElementNode()) continue; if (isHTMLInputElement(node) || isHTMLSelectElement(node) || isHTMLTextAreaElement(node)) return true; } return false; }
AtomicString getInputModeAttribute(Element* element) { if (!element) return AtomicString(); bool queryAttribute = false; if (isHTMLInputElement(*element)) { queryAttribute = toHTMLInputElement(*element).supportsInputModeAttribute(); } else if (isHTMLTextAreaElement(*element)) { queryAttribute = true; } else { element->document().updateStyleAndLayoutTree(); if (hasEditableStyle(*element)) queryAttribute = true; } if (!queryAttribute) return AtomicString(); // TODO(dtapuska): We may wish to restrict this to a yet to be proposed // <contenteditable> or <richtext> element Mozilla discussed at TPAC 2016. return element->fastGetAttribute(HTMLNames::inputmodeAttr).lower(); }