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);
#include "WebEventConversion.h"
#endif
+#if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+#include <WebCore/HTMLAreaElement.h>
+#endif
+
#if ENABLE(TIZEN_CSP)
#include <WebCore/ContentSecurityPolicy.h>
#endif
#include "fontconfig/fontconfig.h"
#include <WebCore/FontCache.h>
#endif
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+#include "visible_units.h"
+#endif
#endif // #if OS(TIZEN)
using namespace WebCore;
result = false;
Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
- if (direction)
- result = focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
- else
- result = focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
+ if (!focusedFrame)
+ return;
+
+ FrameSelection* frameSelection = focusedFrame->selection();
+ if (!frameSelection)
+ return;
+
+ VisiblePosition currentPosition = frameSelection->selection().visibleStart();
+ if (direction) {
+ if (isStartOfLine(currentPosition))
+ return;
+
+ focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
+ } else {
+ if (isEndOfLine(currentPosition))
+ return;
+
+ focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
+ }
+}
+
+void WebPage::scrollContentByLine(const IntPoint&, int direction, bool& result)
+{
+ result = false;
+
+ Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
+ if (!focusedFrame)
+ return;
+
+ FrameSelection* frameSelection = focusedFrame->selection();
+ if (!frameSelection)
+ return;
+
+ VisiblePosition currentPosition = frameSelection->selection().visibleStart();
+ if (direction) {
+ if (inSameLine(currentPosition, previousLinePosition(currentPosition, 0)))
+ return;
+
+ focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, LineGranularity, UserTriggered);
+ } else {
+ if (inSameLine(currentPosition, nextLinePosition(currentPosition, 0)))
+ return;
+
+ focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
+ }
}
#endif
}
#endif
+#if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+static LayoutRect rectToAbsoluteCoordinates(Frame* initialFrame, const LayoutRect& initialRect)
+{
+ LayoutRect rect = initialRect;
+ for (Frame* frame = initialFrame; frame; frame = frame->tree()->parent()) {
+ RenderBoxModelObject* renderer;
+ if (frame->ownerElement() && (renderer = frame->ownerElement()->renderBoxModelObject())) {
+ do {
+ rect.move(renderer->offsetLeft(), renderer->offsetTop());
+ } while ((renderer = renderer->offsetParent()));
+ rect.move(-frame->view()->scrollOffset());
+ }
+ }
+ return rect;
+}
+
+IntRect WebPage::nodeRect(Node* node) const
+{
+ if (!node)
+ return IntRect();
+
+ LayoutRect rect;
+ if (node->hasTagName(HTMLNames::areaTag)) {
+ HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
+ HTMLImageElement* image = area->imageElement();
+ if (!image || !image->renderer())
+ return IntRect();
+
+ rect = rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer()));
+ } else if (node->renderer()) {
+ if (node->isDocumentNode())
+ rect = rectToAbsoluteCoordinates(static_cast<Document*>(node)->frame(), static_cast<Document*>(node)->frame()->view()->visibleContentRect());
+ else {
+ rect = node->getRect();
+ rect.intersect(node->renderer()->absoluteClippedOverflowRect());
+ rect = rectToAbsoluteCoordinates(node->document()->frame(), rect);
+
+ rect.move(node->renderer()->style()->borderLeftWidth(), node->renderer()->style()->borderTopWidth());
+ rect.setWidth(rect.width() - node->renderer()->style()->borderLeftWidth() - node->renderer()->style()->borderRightWidth());
+ rect.setHeight(rect.height() - node->renderer()->style()->borderTopWidth() - node->renderer()->style()->borderBottomWidth());
+ }
+ }
+
+ return pixelSnappedIntRect(rect);
+}
+#endif
+
#if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
// FIXME: Currently with cached pages, hiding Popup list menu is not working correctly.
// This patch is a fix allowing any popup list menu to get close for any page navigation.