| Index: Source/core/editing/DeleteSelectionCommand.cpp
|
| diff --git a/Source/core/editing/DeleteSelectionCommand.cpp b/Source/core/editing/DeleteSelectionCommand.cpp
|
| index b006a9af715a30bf4c4e4bca88ac3bb162bb4dbf..013108ba9d880293d45f4153195ee51ce89c2aef 100644
|
| --- a/Source/core/editing/DeleteSelectionCommand.cpp
|
| +++ b/Source/core/editing/DeleteSelectionCommand.cpp
|
| @@ -37,8 +37,7 @@
|
| #include "core/editing/Editor.h"
|
| #include "core/editing/VisibleUnits.h"
|
| #include "core/editing/htmlediting.h"
|
| -#include "core/html/HTMLInputElement.h"
|
| -#include "core/html/HTMLTextAreaElement.h"
|
| +#include "core/html/HTMLTextFormControlElement.h"
|
| #include "core/page/EditorClient.h"
|
| #include "core/page/Frame.h"
|
| #include "core/rendering/RenderTableCell.h"
|
| @@ -70,6 +69,23 @@ static bool isTableRowEmpty(Node* row)
|
| return true;
|
| }
|
|
|
| +static bool shouldNotHavePlaceholder(HTMLTextFormControlElement* textControl)
|
| +{
|
| + if (!textControl)
|
| + return false;
|
| +
|
| + Node* textElement = textControl->innerTextElement();
|
| + if (!textElement)
|
| + return false;
|
| +
|
| + // When text control is empty, we don't need to have placeholder.
|
| + if (!textElement->firstChild())
|
| + return true;
|
| +
|
| + // Text control ends with placeholder.
|
| + return textElement->lastChild()->hasTagName(brTag);
|
| +}
|
| +
|
| DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements, bool sanitizeMarkup)
|
| : CompositeEditCommand(document)
|
| , m_hasSelectionToDelete(false)
|
| @@ -802,7 +818,9 @@ void DeleteSelectionCommand::doApply()
|
| m_needPlaceholder = false;
|
| }
|
|
|
| -
|
| +
|
| + RefPtr<HTMLTextFormControlElement> textControl = enclosingTextFormControl(m_selectionToDelete.start());
|
| +
|
| // set up our state
|
| initializePositionData();
|
|
|
| @@ -828,7 +846,10 @@ void DeleteSelectionCommand::doApply()
|
| mergeParagraphs();
|
|
|
| removePreviouslySelectedEmptyTableRows();
|
| -
|
| +
|
| + if (m_needPlaceholder && shouldNotHavePlaceholder(textControl.get()))
|
| + m_needPlaceholder = false;
|
| +
|
| RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).get() : 0;
|
|
|
| if (placeholder) {
|
|
|