Пример #1
0
int WebFormControlElement::selectionEnd() const {
  if (isHTMLInputElement(*m_private))
    return constUnwrap<HTMLInputElement>()->selectionEnd();
  if (isHTMLTextAreaElement(*m_private))
    return constUnwrap<HTMLTextAreaElement>()->selectionEnd();
  return 0;
}
Пример #2
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);
}
Пример #3
0
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);
  }
}
Пример #4
0
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);
}
Пример #5
0
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();
}
Пример #7
0
bool WebFormControlElement::autoComplete() const
{
    if (isHTMLInputElement(*m_private))
        return constUnwrap<HTMLInputElement>()->shouldAutocomplete();
    if (isHTMLTextAreaElement(*m_private))
        return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete();
    return false;
}
Пример #8
0
WebString WebFormControlElement::directionForFormData() const
{
    if (isHTMLInputElement(*m_private))
        return constUnwrap<HTMLInputElement>()->directionForFormData();
    if (isHTMLTextAreaElement(*m_private))
        return constUnwrap<HTMLTextAreaElement>()->directionForFormData();
    return WebString();
}
Пример #9
0
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);
}
Пример #10
0
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);
}
Пример #11
0
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();
}
Пример #12
0
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));
}
Пример #13
0
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);
}
Пример #14
0
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);
}
Пример #15
0
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;
}
Пример #16
0
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();
}