| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; | 106 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; |
| 107 position += numCharacters; | 107 position += numCharacters; |
| 108 } | 108 } |
| 109 return [string autorelease]; | 109 return [string autorelease]; |
| 110 } | 110 } |
| 111 | 111 |
| 112 WebPoint getBaselinePoint(FrameView* frameView, const EphemeralRange& range, NSA
ttributedString* string) | 112 WebPoint getBaselinePoint(FrameView* frameView, const EphemeralRange& range, NSA
ttributedString* string) |
| 113 { | 113 { |
| 114 // Compute bottom left corner and convert to AppKit coordinates. | 114 // Compute bottom left corner and convert to AppKit coordinates. |
| 115 // TODO(yosin) We shold avoid to create |Range| object. See crbug.com/529985
. | 115 // TODO(yosin) We shold avoid to create |Range| object. See crbug.com/529985
. |
| 116 IntRect stringRect = enclosingIntRect(createRange(range)->boundingRect()); | 116 IntRect stringRect = frameView->contentsToRootFrame(createRange(range)->boun
dingBox()); |
| 117 printf("=====stringRect: %d,%d,%d,%d\n", stringRect.x(), stringRect.y(), |
| 118 stringRect.width(), stringRect.height()); |
| 117 IntPoint stringPoint = stringRect.minXMaxYCorner(); | 119 IntPoint stringPoint = stringRect.minXMaxYCorner(); |
| 118 stringPoint.setY(frameView->height() - stringPoint.y()); | 120 stringPoint.setY(frameView->height() - stringPoint.y()); |
| 119 | 121 |
| 120 // Adjust for the font's descender. AppKit wants the baseline point. | 122 // Adjust for the font's descender. AppKit wants the baseline point. |
| 121 if ([string length]) { | 123 if ([string length]) { |
| 122 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; | 124 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; |
| 123 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 125 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
| 124 stringPoint.move(0, ceil(-[font descender])); | 126 stringPoint.move(0, ceil(-[font descender])); |
| 125 } | 127 } |
| 126 return stringPoint; | 128 return stringPoint; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (ephemeralRange.isNull()) | 169 if (ephemeralRange.isNull()) |
| 168 return nil; | 170 return nil; |
| 169 | 171 |
| 170 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 172 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
| 171 if (baselinePoint) | 173 if (baselinePoint) |
| 172 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; | 174 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; |
| 173 return result; | 175 return result; |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |