| 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 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 bool WebLocalFrameImpl::hasMarkedText() const | 1016 bool WebLocalFrameImpl::hasMarkedText() const |
| 1017 { | 1017 { |
| 1018 return frame()->inputMethodController().hasComposition(); | 1018 return frame()->inputMethodController().hasComposition(); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 WebRange WebLocalFrameImpl::markedRange() const | 1021 WebRange WebLocalFrameImpl::markedRange() const |
| 1022 { | 1022 { |
| 1023 return frame()->inputMethodController().compositionRange(); | 1023 return frame()->inputMethodController().compositionRange(); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rect) const | 1026 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rectInViewport) const |
| 1027 { | 1027 { |
| 1028 if ((location + length < location) && (location + length)) | 1028 if ((location + length < location) && (location + length)) |
| 1029 length = 0; | 1029 length = 0; |
| 1030 | 1030 |
| 1031 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1031 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
| 1032 ASSERT(editable); | 1032 ASSERT(editable); |
| 1033 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); | 1033 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); |
| 1034 if (!range) | 1034 if (!range) |
| 1035 return false; | 1035 return false; |
| 1036 IntRect intRect = frame()->editor().firstRectForRange(range.get()); | 1036 IntRect intRect = frame()->editor().firstRectForRange(range.get()); |
| 1037 rect = WebRect(intRect); | 1037 rectInViewport = WebRect(intRect); |
| 1038 rect = frame()->view()->contentsToWindow(rect); | 1038 rectInViewport = frame()->view()->contentsToViewport(rectInViewport); |
| 1039 return true; | 1039 return true; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const | 1042 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& pointInViewport
) const |
| 1043 { | 1043 { |
| 1044 if (!frame()) | 1044 if (!frame()) |
| 1045 return kNotFound; | 1045 return kNotFound; |
| 1046 | 1046 |
| 1047 IntPoint point = frame()->view()->windowToContents(webPoint); | 1047 IntPoint point = frame()->view()->viewportToContents(pointInViewport); |
| 1048 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); | 1048 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active); |
| 1049 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); | 1049 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); |
| 1050 if (!range) | 1050 if (!range) |
| 1051 return kNotFound; | 1051 return kNotFound; |
| 1052 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1052 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
| 1053 ASSERT(editable); | 1053 ASSERT(editable); |
| 1054 return PlainTextRange::create(*editable, *range.get()).start(); | 1054 return PlainTextRange::create(*editable, *range.get()).start(); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) | 1057 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 bool WebLocalFrameImpl::selectWordAroundCaret() | 1182 bool WebLocalFrameImpl::selectWordAroundCaret() |
| 1183 { | 1183 { |
| 1184 FrameSelection& selection = frame()->selection(); | 1184 FrameSelection& selection = frame()->selection(); |
| 1185 if (selection.isNone() || selection.isRange()) | 1185 if (selection.isNone() || selection.isRange()) |
| 1186 return false; | 1186 return false; |
| 1187 return frame()->selection().selectWordAroundPosition(selection.selection().v
isibleStart()); | 1187 return frame()->selection().selectWordAroundPosition(selection.selection().v
isibleStart()); |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 void WebLocalFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent
) | 1190 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi
nt& extentInViewport) |
| 1191 { | 1191 { |
| 1192 moveRangeSelection(base, extent); | 1192 moveRangeSelection(baseInViewport, extentInViewport); |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 void WebLocalFrameImpl::selectRange(const WebRange& webRange) | 1195 void WebLocalFrameImpl::selectRange(const WebRange& webRange) |
| 1196 { | 1196 { |
| 1197 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge>>(webRange)) | 1197 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge>>(webRange)) |
| 1198 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
FrameSelection::NonDirectional, NotUserTriggered); | 1198 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
FrameSelection::NonDirectional, NotUserTriggered); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point, WebFrame
::TextGranularity granularity) | 1201 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& pointInViewport
, WebFrame::TextGranularity granularity) |
| 1202 { | 1202 { |
| 1203 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; | 1203 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; |
| 1204 if (granularity == WebFrame::WordGranularity) | 1204 if (granularity == WebFrame::WordGranularity) |
| 1205 blinkGranularity = blink::WordGranularity; | 1205 blinkGranularity = blink::WordGranularity; |
| 1206 frame()->selection().moveRangeSelectionExtent(visiblePositionForWindowPoint(
point), blinkGranularity); | 1206 frame()->selection().moveRangeSelectionExtent(visiblePositionForViewportPoin
t(pointInViewport), blinkGranularity); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint&
extent, WebFrame::TextGranularity granularity) | 1209 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const
WebPoint& extentInViewport, WebFrame::TextGranularity granularity) |
| 1210 { | 1210 { |
| 1211 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; | 1211 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; |
| 1212 if (granularity == WebFrame::WordGranularity) | 1212 if (granularity == WebFrame::WordGranularity) |
| 1213 blinkGranularity = blink::WordGranularity; | 1213 blinkGranularity = blink::WordGranularity; |
| 1214 frame()->selection().moveRangeSelection(visiblePositionForWindowPoint(base),
visiblePositionForWindowPoint(extent), blinkGranularity); | 1214 frame()->selection().moveRangeSelection( |
| 1215 visiblePositionForViewportPoint(baseInViewport), |
| 1216 visiblePositionForViewportPoint(extentInViewport), |
| 1217 blinkGranularity); |
| 1215 } | 1218 } |
| 1216 | 1219 |
| 1217 void WebLocalFrameImpl::moveCaretSelection(const WebPoint& point) | 1220 void WebLocalFrameImpl::moveCaretSelection(const WebPoint& pointInViewport) |
| 1218 { | 1221 { |
| 1219 Element* editable = frame()->selection().rootEditableElement(); | 1222 Element* editable = frame()->selection().rootEditableElement(); |
| 1220 if (!editable) | 1223 if (!editable) |
| 1221 return; | 1224 return; |
| 1222 | 1225 |
| 1223 VisiblePosition position = visiblePositionForWindowPoint(point); | 1226 VisiblePosition position = visiblePositionForViewportPoint(pointInViewport); |
| 1224 frame()->selection().moveTo(position, UserTriggered); | 1227 frame()->selection().moveTo(position, UserTriggered); |
| 1225 } | 1228 } |
| 1226 | 1229 |
| 1227 bool WebLocalFrameImpl::setEditableSelectionOffsets(int start, int end) | 1230 bool WebLocalFrameImpl::setEditableSelectionOffsets(int start, int end) |
| 1228 { | 1231 { |
| 1229 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); | 1232 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); |
| 1230 } | 1233 } |
| 1231 | 1234 |
| 1232 bool WebLocalFrameImpl::setCompositionFromExistingText(int compositionStart, int
compositionEnd, const WebVector<WebCompositionUnderline>& underlines) | 1235 bool WebLocalFrameImpl::setCompositionFromExistingText(int compositionStart, int
compositionEnd, const WebVector<WebCompositionUnderline>& underlines) |
| 1233 { | 1236 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1252 return; | 1255 return; |
| 1253 } | 1256 } |
| 1254 frame()->inputMethodController().extendSelectionAndDelete(before, after); | 1257 frame()->inputMethodController().extendSelectionAndDelete(before, after); |
| 1255 } | 1258 } |
| 1256 | 1259 |
| 1257 void WebLocalFrameImpl::setCaretVisible(bool visible) | 1260 void WebLocalFrameImpl::setCaretVisible(bool visible) |
| 1258 { | 1261 { |
| 1259 frame()->selection().setCaretVisible(visible); | 1262 frame()->selection().setCaretVisible(visible); |
| 1260 } | 1263 } |
| 1261 | 1264 |
| 1262 VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint&
point) | 1265 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin
t& pointInViewport) |
| 1263 { | 1266 { |
| 1264 // FIXME(bokan): crbug.com/371902 - These scale/pinch transforms shouldn't | |
| 1265 // be ad hoc and explicit. | |
| 1266 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | |
| 1267 FloatPoint unscaledPoint(point); | |
| 1268 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); | |
| 1269 unscaledPoint.moveBy(pinchViewport.visibleRect().location()); | |
| 1270 | |
| 1271 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; | 1267 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; |
| 1272 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); | 1268 HitTestResult result(frame()->view()->viewportToContents(pointInViewport)); |
| 1273 frame()->document()->layoutView()->layer()->hitTest(request, result); | 1269 frame()->document()->layoutView()->layer()->hitTest(request, result); |
| 1274 | 1270 |
| 1275 if (Node* node = result.innerNode()) | 1271 if (Node* node = result.innerNode()) |
| 1276 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); | 1272 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); |
| 1277 return VisiblePosition(); | 1273 return VisiblePosition(); |
| 1278 } | 1274 } |
| 1279 | 1275 |
| 1280 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() | 1276 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() |
| 1281 { | 1277 { |
| 1282 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); | 1278 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 { | 2002 { |
| 2007 m_frameWidget = frameWidget; | 2003 m_frameWidget = frameWidget; |
| 2008 } | 2004 } |
| 2009 | 2005 |
| 2010 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2006 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
| 2011 { | 2007 { |
| 2012 return m_frameWidget; | 2008 return m_frameWidget; |
| 2013 } | 2009 } |
| 2014 | 2010 |
| 2015 } // namespace blink | 2011 } // namespace blink |
| OLD | NEW |