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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "core/rendering/HitTestResult.h" | 48 #include "core/rendering/HitTestResult.h" |
49 #include "core/rendering/RenderObject.h" | 49 #include "core/rendering/RenderObject.h" |
50 #include "core/rendering/style/RenderStyle.h" | 50 #include "core/rendering/style/RenderStyle.h" |
51 #include "platform/fonts/Font.h" | 51 #include "platform/fonts/Font.h" |
52 #include "platform/mac/ColorMac.h" | 52 #include "platform/mac/ColorMac.h" |
53 #include "public/platform/WebRect.h" | 53 #include "public/platform/WebRect.h" |
54 #include "public/web/WebHitTestResult.h" | 54 #include "public/web/WebHitTestResult.h" |
55 #include "public/web/WebRange.h" | 55 #include "public/web/WebRange.h" |
56 #include "public/web/WebView.h" | 56 #include "public/web/WebView.h" |
57 #include "web/WebLocalFrameImpl.h" | 57 #include "web/WebLocalFrameImpl.h" |
| 58 #include "web/WebViewImpl.h" |
58 | 59 |
59 using namespace WebCore; | 60 using namespace WebCore; |
60 | 61 |
61 static NSAttributedString* attributedSubstringFromRange(const Range* range) | 62 static NSAttributedString* attributedSubstringFromRange(const Range* range) |
62 { | 63 { |
63 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; | 64 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; |
64 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; | 65 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
65 size_t length = range->endOffset() - range->startOffset(); | 66 size_t length = range->endOffset() - range->startOffset(); |
66 | 67 |
67 unsigned position = 0; | 68 unsigned position = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; | 106 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; |
106 position += numCharacters; | 107 position += numCharacters; |
107 } | 108 } |
108 return [string autorelease]; | 109 return [string autorelease]; |
109 } | 110 } |
110 | 111 |
111 namespace blink { | 112 namespace blink { |
112 | 113 |
113 NSAttributedString* WebSubstringUtil::attributedWordAtPoint(WebView* view, WebPo
int point, WebPoint& baselinePoint) | 114 NSAttributedString* WebSubstringUtil::attributedWordAtPoint(WebView* view, WebPo
int point, WebPoint& baselinePoint) |
114 { | 115 { |
115 HitTestResult result = view->hitTestResultAt(point); | 116 HitTestResult result = static_cast<WebViewImpl*>(view)->coreHitTestResultAt(
point); |
116 if (!result.targetNode()) | 117 if (!result.targetNode()) |
117 return nil; | 118 return nil; |
118 LocalFrame* frame = result.targetNode()->document().frame(); | 119 LocalFrame* frame = result.targetNode()->document().frame(); |
119 FrameView* frameView = frame->view(); | 120 FrameView* frameView = frame->view(); |
120 | 121 |
121 RefPtrWillBeRawPtr<Range> range = frame->rangeForPoint(result.roundedPointIn
InnerNodeFrame()); | 122 RefPtrWillBeRawPtr<Range> range = frame->rangeForPoint(result.roundedPointIn
InnerNodeFrame()); |
122 if (!range) | 123 if (!range) |
123 return nil; | 124 return nil; |
124 | 125 |
125 // Expand to word under point. | 126 // Expand to word under point. |
(...skipping 30 matching lines...) Expand all Loading... |
156 Element* editable = frame->selection().rootEditableElementOrDocumentElement(
); | 157 Element* editable = frame->selection().rootEditableElementOrDocumentElement(
); |
157 ASSERT(editable); | 158 ASSERT(editable); |
158 RefPtrWillBeRawPtr<Range> range(PlainTextRange(location, location + length).
createRange(*editable)); | 159 RefPtrWillBeRawPtr<Range> range(PlainTextRange(location, location + length).
createRange(*editable)); |
159 if (!range) | 160 if (!range) |
160 return nil; | 161 return nil; |
161 | 162 |
162 return attributedSubstringFromRange(range.get()); | 163 return attributedSubstringFromRange(range.get()); |
163 } | 164 } |
164 | 165 |
165 } // namespace blink | 166 } // namespace blink |
OLD | NEW |