- Revision
- 151620
- Author
- [email protected]
- Date
- 2013-06-15 19:21:24 -0700 (Sat, 15 Jun 2013)
Log Message
Move Pasteboard::getStringSelection to Editor, fixing a layering violation
https://bugs.webkit.org/show_bug.cgi?id=117673
Reviewed by Ryosuke Niwa.
* editing/Editor.h: Added stringSelectionForPasteboardWithImageAltText.
* editing/mac/EditorMac.mm:
(WebCore::Editor::stringSelectionForPasteboard): Moved code here from the Pasteboard
class, since all the Pasteboard class did really was turn around and call back here.
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Added. Variant of
the function above that includes image alt text. Separate named functions are often
the best pattern for something like this unless there are many different combinations.
* platform/Pasteboard.h: Remove the Mac-only Pasteboard::getStringSelectioon.
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::writeSelection):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::writeSelectionForTypes):
Call the two new functions instead of the old Pasteboard::getStringSelection.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151619 => 151620)
--- trunk/Source/WebCore/ChangeLog 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/ChangeLog 2013-06-16 02:21:24 UTC (rev 151620)
@@ -1,5 +1,29 @@
2013-06-15 Darin Adler <[email protected]>
+ Move Pasteboard::getStringSelection to Editor, fixing a layering violation
+ https://bugs.webkit.org/show_bug.cgi?id=117673
+
+ Reviewed by Ryosuke Niwa.
+
+ * editing/Editor.h: Added stringSelectionForPasteboardWithImageAltText.
+
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::stringSelectionForPasteboard): Moved code here from the Pasteboard
+ class, since all the Pasteboard class did really was turn around and call back here.
+ (WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Added. Variant of
+ the function above that includes image alt text. Separate named functions are often
+ the best pattern for something like this unless there are many different combinations.
+
+ * platform/Pasteboard.h: Remove the Mac-only Pasteboard::getStringSelectioon.
+
+ * platform/ios/PasteboardIOS.mm:
+ (WebCore::Pasteboard::writeSelection):
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::writeSelectionForTypes):
+ Call the two new functions instead of the old Pasteboard::getStringSelection.
+
+2013-06-15 Darin Adler <[email protected]>
+
Support using clang instead of gcc for bindings preprocessing
https://bugs.webkit.org/show_bug.cgi?id=117674
Modified: trunk/Source/WebCore/editing/Editor.h (151619 => 151620)
--- trunk/Source/WebCore/editing/Editor.h 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/editing/Editor.h 2013-06-16 02:21:24 UTC (rev 151620)
@@ -397,6 +397,7 @@
void writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes);
void readSelectionFromPasteboard(const String& pasteboardName);
String stringSelectionForPasteboard();
+ String stringSelectionForPasteboardWithImageAltText();
PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
#endif
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (151619 => 151620)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2013-06-16 02:21:24 UTC (rev 151620)
@@ -274,11 +274,22 @@
pasteAsPlainTextWithPasteboard(&pasteboard);
}
+// FIXME: Makes no sense that selectedTextForClipboard always includes alt text, but stringSelectionForPasteboard does not.
+// This was left in a bad state when selectedTextForClipboard was added. Need to look over clients and fix this.
String Editor::stringSelectionForPasteboard()
{
- return Pasteboard::getStringSelection(m_frame, DefaultSelectedTextType);
+ String text = selectedText();
+ text.replace(noBreakSpace, ' ');
+ return text;
}
+String Editor::stringSelectionForPasteboardWithImageAltText()
+{
+ String text = selectedTextForClipboard();
+ text.replace(noBreakSpace, ' ');
+ return text;
+}
+
PassRefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteboardType)
{
return Pasteboard::getDataSelection(m_frame, pasteboardType);
Modified: trunk/Source/WebCore/platform/Pasteboard.h (151619 => 151620)
--- trunk/Source/WebCore/platform/Pasteboard.h 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2013-06-16 02:21:24 UTC (rev 151620)
@@ -98,10 +98,6 @@
static PassRefPtr<SharedBuffer> getDataSelection(Frame*, const String& pasteboardType);
#endif
-#if PLATFORM(MAC)
- static String getStringSelection(Frame*, ShouldSerializeSelectedTextForClipboard);
-#endif
-
#if PLATFORM(GTK)
static PassOwnPtr<Pasteboard> create(PassRefPtr<DataObjectGtk>);
static PassOwnPtr<Pasteboard> create(GtkClipboard*);
Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (151619 => 151620)
--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm 2013-06-16 02:21:24 UTC (rev 151620)
@@ -114,13 +114,6 @@
{
}
-String Pasteboard::getStringSelection(Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
-{
- String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText();
- text.replace(noBreakSpace, ' ');
- return text;
-}
-
void Pasteboard::writeSelection(Range* selectedRange, bool /*canSmartCopyOrDelete*/, Frame *frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
{
ASSERT(selectedRange);
@@ -159,7 +152,10 @@
}
// Put plain string on the pasteboard.
- [representations.get() setValue:getStringSelection(frame, shouldSerializeSelectedTextForClipboard) forKey:(NSString *)kUTTypeText];
+ String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard
+ ? frame->editor().stringSelectionForPasteboardWithImageAltText()
+ : frame->editor().stringSelectionForPasteboard();
+ [representations.get() setValue:text forKey:(NSString *)kUTTypeText];
frame->editor().client()->writeDataToPasteboard(representations.get());
}
Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (151619 => 151620)
--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-06-16 02:15:41 UTC (rev 151619)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm 2013-06-16 02:21:24 UTC (rev 151620)
@@ -158,13 +158,6 @@
platformStrategies()->pasteboardStrategy()->setTypes(Vector<String>(), m_pasteboardName);
}
-String Pasteboard::getStringSelection(Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
-{
- String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText();
- text.replace(noBreakSpace, ' ');
- return text;
-}
-
PassRefPtr<SharedBuffer> Pasteboard::getDataSelection(Frame* frame, const String& pasteboardType)
{
if (pasteboardType == WebArchivePboardType) {
@@ -230,8 +223,12 @@
platformStrategies()->pasteboardStrategy()->setBufferForType(getDataSelection(frame, NSRTFPboardType), NSRTFPboardType, m_pasteboardName);
// Put plain string on the pasteboard.
- if (types.contains(String(NSStringPboardType)))
- platformStrategies()->pasteboardStrategy()->setStringForType(getStringSelection(frame, shouldSerializeSelectedTextForClipboard), NSStringPboardType, m_pasteboardName);
+ if (types.contains(String(NSStringPboardType))) {
+ String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard
+ ? frame->editor().stringSelectionForPasteboardWithImageAltText()
+ : frame->editor().stringSelectionForPasteboard();
+ platformStrategies()->pasteboardStrategy()->setStringForType(text, NSStringPboardType, m_pasteboardName);
+ }
if (types.contains(WebSmartPastePboardType))
platformStrategies()->pasteboardStrategy()->setBufferForType(0, WebSmartPastePboardType, m_pasteboardName);