Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: third_party/WebKit/Source/web/mac/WebSubstringUtil.mm

Issue 1616813002: Consider Zoom factor when getting bounding rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698