Bug 920377 part.4 Get rid of nsContentCommandEvent r=roc

This commit is contained in:
Masayuki Nakano 2013-09-27 15:20:54 +09:00
parent feae1c147e
commit 8330b5b7f1
12 changed files with 55 additions and 45 deletions

View File

@ -1073,12 +1073,13 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case NS_CONTENT_COMMAND_REDO:
case NS_CONTENT_COMMAND_PASTE_TRANSFERABLE:
{
DoContentCommandEvent(static_cast<nsContentCommandEvent*>(aEvent));
DoContentCommandEvent(static_cast<WidgetContentCommandEvent*>(aEvent));
}
break;
case NS_CONTENT_COMMAND_SCROLL:
{
DoContentCommandScrollEvent(static_cast<nsContentCommandEvent*>(aEvent));
DoContentCommandScrollEvent(
static_cast<WidgetContentCommandEvent*>(aEvent));
}
break;
case NS_TEXT_TEXT:
@ -4921,7 +4922,7 @@ nsEventStateManager::IsShellVisible(nsIDocShell* aShell)
}
nsresult
nsEventStateManager::DoContentCommandEvent(nsContentCommandEvent* aEvent)
nsEventStateManager::DoContentCommandEvent(WidgetContentCommandEvent* aEvent)
{
EnsureDocument(mPresContext);
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
@ -4996,7 +4997,8 @@ nsEventStateManager::DoContentCommandEvent(nsContentCommandEvent* aEvent)
}
nsresult
nsEventStateManager::DoContentCommandScrollEvent(nsContentCommandEvent* aEvent)
nsEventStateManager::DoContentCommandScrollEvent(
WidgetContentCommandEvent* aEvent)
{
NS_ENSURE_TRUE(mPresContext, NS_ERROR_NOT_AVAILABLE);
nsIPresShell* ps = mPresContext->GetPresShell();
@ -5005,13 +5007,13 @@ nsEventStateManager::DoContentCommandScrollEvent(nsContentCommandEvent* aEvent)
nsIScrollableFrame::ScrollUnit scrollUnit;
switch (aEvent->mScroll.mUnit) {
case nsContentCommandEvent::eCmdScrollUnit_Line:
case WidgetContentCommandEvent::eCmdScrollUnit_Line:
scrollUnit = nsIScrollableFrame::LINES;
break;
case nsContentCommandEvent::eCmdScrollUnit_Page:
case WidgetContentCommandEvent::eCmdScrollUnit_Page:
scrollUnit = nsIScrollableFrame::PAGES;
break;
case nsContentCommandEvent::eCmdScrollUnit_Whole:
case WidgetContentCommandEvent::eCmdScrollUnit_Whole:
scrollUnit = nsIScrollableFrame::WHOLE;
break;
default:

View File

@ -704,8 +704,9 @@ protected:
*/
void FillInEventFromGestureDown(nsMouseEvent* aEvent);
nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
nsresult DoContentCommandEvent(mozilla::WidgetContentCommandEvent* aEvent);
nsresult DoContentCommandScrollEvent(
mozilla::WidgetContentCommandEvent* aEvent);
void DoQuerySelectedText(nsQueryContentEvent* aEvent);

View File

@ -2015,7 +2015,7 @@ nsDOMWindowUtils::SendContentCommandEvent(const nsAString& aType,
else
return NS_ERROR_FAILURE;
nsContentCommandEvent event(true, msg, widget);
WidgetContentCommandEvent event(true, msg, widget);
if (msg == NS_CONTENT_COMMAND_PASTE_TRANSFERABLE) {
event.mTransferable = aTransferable;
}

View File

@ -136,6 +136,5 @@ typedef mozilla::InternalClipboardEvent nsClipboardEvent;
typedef mozilla::InternalFocusEvent nsFocusEvent;
typedef mozilla::InternalTransitionEvent nsTransitionEvent;
typedef mozilla::InternalAnimationEvent nsAnimationEvent;
typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
#endif // mozilla_EventForwards_h__

View File

@ -115,7 +115,4 @@ public:
} // namespace mozilla
// TODO: Remove following typedefs
typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
#endif // mozilla_MiscEvents_h__

View File

@ -2026,8 +2026,9 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
}
// Delete the selected range.
nsRefPtr<TextInputHandler> kungFuDeathGrip(this);
nsContentCommandEvent deleteCommandEvent(true, NS_CONTENT_COMMAND_DELETE,
mWidget);
WidgetContentCommandEvent deleteCommandEvent(true,
NS_CONTENT_COMMAND_DELETE,
mWidget);
DispatchEvent(deleteCommandEvent);
NS_ENSURE_TRUE_VOID(deleteCommandEvent.mSucceeded);
// Be aware! The widget might be destroyed here.

View File

@ -5778,7 +5778,9 @@ static int32_t RoundUp(double aDouble)
// Determine if we can paste (if receiving data from the service).
if (mGeckoChild && returnType) {
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE_TRANSFERABLE, mGeckoChild, true);
WidgetContentCommandEvent command(true,
NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
mGeckoChild, true);
// This might possibly destroy our widget (and null out mGeckoChild).
mGeckoChild->DispatchWindowEvent(command);
if (!mGeckoChild || !command.mSucceeded || !command.mIsEnabled)
@ -5875,9 +5877,9 @@ static int32_t RoundUp(double aDouble)
NS_ENSURE_TRUE(mGeckoChild, false);
nsContentCommandEvent command(true,
NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
mGeckoChild);
WidgetContentCommandEvent command(true,
NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
mGeckoChild);
command.mTransferable = trans;
mGeckoChild->DispatchWindowEvent(command);

View File

@ -1524,9 +1524,9 @@ nsGtkIMModule::DeleteText(const int32_t aOffset, const uint32_t aNChars)
}
// Delete the selection
nsContentCommandEvent contentCommandEvent(true,
NS_CONTENT_COMMAND_DELETE,
mLastFocusedWindow);
WidgetContentCommandEvent contentCommandEvent(true,
NS_CONTENT_COMMAND_DELETE,
mLastFocusedWindow);
mLastFocusedWindow->DispatchEvent(&contentCommandEvent, status);
if (!contentCommandEvent.mSucceeded ||

View File

@ -2892,7 +2892,7 @@ bool
nsWindow::DispatchContentCommandEvent(int32_t aMsg)
{
nsEventStatus status;
nsContentCommandEvent event(true, aMsg, this);
WidgetContentCommandEvent event(true, aMsg, this);
DispatchEvent(&event, status);
return TRUE;
}

View File

@ -1470,7 +1470,7 @@ nsWindow::DispatchCommandEvent(nsIAtom* aCommand)
nsEventStatus
nsWindow::DispatchContentCommandEvent(int32_t aMsg)
{
nsContentCommandEvent event(true, aMsg, this);
WidgetContentCommandEvent event(true, aMsg, this);
nsEventStatus status;
DispatchEvent(&event, status);

View File

@ -556,33 +556,40 @@ MouseScrollHandler::ProcessNativeScrollMessage(nsWindowBase* aWidget,
aWParam, aLParam));
// Scroll message generated by external application
nsContentCommandEvent commandEvent(true, NS_CONTENT_COMMAND_SCROLL, aWidget);
WidgetContentCommandEvent commandEvent(true, NS_CONTENT_COMMAND_SCROLL,
aWidget);
commandEvent.mScroll.mIsHorizontal = (aMessage == WM_HSCROLL);
switch (LOWORD(aWParam)) {
case SB_LINEUP: // SB_LINELEFT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Line;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Line;
commandEvent.mScroll.mAmount = -1;
break;
case SB_LINEDOWN: // SB_LINERIGHT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Line;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Line;
commandEvent.mScroll.mAmount = 1;
break;
case SB_PAGEUP: // SB_PAGELEFT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Page;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Page;
commandEvent.mScroll.mAmount = -1;
break;
case SB_PAGEDOWN: // SB_PAGERIGHT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Page;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Page;
commandEvent.mScroll.mAmount = 1;
break;
case SB_TOP: // SB_LEFT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Whole;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Whole;
commandEvent.mScroll.mAmount = -1;
break;
case SB_BOTTOM: // SB_RIGHT
commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Whole;
commandEvent.mScroll.mUnit =
WidgetContentCommandEvent::eCmdScrollUnit_Whole;
commandEvent.mScroll.mAmount = 1;
break;
default:

View File

@ -5104,7 +5104,8 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
}
if (contentCommandMessage) {
nsContentCommandEvent contentCommand(true, contentCommandMessage, this);
WidgetContentCommandEvent contentCommand(true, contentCommandMessage,
this);
DispatchWindowEvent(&contentCommand);
// tell the driver that we handled the event
*aRetValue = 1;
@ -5356,7 +5357,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_CLEAR:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_DELETE, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_DELETE, this);
DispatchWindowEvent(&command);
result = true;
}
@ -5364,7 +5365,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_CUT:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_CUT, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_CUT, this);
DispatchWindowEvent(&command);
result = true;
}
@ -5372,7 +5373,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_COPY:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_COPY, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_COPY, this);
DispatchWindowEvent(&command);
result = true;
}
@ -5380,7 +5381,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_PASTE:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE, this);
DispatchWindowEvent(&command);
result = true;
}
@ -5388,7 +5389,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case EM_UNDO:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO, this);
DispatchWindowEvent(&command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
@ -5397,7 +5398,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case EM_REDO:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO, this);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO, this);
DispatchWindowEvent(&command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
@ -5409,8 +5410,8 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
// Support EM_CANPASTE message only when wParam isn't specified or
// is plain text format.
if (wParam == 0 || wParam == CF_TEXT || wParam == CF_UNICODETEXT) {
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE,
this, true);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE,
this, true);
DispatchWindowEvent(&command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
@ -5420,8 +5421,8 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case EM_CANUNDO:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO,
this, true);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO,
this, true);
DispatchWindowEvent(&command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;
@ -5430,8 +5431,8 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case EM_CANREDO:
{
nsContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO,
this, true);
WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO,
this, true);
DispatchWindowEvent(&command);
*aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
result = true;