| Index: Source/core/editing/InsertLineBreakCommand.cpp
|
| diff --git a/Source/core/editing/InsertLineBreakCommand.cpp b/Source/core/editing/InsertLineBreakCommand.cpp
|
| index 9a4e72276482140878931745ee8e3af19bccb364..22d9ff26e9b0d85b2225b65b911881ee9362f7a1 100644
|
| --- a/Source/core/editing/InsertLineBreakCommand.cpp
|
| +++ b/Source/core/editing/InsertLineBreakCommand.cpp
|
| @@ -20,7 +20,7 @@
|
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
| * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| #include "config.h"
|
| @@ -43,7 +43,7 @@ namespace WebCore {
|
|
|
| using namespace HTMLNames;
|
|
|
| -InsertLineBreakCommand::InsertLineBreakCommand(Document* document)
|
| +InsertLineBreakCommand::InsertLineBreakCommand(Document* document)
|
| : CompositeEditCommand(document)
|
| {
|
| }
|
| @@ -93,9 +93,9 @@ void InsertLineBreakCommand::doApply()
|
| VisibleSelection selection = endingSelection();
|
| if (!selection.isNonOrphanedCaretOrRange())
|
| return;
|
| -
|
| +
|
| VisiblePosition caret(selection.visibleStart());
|
| - // FIXME: If the node is hidden, we should still be able to insert text.
|
| + // FIXME: If the node is hidden, we should still be able to insert text.
|
| // For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cgi?id=40342
|
| if (caret.isNull())
|
| return;
|
| @@ -103,7 +103,7 @@ void InsertLineBreakCommand::doApply()
|
| Position pos(caret.deepEquivalent());
|
|
|
| pos = positionAvoidingSpecialElementBoundary(pos);
|
| -
|
| +
|
| pos = positionOutsideTabSpan(pos);
|
|
|
| RefPtr<Node> nodeToInsert;
|
| @@ -111,26 +111,26 @@ void InsertLineBreakCommand::doApply()
|
| nodeToInsert = createBreakElement(document());
|
| else
|
| nodeToInsert = document()->createTextNode("\n");
|
| -
|
| +
|
| // FIXME: Need to merge text nodes when inserting just after or before text.
|
|
|
| if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
|
| bool needExtraLineBreak = !pos.deprecatedNode()->hasTagName(hrTag) && !isHTMLTableElement(pos.deprecatedNode());
|
|
|
| insertNodeAt(nodeToInsert.get(), pos);
|
| -
|
| +
|
| if (needExtraLineBreak)
|
| insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert);
|
| -
|
| +
|
| VisiblePosition endingPosition(positionBeforeNode(nodeToInsert.get()));
|
| setEndingSelection(VisibleSelection(endingPosition, endingSelection().isDirectional()));
|
| } else if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.deprecatedNode())) {
|
| insertNodeAt(nodeToInsert.get(), pos);
|
| -
|
| +
|
| // Insert an extra br or '\n' if the just inserted one collapsed.
|
| if (!isStartOfParagraph(positionBeforeNode(nodeToInsert.get())))
|
| insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
|
| -
|
| +
|
| setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM, endingSelection().isDirectional()));
|
| // If we're inserting after all of the rendered text in a text node, or into a non-text node,
|
| // a simple insertion is sufficient.
|
| @@ -143,7 +143,7 @@ void InsertLineBreakCommand::doApply()
|
| splitTextNode(textNode, pos.deprecatedEditingOffset());
|
| insertNodeBefore(nodeToInsert, textNode);
|
| Position endingPosition = firstPositionInNode(textNode);
|
| -
|
| +
|
| // Handle whitespace that occurs after the split
|
| document()->updateLayoutIgnorePendingStylesheets();
|
| if (!endingPosition.isRenderedCharacter()) {
|
| @@ -160,7 +160,7 @@ void InsertLineBreakCommand::doApply()
|
| endingPosition = firstPositionInNode(nbspNode.get());
|
| }
|
| }
|
| -
|
| +
|
| setEndingSelection(VisibleSelection(endingPosition, DOWNSTREAM, endingSelection().isDirectional()));
|
| }
|
|
|
| @@ -176,9 +176,9 @@ void InsertLineBreakCommand::doApply()
|
| applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.get()), lastPositionInOrAfterNode(nodeToInsert.get()));
|
| // Even though this applyStyle operates on a Range, it still sets an endingSelection().
|
| // It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection
|
| - // will either (a) select the line break we inserted, or it will (b) be a caret just
|
| + // will either (a) select the line break we inserted, or it will (b) be a caret just
|
| // before the line break (if the line break is at the end of a block it isn't selectable).
|
| - // So, this next call sets the endingSelection() to a caret just after the line break
|
| + // So, this next call sets the endingSelection() to a caret just after the line break
|
| // that we inserted, or just before it if it's at the end of a block.
|
| setEndingSelection(endingSelection().visibleEnd());
|
| }
|
|
|