mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1534370 part 3. Mark InsertFromTransferable as MOZ_CAN_RUN_SCRIPT. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23042 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6d1f77b386
commit
9a4ba73134
@ -91,10 +91,11 @@ static void deleteTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
||||
if (accWrap) {
|
||||
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||
RefPtr<HyperTextAccessible> text = accWrap->AsHyperText();
|
||||
if (!text || !text->IsTextRole()) {
|
||||
return;
|
||||
}
|
||||
|
@ -406,6 +406,7 @@ class HyperTextAccessible : public AccessibleWrap {
|
||||
void CopyText(int32_t aStartPos, int32_t aEndPos);
|
||||
void CutText(int32_t aStartPos, int32_t aEndPos);
|
||||
void DeleteText(int32_t aStartPos, int32_t aEndPos);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void PasteText(int32_t aPosition);
|
||||
|
||||
/**
|
||||
|
@ -52,5 +52,6 @@ interface nsIAccessibleEditableText : nsISupports
|
||||
* @param position - index at which to insert the text from the system
|
||||
* clipboard into the text represented by this object.
|
||||
*/
|
||||
[can_run_script]
|
||||
void pasteText(in long position);
|
||||
};
|
||||
|
@ -582,7 +582,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvDeleteText(
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessibleChild::RecvPasteText(
|
||||
const uint64_t& aID, const int32_t& aPosition, bool* aValid) {
|
||||
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
|
||||
RefPtr<HyperTextAccessible> acc = IdToHyperTextAccessible(aID);
|
||||
if (acc && acc->IsTextRole()) {
|
||||
*aValid = acc->IsValidOffset(aPosition);
|
||||
acc->PasteText(aPosition);
|
||||
|
@ -206,6 +206,7 @@ class DocAccessibleChild : public DocAccessibleChildBase {
|
||||
const int32_t& aEndPos,
|
||||
bool* aValid) override;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual mozilla::ipc::IPCResult RecvPasteText(const uint64_t& aID,
|
||||
const int32_t& aPosition,
|
||||
bool* aValid) override;
|
||||
|
@ -77,7 +77,8 @@ STDMETHODIMP
|
||||
ia2AccessibleEditableText::pasteText(long aOffset) {
|
||||
MOZ_ASSERT(!HyperTextProxyFor(this));
|
||||
|
||||
HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
|
||||
RefPtr<HyperTextAccessible> textAcc =
|
||||
static_cast<HyperTextAccessibleWrap*>(this);
|
||||
if (textAcc->IsDefunct()) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (!textAcc->IsValidOffset(aOffset)) return E_INVALIDARG;
|
||||
|
@ -34,6 +34,7 @@ class ia2AccessibleEditableText : public IAccessibleEditableText {
|
||||
/* [in] */ long startOffset,
|
||||
/* [in] */ long endOffset);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual HRESULT STDMETHODCALLTYPE pasteText(
|
||||
/* [in] */ long offset);
|
||||
|
||||
|
@ -643,7 +643,8 @@ xpcAccessibleHyperText::PasteText(int32_t aOffset) {
|
||||
if (mIntl.IsNull()) return NS_ERROR_FAILURE;
|
||||
|
||||
if (mIntl.IsAccessible()) {
|
||||
Intl()->PasteText(aOffset);
|
||||
RefPtr<HyperTextAccessible> acc = Intl();
|
||||
acc->PasteText(aOffset);
|
||||
} else {
|
||||
#if defined(XP_WIN)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -1138,7 +1138,9 @@ EditorBase::CanDelete(bool* aCanDelete) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::Paste(int32_t aClipboardType) {
|
||||
nsresult rv = AsTextEditor()->PasteAsAction(aClipboardType, true);
|
||||
// MOZ_KnownLive because we know "this" must be alive.
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(AsTextEditor())->PasteAsAction(aClipboardType, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -395,7 +395,9 @@ PasteCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
|
||||
}
|
||||
TextEditor* textEditor = editor->AsTextEditor();
|
||||
MOZ_ASSERT(textEditor);
|
||||
return textEditor->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
// MOZ_KnownLive because we are holding a stack ref in "editor".
|
||||
return MOZ_KnownLive(textEditor)
|
||||
->PasteAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -469,7 +471,9 @@ PasteTransferableCommand::DoCommandParams(const char* aCommandName,
|
||||
|
||||
TextEditor* textEditor = editor->AsTextEditor();
|
||||
MOZ_ASSERT(textEditor);
|
||||
nsresult rv = textEditor->PasteTransferable(trans);
|
||||
// We know textEditor is known-live here because we are holding a ref to it
|
||||
// via "editor".
|
||||
nsresult rv = MOZ_KnownLive(textEditor)->PasteTransferable(trans);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1091,8 +1095,10 @@ PasteQuotationCommand::DoCommand(const char* aCommandName,
|
||||
}
|
||||
TextEditor* textEditor = editor->AsTextEditor();
|
||||
MOZ_ASSERT(textEditor);
|
||||
nsresult rv = textEditor->PasteAsQuotationAsAction(
|
||||
nsIClipboard::kGlobalClipboard, true);
|
||||
// MOZ_KnownLive because we are holding a stack ref in "editor".
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(textEditor)
|
||||
->PasteAsQuotationAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1109,8 +1115,10 @@ PasteQuotationCommand::DoCommandParams(const char* aCommandName,
|
||||
}
|
||||
TextEditor* textEditor = editor->AsTextEditor();
|
||||
MOZ_ASSERT(textEditor);
|
||||
nsresult rv = textEditor->PasteAsQuotationAsAction(
|
||||
nsIClipboard::kGlobalClipboard, true);
|
||||
// MOZ_KnownLive because we are holding a stack ref in "editor".
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(textEditor)
|
||||
->PasteAsQuotationAsAction(nsIClipboard::kGlobalClipboard, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class EditorCommandBase : public nsIControllerCommand {
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon,
|
||||
bool* aIsEnabled) override = 0;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon) override = 0;
|
||||
|
||||
@ -44,8 +45,10 @@ class EditorCommandBase : public nsIControllerCommand {
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommandName, \
|
||||
nsISupports* aCommandRefCon, \
|
||||
bool* aIsEnabled) override; \
|
||||
MOZ_CAN_RUN_SCRIPT \
|
||||
NS_IMETHOD DoCommand(const char* aCommandName, \
|
||||
nsISupports* aCommandRefCon) override; \
|
||||
MOZ_CAN_RUN_SCRIPT \
|
||||
NS_IMETHOD DoCommandParams(const char* aCommandName, \
|
||||
nsICommandParams* aParams, \
|
||||
nsISupports* aCommandRefCon) override; \
|
||||
|
@ -134,6 +134,7 @@ class HTMLEditor final : public TextEditor,
|
||||
|
||||
NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
|
||||
|
||||
NS_IMETHOD DeleteNode(nsINode* aNode) override;
|
||||
@ -160,6 +161,7 @@ class HTMLEditor final : public TextEditor,
|
||||
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
||||
* before pasting. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult PasteAsQuotationAsAction(int32_t aClipboardType,
|
||||
bool aDispatchPasteEvent) override;
|
||||
|
||||
@ -1410,6 +1412,7 @@ class HTMLEditor final : public TextEditor,
|
||||
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
||||
* before pasting. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult PasteInternal(int32_t aClipboardType, bool aDispatchPasteEvent);
|
||||
|
||||
/**
|
||||
@ -1950,7 +1953,7 @@ class HTMLEditor final : public TextEditor,
|
||||
// (drag&drop or clipboard)
|
||||
virtual nsresult PrepareTransferable(nsITransferable** transferable) override;
|
||||
nsresult PrepareHTMLTransferable(nsITransferable** transferable);
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult InsertFromTransferable(nsITransferable* transferable,
|
||||
Document* aSourceDoc,
|
||||
const nsAString& aContextStr,
|
||||
|
@ -142,7 +142,9 @@ PasteNoFormattingCommand::DoCommand(const char* aCommandName,
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return htmlEditor->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
|
||||
// Known live because we hold a ref above in "editor"
|
||||
return MOZ_KnownLive(htmlEditor)
|
||||
->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -73,6 +73,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
||||
NS_IMETHOD CanCopy(bool* aCanCopy) override;
|
||||
NS_IMETHOD CanDelete(bool* aCanDelete) override;
|
||||
NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
|
||||
|
||||
NS_IMETHOD OutputToString(const nsAString& aFormatType, uint32_t aFlags,
|
||||
@ -119,6 +120,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
||||
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
||||
* before pasting. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult PasteAsAction(int32_t aClipboardType, bool aDispatchPasteEvent);
|
||||
|
||||
/**
|
||||
@ -141,6 +143,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
||||
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
||||
* before pasting. Otherwise, false.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual nsresult PasteAsQuotationAsAction(int32_t aClipboardType,
|
||||
bool aDispatchPasteEvent);
|
||||
|
||||
|
@ -369,8 +369,9 @@ nsresult TextEditor::PasteAsAction(int32_t aClipboardType,
|
||||
if (AsHTMLEditor()) {
|
||||
editActionData.InitializeDataTransferWithClipboard(
|
||||
SettingDataTransfer::eWithFormat, aClipboardType);
|
||||
nsresult rv =
|
||||
AsHTMLEditor()->PasteInternal(aClipboardType, aDispatchPasteEvent);
|
||||
// MOZ_KnownLive because we know "this" must be alive.
|
||||
nsresult rv = MOZ_KnownLive(AsHTMLEditor())
|
||||
->PasteInternal(aClipboardType, aDispatchPasteEvent);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return EditorBase::ToGenericNSResult(rv);
|
||||
}
|
||||
|
@ -286,11 +286,13 @@ interface nsIEditor : nsISupports
|
||||
/** paste the text in the OS clipboard at the cursor position, replacing
|
||||
* the selected text (if any)
|
||||
*/
|
||||
[can_run_script]
|
||||
void paste(in long aSelectionType);
|
||||
|
||||
/** Paste the text in |aTransferable| at the cursor position, replacing the
|
||||
* selected text (if any).
|
||||
*/
|
||||
[can_run_script]
|
||||
void pasteTransferable(in nsITransferable aTransferable);
|
||||
|
||||
/** Can we paste? True if the doc is modifiable, and we have
|
||||
|
@ -138,6 +138,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* Paste the text in the OS clipboard at the cursor position, replacing
|
||||
* the selected text (if any), but strip out any HTML styles and formatting
|
||||
*/
|
||||
[can_run_script]
|
||||
void pasteNoFormatting(in long aSelectionType);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user