Bug 1180564: Don't implement NSTextInput any more, just NSTextInputClient. r=masayuki
authorJosh Aas <joshmoz@fastmail.com>
Sat, 07 Nov 2015 18:19:49 +0900
changeset 271633 8707d23c0be0d0a571f8c12c83a6a54be1f74293
parent 271632 380cc4f598401c14a7c2befdb6c71513af3e8328
child 271634 c4dd82aa903d89b3835ceb38cf0341a4190c383e
push id67719
push userjosh@mozilla.com
push dateSat, 07 Nov 2015 09:20:15 +0000
treeherdermozilla-inbound@8707d23c0be0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1180564
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1180564: Don't implement NSTextInput any more, just NSTextInputClient. r=masayuki
modules/libpref/init/all.js
widget/cocoa/nsChildView.mm
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4929,20 +4929,16 @@ pref("dom.presentation.tcp_server.debug"
 pref("dom.presentation.discovery.enabled", false);
 pref("dom.presentation.discovery.timeout_ms", 10000);
 pref("dom.presentation.discoverable", false);
 
 #ifdef XP_MACOSX
 // Use raw ICU instead of CoreServices API in Unicode collation
 pref("intl.collation.mac.use_icu", true);
 
-// Enable NSTextInput protocol for use with IMEs that have not
-// been updated to use the NSTextInputClient protocol.
-pref("intl.ime.nstextinput.enable", false);
-
 #if !defined(RELEASE_BUILD) || defined(DEBUG)
 // In non-release builds we crash by default on insecure text input (when a
 // password editor has focus but secure event input isn't enabled).  The
 // following pref, when turned on, disables this behavior.  See bug 1188425.
 pref("intl.allow-insecure-text-input", false);
 #endif
 #endif // XP_MACOSX
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -5216,126 +5216,16 @@ PanGestureTypeForEvent(NSEvent* aEvent)
   NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
   bool shouldMinimize = [[userDefaults
           objectForKey:MDAppleMiniaturizeOnDoubleClickKey] boolValue];
 
   return shouldMinimize;
 }
 
 #pragma mark -
-// NSTextInput implementation
-
-- (void)insertText:(id)insertString
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return;
-  }
-
-  NS_ENSURE_TRUE_VOID(mGeckoChild);
-
-  nsAutoRetainCocoaObject kungFuDeathGrip(self);
-
-  NSAttributedString* attrStr;
-  if ([insertString isKindOfClass:[NSAttributedString class]]) {
-    attrStr = static_cast<NSAttributedString*>(insertString);
-  } else {
-    attrStr =
-      [[[NSAttributedString alloc] initWithString:insertString] autorelease];
-  }
-
-  mTextInputHandler->InsertText(attrStr);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-- (void)insertNewline:(id)sender
-{
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return;
-  }
-
-  [self insertText:@"\n"];
-}
-
-- (NSInteger)conversationIdentifier
-{
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return 0;
-  }
-
-  NS_ENSURE_TRUE(mTextInputHandler, reinterpret_cast<NSInteger>(self));
-  return mTextInputHandler->ConversationIdentifier();
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)theRange
-{
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return NSMakeRect(0.0, 0.0, 0.0, 0.0);
-  }
-
-  NSRect rect;
-  NS_ENSURE_TRUE(mTextInputHandler, rect);
-  return mTextInputHandler->FirstRectForCharacterRange(theRange);
-}
-
-- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange
-{
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return nil;
-  }
-
-  NS_ENSURE_TRUE(mTextInputHandler, nil);
-  return mTextInputHandler->GetAttributedSubstringFromRange(theRange);
-}
-
-- (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  // We're considering not implementing NSTextInput. Start by just
-  // preffing its methods off.
-  if (!Preferences::GetBool("intl.ime.nstextinput.enable", false)) {
-    NSLog(@"Set intl.ime.nstextinput.enable to true in about:config to fix input.");
-    return;
-  }
-
-  NS_ENSURE_TRUE_VOID(mTextInputHandler);
-
-  nsAutoRetainCocoaObject kungFuDeathGrip(self);
-
-  NSAttributedString* attrStr;
-  if ([aString isKindOfClass:[NSAttributedString class]]) {
-    attrStr = static_cast<NSAttributedString*>(aString);
-  } else {
-    attrStr = [[[NSAttributedString alloc] initWithString:aString] autorelease];
-  }
-
-  mTextInputHandler->SetMarkedText(attrStr, selRange);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-#pragma mark -
 // NSTextInputClient implementation
 
 - (NSRange)markedRange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   NS_ENSURE_TRUE(mTextInputHandler, NSMakeRange(NSNotFound, 0));
   return mTextInputHandler->MarkedRange();
@@ -5564,16 +5454,21 @@ PanGestureTypeForEvent(NSEvent* aEvent)
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
 
   mTextInputHandler->HandleKeyUpEvent(theEvent);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
+- (void)insertNewline:(id)sender
+{
+  [self insertText:@"\n"];
+}
+
 - (void)flagsChanged:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   NS_ENSURE_TRUE(mGeckoChild, );
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
   mTextInputHandler->HandleFlagsChanged(theEvent);