| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 if (!result.InnerNode()) | 163 if (!result.InnerNode()) |
| 164 return nil; | 164 return nil; |
| 165 LocalFrame* frame = result.InnerNode()->GetDocument().GetFrame(); | 165 LocalFrame* frame = result.InnerNode()->GetDocument().GetFrame(); |
| 166 EphemeralRange range = | 166 EphemeralRange range = |
| 167 frame->RangeForPoint(result.RoundedPointInInnerNodeFrame()); | 167 frame->RangeForPoint(result.RoundedPointInInnerNodeFrame()); |
| 168 if (range.IsNull()) | 168 if (range.IsNull()) |
| 169 return nil; | 169 return nil; |
| 170 | 170 |
| 171 // Expand to word under point. | 171 // Expand to word under point. |
| 172 const VisibleSelection& selection = | 172 const VisibleSelection& selection = CreateVisibleSelectionWithGranularity( |
| 173 CreateVisibleSelection(SelectionInDOMTree::Builder() | 173 SelectionInDOMTree::Builder().SetBaseAndExtent(range).Build(), |
| 174 .SetBaseAndExtent(range) | 174 kWordGranularity); |
| 175 .SetGranularity(kWordGranularity) | |
| 176 .Build()); | |
| 177 const EphemeralRange word_range = selection.ToNormalizedEphemeralRange(); | 175 const EphemeralRange word_range = selection.ToNormalizedEphemeralRange(); |
| 178 | 176 |
| 179 // Convert to NSAttributedString. | 177 // Convert to NSAttributedString. |
| 180 NSAttributedString* string = attributedSubstringFromRange( | 178 NSAttributedString* string = attributedSubstringFromRange( |
| 181 word_range, frame->GetPage()->GetVisualViewport().Scale()); | 179 word_range, frame->GetPage()->GetVisualViewport().Scale()); |
| 182 baseline_point = getBaselinePoint(frame->View(), word_range, string); | 180 baseline_point = getBaselinePoint(frame->View(), word_range, string); |
| 183 return string; | 181 return string; |
| 184 } | 182 } |
| 185 | 183 |
| 186 NSAttributedString* WebSubstringUtil::AttributedSubstringInRange( | 184 NSAttributedString* WebSubstringUtil::AttributedSubstringInRange( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 209 return nil; | 207 return nil; |
| 210 | 208 |
| 211 NSAttributedString* result = attributedSubstringFromRange( | 209 NSAttributedString* result = attributedSubstringFromRange( |
| 212 ephemeral_range, frame->GetPage()->GetVisualViewport().Scale()); | 210 ephemeral_range, frame->GetPage()->GetVisualViewport().Scale()); |
| 213 if (baseline_point) | 211 if (baseline_point) |
| 214 *baseline_point = getBaselinePoint(frame->View(), ephemeral_range, result); | 212 *baseline_point = getBaselinePoint(frame->View(), ephemeral_range, result); |
| 215 return result; | 213 return result; |
| 216 } | 214 } |
| 217 | 215 |
| 218 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |