OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 bool WebLocalFrameImpl::hasMarkedText() const | 1048 bool WebLocalFrameImpl::hasMarkedText() const |
1049 { | 1049 { |
1050 return frame()->inputMethodController().hasComposition(); | 1050 return frame()->inputMethodController().hasComposition(); |
1051 } | 1051 } |
1052 | 1052 |
1053 WebRange WebLocalFrameImpl::markedRange() const | 1053 WebRange WebLocalFrameImpl::markedRange() const |
1054 { | 1054 { |
1055 return frame()->inputMethodController().compositionRange(); | 1055 return frame()->inputMethodController().compositionRange(); |
1056 } | 1056 } |
1057 | 1057 |
1058 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rect) const | 1058 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rectInViewport) const |
1059 { | 1059 { |
1060 if ((location + length < location) && (location + length)) | 1060 if ((location + length < location) && (location + length)) |
1061 length = 0; | 1061 length = 0; |
1062 | 1062 |
1063 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1063 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1064 ASSERT(editable); | 1064 ASSERT(editable); |
1065 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); | 1065 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); |
1066 if (!range) | 1066 if (!range) |
1067 return false; | 1067 return false; |
1068 IntRect intRect = frame()->editor().firstRectForRange(range.get()); | 1068 IntRect intRect = frame()->editor().firstRectForRange(range.get()); |
1069 rect = WebRect(intRect); | 1069 rectInViewport = WebRect(intRect); |
1070 rect = frame()->view()->contentsToWindow(rect); | 1070 rectInViewport = frame()->view()->contentsToViewport(rectInViewport); |
1071 return true; | 1071 return true; |
1072 } | 1072 } |
1073 | 1073 |
1074 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const | 1074 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& pointInViewport
) const |
1075 { | 1075 { |
1076 if (!frame()) | 1076 if (!frame()) |
1077 return kNotFound; | 1077 return kNotFound; |
1078 | 1078 |
1079 IntPoint point = frame()->view()->windowToContents(webPoint); | 1079 IntPoint point = frame()->view()->viewportToContents(pointInViewport); |
1080 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); | 1080 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); |
1081 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); | 1081 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); |
1082 if (!range) | 1082 if (!range) |
1083 return kNotFound; | 1083 return kNotFound; |
1084 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1084 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1085 ASSERT(editable); | 1085 ASSERT(editable); |
1086 return PlainTextRange::create(*editable, *range.get()).start(); | 1086 return PlainTextRange::create(*editable, *range.get()).start(); |
1087 } | 1087 } |
1088 | 1088 |
1089 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) | 1089 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } | 1212 } |
1213 | 1213 |
1214 bool WebLocalFrameImpl::selectWordAroundCaret() | 1214 bool WebLocalFrameImpl::selectWordAroundCaret() |
1215 { | 1215 { |
1216 FrameSelection& selection = frame()->selection(); | 1216 FrameSelection& selection = frame()->selection(); |
1217 if (selection.isNone() || selection.isRange()) | 1217 if (selection.isNone() || selection.isRange()) |
1218 return false; | 1218 return false; |
1219 return frame()->selection().selectWordAroundPosition(selection.selection().v
isibleStart()); | 1219 return frame()->selection().selectWordAroundPosition(selection.selection().v
isibleStart()); |
1220 } | 1220 } |
1221 | 1221 |
1222 void WebLocalFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent
) | 1222 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi
nt& extentInViewport) |
1223 { | 1223 { |
1224 moveRangeSelection(base, extent); | 1224 moveRangeSelection(baseInViewport, extentInViewport); |
1225 } | 1225 } |
1226 | 1226 |
1227 void WebLocalFrameImpl::selectRange(const WebRange& webRange) | 1227 void WebLocalFrameImpl::selectRange(const WebRange& webRange) |
1228 { | 1228 { |
1229 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge>>(webRange)) | 1229 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge>>(webRange)) |
1230 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
FrameSelection::NonDirectional, NotUserTriggered); | 1230 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
FrameSelection::NonDirectional, NotUserTriggered); |
1231 } | 1231 } |
1232 | 1232 |
1233 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point, WebFrame
::TextGranularity granularity) | 1233 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& pointInViewport
, WebFrame::TextGranularity granularity) |
1234 { | 1234 { |
1235 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; | 1235 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; |
1236 if (granularity == WebFrame::WordGranularity) | 1236 if (granularity == WebFrame::WordGranularity) |
1237 blinkGranularity = blink::WordGranularity; | 1237 blinkGranularity = blink::WordGranularity; |
1238 frame()->selection().moveRangeSelectionExtent(visiblePositionForWindowPoint(
point), blinkGranularity); | 1238 frame()->selection().moveRangeSelectionExtent(visiblePositionForViewportPoin
t(pointInViewport), blinkGranularity); |
1239 } | 1239 } |
1240 | 1240 |
1241 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint&
extent, WebFrame::TextGranularity granularity) | 1241 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const
WebPoint& extentInViewport, WebFrame::TextGranularity granularity) |
1242 { | 1242 { |
1243 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; | 1243 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; |
1244 if (granularity == WebFrame::WordGranularity) | 1244 if (granularity == WebFrame::WordGranularity) |
1245 blinkGranularity = blink::WordGranularity; | 1245 blinkGranularity = blink::WordGranularity; |
1246 frame()->selection().moveRangeSelection(visiblePositionForWindowPoint(base),
visiblePositionForWindowPoint(extent), blinkGranularity); | 1246 frame()->selection().moveRangeSelection( |
| 1247 visiblePositionForViewportPoint(baseInViewport), |
| 1248 visiblePositionForViewportPoint(extentInViewport), |
| 1249 blinkGranularity); |
1247 } | 1250 } |
1248 | 1251 |
1249 void WebLocalFrameImpl::moveCaretSelection(const WebPoint& point) | 1252 void WebLocalFrameImpl::moveCaretSelection(const WebPoint& pointInViewport) |
1250 { | 1253 { |
1251 Element* editable = frame()->selection().rootEditableElement(); | 1254 Element* editable = frame()->selection().rootEditableElement(); |
1252 if (!editable) | 1255 if (!editable) |
1253 return; | 1256 return; |
1254 | 1257 |
1255 VisiblePosition position = visiblePositionForWindowPoint(point); | 1258 VisiblePosition position = visiblePositionForViewportPoint(pointInViewport); |
1256 frame()->selection().moveTo(position, UserTriggered); | 1259 frame()->selection().moveTo(position, UserTriggered); |
1257 } | 1260 } |
1258 | 1261 |
1259 bool WebLocalFrameImpl::setEditableSelectionOffsets(int start, int end) | 1262 bool WebLocalFrameImpl::setEditableSelectionOffsets(int start, int end) |
1260 { | 1263 { |
1261 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); | 1264 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); |
1262 } | 1265 } |
1263 | 1266 |
1264 bool WebLocalFrameImpl::setCompositionFromExistingText(int compositionStart, int
compositionEnd, const WebVector<WebCompositionUnderline>& underlines) | 1267 bool WebLocalFrameImpl::setCompositionFromExistingText(int compositionStart, int
compositionEnd, const WebVector<WebCompositionUnderline>& underlines) |
1265 { | 1268 { |
(...skipping 18 matching lines...) Expand all Loading... |
1284 return; | 1287 return; |
1285 } | 1288 } |
1286 frame()->inputMethodController().extendSelectionAndDelete(before, after); | 1289 frame()->inputMethodController().extendSelectionAndDelete(before, after); |
1287 } | 1290 } |
1288 | 1291 |
1289 void WebLocalFrameImpl::setCaretVisible(bool visible) | 1292 void WebLocalFrameImpl::setCaretVisible(bool visible) |
1290 { | 1293 { |
1291 frame()->selection().setCaretVisible(visible); | 1294 frame()->selection().setCaretVisible(visible); |
1292 } | 1295 } |
1293 | 1296 |
1294 VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint&
point) | 1297 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin
t& pointInViewport) |
1295 { | 1298 { |
1296 // FIXME(bokan): crbug.com/371902 - These scale/pinch transforms shouldn't | |
1297 // be ad hoc and explicit. | |
1298 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | |
1299 FloatPoint unscaledPoint(point); | |
1300 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); | |
1301 unscaledPoint.moveBy(pinchViewport.visibleRect().location()); | |
1302 | |
1303 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; | 1299 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; |
1304 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); | 1300 HitTestResult result(frame()->view()->viewportToContents(pointInViewport)); |
1305 frame()->document()->layoutView()->layer()->hitTest(request, result); | 1301 frame()->document()->layoutView()->layer()->hitTest(request, result); |
1306 | 1302 |
1307 if (Node* node = result.innerNode()) | 1303 if (Node* node = result.innerNode()) |
1308 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); | 1304 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); |
1309 return VisiblePosition(); | 1305 return VisiblePosition(); |
1310 } | 1306 } |
1311 | 1307 |
1312 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() | 1308 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() |
1313 { | 1309 { |
1314 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); | 1310 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 { | 2046 { |
2051 m_frameWidget = frameWidget; | 2047 m_frameWidget = frameWidget; |
2052 } | 2048 } |
2053 | 2049 |
2054 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2050 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
2055 { | 2051 { |
2056 return m_frameWidget; | 2052 return m_frameWidget; |
2057 } | 2053 } |
2058 | 2054 |
2059 } // namespace blink | 2055 } // namespace blink |
OLD | NEW |