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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return [string autorelease]; | 116 return [string autorelease]; |
117 } | 117 } |
118 | 118 |
119 WebPoint getBaselinePoint(FrameView* frameView, const EphemeralRange& range, NSA
ttributedString* string) | 119 WebPoint getBaselinePoint(FrameView* frameView, const EphemeralRange& range, NSA
ttributedString* string) |
120 { | 120 { |
121 // Compute bottom left corner and convert to AppKit coordinates. | 121 // Compute bottom left corner and convert to AppKit coordinates. |
122 // TODO(yosin): We shold avoid to create |Range| object. See crbug.com/52998
5. | 122 // TODO(yosin): We shold avoid to create |Range| object. See crbug.com/52998
5. |
123 // TODO(shuchen): Support page-zoom for getting the baseline point. | 123 // TODO(shuchen): Support page-zoom for getting the baseline point. |
124 IntRect stringRect = frameView->contentsToRootFrame(createRange(range)->boun
dingBox()); | 124 IntRect stringRect = frameView->contentsToRootFrame(createRange(range)->boun
dingBox()); |
125 IntPoint stringPoint = stringRect.minXMaxYCorner(); | 125 IntPoint stringPoint = stringRect.minXMaxYCorner(); |
126 stringPoint.setY(frameView->height() - stringPoint.y()); | 126 stringPoint.setY(frameView->root()->height() - stringPoint.y()); |
127 | 127 |
128 // Adjust for the font's descender. AppKit wants the baseline point. | 128 // Adjust for the font's descender. AppKit wants the baseline point. |
129 if ([string length]) { | 129 if ([string length]) { |
130 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; | 130 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; |
131 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 131 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
132 stringPoint.move(0, ceil(-[font descender])); | 132 stringPoint.move(0, ceil(-[font descender])); |
133 } | 133 } |
134 return stringPoint; | 134 return stringPoint; |
135 } | 135 } |
136 | 136 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (ephemeralRange.isNull()) | 175 if (ephemeralRange.isNull()) |
176 return nil; | 176 return nil; |
177 | 177 |
178 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 178 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
179 if (baselinePoint) | 179 if (baselinePoint) |
180 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; | 180 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; |
181 return result; | 181 return result; |
182 } | 182 } |
183 | 183 |
184 } // namespace blink | 184 } // namespace blink |
OLD | NEW |