Bug 392159 Use nsIClipboard::SupportsSelectionClipboard() instead of #ifdef in nsEditorEventListener r=ehsan

This commit is contained in:
Masayuki Nakano 2011-11-30 11:57:41 +09:00
Родитель 91f3fcbf24
Коммит a0d25e7690
4 изменённых файлов: 22 добавлений и 15 удалений

Просмотреть файл

@ -590,13 +590,16 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
if (ctrlKey)
mailEditor = do_QueryObject(mEditor);
PRInt32 clipboard;
#if defined(XP_OS2) || defined(XP_WIN32)
clipboard = nsIClipboard::kGlobalClipboard;
#else
clipboard = nsIClipboard::kSelectionClipboard;
#endif
PRInt32 clipboard = nsIClipboard::kGlobalClipboard;
nsCOMPtr<nsIClipboard> clipboardService =
do_GetService("@mozilla.org/widget/clipboard;1", &rv);
if (NS_SUCCEEDED(rv)) {
bool selectionSupported;
rv = clipboardService->SupportsSelectionClipboard(&selectionSupported);
if (NS_SUCCEEDED(rv) && selectionSupported) {
clipboard = nsIClipboard::kSelectionClipboard;
}
}
if (mailEditor)
mailEditor->PasteAsQuotation(clipboard);

Просмотреть файл

@ -87,6 +87,7 @@ _TEST_FILES = \
test_bug668599.html \
test_bug674770-1.html \
file_bug674770-1.html \
test_bug674770-2.html \
test_bug674861.html \
test_bug676401.html \
test_bug677752.html \
@ -99,11 +100,6 @@ _TEST_FILES = \
test_root_element_replacement.html \
$(NULL)
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
_TEST_FILES += test_bug674770-2.html \
$(NULL)
endif
ifneq (mobile,$(MOZ_BUILD_APP))
_TEST_FILES += test_spellcheck_pref.html \
$(NULL)

Просмотреть файл

@ -64,9 +64,9 @@ SimpleTest.waitForFocus(function() {
SimpleTest.executeSoon(function() {
synthesizeKey("a", { accelKey: true }, frameWindow);
// Windows doesn't have primary selection, we should copy the text to the
// global clipboard.
if (navigator.platform.indexOf("Win") == 0) {
// Windows and Mac don't have primary selection, we should copy the text to
// the global clipboard.
if (!SpecialPowers.supportsSelectionClipboard()) {
SimpleTest.waitForClipboard("pasted",
function() { synthesizeKey("c", { accelKey: true }, frameWindow); },
function() { SimpleTest.executeSoon(runInputTests1) },

Просмотреть файл

@ -687,6 +687,14 @@ SpecialPowersAPI.prototype = {
cbHelperSvc.copyString(preExpectedVal);
},
supportsSelectionClipboard: function() {
if (this._cb == null) {
this._cb = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
}
return this._cb.supportsSelectionClipboard();
},
snapshotWindow: function (win, withCaret) {
var el = this.window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
el.width = win.innerWidth;