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()); |
keishi
2016/01/29 05:49:14
According to the comment boundingRect considers cs
Shu Chen
2016/01/29 05:57:59
If using boundingRect, the result is wrong for zoo
yosin_UTC9
2016/01/29 06:30:52
Add CSS property "-webkit-transform", e.g. -webkit
| |
117 IntPoint stringPoint = stringRect.minXMaxYCorner(); | 117 IntPoint stringPoint = stringRect.minXMaxYCorner(); |
118 stringPoint.setY(frameView->height() - stringPoint.y()); | 118 stringPoint.setY(frameView->height() - stringPoint.y()); |
119 | 119 |
120 // Adjust for the font's descender. AppKit wants the baseline point. | 120 // Adjust for the font's descender. AppKit wants the baseline point. |
121 if ([string length]) { | 121 if ([string length]) { |
122 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU LL]; | 122 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU LL]; |
123 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 123 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
124 stringPoint.move(0, ceil(-[font descender])); | 124 stringPoint.move(0, ceil(-[font descender])); |
125 } | 125 } |
126 return stringPoint; | 126 return stringPoint; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 if (ephemeralRange.isNull()) | 167 if (ephemeralRange.isNull()) |
168 return nil; | 168 return nil; |
169 | 169 |
170 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 170 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
171 if (baselinePoint) | 171 if (baselinePoint) |
172 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result) ; | 172 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result) ; |
173 return result; | 173 return result; |
174 } | 174 } |
175 | 175 |
176 } // namespace blink | 176 } // namespace blink |
OLD | NEW |