Bug 950564 ComplexTextInputPanel should be positioned to bottom-left of the focused plugin feedback=emk, r=smichaud

This commit is contained in:
Masayuki Nakano 2013-12-20 08:19:17 +09:00
parent 249b2e4e75
commit eae4be4eb8
5 changed files with 57 additions and 0 deletions

View File

@ -3026,6 +3026,9 @@ pref("ui.panel.default_level_parent", false);
pref("ui.plugin.cancel_composition_at_input_source_changed", false);
// The min width of composition window for plugins
pref("ui.plugin.panel.min-width", 500);
pref("mousewheel.system_scroll_override_on_root_content.enabled", false);
// Macbook touchpad two finger pixel scrolling

View File

@ -41,6 +41,10 @@
- (void)cancelComposition;
- (BOOL)inComposition;
// This places the text input panel fully onscreen and below the lower left
// corner of the focused plugin.
- (void)adjustTo:(NSView*)view;
@end
#endif // ComplexTextInputPanel_h_

View File

@ -27,7 +27,10 @@
#import "ComplexTextInputPanel.h"
#include <algorithm>
#include "mozilla/Preferences.h"
#include "nsChildView.h"
#include "nsCocoaFeatures.h"
using namespace mozilla;
@ -147,4 +150,46 @@ using namespace mozilla;
return [mInputTextView hasMarkedText];
}
- (void)adjustTo:(NSView*)view
{
NSRect viewRect = [view frame];
viewRect.origin.x = 0;
viewRect.origin.y = 0;
viewRect = [view convertRect:viewRect toView:nil];
if (nsCocoaFeatures::OnLionOrLater()) {
viewRect = [[view window] convertRectToScreen:viewRect];
} else {
viewRect.origin = [[view window] convertBaseToScreen:viewRect.origin];
}
NSRect selfRect = [self frame];
// XXX Is this work well with Retina display?
CGFloat minWidth = static_cast<CGFloat>(
Preferences::GetUint("ui.plugin.panel.min-width", 500));
NSRect rect = NSMakeRect(viewRect.origin.x,
viewRect.origin.y - selfRect.size.height,
std::min(viewRect.size.width, minWidth),
selfRect.size.height);
// Adjust to screen.
NSRect screenRect = [[NSScreen mainScreen] visibleFrame];
if (rect.origin.x < screenRect.origin.x) {
rect.origin.x = screenRect.origin.x;
}
if (rect.origin.y < screenRect.origin.y) {
rect.origin.y = screenRect.origin.y;
}
CGFloat xMostOfScreen = screenRect.origin.x + screenRect.size.width;
CGFloat yMostOfScreen = screenRect.origin.y + screenRect.size.height;
CGFloat xMost = rect.origin.x + rect.size.width;
CGFloat yMost = rect.origin.y + rect.size.height;
if (xMostOfScreen < xMost) {
rect.origin.x -= xMost - xMostOfScreen;
}
if (yMostOfScreen < yMost) {
rect.origin.y -= yMost - yMostOfScreen;
}
[self setFrame:rect display:[self isVisible]];
}
@end

View File

@ -3945,6 +3945,7 @@ PluginTextInputHandler::HandleKeyDownEventForPlugin(NSEvent* aNativeKeyEvent)
ComplexTextInputPanel* ctiPanel =
[ComplexTextInputPanel sharedComplexTextInputPanel];
[ctiPanel adjustTo:mView];
// If a composition is in progress then simply let the input panel continue
// it.

View File

@ -185,6 +185,10 @@ enum {
};
typedef NSUInteger NSEventPhase;
@interface NSWindow (LionWindowFeatures)
- (NSRect)convertRectToScreen:(NSRect)aRect;
@end
#ifdef __LP64__
enum {
NSEventSwipeTrackingLockDirection = 0x1 << 0,