WebKit Bugzilla
Attachment 362752 Details for
Bug 194880
: Smart Insert for paragraphs.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194880-20190222124518.patch (text/plain), 6.30 KB, created by
Megan Gardner
on 2019-02-22 12:45:19 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Megan Gardner
Created:
2019-02-22 12:45:19 PST
Size:
6.30 KB
patch
obsolete
>Subversion Revision: 241953 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 8e793d00f733f8073f2e44115fdb41270b0b65c5..a5b5694575a88239befb4058f4af919a16ac46be 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2019-02-20 Megan Gardner <megan_gardner@apple.com> >+ >+ Smart Insert for paragraphs. >+ https://bugs.webkit.org/show_bug.cgi?id=194880 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * editing/CompositeEditCommand.cpp: >+ (WebCore::CompositeEditCommand::insertParagraphSeparatorAtPosition): >+ (WebCore::CompositeEditCommand::insertParagraphSeparator): >+ * editing/CompositeEditCommand.h: >+ * editing/DictationCommand.cpp: >+ (WebCore::DictationCommand::insertParagraphSeparator): >+ * editing/Editing.cpp: >+ (WebCore::newlineString): >+ * editing/Editing.h: >+ * editing/InsertParagraphSeparatorCommand.cpp: >+ (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand): >+ (WebCore::InsertParagraphSeparatorCommand::doApply): >+ * editing/InsertParagraphSeparatorCommand.h: >+ (WebCore::InsertParagraphSeparatorCommand::create): >+ * editing/ReplaceSelectionCommand.cpp: >+ (WebCore::ReplaceSelectionCommand::doApply): >+ (WebCore::ReplaceSelectionCommand::addNewLinesForSmartReplace): >+ * editing/ReplaceSelectionCommand.h: >+ * editing/TypingCommand.cpp: >+ (WebCore::TypingCommand::insertParagraphSeparator): >+ > 2019-02-22 Wenson Hsieh <wenson_hsieh@apple.com> > > Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction >diff --git a/Source/WebCore/editing/CompositeEditCommand.h b/Source/WebCore/editing/CompositeEditCommand.h >index 04c21ff341c48963934c5de2d0e71c3cc9f38715..12819f20f9028a6d6fb0098aab877e073f5da029 100644 >--- a/Source/WebCore/editing/CompositeEditCommand.h >+++ b/Source/WebCore/editing/CompositeEditCommand.h >@@ -152,6 +152,7 @@ protected: > void insertNodeAt(Ref<Node>&&, const Position&); > void insertNodeAtTabSpanPosition(Ref<Node>&&, const Position&); > void insertNodeBefore(Ref<Node>&&, Node& refChild, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable); >+ void insertParagraphSeparatorAtPosition(const Position&, bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false); > void insertParagraphSeparator(bool useDefaultParagraphElement = false, bool pasteBlockqutoeIntoUnquotedArea = false); > void insertLineBreak(); > void insertTextIntoNode(Text&, unsigned offset, const String& text); >diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp >index d5eced5825a055e8c0a8b42561af262a55e7dbb0..40430237b99caabd794472e7a7d749ac1fb58ee3 100644 >--- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp >+++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp >@@ -1269,6 +1269,10 @@ void ReplaceSelectionCommand::doApply() > > if (shouldPerformSmartReplace()) > addSpacesForSmartReplace(); >+ >+ if (shouldPerformSmartParagraphReplace()) >+ addNewLinesForSmartReplace(); >+ > > // If we are dealing with a fragment created from plain text > // no style matching is necessary. >@@ -1325,12 +1329,58 @@ bool ReplaceSelectionCommand::shouldPerformSmartReplace() const > > return true; > } >+ >+bool ReplaceSelectionCommand::shouldPerformSmartParagraphReplace() const >+{ >+ if (!m_smartReplace) >+ return false; >+ // <MMG> add a check for iOS >+ >+ Element* textControl = enclosingTextFormControl(positionAtStartOfInsertedContent().deepEquivalent()); >+ if (is<HTMLInputElement>(textControl)) >+ return false; >+ >+ return true; >+} > > static bool isCharacterSmartReplaceExemptConsideringNonBreakingSpace(UChar32 character, bool previousCharacter) > { > return isCharacterSmartReplaceExempt(character == noBreakSpace ? ' ' : character, previousCharacter); > } > >+void ReplaceSelectionCommand::addNewLinesForSmartReplace() >+{ >+ VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent(); >+ VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent(); >+ >+ Position endUpstream = endOfInsertedContent.deepEquivalent().upstream(); >+ >+ Position startDownstream = startOfInsertedContent.deepEquivalent().downstream(); >+ >+ bool isFullParagraph = isStartOfParagraph(startOfInsertedContent) && isEndOfParagraph(endOfInsertedContent); >+ >+ if (!isFullParagraph) >+ return; >+ >+ bool reachedBoundary = false; >+ VisiblePosition positionBeforeStart = startOfInsertedContent.previous(CannotCrossEditingBoundary, &reachedBoundary); >+ if (!reachedBoundary) { >+ if (isEndOfLine(positionBeforeStart)) { >+ applyCommandToComposite(SetSelectionCommand::create(VisibleSelection(startOfInsertedContent), FrameSelection::defaultSetSelectionOptions())); >+ insertParagraphSeparator(); >+ } >+ } >+ >+ reachedBoundary = false; >+ VisiblePosition positionAfterEnd = endOfInsertedContent.next(CannotCrossEditingBoundary, &reachedBoundary); >+ if (!reachedBoundary) { >+ if (isStartOfLine(positionAfterEnd)) { >+ applyCommandToComposite(SetSelectionCommand::create(VisibleSelection(endOfInsertedContent), FrameSelection::defaultSetSelectionOptions())); >+ insertParagraphSeparator(); >+ } >+ } >+} >+ > void ReplaceSelectionCommand::addSpacesForSmartReplace() > { > VisiblePosition startOfInsertedContent = positionAtStartOfInsertedContent(); >diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.h b/Source/WebCore/editing/ReplaceSelectionCommand.h >index a2581cba06b7f40a69449cbfb75fcd8a8530ca26..0b2eb99a1efec728461cd04fc7af9ae2c2559d7b 100644 >--- a/Source/WebCore/editing/ReplaceSelectionCommand.h >+++ b/Source/WebCore/editing/ReplaceSelectionCommand.h >@@ -108,7 +108,9 @@ private: > VisiblePosition positionAtEndOfInsertedContent() const; > > bool shouldPerformSmartReplace() const; >+ bool shouldPerformSmartParagraphReplace() const; > void addSpacesForSmartReplace(); >+ void addNewLinesForSmartReplace(); > void completeHTMLReplacement(const Position& lastPositionToSelect); > void mergeTextNodesAroundPosition(Position&, Position& positionOnlyToBeUpdated); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194880
:
362561
|
362570
|
362571
|
362575
|
362581
|
362752
|
362948
|
363023
|
363050
|
363070
|
363148
|
363170
|
364468
|
364495
|
364496
|
364509
|
364539
|
364542
|
364547
|
364548
|
364699
|
364876
|
365049
|
365076
|
365097