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)
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) {
newUnderlines.last().endOffset = availableLength;
}
}
+
+ m_page->editorClient()->lockRespondToChangedSelection();
targetFrame->editor()->setComposition(newCompositionString, newUnderlines, cursorPosition, 0);
+ m_page->editorClient()->unlockRespondToChangedSelection();
+
return;
}
}
}
+
+ m_page->editorClient()->lockRespondToChangedSelection();
#endif
targetFrame->editor()->setComposition(compositionString, underlines, cursorPosition, 0);
#if ENABLE(TIZEN_ISF_PORT)
- m_page->editorClient()->respondToChangedSelection(targetFrame);
+ m_page->editorClient()->unlockRespondToChangedSelection();
#endif
}
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
return true;
}
-
-void WebPage::getCaretPosition(IntRect& rect)
-{
- Frame* frame = m_page->focusController()->focusedOrMainFrame();
- if (!frame)
- return;
-
- FrameSelection* controller = frame->selection();
- if (!controller)
- return;
-
- Node* node = controller->start().deprecatedNode();
- if (!node || !node->renderer() || !node->isContentEditable())
- return;
-
- if (controller->isCaret()) {
- FrameView* frameView = frame->view();
- if (!frameView)
- return;
-
- rect = frameView->contentsToWindow(controller->absoluteCaretBounds());
- }
-}
#endif
#if ENABLE(TIZEN_ISF_PORT)
send(Messages::WebPageProxy::DidCancelComposition());
}
-void WebPage::getCursorOffset(int& offset)
-{
- offset = 0;
- Frame* frame = m_page->focusController()->focusedOrMainFrame();
- if (!frame || !frame->editor()->canEdit())
- return;
-
- Position base = frame->selection()->base();
- Node* baseNode = base.containerNode();
- if (baseNode)
- offset = baseNode->isTextNode() ? base.offsetInContainerNode() : 0;
-}
-
-void WebPage::getSurroundingTextAndCursorOffset(String& text, int& offset)
+void WebPage::prepareKeyDownEvent()
{
- text = String();
- offset = 0;
-
- Frame* frame = m_page->focusController()->focusedOrMainFrame();
- if (!frame || !frame->editor()->canEdit())
- return;
-
- Position base = frame->selection()->base();
- Node* baseNode = base.containerNode();
- if (baseNode && baseNode->isTextNode()) {
- text = baseNode->textContent();
- offset = base.offsetInContainerNode();
- }
+ m_prepareKeyDownEvent = true;
}
-void WebPage::getSelectionRect(bool isOnlyEditable, IntRect& rect)
+void WebPage::swapKeyPressCommands(Vector<OwnPtr<KeyPressCommand> >& commands)
{
- rect = IntRect();
-
- Frame* frame = m_page->focusController()->focusedFrame();
- if (!frame || !frame->view())
- return;
-
- FrameSelection* selection = frame->selection();
- Node* node = selection->start().deprecatedNode();
- if (!node || !node->renderer() || (isOnlyEditable && !node->isContentEditable()))
- return;
-
- if (selection->isCaret())
- rect = frame->view()->contentsToWindow(selection->absoluteCaretBounds());
- else if (selection->isRange())
- rect = frame->view()->contentsToWindow(enclosingIntRect(selection->bounds(false)));
+ m_keyPressCommands.swap(commands);
}
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);
frame->selection()->setSelection(selection);
frame->editor()->deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
}
+
+void WebPage::updateEditorStateRect(const Frame* frame, EditorState& state) const
+{
+ ASSERT(frame->selection()->rootEditableElement());
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ Vector<IntRect> rects;
+ calcFocusedRects(frame->selection()->rootEditableElement(), rects);
+ state.editorRect = unionRect(rects);
+#endif
+
+ if (frame->selection()->isCaret())
+ state.selectionRect = frame->view()->contentsToWindow(frame->selection()->absoluteCaretBounds());
+ else if (frame->selection()->isRange())
+ state.selectionRect = frame->view()->contentsToWindow(enclosingIntRect(frame->selection()->bounds(false)));
+}
#endif
#if ENABLE(TIZEN_INPUT_TAG_EXTENSION) || ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
#if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
-static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
+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;
+}
+
+#if ENABLE(TOUCH_ADJUSTMENT)
+void WebPage::getFocusedRect(HitTestResult hitTestResult, Page* page, bool setFocus, Vector<IntRect>& rects, const IntPoint& point, const IntSize& area)
+#else
+void WebPage::getFocusedRect(HitTestResult hitTestResult, Page* page, bool setFocus, Vector<IntRect>& rects)
+#endif
{
Node* node = hitTestResult.innerNode();
+#if ENABLE(TOUCH_ADJUSTMENT)
+ IntPoint adustedPoint;
+ Frame* mainFrame = page->mainFrame();
+ Node* adjustedNode = 0;
+ mainFrame->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adustedPoint, adjustedNode);
+ 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();
+ return;
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();
}
- if (!isFocusRingDrawable) {
- if (node->hasTagName(HTMLNames::imgTag))
- return getNodeRect(node, node, !hitTestResult.absoluteImageURL().isEmpty());
+ // 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;
+ }
+ child = child->traverseNextNode(focusableNode);
+ }
+ }
- return IntRect();
+ if (!isFocusRingDrawable) {
+ if (!node->hasTagName(HTMLNames::imgTag))
+ return;
+ focusableNode = node;
}
- return getNodeRect(node, focusableNode, !hitTestResult.absoluteImageURL().isEmpty());
+ if (setFocus)
+ setFocusedNode(focusableNode);
+
+ calcFocusedRects(focusableNode, rects);
}
#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)
- hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get());
+ bool setFocus = hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeSetFocus;
+#if ENABLE(TOUCH_ADJUSTMENT)
+ getFocusedRect(hitTestResult, m_page.get(), setFocus, hitTestResultData.focusedRects, point, area);
+#else
+ getFocusedRect(hitTestResult, m_page.get(), setFocus, hitTestResultData.focusedRects);
+#endif
+
+ // Don't display FocusRect if the size is too big..
+ IntRect framerect = frameView->visibleContentRect(true);
+ for (size_t i = 0; i < hitTestResultData.focusedRects.size(); ++i) {
+ if (hitTestResultData.focusedRects[i].width() > (0.8 * framerect.width())
+ && hitTestResultData.focusedRects[i].height() > (0.8 * framerect.height()))
+ hitTestResultData.focusedRects.clear();
+ }
+
if (hitTestResult.innerNode() && hitTestResult.innerNode()->renderer() && hitTestResult.innerNode()->renderer()->style()) {
hitTestResultData.focusedColor = hitTestResult.innerNode()->renderer()->style()->tapHighlightColor();
if (!hitTestResultData.focusedColor.hasAlpha())
}
#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)
{
#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;
focusedFrame = newFocusFrame;
}
-#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
HTMLInputElement* inputElement = node->toInputElement();
-#endif
if (hitTestResult.isContentEditable()) {
-#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- if (!inputElement || (inputElement
- && !inputElement->isDateField() && !inputElement->isDateTimeField() && !inputElement->isDateTimeLocalField()
- && !inputElement->isMonthField() && !inputElement->isTimeField() && !inputElement->isWeekField())) {
- result = setCaretPosition(point);
- return;
- }
-#else
result = setCaretPosition(point);
return;
-#endif
}
#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
}
#endif
- 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;
- }
+ 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;
}
}
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;
}
}
if (size == 1) {
Element* rootEditableElement = focusedFrame->selection()->rootEditableElement();
if (rootEditableElement) {
- IntRect editorRect = nodeRect(rootEditableElement);
+ Vector<IntRect> rects;
+ calcFocusedRects(rootEditableElement, rects);
+ IntRect editorRect = unionRect(rects);
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
if (m_editorState.editorRect != editorRect) {
#endif
#if ENABLE(TIZEN_SCREEN_READER)
-void WebPage::raiseTapEvent(const IntPoint& position, const IntPoint& globalPosition)
+void WebPage::moveScreenReaderFocus(bool forward, bool& result)
{
- 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());
- if (!frame->eventHandler()->handleTouchEvent(platform(touchStartEvent))) {
- WebGestureEvent gestureEvent(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
- frame->eventHandler()->handleGestureEvent(platform(gestureEvent));
- }
+ if (!m_screenReader)
+ m_screenReader = ScreenReader::create(this);
- touchPoints.at(0).setState(WebPlatformTouchPoint::TouchReleased);
- WebTouchEvent touchEndEvent(WebEvent::TouchEnd, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
- frame->eventHandler()->handleTouchEvent(platform(touchEndEvent));
+ result = m_screenReader->moveFocus(forward);
}
-static void sendScreenReaderFocusRect(WebPage* page, Node* node)
+void WebPage::moveScreenReaderFocusByPoint(const IntPoint& point)
{
- bool isImage = false;
- if (node->isElementNode()) {
- Element* element = static_cast<Element*>(node);
- isImage = !element->getAttribute(element->imageSourceAttributeName()).isEmpty();
- }
+ if (!m_screenReader)
+ m_screenReader = ScreenReader::create(this);
- page->send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(getNodeRect(node, node, isImage)));
+ if (!m_screenReader->moveFocus(point))
+ return;
}
-void WebPage::moveScreenReaderFocus(bool forward, bool& result)
+void WebPage::clearScreenReaderFocus()
{
if (!m_screenReader)
- m_screenReader = ScreenReader::create(this);
-
- if (!m_screenReader->moveFocus(forward)) {
- result = false;
- send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(IntRect()));
return;
- } else {
- result = true;
- sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
- }
+
+ m_screenReader->clearFocus();
}
-void WebPage::moveScreenReaderFocusByPoint(const IntPoint& point)
+void WebPage::raiseTapEvent(const IntPoint& position, const IntPoint& globalPosition, bool& result)
{
- if (!m_screenReader)
- m_screenReader = ScreenReader::create(this);
+ result = false;
- if (!m_screenReader->moveFocus(point))
+#if ENABLE(GESTURE_EVENTS)
+ Frame* frame = m_page->mainFrame();
+ if (!frame->view())
return;
- sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
+ 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::recalcScreenReaderFocusRect()
+void WebPage::adjustScreenReaderFocusedObjectValue(bool up)
{
- if (!m_screenReader || !m_screenReader->getFocusedNode())
+ if (!m_screenReader || !m_focusedNode || !m_focusedNode->toInputElement())
return;
- sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
+ ExceptionCode ec;
+ if (up)
+ m_focusedNode->toInputElement()->stepUp(ec);
+ else
+ m_focusedNode->toInputElement()->stepDown(ec);
}
void WebPage::updateScreenReaderFocus(RenderObject* object)
m_screenReader->clearFocus();
else if (!m_screenReader->rendererWillBeDestroyed(object))
return;
-
- send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(IntRect()));
}
void WebPage::clearScreenReader()
}
#endif
-#if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
static LayoutRect rectToAbsoluteCoordinates(Frame* initialFrame, const LayoutRect& initialRect)
{
LayoutRect rect = initialRect;
return rect;
}
-IntRect WebPage::nodeRect(Node* node) const
+void WebPage::calcFocusedRects(Node* node, Vector<IntRect>& rects) const
{
- if (!node)
- return IntRect();
+ if (!node || !node->renderer())
+ return;
+
+ RenderObject* renderer = node->renderer();
+ FrameView* view = node->document()->frame()->view();
+
+ IntPoint absolutePoint;
+ absolutePoint = view->convertToContainingWindow(view->convertFromRenderer(renderer, absolutePoint));
+ renderer->addFocusRingRects(rects, absolutePoint);
+
+ if (!rects.isEmpty())
+ return;
LayoutRect rect;
if (node->hasTagName(HTMLNames::areaTag)) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
HTMLImageElement* image = area->imageElement();
if (!image || !image->renderer())
- return IntRect();
+ return;
rect = rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer()));
} else if (node->renderer()) {
}
}
- return pixelSnappedIntRect(rect);
+ rects.append(pixelSnappedIntRect(rect));
+}
+#endif
+
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+void WebPage::setFocusedNode(Node* node)
+{
+ m_focusedNode = node;
+ didChangeFocusedRects();
+}
+
+void WebPage::didChangeFocusedRects()
+{
+ Vector<IntRect> rects;
+ calcFocusedRects(m_focusedNode.get(), rects);
+ if (m_focusedRects == rects)
+ return;
+
+ m_focusedRects = rects;
+ send(Messages::WebPageProxy::DidChangeFocusedRects(m_focusedRects));
+}
+
+void WebPage::recalcFocusedRects()
+{
+ if (!m_focusedNode)
+ return;
+
+ didChangeFocusedRects();
}
#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;
+ IntRect previousEditorRect = m_editorState.editorRect;
+ updateEditorStateRect(frame, m_editorState);
+
+ if (m_editorState.editorRect != previousEditorRect) {
m_editorState.updateEditorRectOnly = true;
send(Messages::WebPageProxy::EditorStateChanged(m_editorState));
}
}
#endif
+
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+ didChangeFocusedRects();
+#endif
}
+
+#if ENABLE(TIZEN_FOCUS_UI)
+void WebPage::setSpatialNavigationEnabled(bool enabled)
+{
+ m_page->settings()->setSpatialNavigationEnabled(enabled);
+
+ if (m_focusedNode && m_focusedNode->renderer())
+ m_focusedNode->renderer()->repaint();
+
+ if (!enabled)
+ setFocusedNode(0);
+}
+#endif
#endif // #if OS(TIZEN)
} // namespace WebKit