| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/editing/iterators/TextIterator.h" | 43 #include "core/editing/iterators/TextIterator.h" |
| 44 #include "core/frame/FrameView.h" | 44 #include "core/frame/FrameView.h" |
| 45 #include "core/frame/LocalFrame.h" | 45 #include "core/frame/LocalFrame.h" |
| 46 #include "core/html/HTMLElement.h" | 46 #include "core/html/HTMLElement.h" |
| 47 #include "core/layout/HitTestResult.h" | 47 #include "core/layout/HitTestResult.h" |
| 48 #include "core/layout/LayoutObject.h" | 48 #include "core/layout/LayoutObject.h" |
| 49 #include "core/style/ComputedStyle.h" | 49 #include "core/style/ComputedStyle.h" |
| 50 #include "platform/fonts/Font.h" | 50 #include "platform/fonts/Font.h" |
| 51 #include "platform/mac/ColorMac.h" | 51 #include "platform/mac/ColorMac.h" |
| 52 #include "public/platform/WebRect.h" | 52 #include "public/platform/WebRect.h" |
| 53 #include "public/web/WebFrameWidget.h" |
| 53 #include "public/web/WebHitTestResult.h" | 54 #include "public/web/WebHitTestResult.h" |
| 55 #include "public/web/WebLocalFrame.h" |
| 54 #include "public/web/WebRange.h" | 56 #include "public/web/WebRange.h" |
| 55 #include "public/web/WebView.h" | 57 #include "web/WebFrameWidgetBase.h" |
| 56 #include "web/WebLocalFrameImpl.h" | 58 #include "web/WebLocalFrameImpl.h" |
| 57 #include "web/WebViewImpl.h" | |
| 58 | 59 |
| 59 using namespace blink; | 60 using namespace blink; |
| 60 | 61 |
| 61 static NSAttributedString* attributedSubstringFromRange(const EphemeralRange& ra
nge) | 62 static NSAttributedString* attributedSubstringFromRange(const EphemeralRange& ra
nge) |
| 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.endPosition().computeOffsetInContainerNode() - range.s
tartPosition().computeOffsetInContainerNode(); | 66 size_t length = range.endPosition().computeOffsetInContainerNode() - range.s
tartPosition().computeOffsetInContainerNode(); |
| 66 | 67 |
| 67 unsigned position = 0; | 68 unsigned position = 0; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if ([string length]) { | 130 if ([string length]) { |
| 130 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; | 131 NSDictionary* attributes = [string attributesAtIndex:0 effectiveRange:NU
LL]; |
| 131 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) | 132 if (NSFont* font = [attributes objectForKey:NSFontAttributeName]) |
| 132 stringPoint.move(0, ceil(-[font descender])); | 133 stringPoint.move(0, ceil(-[font descender])); |
| 133 } | 134 } |
| 134 return stringPoint; | 135 return stringPoint; |
| 135 } | 136 } |
| 136 | 137 |
| 137 namespace blink { | 138 namespace blink { |
| 138 | 139 |
| 139 NSAttributedString* WebSubstringUtil::attributedWordAtPoint(WebView* view, WebPo
int point, WebPoint& baselinePoint) | 140 NSAttributedString* WebSubstringUtil::attributedWordAtPoint(WebFrameWidget* fram
eWidget, WebPoint point, WebPoint& baselinePoint) |
| 140 { | 141 { |
| 141 HitTestResult result = static_cast<WebViewImpl*>(view)->coreHitTestResultAt(
point); | 142 HitTestResult result = static_cast<WebFrameWidgetBase*>(frameWidget)->coreHi
tTestResultAt(point); |
| 143 |
| 142 if (!result.innerNode()) | 144 if (!result.innerNode()) |
| 143 return nil; | 145 return nil; |
| 144 LocalFrame* frame = result.innerNode()->document().frame(); | 146 LocalFrame* frame = result.innerNode()->document().frame(); |
| 145 EphemeralRange range = frame->rangeForPoint(result.roundedPointInInnerNodeFr
ame()); | 147 EphemeralRange range = frame->rangeForPoint(result.roundedPointInInnerNodeFr
ame()); |
| 146 if (range.isNull()) | 148 if (range.isNull()) |
| 147 return nil; | 149 return nil; |
| 148 | 150 |
| 149 // Expand to word under point. | 151 // Expand to word under point. |
| 150 VisibleSelection selection(range); | 152 VisibleSelection selection(range); |
| 151 selection.expandUsingGranularity(WordGranularity); | 153 selection.expandUsingGranularity(WordGranularity); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 175 if (ephemeralRange.isNull()) | 177 if (ephemeralRange.isNull()) |
| 176 return nil; | 178 return nil; |
| 177 | 179 |
| 178 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 180 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
| 179 if (baselinePoint) | 181 if (baselinePoint) |
| 180 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; | 182 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; |
| 181 return result; | 183 return result; |
| 182 } | 184 } |
| 183 | 185 |
| 184 } // namespace blink | 186 } // namespace blink |
| OLD | NEW |