- Revision
- 173682
- Author
- [email protected]
- Date
- 2014-09-16 17:48:01 -0700 (Tue, 16 Sep 2014)
Log Message
Should have an editing behavior specific for IOS.
https://bugs.webkit.org/show_bug.cgi?id=136876
Reviewed by Sam Weinig.
This patch introduces a new editing behavior type to be able
to perform editing tasks that are specific to iOS.
All the existing EditingBehavior methods return the same boolean
value for for Mac and iOS. A new one has been introduced to support
a specific behavior in the DeleteSelectionCommand.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::doApply):
* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldConsiderSelectionAsDirectional):
(WebCore::EditingBehavior::shouldCenterAlignWhenSelectionIsRevealed):
(WebCore::EditingBehavior::shouldToggleStyleBasedOnStartOfSelection):
(WebCore::EditingBehavior::shouldAlwaysGrowSelectionWhenExtendingToBoundary):
(WebCore::EditingBehavior::shouldSelectOnContextualMenuClick):
(WebCore::EditingBehavior::shouldExtendSelectionByWordOrLineAcrossCaret):
(WebCore::EditingBehavior::shouldRebalanceWhiteSpacesInSecureField):
* editing/EditingBehaviorTypes.h:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::positionForPlatform):
* page/Settings.cpp:
(WebCore::editingBehaviorTypeForPlatform):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setEditingBehavior):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (173681 => 173682)
--- trunk/Source/WebCore/ChangeLog 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/ChangeLog 2014-09-17 00:48:01 UTC (rev 173682)
@@ -1,3 +1,34 @@
+2014-09-16 Enrica Casucci <[email protected]>
+
+ Should have an editing behavior specific for IOS.
+ https://bugs.webkit.org/show_bug.cgi?id=136876
+
+ Reviewed by Sam Weinig.
+
+ This patch introduces a new editing behavior type to be able
+ to perform editing tasks that are specific to iOS.
+ All the existing EditingBehavior methods return the same boolean
+ value for for Mac and iOS. A new one has been introduced to support
+ a specific behavior in the DeleteSelectionCommand.
+
+ * editing/DeleteSelectionCommand.cpp:
+ (WebCore::DeleteSelectionCommand::doApply):
+ * editing/EditingBehavior.h:
+ (WebCore::EditingBehavior::shouldConsiderSelectionAsDirectional):
+ (WebCore::EditingBehavior::shouldCenterAlignWhenSelectionIsRevealed):
+ (WebCore::EditingBehavior::shouldToggleStyleBasedOnStartOfSelection):
+ (WebCore::EditingBehavior::shouldAlwaysGrowSelectionWhenExtendingToBoundary):
+ (WebCore::EditingBehavior::shouldSelectOnContextualMenuClick):
+ (WebCore::EditingBehavior::shouldExtendSelectionByWordOrLineAcrossCaret):
+ (WebCore::EditingBehavior::shouldRebalanceWhiteSpacesInSecureField):
+ * editing/EditingBehaviorTypes.h:
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::positionForPlatform):
+ * page/Settings.cpp:
+ (WebCore::editingBehaviorTypeForPlatform):
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::setEditingBehavior):
+
2014-09-16 Commit Queue <[email protected]>
Unreviewed, rolling out r173670.
Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (173681 => 173682)
--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp 2014-09-17 00:48:01 UTC (rev 173682)
@@ -861,24 +861,17 @@
insertNodeAt(placeholder.get(), m_endingPosition);
}
-#if PLATFORM(IOS)
- // This checking is due to iphone shows the last entered character momentarily, removing and adding back the
- // space when deleting password cause space been showed insecurely.
- bool isSecure = NO;
- Node* node = m_endingPosition.deprecatedNode();
- if (node && node->isTextNode()) {
- Text* textNode = static_cast<Text*>(node);
- if (textNode->length() > 0) {
- RenderObject* renderer = textNode->renderer();
- isSecure = renderer->style().textSecurity() != TSNONE;
- }
+ bool shouldRebalaceWhiteSpace = true;
+ if (!frame().editor().behavior().shouldRebalanceWhiteSpacesInSecureField()) {
+ Node* node = m_endingPosition.deprecatedNode();
+ if (node && node->isTextNode()) {
+ Text* textNode = toText(node);
+ if (textNode->length())
+ shouldRebalaceWhiteSpace = textNode->renderer()->style().textSecurity() == TSNONE;
+ }
}
-
- if (!isSecure)
+ if (shouldRebalaceWhiteSpace)
rebalanceWhitespaceAt(m_endingPosition);
-#else
- rebalanceWhitespaceAt(m_endingPosition);
-#endif
calculateTypingStyleAfterDelete();
Modified: trunk/Source/WebCore/editing/EditingBehavior.h (173681 => 173682)
--- trunk/Source/WebCore/editing/EditingBehavior.h 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/editing/EditingBehavior.h 2014-09-17 00:48:01 UTC (rev 173682)
@@ -46,22 +46,22 @@
// On Windows, selections should always be considered as directional, regardless if it is
// mouse-based or keyboard-based.
- bool shouldConsiderSelectionAsDirectional() const { return m_type != EditingMacBehavior; }
+ bool shouldConsiderSelectionAsDirectional() const { return m_type != EditingMacBehavior && m_type != EditingIOSBehavior; }
// On Mac, when revealing a selection (for example as a result of a Find operation on the Browser),
// content should be scrolled such that the selection gets certer aligned.
- bool shouldCenterAlignWhenSelectionIsRevealed() const { return m_type == EditingMacBehavior; }
+ bool shouldCenterAlignWhenSelectionIsRevealed() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
// On Mac, style is considered present when present at the beginning of selection. On other platforms,
// style has to be present throughout the selection.
- bool shouldToggleStyleBasedOnStartOfSelection() const { return m_type == EditingMacBehavior; }
+ bool shouldToggleStyleBasedOnStartOfSelection() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
// Standard Mac behavior when extending to a boundary is grow the selection rather than leaving the base
// in place and moving the extent. Matches NSTextView.
- bool shouldAlwaysGrowSelectionWhenExtendingToBoundary() const { return m_type == EditingMacBehavior; }
+ bool shouldAlwaysGrowSelectionWhenExtendingToBoundary() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
// On Mac, when processing a contextual click, the object being clicked upon should be selected.
- bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior; }
+ bool shouldSelectOnContextualMenuClick() const { return m_type == EditingMacBehavior || m_type == EditingIOSBehavior; }
// On Linux, should be able to get and insert spelling suggestions without selecting the misspelled word.
bool shouldAllowSpellingSuggestionsWithoutSelection() const
@@ -78,13 +78,17 @@
// On Mac, selecting backwards by word/line from the middle of a word/line, and then going
// forward leaves the caret back in the middle with no selection, instead of directly selecting
// to the other end of the line/word (Unix/Windows behavior).
- bool shouldExtendSelectionByWordOrLineAcrossCaret() const { return m_type != EditingMacBehavior; }
+ bool shouldExtendSelectionByWordOrLineAcrossCaret() const { return m_type != EditingMacBehavior && m_type != EditingIOSBehavior; }
// Based on native behavior, when using ctrl(alt)+arrow to move caret by word, ctrl(alt)+left arrow moves caret to
// immediately before the word in all platforms, for example, the word break positions are: "|abc |def |hij |opq".
// But ctrl+right arrow moves caret to "abc |def |hij |opq" on Windows and "abc| def| hij| opq|" on Mac and Linux.
bool shouldSkipSpaceWhenMovingRight() const { return m_type == EditingWindowsBehavior; }
+ // On iOS the last entered character in a secure filed is shown momentarily, removing and adding back the
+ // space when deleting password cause space been showed insecurely.
+ bool shouldRebalanceWhiteSpacesInSecureField() const { return m_type != EditingIOSBehavior; }
+
private:
EditingBehaviorType m_type;
};
Modified: trunk/Source/WebCore/editing/EditingBehaviorTypes.h (173681 => 173682)
--- trunk/Source/WebCore/editing/EditingBehaviorTypes.h 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/editing/EditingBehaviorTypes.h 2014-09-17 00:48:01 UTC (rev 173682)
@@ -39,7 +39,8 @@
enum EditingBehaviorType {
EditingMacBehavior,
EditingWindowsBehavior,
- EditingUnixBehavior
+ EditingUnixBehavior,
+ EditingIOSBehavior
};
} // WebCore namespace
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (173681 => 173682)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2014-09-17 00:48:01 UTC (rev 173682)
@@ -616,7 +616,7 @@
VisiblePosition FrameSelection::positionForPlatform(bool isGetStart) const
{
- if (m_frame && m_frame->settings().editingBehaviorType() == EditingMacBehavior)
+ if (m_frame && (m_frame->settings().editingBehaviorType() == EditingMacBehavior || m_frame->settings().editingBehaviorType() == EditingIOSBehavior))
return isGetStart ? m_selection.visibleStart() : m_selection.visibleEnd();
// Linux and Windows always extend selections from the extent endpoint.
// FIXME: VisibleSelection should be fixed to ensure as an invariant that
Modified: trunk/Source/WebCore/page/Settings.cpp (173681 => 173682)
--- trunk/Source/WebCore/page/Settings.cpp 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/page/Settings.cpp 2014-09-17 00:48:01 UTC (rev 173682)
@@ -107,7 +107,9 @@
static EditingBehaviorType editingBehaviorTypeForPlatform()
{
return
-#if OS(DARWIN)
+#if PLATFORM(IOS)
+ EditingIOSBehavior
+#elif OS(DARWIN)
EditingMacBehavior
#elif OS(WINDOWS)
EditingWindowsBehavior
Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (173681 => 173682)
--- trunk/Source/WebCore/testing/InternalSettings.cpp 2014-09-17 00:32:18 UTC (rev 173681)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp 2014-09-17 00:48:01 UTC (rev 173682)
@@ -349,6 +349,8 @@
settings()->setEditingBehaviorType(EditingMacBehavior);
else if (equalIgnoringCase(editingBehavior, "unix"))
settings()->setEditingBehaviorType(EditingUnixBehavior);
+ else if (equalIgnoringCase(editingBehavior, "ios"))
+ settings()->setEditingBehaviorType(EditingIOSBehavior);
else
ec = SYNTAX_ERR;
}