Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 1123563003: Improving direction-based selection strategy. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding StrategyState enum to replace m_cleared, m_lastMoveShrunkSelection. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1242 }
1243 1243
1244 void WebLocalFrameImpl::selectRange(const WebRange& webRange) 1244 void WebLocalFrameImpl::selectRange(const WebRange& webRange)
1245 { 1245 {
1246 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran ge>>(webRange)) 1246 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran ge>>(webRange))
1247 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY, FrameSelection::NonDirectional, NotUserTriggered); 1247 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY, FrameSelection::NonDirectional, NotUserTriggered);
1248 } 1248 }
1249 1249
1250 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) 1250 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point)
1251 { 1251 {
1252 frame()->selection().moveRangeSelectionExtent(visiblePositionForViewportPoin t(point)); 1252 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon tents(point));
1253 } 1253 }
1254 1254
1255 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity) 1255 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity)
1256 { 1256 {
1257 blink::TextGranularity blinkGranularity = blink::CharacterGranularity; 1257 blink::TextGranularity blinkGranularity = blink::CharacterGranularity;
1258 if (granularity == WebFrame::WordGranularity) 1258 if (granularity == WebFrame::WordGranularity)
1259 blinkGranularity = blink::WordGranularity; 1259 blinkGranularity = blink::WordGranularity;
1260 frame()->selection().moveRangeSelection( 1260 frame()->selection().moveRangeSelection(
1261 visiblePositionForViewportPoint(baseInViewport), 1261 visiblePositionForViewportPoint(baseInViewport),
1262 visiblePositionForViewportPoint(extentInViewport), 1262 visiblePositionForViewportPoint(extentInViewport),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 frame()->inputMethodController().extendSelectionAndDelete(before, after); 1303 frame()->inputMethodController().extendSelectionAndDelete(before, after);
1304 } 1304 }
1305 1305
1306 void WebLocalFrameImpl::setCaretVisible(bool visible) 1306 void WebLocalFrameImpl::setCaretVisible(bool visible)
1307 { 1307 {
1308 frame()->selection().setCaretVisible(visible); 1308 frame()->selection().setCaretVisible(visible);
1309 } 1309 }
1310 1310
1311 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin t& pointInViewport) 1311 VisiblePosition WebLocalFrameImpl::visiblePositionForViewportPoint(const WebPoin t& pointInViewport)
1312 { 1312 {
1313 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping; 1313 return visiblePositionForContentsPoint(frame()->view()->viewportToContents(p ointInViewport), frame());
1314 HitTestResult result(request, frame()->view()->viewportToContents(pointInVie wport));
1315 frame()->document()->layoutView()->layer()->hitTest(result);
1316
1317 if (Node* node = result.innerNode())
1318 return frame()->selection().selection().visiblePositionRespectingEditing Boundary(result.localPoint(), node);
1319 return VisiblePosition();
1320 } 1314 }
1321 1315
1322 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() 1316 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported()
1323 { 1317 {
1324 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo de(frame(), WebNode(frame()->document()->focusedElement())); 1318 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo de(frame(), WebNode(frame()->document()->focusedElement()));
1325 if (container && container->supportsInputMethod()) 1319 if (container && container->supportsInputMethod())
1326 return container->plugin(); 1320 return container->plugin();
1327 return 0; 1321 return 0;
1328 } 1322 }
1329 1323
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 { 2084 {
2091 m_frameWidget = frameWidget; 2085 m_frameWidget = frameWidget;
2092 } 2086 }
2093 2087
2094 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const 2088 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const
2095 { 2089 {
2096 return m_frameWidget; 2090 return m_frameWidget;
2097 } 2091 }
2098 2092
2099 } // namespace blink 2093 } // namespace blink
OLDNEW
« Source/core/editing/GranularityStrategy.cpp ('K') | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698