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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "core/layout/LayoutObject.h" | 51 #include "core/layout/LayoutObject.h" |
52 #include "core/page/Page.h" | 52 #include "core/page/Page.h" |
53 #include "core/style/ComputedStyle.h" | 53 #include "core/style/ComputedStyle.h" |
54 #include "platform/fonts/Font.h" | 54 #include "platform/fonts/Font.h" |
55 #include "platform/mac/ColorMac.h" | 55 #include "platform/mac/ColorMac.h" |
56 #include "public/platform/WebRect.h" | 56 #include "public/platform/WebRect.h" |
57 #include "public/web/WebFrameWidget.h" | 57 #include "public/web/WebFrameWidget.h" |
58 #include "public/web/WebHitTestResult.h" | 58 #include "public/web/WebHitTestResult.h" |
59 #include "public/web/WebLocalFrame.h" | 59 #include "public/web/WebLocalFrame.h" |
60 | 60 |
61 using namespace blink; | 61 namespace blink { |
62 | 62 |
63 static NSAttributedString* attributedSubstringFromRange( | 63 namespace { |
64 const EphemeralRange& range, | 64 |
65 float fontScale) { | 65 NSAttributedString* attributedSubstringFromRange(const EphemeralRange& range, |
| 66 float fontScale) { |
66 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]; | 67 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]; |
67 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; | 68 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
68 size_t length = range.EndPosition().ComputeOffsetInContainerNode() - | 69 size_t length = range.EndPosition().ComputeOffsetInContainerNode() - |
69 range.StartPosition().ComputeOffsetInContainerNode(); | 70 range.StartPosition().ComputeOffsetInContainerNode(); |
70 | 71 |
71 unsigned position = 0; | 72 unsigned position = 0; |
72 | 73 |
73 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 74 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
74 // needs to be audited. see http://crbug.com/590369 for more details. | 75 // needs to be audited. see http://crbug.com/590369 for more details. |
75 range.StartPosition() | 76 range.StartPosition() |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 143 |
143 // Adjust for the font's descender. AppKit wants the baseline point. | 144 // Adjust for the font's descender. AppKit wants the baseline point. |
144 if ([string length]) { | 145 if ([string length]) { |
145 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NULL]; | 146 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NULL]; |
146 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 147 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
147 stringPoint.Move(0, ceil([font descender])); | 148 stringPoint.Move(0, ceil([font descender])); |
148 } | 149 } |
149 return stringPoint; | 150 return stringPoint; |
150 } | 151 } |
151 | 152 |
152 namespace blink { | 153 } // namespace |
153 | 154 |
154 NSAttributedString* WebSubstringUtil::AttributedWordAtPoint( | 155 NSAttributedString* WebSubstringUtil::AttributedWordAtPoint( |
155 WebFrameWidget* frame_widget, | 156 WebFrameWidget* frame_widget, |
156 WebPoint point, | 157 WebPoint point, |
157 WebPoint& baseline_point) { | 158 WebPoint& baseline_point) { |
158 HitTestResult result = static_cast<WebFrameWidgetBase*>(frame_widget) | 159 HitTestResult result = static_cast<WebFrameWidgetBase*>(frame_widget) |
159 ->CoreHitTestResultAt(point); | 160 ->CoreHitTestResultAt(point); |
160 | 161 |
161 if (!result.InnerNode()) | 162 if (!result.InnerNode()) |
162 return nil; | 163 return nil; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return nil; | 206 return nil; |
206 | 207 |
207 NSAttributedString* result = attributedSubstringFromRange( | 208 NSAttributedString* result = attributedSubstringFromRange( |
208 ephemeral_range, frame->GetPage()->GetVisualViewport().Scale()); | 209 ephemeral_range, frame->GetPage()->GetVisualViewport().Scale()); |
209 if (baseline_point) | 210 if (baseline_point) |
210 *baseline_point = getBaselinePoint(frame->View(), ephemeral_range, result); | 211 *baseline_point = getBaselinePoint(frame->View(), ephemeral_range, result); |
211 return result; | 212 return result; |
212 } | 213 } |
213 | 214 |
214 } // namespace blink | 215 } // namespace blink |
OLD | NEW |