Whole block area is highlighted instead of only Selected option.
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / efl / WebPageEfl.cpp
index f9ba8e8..f74b956 100755 (executable)
@@ -74,8 +74,8 @@
 #include <WebCore/Pasteboard.h>
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
-#include "WebInspectorServerEfl.h"
+#if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
+#include "WebInspectorServerTizen.h"
 #endif
 
 #if ENABLE(TIZEN_WEB_STORAGE)
 #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
 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
 #include "WebPageSerializerTizen.h"
 #endif
+
+#if ENABLE(TIZEN_USE_SETTINGS_FONT)
+#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;
@@ -169,6 +182,9 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
 #if ENABLE(TIZEN_LOAD_REMOTE_IMAGES)
     settings->setLoadRemoteImages(store.getBoolValueForKey(WebPreferencesKey::loadRemoteImagesKey()));
 #endif
+#if ENABLE(TIZEN_LINK_EFFECT)
+    settings->setLinkEffectEnabled(store.getBoolValueForKey(WebPreferencesKey::linkEffectEnabledKey()));
+#endif
 #if ENABLE(TIZEN_ISF_PORT)
     settings->setEnableDefaultKeypad(store.getBoolValueForKey(WebPreferencesKey::defaultKeypadEnabledKey()));
 #endif
@@ -274,7 +290,18 @@ void WebPage::confirmComposition(const String& compositionString)
     if (!targetFrame)
         return;
 
+#if ENABLE(TIZEN_ISF_PORT)
+    if (m_prepareKeyDownEvent) {
+        m_keyPressCommands.append(adoptPtr(new ConfirmCompositionKeyPressCommand(compositionString)));
+        return;
+    }
+#endif
+
     targetFrame->editor()->confirmComposition(compositionString);
+
+#if ENABLE(TIZEN_ISF_PORT)
+    m_page->editorClient()->respondToChangedSelection(targetFrame);
+#endif
 }
 
 void WebPage::setComposition(const String& compositionString, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition)
@@ -284,6 +311,14 @@ void WebPage::setComposition(const String& compositionString, const Vector<WebCo
         return;
 
 #if ENABLE(TIZEN_ISF_PORT)
+    if (!targetFrame->editor()->hasComposition() && compositionString.isEmpty())
+        return;
+
+    if (m_prepareKeyDownEvent) {
+        m_keyPressCommands.append(adoptPtr(new SetCompositionKeyPressCommand(compositionString, underlines, cursorPosition)));
+        return;
+    }
+
     if (targetFrame->selection()->rootEditableElement()) {
         HTMLTextFormControlElement* textFormControl = toTextFormControl(targetFrame->selection()->rootEditableElement()->shadowAncestorNode());
         if (textFormControl && textFormControl->maxLength() >= 0) {
@@ -312,6 +347,10 @@ void WebPage::setComposition(const String& compositionString, const Vector<WebCo
 #endif
 
     targetFrame->editor()->setComposition(compositionString, underlines, cursorPosition, 0);
+
+#if ENABLE(TIZEN_ISF_PORT)
+    m_page->editorClient()->respondToChangedSelection(targetFrame);
+#endif
 }
 
 void WebPage::cancelComposition()
@@ -552,6 +591,11 @@ bool WebPage::setCaretPosition(const IntPoint& pos)
         if (!node || !node->renderer())
             return false;
 
+        Element* currentRootEditableElement = node->rootEditableElement();
+        Element* newRootEditableElement = innerNode->rootEditableElement();
+        if (currentRootEditableElement != newRootEditableElement)
+            return false;
+
         IntRect rect = controller->caretRenderer()->absoluteBoundingBoxRect(true);
 
         // The below wirtten code is not correct way to implement. Presntly the is no
@@ -637,6 +681,17 @@ void WebPage::didCancelComposition(Node* valueChangedNode)
     send(Messages::WebPageProxy::DidCancelComposition());
 }
 
+void WebPage::prepareKeyDownEvent()
+{
+    m_prepareKeyDownEvent = true;
+    m_keyPressCommands.clear();
+}
+
+void WebPage::swapKeyPressCommands(Vector<OwnPtr<KeyPressCommand> >& commands)
+{
+    m_keyPressCommands.swap(commands);
+}
+
 void WebPage::getCursorOffset(int& offset)
 {
     offset = 0;
@@ -692,6 +747,11 @@ void WebPage::deleteSurroundingText(int offset, int count)
     if (!frame || !frame->editor()->canEdit())
         return;
 
+    if (m_prepareKeyDownEvent) {
+        m_keyPressCommands.append(adoptPtr(new DeleteTextKeyPressCommand(offset, count)));
+        return;
+    }
+
     Position base(frame->selection()->base());
     offset += base.offsetInContainerNode();
     base.moveToOffset(offset);
@@ -839,28 +899,82 @@ static IntRect getNodeRect(Node* node, Node* focusableNode, bool isImage)
 
 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+#if ENABLE(TOUCH_ADJUSTMENT)
+static bool isClickableOrFocusable(Node* focusableNode)
+{
+
+   if (!focusableNode)
+       return false;
+   if (focusableNode->disabled())
+        return false;
+   if (!focusableNode->inDocument())
+        return false;
+   if (!focusableNode->renderer() || focusableNode->renderer()->style()->visibility() != VISIBLE)
+        return false;
+   if (focusableNode->isFocusable()) {
+       if (focusableNode->isLink()
+           || focusableNode->hasTagName(HTMLNames::inputTag)
+           || focusableNode->hasTagName(HTMLNames::selectTag)
+           || focusableNode->hasTagName(HTMLNames::buttonTag))
+           return true;
+   }
+   if (focusableNode->supportsFocus()
+       || focusableNode->hasEventListeners(eventNames().clickEvent)
+       || focusableNode->hasEventListeners(eventNames().mousedownEvent)
+       || focusableNode->hasEventListeners(eventNames().mouseupEvent)) {
+       return true;
+   }
+   return false;
+}
+
+static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page, const IntPoint& point, const IntSize& area)
+#else
 static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
+#endif
 {
     Node* node = hitTestResult.innerNode();
+#if ENABLE(TOUCH_ADJUSTMENT)
+    Node* adjustedNode = 0;
+    IntPoint adustedPoint;
+    Frame* mainFrame = page->mainFrame();
+    if (!isClickableOrFocusable(node))
+        mainFrame->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adustedPoint, adjustedNode);
+
+    if (adjustedNode)
+        node = adjustedNode;
+#endif
+    if (!node)
+        return IntRect();
+
     bool isFocusRingDrawable = false;
     Node* focusableNode = node;
     while (focusableNode) {
         RenderObject* renderer = focusableNode->renderer();
-        if (renderer && renderer->isRoot())
+        if (renderer && (renderer->isBody() || renderer->isRenderView() || renderer->isRoot()))
             break;
 
-        if (focusableNode->isFocusable()) {
-            if (focusableNode->isLink()
-                || focusableNode->hasTagName(HTMLNames::inputTag)
-                || focusableNode->hasTagName(HTMLNames::selectTag)
-                || focusableNode->hasTagName(HTMLNames::buttonTag))
-                isFocusRingDrawable = true;
+        if (isClickableOrFocusable(focusableNode)) {
+            isFocusRingDrawable = true;
             break;
         }
 
         focusableNode = focusableNode->parentNode();
     }
 
+    // Don't draw focus ring if child is focusable or has trigger
+    if (focusableNode && focusableNode->isContainerNode() && !focusableNode->isLink()) {
+        WebCore::Node *child = static_cast<const ContainerNode*>(focusableNode)->firstChild();
+        while(child) {
+            if( child->supportsFocus()
+                || child->hasEventListeners(eventNames().clickEvent)
+                || child->hasEventListeners(eventNames().mousedownEvent)
+                || child->hasEventListeners(eventNames().mouseupEvent)) {
+                return IntRect();
+            }
+            child = child->traverseNextNode(focusableNode);
+        }
+    }
+
     if (!isFocusRingDrawable) {
         if (node->hasTagName(HTMLNames::imgTag))
             return getNodeRect(node, node, !hitTestResult.absoluteImageURL().isEmpty());
@@ -872,7 +986,11 @@ static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
 }
 #endif
 
+#if ENABLE(TOUCH_ADJUSTMENT)
+void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, const IntSize& area, WebHitTestResult::Data& hitTestResultData)
+#else
 void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHitTestResult::Data& hitTestResultData)
+#endif
 {
     Frame* frame = m_page->mainFrame();
     FrameView* frameView = frame->view();
@@ -885,6 +1003,7 @@ void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHi
     hitTestResultData.absoluteMediaURL = hitTestResult.absoluteMediaURL().string();
     hitTestResultData.linkLabel = hitTestResult.textContent();
     hitTestResultData.linkTitle = hitTestResult.titleDisplayString();
+    hitTestResultData.isContentEditable = hitTestResult.isContentEditable();
 #if ENABLE(TIZEN_DRAG_SUPPORT)
     hitTestResultData.isDragSupport = hitTestResult.isDragSupport();
 #endif
@@ -908,7 +1027,19 @@ void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHi
     hitTestResultData.hitTestMode = hitTestMode;
 
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+#if ENABLE(TOUCH_ADJUSTMENT)
+    hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get(), point, area);
+#else
     hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get());
+#endif
+
+    // Don't display FocusRect if the size is too big..
+    IntRect framerect = frameView->visibleContentRect(true);
+    if (hitTestResultData.focusedRect.width() > (0.8 * framerect.width())
+        && hitTestResultData.focusedRect.height() > (0.8 * framerect.height())) {
+        hitTestResultData.focusedRect = IntRect();
+    }
+
     if (hitTestResult.innerNode() && hitTestResult.innerNode()->renderer() && hitTestResult.innerNode()->renderer()->style()) {
         hitTestResultData.focusedColor = hitTestResult.innerNode()->renderer()->style()->tapHighlightColor();
         if (!hitTestResultData.focusedColor.hasAlpha())
@@ -966,13 +1097,6 @@ void WebPage::setStorageQuotaBytes(uint32_t quota)
 }
 #endif
 
-#if ENABLE(TIZEN_RECORDING_SURFACE_SET)
-void WebPage::recordingSurfaceSetEnableSet(bool enable)
-{
-    m_recordingSurfaceSetSettings = enable;
-}
-#endif
-
 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
 void WebPage::setClipboardDataForPaste(const String& data, const String& type)
 {
@@ -1011,6 +1135,26 @@ void WebPage::resumeJavaScriptAndResources()
     mainFrame->loader()->resumeAllLoaders();
 }
 
+void WebPage::suspendAnimations()
+{
+    Frame* mainFrame = m_page->mainFrame();
+    if (!mainFrame)
+        return;
+
+    for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
+        frame->animation()->suspendAnimationsForDocument(frame->document());
+}
+
+void WebPage::resumeAnimations()
+{
+    Frame* mainFrame = m_page->mainFrame();
+    if (!mainFrame)
+        return;
+
+    for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
+        frame->animation()->resumeAnimationsForDocument(frame->document());
+}
+
 #if ENABLE(TIZEN_SYNC_REQUEST_ANIMATION_FRAME)
 void WebPage::suspendAnimationController()
 {
@@ -1041,19 +1185,19 @@ void WebPage::resumeAnimationController()
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
+#if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
 void WebPage::startInspectorServer(uint32_t port,  uint32_t& allocatedPort)
 {
-    bool ret = WebInspectorServerEfl::server()->startServer(port);
+    bool ret = WebInspectorServerTizen::server()->startServer(port);
     if (ret)
-        allocatedPort = WebInspectorServerEfl::server()->getServerPort();
+        allocatedPort = WebInspectorServerTizen::server()->getServerPort();
     else
         allocatedPort = 0;
 }
 
 void WebPage::stopInspectorServer(bool& result)
 {
-    result = WebInspectorServerEfl::server()->stopServer();
+    result = WebInspectorServerTizen::server()->stopServer();
 }
 #endif
 
@@ -1136,19 +1280,6 @@ void WebPage::resumePlugin()
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void WebPage::getTextStyleStateForSelection()
-{
-    Frame* frame = m_page->focusController()->focusedOrMainFrame();
-
-    int underlineState = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline");
-    int italicState = frame->editor()->selectionHasStyle(CSSPropertyFontStyle, "italic");
-    int boldState = frame->editor()->selectionHasStyle(CSSPropertyFontWeight, "bold");
-
-    send(Messages::WebPageProxy::DidGetTextStyleStateForSelection(underlineState, italicState, boldState));
-}
-#endif
-
 #if ENABLE(TIZEN_MULTIPLE_SELECT)
 void WebPage::didChangeSelectedIndexForActivePopupMenuMultiple(Vector<int32_t> newIndex)
 {
@@ -1172,7 +1303,7 @@ void WebPage::startOfflinePageSave(String subresourceFolderName)
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-void WebPage::selectClosestWord(const IntPoint& point, bool isStartedTextSelectionFromOutside, bool& result)
+void WebPage::selectClosestWord(const IntPoint& point, bool& result)
 {
     result = false;
 
@@ -1191,9 +1322,7 @@ void WebPage::selectClosestWord(const IntPoint& point, bool isStartedTextSelecti
          focusedFrame = newFocusFrame;
      }
 
-#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
     HTMLInputElement* inputElement = node->toInputElement();
-#endif
 
     if (hitTestResult.isContentEditable()) {
 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
@@ -1216,14 +1345,25 @@ void WebPage::selectClosestWord(const IntPoint& point, bool isStartedTextSelecti
 #endif
         return;
 
-    if (!isStartedTextSelectionFromOutside) {
-        for (Node* node = hitTestResult.innerNonSharedNode(); node; node = node->parentNode()) {
-            if (node->isFocusable()) {
-                // Text selection shoud not be started when text of <button> tag is selected.
-                if (node->hasTagName(HTMLNames::buttonTag))
-                    return;
-                break;
-            }
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+    if (inputElement
+        && (inputElement->isDateField() || inputElement->isDateTimeField() || inputElement->isDateTimeLocalField()
+        || inputElement->isMonthField() || inputElement->isTimeField() || inputElement->isWeekField())) {
+        if (inputElement->value().isEmpty())
+            return;
+    }
+#endif
+
+    for (Node* node = hitTestResult.innerNonSharedNode(); node; node = node->parentNode()) {
+        if (node->isFocusable()) {
+            // Text selection shoud not be started when text of <button> tag is selected.
+            if (node->hasTagName(HTMLNames::buttonTag))
+                return;
+
+            if (inputElement && inputElement->isTextButton())
+                return;
+
+            break;
         }
     }
 
@@ -1259,9 +1399,9 @@ void WebPage::selectClosestWord(const IntPoint& point, bool isStartedTextSelecti
     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();
@@ -1279,8 +1419,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;
@@ -1294,6 +1432,7 @@ void WebPage::setLeftSelection(const IntPoint& point, bool& result)
     }
 
     OwnPtr<VisiblePosition> position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos)));
+    Position base = frameSelection->base();
     Position extent = frameSelection->extent();
 
     Node* newSelectionStartNode = position->deepEquivalent().deprecatedNode();
@@ -1301,8 +1440,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
@@ -1313,20 +1451,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();
@@ -1356,14 +1509,14 @@ void WebPage::setRightSelection(const IntPoint& point, bool& result)
 
     OwnPtr<VisiblePosition> 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
@@ -1375,11 +1528,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;
     }
 }
 
@@ -1396,19 +1565,8 @@ void WebPage::getSelectionHandlers(IntRect& leftRect, IntRect& rightRect)
 
     RefPtr<Range> selectedRange = focusedFrame->selection()->toNormalizedRange();
 
-    Vector<IntRect> rects, tempRects;
-    selectedRange->boundingBoxEx(tempRects, true);
-
-    IntRect boundsRect =  enclosingIntRect(focusedFrame->selection()->bounds());
-    for (size_t i = 0; i < tempRects.size(); i++) {
-        if (boundsRect.contains(tempRects[i]))
-            rects.append(tempRects[i]);
-        else {
-            tempRects[i].intersect(boundsRect);
-            if (!tempRects[i].isEmpty())
-                rects.append(tempRects[i]);
-        }
-    }
+    Vector<IntRect> rects;
+    selectedRange->boundingBoxEx(rects, true);
 
     unsigned size = rects.size();
     if (size > 0) {
@@ -1418,14 +1576,15 @@ void WebPage::getSelectionHandlers(IntRect& leftRect, IntRect& rightRect)
         // If selection rect size is greater than editor rect size because of round operation,
         // selection rect size should be changed to editor rect size.
         if (size == 1) {
-            Element* selectionRoot = focusedFrame->selection()->rootEditableElement();
-            if (selectionRoot) {
-                IntRect editorRect = focusedFrame->view()->contentsToWindow(selectionRoot->getPixelSnappedRect());
+            Element* rootEditableElement = focusedFrame->selection()->rootEditableElement();
+            if (rootEditableElement) {
+                IntRect editorRect = nodeRect(rootEditableElement);
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
                 if (m_editorState.editorRect != editorRect) {
                     EditorState state = editorState();
                     state.updateEditorRectOnly = true;
+                    setEditorState(state);
                     send(Messages::WebPageProxy::EditorStateChanged(state));
                 }
 #endif
@@ -1508,41 +1667,62 @@ void WebPage::scrollContentByCharacter(const IntPoint&, int direction, bool& res
     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);
-}
-#endif
+    if (!focusedFrame)
+        return;
 
-#if ENABLE(TIZEN_LINK_MAGNIFIER)
-void WebPage::getLinkMagnifierRect(const IntPoint& position, const IntSize& size)
-{
-    send(Messages::WebPageProxy::DidGetLinkMagnifierRect(position, LinkMagnifier::rect(this, position, size)));
+    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);
+    }
 }
-#endif
 
-#if ENABLE(TIZEN_SCREEN_READER)
-void WebPage::raiseTapEvent(const IntPoint& position, const IntPoint& globalPosition)
+void WebPage::scrollContentByLine(const IntPoint&, int direction, bool& result)
 {
-    Frame* frame = m_page->mainFrame();
-    if (!frame->view())
+    result = false;
+
+    Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
+    if (!focusedFrame)
         return;
 
-    Vector<WebPlatformTouchPoint> touchPoints;
-    touchPoints.append(WebPlatformTouchPoint(0, WebPlatformTouchPoint::TouchPressed, globalPosition, position));
+    FrameSelection* frameSelection = focusedFrame->selection();
+    if (!frameSelection)
+        return;
 
-    WebTouchEvent touchStartEvent(WebEvent::TouchStart, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
-    if (!frame->eventHandler()->handleTouchEvent(platform(touchStartEvent))) {
-        WebGestureEvent gestureEvent(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
-        frame->eventHandler()->handleGestureEvent(platform(gestureEvent));
+    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
 
-    touchPoints.at(0).setState(WebPlatformTouchPoint::TouchReleased);
-    WebTouchEvent touchEndEvent(WebEvent::TouchEnd, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
-    frame->eventHandler()->handleTouchEvent(platform(touchEndEvent));
+#if ENABLE(TIZEN_LINK_MAGNIFIER)
+void WebPage::getLinkMagnifierRect(const IntPoint& position, const IntSize& size)
+{
+    send(Messages::WebPageProxy::DidGetLinkMagnifierRect(position, LinkMagnifier::rect(this, position, size)));
 }
+#endif
 
+#if ENABLE(TIZEN_SCREEN_READER)
 static void sendScreenReaderFocusRect(WebPage* page, Node* node)
 {
     bool isImage = false;
@@ -1580,6 +1760,54 @@ void WebPage::moveScreenReaderFocusByPoint(const IntPoint& point)
     sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
 }
 
+void WebPage::clearScreenReaderFocus()
+{
+    if (!m_screenReader)
+        return;
+
+    m_screenReader->clearFocus();
+}
+
+void WebPage::raiseTapEvent(const IntPoint& position, const IntPoint& globalPosition, bool& result)
+{
+    result = false;
+
+#if ENABLE(GESTURE_EVENTS)
+    Frame* frame = m_page->mainFrame();
+    if (!frame->view())
+        return;
+
+    Vector<WebPlatformTouchPoint> touchPoints;
+    touchPoints.append(WebPlatformTouchPoint(0, WebPlatformTouchPoint::TouchPressed, globalPosition, position));
+
+    WebTouchEvent touchStartEvent(WebEvent::TouchStart, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
+    bool handled = frame->eventHandler()->handleTouchEvent(platform(touchStartEvent));
+
+    touchPoints.at(0).setState(WebPlatformTouchPoint::TouchReleased);
+
+    WebTouchEvent touchEndEvent(WebEvent::TouchEnd, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
+    handled |= frame->eventHandler()->handleTouchEvent(platform(touchEndEvent));
+
+    if (!handled) {
+        WebGestureEvent gestureEvent(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
+        frame->eventHandler()->handleGestureEvent(platform(gestureEvent));
+        result = true;
+    }
+#endif
+}
+
+void WebPage::adjustScreenReaderFocusedObjectValue(bool up)
+{
+    if (!m_screenReader || !m_screenReader->getFocusedNode() || !m_screenReader->getFocusedNode()->toInputElement())
+        return;
+
+    ExceptionCode ec;
+    if (up)
+        m_screenReader->getFocusedNode()->toInputElement()->stepUp(ec);
+    else
+        m_screenReader->getFocusedNode()->toInputElement()->stepDown(ec);
+}
+
 void WebPage::recalcScreenReaderFocusRect()
 {
     if (!m_screenReader || !m_screenReader->getFocusedNode())
@@ -1607,6 +1835,53 @@ void WebPage::clearScreenReader()
 }
 #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.
@@ -1615,6 +1890,7 @@ void WebPage::notifyTransitionToCommitted(bool forNewPage)
     if (m_activePopupMenu) {
         TIZEN_LOGI("");
         m_activePopupMenu->hide();
+        m_activePopupMenu = 0;
     }
 }
 #endif
@@ -1647,6 +1923,44 @@ void WebPage::setLocalStorageDirectory(const String& path)
     m_page->settings()->setLocalStorageDatabasePath(path);
 }
 #endif
+
+#if ENABLE(TIZEN_USE_SETTINGS_FONT)
+void WebPage::useSettingsFont()
+{
+    if (!WebCore::fontCache()->isFontFamliyTizen())
+        return;
+
+    FcInitReinitialize();
+    WebCore::fontCache()->invalidate();
+
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return;
+
+    frameView->forceLayout();
+}
+#endif
+
+void WebPage::didChangeContents(const IntRect& rect)
+{
+    if (!m_page)
+        return;
+
+    Frame* frame = m_page->focusController()->focusedOrMainFrame();
+    if (!frame || !frame->view() || frame->view()->needsLayout())
+        return;
+
+#if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+    if (m_editorState.isContentEditable && rect.intersects(m_editorState.editorRect) && frame->selection()->rootEditableElement()) {
+        IntRect currentEditorRect = nodeRect(frame->selection()->rootEditableElement());
+        if (m_editorState.editorRect != currentEditorRect) {
+            m_editorState.editorRect = currentEditorRect;
+            m_editorState.updateEditorRectOnly = true;
+            send(Messages::WebPageProxy::EditorStateChanged(m_editorState));
+        }
+    }
+#endif
+}
 #endif // #if OS(TIZEN)
 
 } // namespace WebKit