Bug 1018486 - Part 3: Changes in widget/cocoa/, r=mstange

MozReview-Commit-ID: DhvanRhe9XE
This commit is contained in:
Michael Layzell 2016-07-18 12:36:38 -04:00
Родитель 5d1745c161
Коммит e67b01fcd0
5 изменённых файлов: 22 добавлений и 19 удалений

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

@ -1534,7 +1534,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
[NSCursor setHiddenUntilMouseMoves:YES]; [NSCursor setHiddenUntilMouseMoves:YES];
} }
RefPtr<nsChildView> kungFuDeathGrip(mWidget); RefPtr<nsChildView> widget(mWidget);
KeyEventState* currentKeyEvent = PushKeyEvent(aNativeEvent); KeyEventState* currentKeyEvent = PushKeyEvent(aNativeEvent);
AutoKeyEventStateCleaner remover(this); AutoKeyEventStateCleaner remover(this);
@ -1553,7 +1553,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
return false; return false;
} }
WidgetKeyboardEvent imeEvent(true, eKeyDown, mWidget); WidgetKeyboardEvent imeEvent(true, eKeyDown, widget);
currentKeyEvent->InitKeyEvent(this, imeEvent); currentKeyEvent->InitKeyEvent(this, imeEvent);
imeEvent.mPluginTextEventString.Assign(committed); imeEvent.mPluginTextEventString.Assign(committed);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
@ -1574,7 +1574,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
return false; return false;
} }
WidgetKeyboardEvent keydownEvent(true, eKeyDown, mWidget); WidgetKeyboardEvent keydownEvent(true, eKeyDown, widget);
currentKeyEvent->InitKeyEvent(this, keydownEvent); currentKeyEvent->InitKeyEvent(this, keydownEvent);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
@ -1613,7 +1613,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
// Don't call interpretKeyEvents when a plugin has focus. If we call it, // Don't call interpretKeyEvents when a plugin has focus. If we call it,
// for example, a character is inputted twice during a composition in e10s // for example, a character is inputted twice during a composition in e10s
// mode. // mode.
if (!mWidget->IsPluginFocused() && (IsIMEEnabled() || IsASCIICapableOnly())) { if (!widget->IsPluginFocused() && (IsIMEEnabled() || IsASCIICapableOnly())) {
MOZ_LOG(gLog, LogLevel::Info, MOZ_LOG(gLog, LogLevel::Info,
("%p TextInputHandler::HandleKeyDownEvent, calling interpretKeyEvents", ("%p TextInputHandler::HandleKeyDownEvent, calling interpretKeyEvents",
this)); this));
@ -1647,7 +1647,7 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
return false; return false;
} }
WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
currentKeyEvent->InitKeyEvent(this, keypressEvent); currentKeyEvent->InitKeyEvent(this, keypressEvent);
// If we called interpretKeyEvents and this isn't normal character input // If we called interpretKeyEvents and this isn't normal character input
@ -1743,6 +1743,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
} }
RefPtr<nsChildView> kungFuDeathGrip(mWidget); RefPtr<nsChildView> kungFuDeathGrip(mWidget);
mozilla::Unused << kungFuDeathGrip; // Not referenced within this function
MOZ_LOG(gLog, LogLevel::Info, MOZ_LOG(gLog, LogLevel::Info,
("%p TextInputHandler::HandleFlagsChanged, aNativeEvent=%p, " ("%p TextInputHandler::HandleFlagsChanged, aNativeEvent=%p, "
@ -2195,7 +2196,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
return; return;
} }
RefPtr<nsChildView> kungFuDeathGrip(mWidget); RefPtr<nsChildView> widget(mWidget);
// If the replacement range is specified, select the range. Then, the // If the replacement range is specified, select the range. Then, the
// selection will be replaced by the later keypress event. // selection will be replaced by the later keypress event.
@ -2214,7 +2215,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
} }
// Dispatch keypress event with char instead of compositionchange event // Dispatch keypress event with char instead of compositionchange event
WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
// XXX Why do we need to dispatch keypress event for not inputting any // XXX Why do we need to dispatch keypress event for not inputting any
// string? If it wants to delete the specified range, should we // string? If it wants to delete the specified range, should we
// dispatch an eContentCommandDelete event instead? Because this // dispatch an eContentCommandDelete event instead? Because this
@ -2263,7 +2264,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString,
bool bool
TextInputHandler::DoCommandBySelector(const char* aSelector) TextInputHandler::DoCommandBySelector(const char* aSelector)
{ {
RefPtr<nsChildView> kungFuDeathGrip(mWidget); RefPtr<nsChildView> widget(mWidget);
KeyEventState* currentKeyEvent = GetCurrentKeyEvent(); KeyEventState* currentKeyEvent = GetCurrentKeyEvent();
@ -2289,7 +2290,7 @@ TextInputHandler::DoCommandBySelector(const char* aSelector)
return false; return false;
} }
WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); WidgetKeyboardEvent keypressEvent(true, eKeyPress, widget);
currentKeyEvent->InitKeyEvent(this, keypressEvent); currentKeyEvent->InitKeyEvent(this, keypressEvent);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;

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

@ -1406,6 +1406,8 @@ nsresult nsChildView::ConfigureChildren(const nsTArray<Configuration>& aConfigur
NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event, NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event,
nsEventStatus& aStatus) nsEventStatus& aStatus)
{ {
RefPtr<nsChildView> kungFuDeathGrip(this);
#ifdef DEBUG #ifdef DEBUG
debug_DumpEvent(stdout, event->mWidget, event, "something", 0); debug_DumpEvent(stdout, event->mWidget, event, "something", 0);
#endif #endif
@ -1429,16 +1431,16 @@ NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event,
// If the listener is NULL, check if the parent is a popup. If it is, then // If the listener is NULL, check if the parent is a popup. If it is, then
// this child is the popup content view attached to a popup. Get the // this child is the popup content view attached to a popup. Get the
// listener from the parent popup instead. // listener from the parent popup instead.
nsCOMPtr<nsIWidget> kungFuDeathGrip = do_QueryInterface(mParentWidget ? mParentWidget : this); nsCOMPtr<nsIWidget> parentWidget = mParentWidget;
if (!listener && mParentWidget) { if (!listener && parentWidget) {
if (mParentWidget->WindowType() == eWindowType_popup) { if (parentWidget->WindowType() == eWindowType_popup) {
// Check just in case event->mWidget isn't this widget // Check just in case event->mWidget isn't this widget
if (event->mWidget) { if (event->mWidget) {
listener = event->mWidget->GetWidgetListener(); listener = event->mWidget->GetWidgetListener();
} }
if (!listener) { if (!listener) {
event->mWidget = mParentWidget; event->mWidget = parentWidget;
listener = mParentWidget->GetWidgetListener(); listener = parentWidget->GetWidgetListener();
} }
} }
} }
@ -6066,8 +6068,8 @@ nsChildView::GetSelectionAsPlaintext(nsAString& aResult)
id<mozAccessible> nativeAccessible = nil; id<mozAccessible> nativeAccessible = nil;
nsAutoRetainCocoaObject kungFuDeathGrip(self); nsAutoRetainCocoaObject kungFuDeathGrip(self);
nsCOMPtr<nsIWidget> kungFuDeathGrip2(mGeckoChild); RefPtr<nsChildView> geckoChild(mGeckoChild);
RefPtr<a11y::Accessible> accessible = mGeckoChild->GetDocumentAccessible(); RefPtr<a11y::Accessible> accessible = geckoChild->GetDocumentAccessible();
if (!accessible) if (!accessible)
return nil; return nil;

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

@ -1886,6 +1886,7 @@ nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
aStatus = nsEventStatus_eIgnore; aStatus = nsEventStatus_eIgnore;
nsCOMPtr<nsIWidget> kungFuDeathGrip(event->mWidget); nsCOMPtr<nsIWidget> kungFuDeathGrip(event->mWidget);
mozilla::Unused << kungFuDeathGrip; // Not used within this function
if (mWidgetListener) if (mWidgetListener)
aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents); aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents);

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

@ -421,7 +421,6 @@ void nsMenuX::MenuConstruct()
if (ownerDoc && jsapi.Init(ownerDoc->GetInnerWindow())) { if (ownerDoc && jsapi.Init(ownerDoc->GetInnerWindow())) {
JSContext* cx = jsapi.cx(); JSContext* cx = jsapi.cx();
JS::RootedObject ignoredObj(cx); JS::RootedObject ignoredObj(cx);
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup, xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
NS_GET_IID(nsISupports), ignoredObj.address()); NS_GET_IID(nsISupports), ignoredObj.address());
mXBLAttached = true; mXBLAttached = true;

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

@ -219,8 +219,8 @@ WidgetShutdownObserver::Observe(nsISupports *aSubject,
const char16_t *aData) const char16_t *aData)
{ {
if (mWidget && !strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { if (mWidget && !strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
nsCOMPtr<nsIWidget> kungFuDeathGrip(mWidget); RefPtr<nsBaseWidget> widget(mWidget);
mWidget->Shutdown(); widget->Shutdown();
} }
return NS_OK; return NS_OK;
} }