return true;
}
+static int s_textSelectionMargin = 5;
+
void TextSelection::textSelectionMove(const IntPoint& point, bool isStartedTextSelectionFromOutside)
{
// text selection should be ignored when longtap on handle from osp
if (editorState.isContentEditable) {
IntRect mapRect = m_viewImpl->transformToScene().mapRect(editorState.editorRect);
IntPoint updatedPoint = point;
- if ((point.y() < mapRect.y()) || (point.y() > ((mapRect.y()) + (mapRect.height()))))
- updatedPoint.setY((mapRect.y()) + ((mapRect.height())/2) );
+ bool scrolledY = false;
+ if (point.y() < mapRect.y()) {
+ updatedPoint.setY(mapRect.y() + s_textSelectionMargin);
+ if (m_viewImpl->page()->scrollContentByLine(point,WebCore::DirectionBackward)) {
+ scrolledY = true;
+ updateMagnifier(updatedPoint);
+ }
+ } else if (point.y() > mapRect.maxY()) {
+ updatedPoint.setY(mapRect.maxY() - s_textSelectionMargin);
+ if (m_viewImpl->page()->scrollContentByLine(point,WebCore::DirectionForward)) {
+ scrolledY = true;
+ updateMagnifier(updatedPoint);
+ }
+ }
+ bool scrolledX = false;
if (point.x() < mapRect.x()) {
- updatedPoint.setX(mapRect.x());
- if (m_viewImpl->page()->scrollContentByCharacter(point,WebCore::DirectionBackward))
+ updatedPoint.setX(mapRect.x() + s_textSelectionMargin);
+ if (m_viewImpl->page()->scrollContentByCharacter(point,WebCore::DirectionBackward)) {
+ scrolledX = true;
updateMagnifier(updatedPoint);
- } else if (point.x() > ((mapRect.x()) + (mapRect.width()))) {
- updatedPoint.setX((mapRect.x()) + (mapRect.width()));
- if (m_viewImpl->page()->scrollContentByCharacter(point,WebCore::DirectionForward))
+ }
+ } else if (point.x() > mapRect.maxX()) {
+ updatedPoint.setX(mapRect.maxX() - s_textSelectionMargin);
+ if (m_viewImpl->page()->scrollContentByCharacter(point,WebCore::DirectionForward)) {
+ scrolledX = true;
updateMagnifier(updatedPoint);
- } else {
+ }
+ }
+
+ if (!scrolledX && !scrolledY) {
viewPoint = m_viewImpl->transformFromScene().mapPoint(updatedPoint);
m_viewImpl->page()->selectClosestWord(viewPoint, isStartedTextSelectionFromOutside);
updateMagnifier(updatedPoint);