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 float scale = frameView->frame().pageZoomFactor() * frameView->frame().textZ oomFactor(); |
yosin_UTC9
2016/01/26 03:44:17
Which coordinate space do you want to get?
See htt
Shu Chen
2016/01/26 13:06:43
Done. Will the new change work?
| |
117 FloatRect rect = createRange(range)->boundingRect(); | |
118 rect.setX(rect.x() * scale); | |
119 rect.setY(rect.y() * scale); | |
120 rect.setWidth(rect.width() * scale); | |
121 rect.setHeight(rect.height() * scale); | |
122 IntRect stringRect = enclosingIntRect(rect); | |
117 IntPoint stringPoint = stringRect.minXMaxYCorner(); | 123 IntPoint stringPoint = stringRect.minXMaxYCorner(); |
118 stringPoint.setY(frameView->height() - stringPoint.y()); | 124 stringPoint.setY(frameView->height() - stringPoint.y()); |
119 | 125 |
120 // Adjust for the font's descender. AppKit wants the baseline point. | 126 // Adjust for the font's descender. AppKit wants the baseline point. |
121 if ([string length]) { | 127 if ([string length]) { |
122 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU LL]; | 128 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU LL]; |
123 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 129 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
124 stringPoint.move(0, ceil(-[font descender])); | 130 stringPoint.move(0, ceil(-[font descender])); |
125 } | 131 } |
126 return stringPoint; | 132 return stringPoint; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 if (ephemeralRange.isNull()) | 173 if (ephemeralRange.isNull()) |
168 return nil; | 174 return nil; |
169 | 175 |
170 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 176 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
171 if (baselinePoint) | 177 if (baselinePoint) |
172 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result) ; | 178 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result) ; |
173 return result; | 179 return result; |
174 } | 180 } |
175 | 181 |
176 } // namespace blink | 182 } // namespace blink |
OLD | NEW |