Changeset 201942 in webkit


Ignore:
Timestamp:
Jun 10, 2016 3:00:23 PM (8 years ago)
Author:
rniwa@webkit.org
Message:

Add SPI to disable spellchecking on auto-fillable text fields
https://bugs.webkit.org/show_bug.cgi?id=158611

Reviewed by Anders Carlsson.

Source/WebCore:

Added a boolean flag m_isSpellCheckingEnabled to HTMLInputElement. This flag defaults to true, and can be set
to false by WebKit2 C API.

  • editing/Editor.cpp:

(WebCore::Editor::isSpellCheckingEnabledFor): Fixed a bug that we were calling isSpellCheckingEnabled on
the div inside an input element's shadow tree instead of the input element itself.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::HTMLInputElement): Initialize m_spellcheckEnabled to true (it's a bit field).
(WebCore::HTMLInputElement::isSpellCheckingEnabled): Added. Return false if m_spellcheckEnabled is false.

  • html/HTMLInputElement.h:

(WebCore::HTMLInputElement::setSpellcheckEnabled): Added.

Source/WebKit2:

Added WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled to disable spellchecking on a text field.

This is used by WebKit2 client which desires to disable spellchecking and notably autocorrection on
login forms, etc... where such feature would interfere with user's actions.

  • WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:

(WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled): Added.

  • WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
  • WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:

(WebKit::InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled): Added.

  • WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201941 r201942  
     12016-06-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add SPI to disable spellchecking on auto-fillable text fields
     4        https://bugs.webkit.org/show_bug.cgi?id=158611
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Added a boolean flag m_isSpellCheckingEnabled to HTMLInputElement. This flag defaults to true, and can be set
     9        to false by WebKit2 C API.
     10
     11        * editing/Editor.cpp:
     12        (WebCore::Editor::isSpellCheckingEnabledFor): Fixed a bug that we were calling isSpellCheckingEnabled on
     13        the div inside an input element's shadow tree instead of the input element itself.
     14        * html/HTMLInputElement.cpp:
     15        (WebCore::HTMLInputElement::HTMLInputElement): Initialize m_spellcheckEnabled to true (it's a bit field).
     16        (WebCore::HTMLInputElement::isSpellCheckingEnabled): Added. Return false if m_spellcheckEnabled is false.
     17        * html/HTMLInputElement.h:
     18        (WebCore::HTMLInputElement::setSpellcheckEnabled): Added.
     19
    1202016-06-10  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebCore/editing/Editor.cpp

    r201490 r201942  
    23732373    if (!node)
    23742374        return false;
    2375     const Element* focusedElement = is<Element>(*node) ? downcast<Element>(node) : node->parentElement();
    2376     if (!focusedElement)
     2375    Element* element = is<Element>(*node) ? downcast<Element>(node) : node->parentElement();
     2376    if (!element)
    23772377        return false;
    2378     return focusedElement->isSpellCheckingEnabled();
     2378    if (element->isInUserAgentShadowTree()) {
     2379        if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(firstPositionInOrBeforeNode(element)))
     2380            return textControl->isSpellCheckingEnabled();
     2381    }
     2382    return element->isSpellCheckingEnabled();
    23792383}
    23802384
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r201659 r201942  
    118118    , m_hasTouchEventHandler(false)
    119119#endif
     120    , m_isSpellCheckingEnabled(true)
    120121    // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and
    121122    // its shadow subtree, just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
     
    422423{
    423424    return m_inputType->shouldUseInputMethod();
     425}
     426
     427bool HTMLInputElement::isSpellCheckingEnabled() const
     428{
     429    return m_isSpellCheckingEnabled && HTMLTextFormControlElement::isSpellCheckingEnabled();
    424430}
    425431
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r201739 r201942  
    308308    void endEditing();
    309309
     310    void setSpellcheckEnabled(bool enabled) { m_isSpellCheckingEnabled = enabled; }
     311
    310312    static Vector<FileChooserFileInfo> filesFromFileInputFormControlState(const FormControlState&);
    311313
     
    349351    void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) final;
    350352    bool shouldUseInputMethod() final;
     353    bool isSpellCheckingEnabled() const final;
    351354
    352355    bool isTextFormControl() const final { return isTextField(); }
     
    449452    bool m_hasTouchEventHandler : 1;
    450453#endif
     454    bool m_isSpellCheckingEnabled : 1;
    451455    std::unique_ptr<InputType> m_inputType;
    452456    // The ImageLoader must be owned by this element because the loader code assumes
  • trunk/Source/WebKit2/ChangeLog

    r201941 r201942  
     12016-06-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add SPI to disable spellchecking on auto-fillable text fields
     4        https://bugs.webkit.org/show_bug.cgi?id=158611
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Added WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled to disable spellchecking on a text field.
     9
     10        This is used by WebKit2 client which desires to disable spellchecking and notably autocorrection on
     11        login forms, etc... where such feature would interfere with user's actions.
     12
     13        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
     14        (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled): Added.
     15        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
     16        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
     17        (WebKit::InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled): Added.
     18        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
     19
    1202016-06-10  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp

    r195685 r201942  
    9696}
    9797
     98void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled)
     99{
     100    toImpl(htmlInputElementHandleRef)->setHTMLInputElementSpellcheckEnabled(enabled);
     101}
     102
    98103bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef)
    99104{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h

    r195685 r201942  
    6060/* HTMLInputElement Specific Operations */
    6161WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value);
     62WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandle, bool enabled);
    6263WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle);
    6364WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled);
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp

    r195685 r201942  
    211211}
    212212
     213void InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled(bool enabled)
     214{
     215    if (!is<HTMLInputElement>(m_node))
     216        return;
     217
     218    downcast<HTMLInputElement>(m_node.get()).setSpellcheckEnabled(enabled);
     219}
     220
    213221bool InjectedBundleNodeHandle::isHTMLInputElementAutoFilled() const
    214222{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h

    r195685 r201942  
    6767    PassRefPtr<InjectedBundleRangeHandle> visibleRange();
    6868    void setHTMLInputElementValueForUser(const String&);
     69    void setHTMLInputElementSpellcheckEnabled(bool);
    6970    bool isHTMLInputElementAutoFilled() const;
    7071    void setHTMLInputElementAutoFilled(bool);
Note: See TracChangeset for help on using the changeset viewer.