From 8edc44e588f082a5fedfb25c2966b0d807874c26 Mon Sep 17 00:00:00 2001 From: harrison Date: Sat, 19 Mar 2005 16:07:18 +0000 Subject: [PATCH] Reviewed by me (written by Patti Yeh). CangJie: the candidate window appears at the top left hand corner during typing in Mail and iChat * WebView.subproj/WebHTMLView.m: (-[WebHTMLView firstRectForCharacterRange:]): Use selected range if there is no marked range. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8931 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKit/ChangeLog | 10 +++++++++ WebKit/WebView.subproj/WebHTMLView.m | 31 +++++++++++++++++----------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index 7903908cda8e..01f87cc8d7f4 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,13 @@ +2005-03-19 David Harrison + + Reviewed by me (written by Patti Yeh). + + CangJie: the candidate window appears at the top left hand corner during typing in Mail and iChat + + * WebView.subproj/WebHTMLView.m: + (-[WebHTMLView firstRectForCharacterRange:]): + Use selected range if there is no marked range. + === Safari-408 === 2005-03-18 David Harrison diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m index d18f0a9f1373..7c9d2cf6a398 100644 --- a/WebKit/WebView.subproj/WebHTMLView.m +++ b/WebKit/WebView.subproj/WebHTMLView.m @@ -4899,20 +4899,27 @@ static NSArray *validAttributes = nil; - (NSRect)firstRectForCharacterRange:(NSRange)theRange { - if (![self hasMarkedText]) { - return NSMakeRect(0,0,0,0); - } - + NSRect resultRect = NSMakeRect(0,0,0,0); WebBridge *bridge = [self _bridge]; + DOMRange *rectRange = nil; + + if ([self hasMarkedText]) { + rectRange = [[bridge DOMDocument] createRange]; + DOMRange *markedRange = [bridge markedTextDOMRange]; + [rectRange setStart:[markedRange startContainer] :theRange.location]; + [rectRange setEnd:[markedRange startContainer] :(theRange.location + theRange.length)]; + } else { + // no marked text, so use current selection instead + // this helps for text input methods that unmark and delete the typed characters, + // then put up a word selector at the current insertion point + rectRange = [self _selectedRange]; + } - DOMRange *rectRange = [[bridge DOMDocument] createRange]; - DOMRange *markedRange = [bridge markedTextDOMRange]; - [rectRange setStart:[markedRange startContainer] :theRange.location]; - [rectRange setEnd:[markedRange startContainer] :(theRange.location + theRange.length)]; - - NSRect resultRect = [self convertRect:[bridge firstRectForDOMRange:rectRange] toView:nil]; - resultRect.origin = [[self window] convertBaseToScreen:resultRect.origin]; - + if ([rectRange startContainer]) { + resultRect = [self convertRect:[bridge firstRectForDOMRange:rectRange] toView:nil]; + resultRect.origin = [[self window] convertBaseToScreen:resultRect.origin]; + } + return resultRect; } -- 2.36.0