Use Patti Yeh's hack to determine the appropriate rectangle
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2005 03:03:02 +0000 (03:03 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Mar 2005 03:03:02 +0000 (03:03 +0000)
to place the "associated word" window.
If there is no marked text firstRectForCharacterRange: will
use the selected range to determine the returned rectangle,
ignoring the input range.  This is the fix from
4029491 that I previously backed out.

        Reviewed by Vicki.

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView firstRectForCharacterRange:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebView.subproj/WebHTMLView.m

index 562a6c080739556a0d825c40812f69d2d7e435db..0ece2bcaed89aeecd1b8deb98f694ff1cdad52f0 100644 (file)
@@ -1,3 +1,17 @@
+2005-03-23  Richard Williamson   <rjw@apple.com>
+
+       Use Patti Yeh's hack to determine the appropriate rectangle
+       to place the "associated word" window.  
+       If there is no marked text firstRectForCharacterRange: will
+       use the selected range to determine the returned rectangle,
+       ignoring the input range.  This is the fix from
+       4029491 that I previously backed out.
+
+        Reviewed by Vicki.
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView firstRectForCharacterRange:]):
+
 2005-03-23  Richard Williamson   <rjw@apple.com>
 
        Fixed <rdar://problem/4062490> REGRESSION (WebKit-408): no subresources reported in Activity window after going back at hrweb.apple.com
index 805a3263f5206029944fd661bce309654460f687..bcc889122faaa03def62e854ef801544b2b99974 100644 (file)
@@ -4904,11 +4904,23 @@ static NSArray *validAttributes = nil;
 {
     WebBridge *bridge = [self _bridge];
     
-    DOMRange *range = [bridge convertToObjCDOMRange:theRange];
+    DOMRange *range;
     
-    NSRect resultRect = [self convertRect:[bridge firstRectForDOMRange:range] toView:nil];
-    resultRect.origin = [[self window] convertBaseToScreen:resultRect.origin];
+    if ([self hasMarkedText]) {
+        range = [bridge convertToObjCDOMRange:theRange];
+    }
+    else {
+        range = [self _selectedRange];
+    }
     
+    NSRect resultRect;
+    if ([range startContainer]) {
+        resultRect = [self convertRect:[bridge firstRectForDOMRange:range] toView:nil];
+        resultRect.origin = [[self window] convertBaseToScreen:resultRect.origin];
+    }
+    else {
+        resultRect = NSMakeRect(0,0,0,0);
+    }
     return resultRect;
 }