<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168652] branches/safari-538.34-branch/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168652">168652</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2014-05-12 16:01:49 -0700 (Mon, 12 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/168650">r168650</a>. </pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari53834branchSourceWebCoreChangeLog">branches/safari-538.34-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreWebCoreexpin">branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#branchessafari53834branchSourceWebCoredomTextEventcpp">branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.cpp</a></li>
<li><a href="#branchessafari53834branchSourceWebCoredomTextEventh">branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.h</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingEditorcpp">branches/safari-538.34-branch/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingEditorh">branches/safari-538.34-branch/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingReplaceSelectionCommandcpp">branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingReplaceSelectionCommandh">branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.h</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingeflEditorEflcpp">branches/safari-538.34-branch/Source/WebCore/editing/efl/EditorEfl.cpp</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingiosEditorIOSmm">branches/safari-538.34-branch/Source/WebCore/editing/ios/EditorIOS.mm</a></li>
<li><a href="#branchessafari53834branchSourceWebCoreeditingmacEditorMacmm">branches/safari-538.34-branch/Source/WebCore/editing/mac/EditorMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari53834branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/ChangeLog (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/ChangeLog        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/ChangeLog        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -1,5 +1,61 @@
</span><span class="cx"> 2014-04-17 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r168650
+
+ 2014-05-12 Brady Eidson <beidson@apple.com>
+
+ Teach Editor to support more direct replacement of a Node
+ <rdar://problem/16817952> and https://bugs.webkit.org/show_bug.cgi?id=132834
+
+ Reviewed by Enrica Casucci.
+
+ The new method "Editor::replaceNodeFromPasteboard" has the intent that the new DocumentFragment
+ from the pasteboard is as similar to the old Node as possible.
+
+ In practice, the new DocumentFragment:
+ 1 - Can represent a single node that's missing various attributes the original Node had.
+ 2 - Can be an unwanted fragment of arbitrary depth when the replacement happens inside Mail.app
+
+ This fixes both of these issues.
+
+ Add a MailBlockquoteHandling enum class for various Editor operations to pass through to the
+ ReplaceSelectionCommand:
+ * editing/Editor.cpp:
+ (WebCore::Editor::handleTextEvent):
+ (WebCore::Editor::pasteAsFragment):
+ (WebCore::Editor::pasteWithPasteboard):
+ (WebCore::Editor::replaceSelectionWithFragment):
+ * editing/Editor.h:
+
+ * dom/TextEvent.cpp:
+ (WebCore::TextEvent::createForPlainTextPaste):
+ (WebCore::TextEvent::createForFragmentPaste):
+ (WebCore::TextEvent::TextEvent):
+ * dom/TextEvent.h:
+ (WebCore::TextEvent::mailBlockquoteHandling):
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand):
+ (WebCore::ReplaceSelectionCommand::doApply): Consider whether or not this particular Editor
+ operation was meant to give special consideration to Mail's Blockquotes.
+ * editing/ReplaceSelectionCommand.h:
+
+ * editing/efl/EditorEfl.cpp:
+ (WebCore::Editor::pasteWithPasteboard):
+ * editing/ios/EditorIOS.mm:
+ (WebCore::Editor::pasteWithPasteboard):
+
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::pasteWithPasteboard):
+ (WebCore::Editor::readSelectionFromPasteboard):
+ (WebCore::maybeCopyNodeAttributesToFragment): If the new DocumentFragment represents a single HTML node
+ with the same tag name is the original HTML node, copy over most attributes from the original node.
+ (WebCore::Editor::replaceNodeFromPasteboard): Create the fragment, run it through maybeCopyNodeAttributesToFragment.
+
+ * WebCore.exp.in:
+
+2014-04-17 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r168565
</span><span class="cx">
</span><span class="cx"> 2014-05-09 Joseph Pecoraro <pecoraro@apple.com>
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/WebCore.exp.in        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -1144,7 +1144,7 @@
</span><span class="cx"> __ZN7WebCore6Editor13rangeForPointERKNS_8IntPointE
</span><span class="cx"> __ZN7WebCore6Editor14setCompositionERKN3WTF6StringERKNS1_6VectorINS_20CompositionUnderlineELm0ENS1_15CrashOnOverflowEEEjj
</span><span class="cx"> __ZN7WebCore6Editor14simplifyMarkupEPNS_4NodeES2_
</span><del>-__ZN7WebCore6Editor15pasteAsFragmentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbb
</del><ins>+__ZN7WebCore6Editor15pasteAsFragmentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbNS_22MailBlockquoteHandlingE
</ins><span class="cx"> __ZN7WebCore6Editor16pasteAsPlainTextEv
</span><span class="cx"> __ZN7WebCore6Editor17cancelCompositionEv
</span><span class="cx"> __ZN7WebCore6Editor17insertOrderedListEv
</span><span class="lines">@@ -1164,7 +1164,7 @@
</span><span class="cx"> __ZN7WebCore6Editor26increaseSelectionListLevelEv
</span><span class="cx"> __ZN7WebCore6Editor26toggleOverwriteModeEnabledEv
</span><span class="cx"> __ZN7WebCore6Editor26writeSelectionToPasteboardERNS_10PasteboardE
</span><del>-__ZN7WebCore6Editor28replaceSelectionWithFragmentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbb
</del><ins>+__ZN7WebCore6Editor28replaceSelectionWithFragmentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbNS_22MailBlockquoteHandlingE
</ins><span class="cx"> __ZN7WebCore6Editor28updateEditorUINowIfScheduledEv
</span><span class="cx"> __ZN7WebCore6Editor29canDecreaseSelectionListLevelEv
</span><span class="cx"> __ZN7WebCore6Editor29canIncreaseSelectionListLevelEv
</span><span class="lines">@@ -2249,7 +2249,7 @@
</span><span class="cx"> __ZN7WebCore6Editor24advanceToNextMisspellingEb
</span><span class="cx"> __ZN7WebCore6Editor25replaceNodeFromPasteboardEPNS_4NodeERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore6Editor26dataSelectionForPasteboardERKN3WTF6StringE
</span><del>-__ZN7WebCore6Editor27readSelectionFromPasteboardERKN3WTF6StringE
</del><ins>+__ZN7WebCore6Editor27readSelectionFromPasteboardERKN3WTF6StringENS_22MailBlockquoteHandlingE
</ins><span class="cx"> __ZN7WebCore6Editor28stringSelectionForPasteboardEv
</span><span class="cx"> __ZN7WebCore6Editor28toggleAutomaticLinkDetectionEv
</span><span class="cx"> __ZN7WebCore6Editor30toggleAutomaticTextReplacementEv
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoredomTextEventcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.cpp (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.cpp        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.cpp        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "TextEvent.h"
</span><span class="cx">
</span><span class="cx"> #include "DocumentFragment.h"
</span><ins>+#include "Editor.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -43,12 +44,12 @@
</span><span class="cx">
</span><span class="cx"> PassRefPtr<TextEvent> TextEvent::createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace)
</span><span class="cx"> {
</span><del>- return adoptRef(new TextEvent(view, data, 0, shouldSmartReplace, false));
</del><ins>+ return adoptRef(new TextEvent(view, data, 0, shouldSmartReplace, false, MailBlockquoteHandling::RespectBlockquote));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle)
</del><ins>+PassRefPtr<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><del>- return adoptRef(new TextEvent(view, "", data, shouldSmartReplace, shouldMatchStyle));
</del><ins>+ return adoptRef(new TextEvent(view, "", data, shouldSmartReplace, shouldMatchStyle, mailBlockquoteHandling));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<TextEvent> TextEvent::createForDrop(PassRefPtr<AbstractView> view, const String& data)
</span><span class="lines">@@ -65,6 +66,7 @@
</span><span class="cx"> : m_inputType(TextEventInputKeyboard)
</span><span class="cx"> , m_shouldSmartReplace(false)
</span><span class="cx"> , m_shouldMatchStyle(false)
</span><ins>+ , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -75,17 +77,18 @@
</span><span class="cx"> , m_pastingFragment(0)
</span><span class="cx"> , m_shouldSmartReplace(false)
</span><span class="cx"> , m_shouldMatchStyle(false)
</span><ins>+ , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment,
- bool shouldSmartReplace, bool shouldMatchStyle)
</del><ins>+TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> : UIEvent(eventNames().textInputEvent, true, true, view, 0)
</span><span class="cx"> , m_inputType(TextEventInputPaste)
</span><span class="cx"> , m_data(data)
</span><span class="cx"> , m_pastingFragment(pastingFragment)
</span><span class="cx"> , m_shouldSmartReplace(shouldSmartReplace)
</span><span class="cx"> , m_shouldMatchStyle(shouldMatchStyle)
</span><ins>+ , m_mailBlockquoteHandling(mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -95,6 +98,7 @@
</span><span class="cx"> , m_data(data)
</span><span class="cx"> , m_shouldSmartReplace(false)
</span><span class="cx"> , m_shouldMatchStyle(false)
</span><ins>+ , m_mailBlockquoteHandling(MailBlockquoteHandling::RespectBlockquote)
</ins><span class="cx"> , m_dictationAlternatives(dictationAlternatives)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoredomTextEventh"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.h (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.h        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/dom/TextEvent.h        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -35,14 +35,16 @@
</span><span class="cx">
</span><span class="cx"> class DocumentFragment;
</span><span class="cx">
</span><ins>+ enum class MailBlockquoteHandling;
+
</ins><span class="cx"> class TextEvent : public UIEvent {
</span><span class="cx"> public:
</span><span class="cx">
</span><span class="cx"> static PassRefPtr<TextEvent> create();
</span><span class="cx"> static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard);
</span><del>- static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace);
- static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle);
- static PassRefPtr<TextEvent> createForDrop(PassRefPtr<AbstractView> view, const String& data);
</del><ins>+ static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView>, const String& data, bool shouldSmartReplace);
+ static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView>, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
+ static PassRefPtr<TextEvent> createForDrop(PassRefPtr<AbstractView>, const String& data);
</ins><span class="cx"> static PassRefPtr<TextEvent> createForDictation(PassRefPtr<AbstractView>, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
</span><span class="cx">
</span><span class="cx"> virtual ~TextEvent();
</span><span class="lines">@@ -62,6 +64,7 @@
</span><span class="cx">
</span><span class="cx"> bool shouldSmartReplace() const { return m_shouldSmartReplace; }
</span><span class="cx"> bool shouldMatchStyle() const { return m_shouldMatchStyle; }
</span><ins>+ MailBlockquoteHandling mailBlockquoteHandling() const { return m_mailBlockquoteHandling; }
</ins><span class="cx"> DocumentFragment* pastingFragment() const { return m_pastingFragment.get(); }
</span><span class="cx"> const Vector<DictationAlternative>& dictationAlternatives() const { return m_dictationAlternatives; }
</span><span class="cx">
</span><span class="lines">@@ -69,8 +72,7 @@
</span><span class="cx"> TextEvent();
</span><span class="cx">
</span><span class="cx"> TextEvent(PassRefPtr<AbstractView>, const String& data, TextEventInputType = TextEventInputKeyboard);
</span><del>- TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment>,
- bool shouldSmartReplace, bool shouldMatchStyle);
</del><ins>+ TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment>, bool shouldSmartReplace, bool shouldMatchStyle, MailBlockquoteHandling);
</ins><span class="cx"> TextEvent(PassRefPtr<AbstractView>, const String& data, const Vector<DictationAlternative>& dictationAlternatives);
</span><span class="cx">
</span><span class="cx"> virtual bool isTextEvent() const override;
</span><span class="lines">@@ -81,6 +83,7 @@
</span><span class="cx"> RefPtr<DocumentFragment> m_pastingFragment;
</span><span class="cx"> bool m_shouldSmartReplace;
</span><span class="cx"> bool m_shouldMatchStyle;
</span><ins>+ MailBlockquoteHandling m_mailBlockquoteHandling;
</ins><span class="cx"> Vector<DictationAlternative> m_dictationAlternatives;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/Editor.cpp (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/Editor.cpp        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/Editor.cpp        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -266,7 +266,7 @@
</span><span class="cx"> if (client()->performsTwoStepPaste(event->pastingFragment()))
</span><span class="cx"> return true;
</span><span class="cx"> #endif
</span><del>- replaceSelectionWithFragment(event->pastingFragment(), false, event->shouldSmartReplace(), event->shouldMatchStyle());
</del><ins>+ replaceSelectionWithFragment(event->pastingFragment(), false, event->shouldSmartReplace(), event->shouldMatchStyle(), event->mailBlockquoteHandling());
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -528,12 +528,12 @@
</span><span class="cx"> target->dispatchEvent(TextEvent::createForPlainTextPaste(document().domWindow(), pastingText, smartReplace), IGNORE_EXCEPTION);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle)
</del><ins>+void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle, MailBlockquoteHandling respectsMailBlockquote)
</ins><span class="cx"> {
</span><span class="cx"> Node* target = findEventTargetFromSelection();
</span><span class="cx"> if (!target)
</span><span class="cx"> return;
</span><del>- target->dispatchEvent(TextEvent::createForFragmentPaste(document().domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION);
</del><ins>+ target->dispatchEvent(TextEvent::createForFragmentPaste(document().domWindow(), pastingFragment, smartReplace, matchStyle, respectsMailBlockquote), IGNORE_EXCEPTION);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Editor::pasteAsPlainTextBypassingDHTML()
</span><span class="lines">@@ -565,7 +565,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(COCOA) && !PLATFORM(EFL)
</span><del>-void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
</del><ins>+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<Range> range = selectedRange();
</span><span class="cx"> if (!range)
</span><span class="lines">@@ -574,7 +574,7 @@
</span><span class="cx"> bool chosePlainText;
</span><span class="cx"> RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
</span><span class="cx"> if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
</span><del>- pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText);
</del><ins>+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -597,7 +597,7 @@
</span><span class="cx"> return client()->shouldInsertNode(fragment.get(), replacingDOMRange.get(), givenAction);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
</del><ins>+void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment, bool selectReplacement, bool smartReplace, bool matchStyle, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> VisibleSelection selection = m_frame.selection().selection();
</span><span class="cx"> if (selection.isNone() || !selection.isContentEditable() || !fragment)
</span><span class="lines">@@ -610,6 +610,9 @@
</span><span class="cx"> options |= ReplaceSelectionCommand::SmartReplace;
</span><span class="cx"> if (matchStyle)
</span><span class="cx"> options |= ReplaceSelectionCommand::MatchStyle;
</span><ins>+ if (mailBlockquoteHandling == MailBlockquoteHandling::IgnoreBlockquote)
+ options |= ReplaceSelectionCommand::IgnoreMailBlockquote;
+
</ins><span class="cx"> applyCommand(ReplaceSelectionCommand::create(document(), fragment, options, EditActionPaste));
</span><span class="cx"> revealSelectionAfterEditingOperation();
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/Editor.h (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/Editor.h        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/Editor.h        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -90,6 +90,11 @@
</span><span class="cx"> enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM, CommandFromDOMWithUserInterface };
</span><span class="cx"> enum EditorParagraphSeparator { EditorParagraphSeparatorIsDiv, EditorParagraphSeparatorIsP };
</span><span class="cx">
</span><ins>+enum class MailBlockquoteHandling {
+ RespectBlockquote,
+ IgnoreBlockquote,
+};
+
</ins><span class="cx"> class Editor {
</span><span class="cx"> public:
</span><span class="cx"> explicit Editor(Frame&);
</span><span class="lines">@@ -335,7 +340,7 @@
</span><span class="cx"> void handleAlternativeTextUIResult(const String& correction);
</span><span class="cx"> void dismissCorrectionPanelAsIgnored();
</span><span class="cx">
</span><del>- void pasteAsFragment(PassRefPtr<DocumentFragment>, bool smartReplace, bool matchStyle);
</del><ins>+ void pasteAsFragment(PassRefPtr<DocumentFragment>, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</ins><span class="cx"> void pasteAsPlainText(const String&, bool smartReplace);
</span><span class="cx">
</span><span class="cx"> // This is only called on the mac where paste is implemented primarily at the WebKit level.
</span><span class="lines">@@ -377,7 +382,7 @@
</span><span class="cx"> void textDidChangeInTextArea(Element*);
</span><span class="cx"> WritingDirection baseWritingDirectionForSelectionStart() const;
</span><span class="cx">
</span><del>- void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle);
</del><ins>+ void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</ins><span class="cx"> void replaceSelectionWithText(const String&, bool selectReplacement, bool smartReplace);
</span><span class="cx"> bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int length) const;
</span><span class="cx"> void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSelection);
</span><span class="lines">@@ -431,7 +436,7 @@
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> bool canCopyExcludingStandaloneImages();
</span><span class="cx"> void takeFindStringFromSelection();
</span><del>- void readSelectionFromPasteboard(const String& pasteboardName);
</del><ins>+ void readSelectionFromPasteboard(const String& pasteboardName, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</ins><span class="cx"> void replaceNodeFromPasteboard(Node*, const String& pasteboardName);
</span><span class="cx"> PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
</span><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="lines">@@ -450,7 +455,7 @@
</span><span class="cx"> bool canDeleteRange(Range*) const;
</span><span class="cx"> bool canSmartReplaceWithPasteboard(Pasteboard&);
</span><span class="cx"> void pasteAsPlainTextWithPasteboard(Pasteboard&);
</span><del>- void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
</del><ins>+ void pasteWithPasteboard(Pasteboard*, bool allowPlainText, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</ins><span class="cx"> String plainTextFromPasteboard(const PasteboardPlainText&);
</span><span class="cx">
</span><span class="cx"> void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingReplaceSelectionCommandcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -378,6 +378,7 @@
</span><span class="cx"> , m_editAction(editAction)
</span><span class="cx"> , m_sanitizeFragment(options & SanitizeFragment)
</span><span class="cx"> , m_shouldMergeEnd(false)
</span><ins>+ , m_ignoreMailBlockquote(options & IgnoreMailBlockquote)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -933,12 +934,12 @@
</span><span class="cx"> Node* startBlock = enclosingBlock(visibleStart.deepEquivalent().deprecatedNode());
</span><span class="cx">
</span><span class="cx"> Position insertionPos = selection.start();
</span><del>- bool startIsInsideMailBlockquote = enclosingNodeOfType(insertionPos, isMailBlockquote, CanCrossEditingBoundary);
</del><ins>+ bool shouldHandleMailBlockquote = enclosingNodeOfType(insertionPos, isMailBlockquote, CanCrossEditingBoundary) && !m_ignoreMailBlockquote;
</ins><span class="cx"> bool selectionIsPlainText = !selection.isContentRichlyEditable();
</span><span class="cx"> Element* currentRoot = selection.rootEditableElement();
</span><span class="cx">
</span><del>- if ((selectionStartWasStartOfParagraph && selectionEndWasEndOfParagraph && !startIsInsideMailBlockquote) ||
- startBlock == currentRoot || isListItem(startBlock) || selectionIsPlainText)
</del><ins>+ if ((selectionStartWasStartOfParagraph && selectionEndWasEndOfParagraph && !shouldHandleMailBlockquote)
+ || startBlock == currentRoot || isListItem(startBlock) || selectionIsPlainText)
</ins><span class="cx"> m_preventNesting = false;
</span><span class="cx">
</span><span class="cx"> if (selection.isRange()) {
</span><span class="lines">@@ -948,7 +949,7 @@
</span><span class="cx"> // will leave hanging block(s).
</span><span class="cx"> // Merge blocks if the start of the selection was in a Mail blockquote, since we handle
</span><span class="cx"> // that case specially to prevent nesting.
</span><del>- bool mergeBlocksAfterDelete = startIsInsideMailBlockquote || isEndOfParagraph(visibleEnd) || isStartOfBlock(visibleStart);
</del><ins>+ bool mergeBlocksAfterDelete = shouldHandleMailBlockquote || isEndOfParagraph(visibleEnd) || isStartOfBlock(visibleStart);
</ins><span class="cx"> // FIXME: We should only expand to include fully selected special elements if we are copying a
</span><span class="cx"> // selection and pasting it on top of itself.
</span><span class="cx"> deleteSelection(false, mergeBlocksAfterDelete, true, false);
</span><span class="lines">@@ -977,7 +978,7 @@
</span><span class="cx"> // As long as the div styles are the same, visually you'd expect: <div>xbar</div><div>bar</div><div>bazx</div>,
</span><span class="cx"> // not <div>xbar<div>bar</div><div>bazx</div></div>.
</span><span class="cx"> // Don't do this if the selection started in a Mail blockquote.
</span><del>- if (m_preventNesting && !startIsInsideMailBlockquote && !isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {
</del><ins>+ if (m_preventNesting && !shouldHandleMailBlockquote && !isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {
</ins><span class="cx"> insertParagraphSeparator();
</span><span class="cx"> setEndingSelection(endingSelection().visibleStart().previous());
</span><span class="cx"> }
</span><span class="lines">@@ -987,7 +988,7 @@
</span><span class="cx"> // We don't want any of the pasted content to end up nested in a Mail blockquote, so first break
</span><span class="cx"> // out of any surrounding Mail blockquotes. Unless we're inserting in a table, in which case
</span><span class="cx"> // breaking the blockquote will prevent the content from actually being inserted in the table.
</span><del>- if (startIsInsideMailBlockquote && m_preventNesting && !(enclosingNodeOfType(insertionPos, &isTableStructureNode))) {
</del><ins>+ if (shouldHandleMailBlockquote && m_preventNesting && !(enclosingNodeOfType(insertionPos, &isTableStructureNode))) {
</ins><span class="cx"> applyCommandToComposite(BreakBlockquoteCommand::create(document()));
</span><span class="cx"> // This will leave a br between the split.
</span><span class="cx"> Node* br = endingSelection().start().deprecatedNode();
</span><span class="lines">@@ -1016,7 +1017,7 @@
</span><span class="cx">
</span><span class="cx"> // Adjust insertionPos to prevent nesting.
</span><span class="cx"> // If the start was in a Mail blockquote, we will have already handled adjusting insertionPos above.
</span><del>- if (m_preventNesting && insertionBlock && !isTableCell(insertionBlock.get()) && !startIsInsideMailBlockquote) {
</del><ins>+ if (m_preventNesting && insertionBlock && !isTableCell(insertionBlock.get()) && !shouldHandleMailBlockquote) {
</ins><span class="cx"> ASSERT(insertionBlock != currentRoot);
</span><span class="cx"> VisiblePosition visibleInsertionPos(insertionPos);
</span><span class="cx"> if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInsertionPos) && fragment.hasInterchangeNewlineAtEnd()))
</span><span class="lines">@@ -1162,7 +1163,7 @@
</span><span class="cx"> // the start merge so that the start merge doesn't effect our decision.
</span><span class="cx"> m_shouldMergeEnd = shouldMergeEnd(selectionEndWasEndOfParagraph);
</span><span class="cx">
</span><del>- if (shouldMergeStart(selectionStartWasStartOfParagraph, fragment.hasInterchangeNewlineAtStart(), startIsInsideMailBlockquote)) {
</del><ins>+ if (shouldMergeStart(selectionStartWasStartOfParagraph, fragment.hasInterchangeNewlineAtStart(), shouldHandleMailBlockquote)) {
</ins><span class="cx"> VisiblePosition startOfParagraphToMove = positionAtStartOfInsertedContent();
</span><span class="cx"> VisiblePosition destination = startOfParagraphToMove.previous();
</span><span class="cx"> // We need to handle the case where we need to merge the end
</span><span class="lines">@@ -1211,7 +1212,7 @@
</span><span class="cx"> } else {
</span><span class="cx"> // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph
</span><span class="cx"> // block's style seems to annoy users.
</span><del>- insertParagraphSeparator(true, !startIsInsideMailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(),
</del><ins>+ insertParagraphSeparator(true, !shouldHandleMailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(),
</ins><span class="cx"> isMailBlockquote, CannotCrossEditingBoundary, insertedNodes.firstNodeInserted()->parentNode()));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingReplaceSelectionCommandh"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.h (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.h        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/ReplaceSelectionCommand.h        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -42,7 +42,8 @@
</span><span class="cx"> MatchStyle = 1 << 2,
</span><span class="cx"> PreventNesting = 1 << 3,
</span><span class="cx"> MovingParagraph = 1 << 4,
</span><del>- SanitizeFragment = 1 << 5
</del><ins>+ SanitizeFragment = 1 << 5,
+ IgnoreMailBlockquote = 1 << 6,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef unsigned CommandOptions;
</span><span class="lines">@@ -115,6 +116,7 @@
</span><span class="cx"> EditAction m_editAction;
</span><span class="cx"> bool m_sanitizeFragment;
</span><span class="cx"> bool m_shouldMergeEnd;
</span><ins>+ bool m_ignoreMailBlockquote;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingeflEditorEflcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/efl/EditorEfl.cpp (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/efl/EditorEfl.cpp        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/efl/EditorEfl.cpp        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::pasteWithPasteboard(Pasteboard*, bool)
</del><ins>+void Editor::pasteWithPasteboard(Pasteboard*, bool, MailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingiosEditorIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/ios/EditorIOS.mm (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/ios/EditorIOS.mm        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/ios/EditorIOS.mm        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -536,7 +536,7 @@
</span><span class="cx"> return reader.fragment.release();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
</del><ins>+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<Range> range = selectedRange();
</span><span class="cx">
</span><span class="lines">@@ -546,7 +546,7 @@
</span><span class="cx"> fragment = webContentFromPasteboard(*pasteboard, *range, allowPlainText, chosePlainText);
</span><span class="cx">
</span><span class="cx"> if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
</span><del>- pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false);
</del><ins>+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebCoreeditingmacEditorMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebCore/editing/mac/EditorMac.mm (168651 => 168652)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebCore/editing/mac/EditorMac.mm        2014-05-12 22:57:46 UTC (rev 168651)
+++ branches/safari-538.34-branch/Source/WebCore/editing/mac/EditorMac.mm        2014-05-12 23:01:49 UTC (rev 168652)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> [[NSApplication sharedApplication] orderFrontColorPanel:nil];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText)
</del><ins>+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<Range> range = selectedRange();
</span><span class="cx">
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> RefPtr<DocumentFragment> fragment = webContentFromPasteboard(*pasteboard, *range, allowPlainText, chosePlainText);
</span><span class="cx">
</span><span class="cx"> if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
</span><del>- pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false);
</del><ins>+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
</ins><span class="cx">
</span><span class="cx"> client()->setInsertionPasteboard(String());
</span><span class="cx"> }
</span><span class="lines">@@ -256,15 +256,39 @@
</span><span class="cx"> platformStrategies()->pasteboardStrategy()->setStringForType(m_frame.displayStringModifiedByEncoding(selectedTextForDataTransfer()), NSStringPboardType, NSFindPboard);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::readSelectionFromPasteboard(const String& pasteboardName)
</del><ins>+void Editor::readSelectionFromPasteboard(const String& pasteboardName, MailBlockquoteHandling mailBlockquoteHandling)
</ins><span class="cx"> {
</span><span class="cx"> Pasteboard pasteboard(pasteboardName);
</span><span class="cx"> if (m_frame.selection().selection().isContentRichlyEditable())
</span><del>- pasteWithPasteboard(&pasteboard, true);
</del><ins>+ pasteWithPasteboard(&pasteboard, true, mailBlockquoteHandling);
</ins><span class="cx"> else
</span><span class="cx"> pasteAsPlainTextWithPasteboard(pasteboard);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void maybeCopyNodeAttributesToFragment(Node* node, DocumentFragment* fragment)
+{
+ // This is only supported for single-Node fragments.
+ Node* firstChild = fragment->firstChild();
+ if (firstChild != fragment->lastChild())
+ return;
+
+ // And only supported for HTML elements.
+ if (!node->isHTMLElement() || !firstChild->isHTMLElement())
+ return;
+
+ // And only if the source Element and destination Element have the same HTML tag name.
+ const Element& oldElement = toHTMLElement(*node);
+ Element& newElement = toHTMLElement(*firstChild);
+ if (!oldElement.hasTagName(newElement.tagQName()))
+ return;
+
+ for (const Attribute& attribute : oldElement.attributesIterator()) {
+ if (newElement.hasAttribute(attribute.name()))
+ continue;
+ newElement.setAttribute(attribute.name(), attribute.value());
+ }
+}
+
</ins><span class="cx"> void Editor::replaceNodeFromPasteboard(Node* node, const String& pasteboardName)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(node);
</span><span class="lines">@@ -275,7 +299,25 @@
</span><span class="cx"> RefPtr<Range> range = Range::create(node->document(), Position(node, Position::PositionIsBeforeAnchor), Position(node, Position::PositionIsAfterAnchor));
</span><span class="cx"> m_frame.selection().setSelection(VisibleSelection(range.get()), FrameSelection::DoNotSetFocus);
</span><span class="cx">
</span><del>- readSelectionFromPasteboard(pasteboardName);
</del><ins>+ Pasteboard pasteboard(pasteboardName);
+
+ if (!m_frame.selection().selection().isContentRichlyEditable()) {
+ pasteAsPlainTextWithPasteboard(pasteboard);
+ return;
+ }
+
+ // FIXME: How can this hard-coded pasteboard name be right, given that the passed-in pasteboard has a name?
+ client()->setInsertionPasteboard(NSGeneralPboard);
+
+ bool chosePlainText;
+ RefPtr<DocumentFragment> fragment = webContentFromPasteboard(pasteboard, *range, true, chosePlainText);
+
+ maybeCopyNodeAttributesToFragment(node, fragment.get());
+
+ if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(pasteboard), false, MailBlockquoteHandling::IgnoreBlockquote);
+
+ client()->setInsertionPasteboard(String());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME: Makes no sense that selectedTextForDataTransfer always includes alt text, but stringSelectionForPasteboard does not.
</span></span></pre>
</div>
</div>
</body>
</html>