Diff
Modified: trunk/Source/WebCore/ChangeLog (208874 => 208875)
--- trunk/Source/WebCore/ChangeLog 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/ChangeLog 2016-11-18 04:57:50 UTC (rev 208875)
@@ -1,3 +1,35 @@
+2016-11-17 Ryosuke Niwa <[email protected]>
+
+ WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled should keep text replacement enabled
+ https://bugs.webkit.org/show_bug.cgi?id=164857
+ <rdar://problem/27721742>
+
+ Reviewed by Wenson Hsieh.
+
+ It turns out that some users want text replacement to be always enabled so change the semantics of
+ WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled to only disable everything else.
+
+ Instead of completely disabling spellchecking, remove all text checking options but text replacement
+ when the user types into an input element on which this API is used to disable spellchecking.
+
+ No new tests since we don't have a good facility to test text replacement.
+
+ * dom/Element.h:
+ (WebCore::Element::isSpellCheckingEnabled): Made this non-virtual now that there is no override.
+ * editing/Editor.cpp:
+ (WebCore::Editor::replaceSelectionWithFragment):
+ (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Don't call resolveTextCheckingTypeMask twice.
+ (WebCore::Editor::resolveTextCheckingTypeMask): Filter out the text checking options if the root editable
+ element is inside an input element on which isSpellcheckDisabledExceptTextReplacement is set to true.
+ * editing/Editor.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::HTMLInputElement):
+ (WebCore::HTMLInputElement::isSpellCheckingEnabled): Deleted.
+ * html/HTMLInputElement.h:
+ (WebCore::HTMLInputElement::setSpellcheckDisabledExceptTextReplacement): Renamed from setSpellcheckEnabled
+ to reflect the new semantics.
+ (WebCore::HTMLInputElement::isSpellcheckDisabledExceptTextReplacement): Ditto.
+
2016-11-17 John Wilander <[email protected]>
Resource load statistics: Cover further data records, count removed data records, and only fire handler when needed
Modified: trunk/Source/WebCore/dom/Element.h (208874 => 208875)
--- trunk/Source/WebCore/dom/Element.h 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/dom/Element.h 2016-11-18 04:57:50 UTC (rev 208875)
@@ -482,7 +482,7 @@
const AtomicString& UIActions() const;
#endif
- virtual bool isSpellCheckingEnabled() const;
+ bool isSpellCheckingEnabled() const;
RenderNamedFlowFragment* renderNamedFlowFragment() const;
Modified: trunk/Source/WebCore/editing/Editor.cpp (208874 => 208875)
--- trunk/Source/WebCore/editing/Editor.cpp 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/editing/Editor.cpp 2016-11-18 04:57:50 UTC (rev 208875)
@@ -54,6 +54,7 @@
#include "HTMLFormControlElement.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "IndentOutdentCommand.h"
@@ -521,7 +522,7 @@
return;
RefPtr<Range> rangeToCheck = Range::create(document(), firstPositionInNode(nodeToCheck), lastPositionInNode(nodeToCheck));
- m_spellChecker->requestCheckingFor(SpellCheckRequest::create(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), TextCheckingProcessBatch, rangeToCheck, rangeToCheck));
+ m_spellChecker->requestCheckingFor(SpellCheckRequest::create(resolveTextCheckingTypeMask(*nodeToCheck, TextCheckingTypeSpelling | TextCheckingTypeGrammar), TextCheckingProcessBatch, rangeToCheck, rangeToCheck));
}
void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace, EditAction editingAction)
@@ -2374,7 +2375,8 @@
bool asynchronous = m_frame.settings().asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel;
// In asynchronous mode, we intentionally check paragraph-wide sentence.
- auto request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessIncremental, asynchronous ? paragraphRange : rangeToCheck, paragraphRange);
+ const auto resolvedOptions = resolveTextCheckingTypeMask(editableNode, textCheckingOptions);
+ auto request = SpellCheckRequest::create(resolvedOptions, TextCheckingProcessIncremental, asynchronous ? paragraphRange : rangeToCheck, paragraphRange);
if (asynchronous) {
m_spellChecker->requestCheckingFor(WTFMove(request));
@@ -2382,7 +2384,7 @@
}
Vector<TextCheckingResult> results;
- checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results, m_frame.selection().selection());
+ checkTextOfParagraph(*textChecker(), paragraphToCheck.text(), resolvedOptions, results, m_frame.selection().selection());
markAndReplaceFor(WTFMove(request), results);
}
@@ -3482,8 +3484,18 @@
return false;
}
-TextCheckingTypeMask Editor::resolveTextCheckingTypeMask(TextCheckingTypeMask textCheckingOptions)
+TextCheckingTypeMask Editor::resolveTextCheckingTypeMask(const Node& rootEditableElement, TextCheckingTypeMask textCheckingOptions)
{
+#if USE(AUTOMATIC_TEXT_REPLACEMENT) && !PLATFORM(IOS)
+ bool _onlyAllowsTextReplacement_ = false;
+ if (auto* host = rootEditableElement.shadowHost())
+ _onlyAllowsTextReplacement_ = is<HTMLInputElement>(host) && downcast<HTMLInputElement>(*host).isSpellcheckDisabledExceptTextReplacement();
+ if (onlyAllowsTextReplacement)
+ textCheckingOptions &= TextCheckingTypeReplacement;
+#else
+ UNUSED_PARAM(rootEditableElement);
+#endif
+
bool shouldMarkSpelling = textCheckingOptions & TextCheckingTypeSpelling;
bool shouldMarkGrammar = textCheckingOptions & TextCheckingTypeGrammar;
#if !PLATFORM(IOS)
@@ -3505,16 +3517,18 @@
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
bool shouldPerformReplacement = textCheckingOptions & TextCheckingTypeReplacement;
if (shouldPerformReplacement) {
- if (isAutomaticLinkDetectionEnabled())
- checkingTypes |= TextCheckingTypeLink;
- if (isAutomaticQuoteSubstitutionEnabled())
- checkingTypes |= TextCheckingTypeQuote;
- if (isAutomaticDashSubstitutionEnabled())
- checkingTypes |= TextCheckingTypeDash;
+ if (!onlyAllowsTextReplacement) {
+ if (isAutomaticLinkDetectionEnabled())
+ checkingTypes |= TextCheckingTypeLink;
+ if (isAutomaticQuoteSubstitutionEnabled())
+ checkingTypes |= TextCheckingTypeQuote;
+ if (isAutomaticDashSubstitutionEnabled())
+ checkingTypes |= TextCheckingTypeDash;
+ if (shouldMarkSpelling && isAutomaticSpellingCorrectionEnabled())
+ checkingTypes |= TextCheckingTypeCorrection;
+ }
if (isAutomaticTextReplacementEnabled())
checkingTypes |= TextCheckingTypeReplacement;
- if (shouldMarkSpelling && isAutomaticSpellingCorrectionEnabled())
- checkingTypes |= TextCheckingTypeCorrection;
}
#endif
#endif // !PLATFORM(IOS)
Modified: trunk/Source/WebCore/editing/Editor.h (208874 => 208875)
--- trunk/Source/WebCore/editing/Editor.h 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/editing/Editor.h 2016-11-18 04:57:50 UTC (rev 208875)
@@ -493,7 +493,7 @@
void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
- TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
+ TextCheckingTypeMask resolveTextCheckingTypeMask(const Node& rootEditableElement, TextCheckingTypeMask);
WEBCORE_EXPORT String selectedText(TextIteratorBehavior) const;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (208874 => 208875)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2016-11-18 04:57:50 UTC (rev 208875)
@@ -116,7 +116,7 @@
#if ENABLE(TOUCH_EVENTS)
, m_hasTouchEventHandler(false)
#endif
- , m_isSpellCheckingEnabled(true)
+ , m_isSpellcheckDisabledExceptTextReplacement(false)
// m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and
// its shadow subtree, just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
, m_inputType(createdByParser ? nullptr : InputType::createText(*this))
@@ -464,11 +464,6 @@
return m_inputType->shouldUseInputMethod();
}
-bool HTMLInputElement::isSpellCheckingEnabled() const
-{
- return m_isSpellCheckingEnabled && HTMLTextFormControlElement::isSpellCheckingEnabled();
-}
-
void HTMLInputElement::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction)
{
m_inputType->handleFocusEvent(oldFocusedNode, direction);
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (208874 => 208875)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2016-11-18 04:57:50 UTC (rev 208875)
@@ -303,7 +303,8 @@
void endEditing();
- void setSpellcheckEnabled(bool enabled) { m_isSpellCheckingEnabled = enabled; }
+ void setSpellcheckDisabledExceptTextReplacement(bool disabled) { m_isSpellcheckDisabledExceptTextReplacement = disabled; }
+ bool isSpellcheckDisabledExceptTextReplacement() const { return m_isSpellcheckDisabledExceptTextReplacement; }
static Vector<FileChooserFileInfo> filesFromFileInputFormControlState(const FormControlState&);
@@ -346,7 +347,6 @@
bool supportLabels() const final;
void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) final;
bool shouldUseInputMethod() final;
- bool isSpellCheckingEnabled() const final;
bool isTextFormControl() const final { return isTextField(); }
@@ -448,7 +448,7 @@
#if ENABLE(TOUCH_EVENTS)
bool m_hasTouchEventHandler : 1;
#endif
- bool m_isSpellCheckingEnabled : 1;
+ bool m_isSpellcheckDisabledExceptTextReplacement : 1;
std::unique_ptr<InputType> m_inputType;
// The ImageLoader must be owned by this element because the loader code assumes
// that it lives as long as its owning element lives. If we move the loader into
Modified: trunk/Source/WebKit2/ChangeLog (208874 => 208875)
--- trunk/Source/WebKit2/ChangeLog 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebKit2/ChangeLog 2016-11-18 04:57:50 UTC (rev 208875)
@@ -1,3 +1,14 @@
+2016-11-17 Ryosuke Niwa <[email protected]>
+
+ WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled should keep text replacement enabled
+ https://bugs.webkit.org/show_bug.cgi?id=164857
+ <rdar://problem/27721742>
+
+ Reviewed by Wenson Hsieh.
+
+ * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+ (WebKit::InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled):
+
2016-11-17 John Wilander <[email protected]>
Resource load statistics: Cover further data records, count removed data records, and only fire handler when needed
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (208874 => 208875)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp 2016-11-18 03:32:53 UTC (rev 208874)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp 2016-11-18 04:57:50 UTC (rev 208875)
@@ -215,7 +215,7 @@
if (!is<HTMLInputElement>(m_node))
return;
- downcast<HTMLInputElement>(m_node.get()).setSpellcheckEnabled(enabled);
+ downcast<HTMLInputElement>(m_node.get()).setSpellcheckDisabledExceptTextReplacement(!enabled);
}
bool InjectedBundleNodeHandle::isHTMLInputElementAutoFilled() const