X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=Source%2FWebKit2%2FWebProcess%2FWebPage%2Fefl%2FWebPageEfl.cpp;h=ffeb66841f690d190e9838eb8dd56e3a7b2ffb40;hb=b8bed2469cb69146c1b048442418e82b9214f8bc;hp=015d5eac336512866eab028702ff29f764039aa5;hpb=d8803adf21c9f41f0388e6ecadae10472a012395;p=framework%2Fweb%2Fwebkit-efl.git diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp index 015d5ea..ffeb668 100755 --- a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp @@ -1332,9 +1332,9 @@ void WebPage::selectClosestWord(const IntPoint& point, bool& result) result = true; } -void WebPage::setLeftSelection(const IntPoint& point, bool& result) +void WebPage::setLeftSelection(const IntPoint& point, const int direction, int& result) { - result = false; + result = HandleMovingDirectionNone; Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame(); FrameSelection* frameSelection = focusedFrame->selection(); @@ -1352,8 +1352,6 @@ void WebPage::setLeftSelection(const IntPoint& point, bool& result) IntPoint pos = frameView->windowToContents(point); IntRect leftRect, rightRect; getSelectionHandlers(leftRect, rightRect); - if ((rightRect.y() + rightRect.height()) < pos.y()) - pos.setY(rightRect.y() + (rightRect.height()/2)); if (selectionEndNode->rendererIsEditable() && !selectionEndNode->rendererIsRichlyEditable()) { const int boundariesWidth = 2; @@ -1367,6 +1365,7 @@ void WebPage::setLeftSelection(const IntPoint& point, bool& result) } OwnPtr position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos))); + Position base = frameSelection->base(); Position extent = frameSelection->extent(); Node* newSelectionStartNode = position->deepEquivalent().deprecatedNode(); @@ -1374,8 +1373,7 @@ void WebPage::setLeftSelection(const IntPoint& point, bool& result) // both start and end nodes should be in the same area type: both should be editable or both should be not editable // Check if the new position is before the extent's position if (newSelectionStartNode - && selectionEndNode->isContentEditable() == newSelectionStartNode->isContentEditable() - && comparePositions(position->deepEquivalent(), extent) < 0) { + && selectionEndNode->isContentEditable() == newSelectionStartNode->isContentEditable()) { // Change the 'base' and 'extent' positions to 'start' and 'end' positions. // We do it, because without this, the other modification of the selection // would destroy the 'start' and/or 'end' positions and set them to @@ -1386,20 +1384,35 @@ void WebPage::setLeftSelection(const IntPoint& point, bool& result) bool oldProhibitsScrolling = focusedFrame->view()->prohibitsScrolling(); focusedFrame->view()->setProhibitsScrolling(true); - frameSelection->setBase(*position); + if (direction == HandleMovingDirectionNormal) { + if (comparePositions(position->deepEquivalent(), extent) < 0) { + frameSelection->setBase(*position); + result = HandleMovingDirectionNormal; + } else if (comparePositions(position->deepEquivalent(), extent) > 0) { + frameSelection->setExtent(*position); + frameSelection->setBase(extent); + result = HandleMovingDirectionReverse; + } + } else if (direction == HandleMovingDirectionReverse) { + if (comparePositions(position->deepEquivalent(), base) > 0) { + frameSelection->setExtent(*position); + result = HandleMovingDirectionReverse; + } else if (comparePositions(position->deepEquivalent(), base) < 0) { + frameSelection->setBase(*position); + frameSelection->setExtent(base); + result = HandleMovingDirectionNormal; + } + } focusedFrame->view()->setProhibitsScrolling(oldProhibitsScrolling); // This forces webkit to show selection // m_coreFrame->invalidateSelection(); - - result = true; } } - -void WebPage::setRightSelection(const IntPoint& point, bool& result) +void WebPage::setRightSelection(const IntPoint& point, const int direction, int& result) { - result = false; + result = HandleMovingDirectionNone; Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame(); FrameSelection* frameSelection = focusedFrame->selection(); @@ -1429,14 +1442,14 @@ void WebPage::setRightSelection(const IntPoint& point, bool& result) OwnPtr position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos))); Position base = frameSelection->base(); + Position extent = frameSelection->extent(); Node* newSelectionEndNode = position->deepEquivalent().deprecatedNode(); // both start and end nodes should be in the same area type: both should be editable or both should be not editable // Check if the new position is after the base's position if (newSelectionEndNode - && selectionStartNode->isContentEditable() == newSelectionEndNode->isContentEditable() - && comparePositions(position->deepEquivalent(), base) > 0) { + && selectionStartNode->isContentEditable() == newSelectionEndNode->isContentEditable()) { // Change the 'base' and 'extent' positions to 'start' and 'end' positions. // We do it, because without this, the other modifications of the selection // would destroy the 'start' and/or 'end' positions and set them to @@ -1448,11 +1461,27 @@ void WebPage::setRightSelection(const IntPoint& point, bool& result) bool oldProhibitsScrolling = focusedFrame->view()->prohibitsScrolling(); focusedFrame->view()->setProhibitsScrolling(true); - frameSelection->setExtent(*position); + if (direction == HandleMovingDirectionNormal) { + if (comparePositions(position->deepEquivalent(), base) > 0) { + frameSelection->setExtent(*position); + result = HandleMovingDirectionNormal; + } else if (comparePositions(position->deepEquivalent(), base) < 0) { + frameSelection->setBase(*position); + frameSelection->setExtent(base); + result = HandleMovingDirectionReverse; + } + } else if (direction == HandleMovingDirectionReverse) { + if (comparePositions(position->deepEquivalent(), extent) < 0) { + frameSelection->setBase(*position); + result = HandleMovingDirectionReverse; + } else if (comparePositions(position->deepEquivalent(), extent) > 0) { + frameSelection->setExtent(*position); + frameSelection->setBase(extent); + result = HandleMovingDirectionNormal; + } + } focusedFrame->view()->setProhibitsScrolling(oldProhibitsScrolling); - - result = true; } }