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 (!targetFrame)
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 ENABLE(TIZEN_ISF_PORT)
if (targetFrame->selection()->rootEditableElement()) {
HTMLTextFormControlElement* textFormControl = toTextFormControl(targetFrame->selection()->rootEditableElement()->shadowAncestorNode());
if (textFormControl && textFormControl->maxLength() >= 0) {
#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();
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());
}
#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();
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())
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();
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;
}
OwnPtr<VisiblePosition> position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos)));
+ Position base = frameSelection->base();
Position extent = frameSelection->extent();
Node* newSelectionStartNode = 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 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
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();
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
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;
}
}
void WebPage::didChangeContents(const IntRect& rect)
{
+ if (!m_page)
+ return;
+
Frame* frame = m_page->focusController()->focusedOrMainFrame();
if (!frame || !frame->view() || frame->view()->needsLayout())
return;