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
}
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)
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;
- 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)
-{
- 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();
- }
-}
-
-void WebPage::getSelectionRect(bool isOnlyEditable, IntRect& rect)
-{
- 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)));
-}
-
void WebPage::deleteSurroundingText(int offset, int count)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
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(TOUCH_ADJUSTMENT)
-static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page, const IntPoint& point, const IntSize& area)
+void WebPage::getFocusedRect(HitTestResult hitTestResult, Page* page, bool setFocus, Vector<IntRect>& rects, const IntPoint& point, const IntSize& area)
#else
-static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
+void WebPage::getFocusedRect(HitTestResult hitTestResult, Page* page, bool setFocus, Vector<IntRect>& rects)
#endif
{
Node* node = hitTestResult.innerNode();
#if ENABLE(TOUCH_ADJUSTMENT)
- Node* adjustedNode = 0;
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);
node = adjustedNode;
#endif
if (!node)
- return IntRect();
+ return;
bool isFocusRingDrawable = false;
Node* focusableNode = node;
|| child->hasEventListeners(eventNames().clickEvent)
|| child->hasEventListeners(eventNames().mousedownEvent)
|| child->hasEventListeners(eventNames().mouseupEvent)) {
- return IntRect();
+ return;
}
child = child->traverseNextNode(focusableNode);
}
}
if (!isFocusRingDrawable) {
- if (node->hasTagName(HTMLNames::imgTag))
- return getNodeRect(node, node, !hitTestResult.absoluteImageURL().isEmpty());
-
- return IntRect();
+ if (!node->hasTagName(HTMLNames::imgTag))
+ return;
+ focusableNode = node;
}
- return getNodeRect(node, focusableNode, !hitTestResult.absoluteImageURL().isEmpty());
+ if (setFocus)
+ setFocusedNode(focusableNode);
+
+ calcFocusedRects(focusableNode, rects);
}
#endif
hitTestResultData.hitTestMode = hitTestMode;
#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+ bool setFocus = hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeSetFocus;
#if ENABLE(TOUCH_ADJUSTMENT)
- hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get(), point, area);
+ getFocusedRect(hitTestResult, m_page.get(), setFocus, hitTestResultData.focusedRects, point, area);
#else
- hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get());
+ getFocusedRect(hitTestResult, m_page.get(), setFocus, hitTestResultData.focusedRects);
#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();
+ 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()) {
HTMLInputElement* inputElement = node->toInputElement();
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)
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)
-static void sendScreenReaderFocusRect(WebPage* page, ScreenReader* screenReader)
-{
- Node* node = screenReader->getFocusedNode();
- IntRect rect;
-
- if (node) {
- bool isImage = false;
- if (node->isElementNode()) {
- Element* element = static_cast<Element*>(node);
- isImage = !element->getAttribute(element->imageSourceAttributeName()).isEmpty();
- }
- rect = getNodeRect(node, node, isImage);
- }
-
- screenReader->setFocusedRect(rect);
- page->send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(rect));
-}
-
void WebPage::moveScreenReaderFocus(bool forward, bool& result)
{
if (!m_screenReader)
m_screenReader = ScreenReader::create(this);
result = m_screenReader->moveFocus(forward);
- sendScreenReaderFocusRect(this, m_screenReader.get());
}
void WebPage::moveScreenReaderFocusByPoint(const IntPoint& point)
if (!m_screenReader->moveFocus(point))
return;
-
- sendScreenReaderFocusRect(this, m_screenReader.get());
}
void WebPage::clearScreenReaderFocus()
void WebPage::adjustScreenReaderFocusedObjectValue(bool up)
{
- if (!m_screenReader || !m_screenReader->getFocusedNode() || !m_screenReader->getFocusedNode()->toInputElement())
+ if (!m_screenReader || !m_focusedNode || !m_focusedNode->toInputElement())
return;
ExceptionCode ec;
if (up)
- m_screenReader->getFocusedNode()->toInputElement()->stepUp(ec);
+ m_focusedNode->toInputElement()->stepUp(ec);
else
- m_screenReader->getFocusedNode()->toInputElement()->stepDown(ec);
-}
-
-void WebPage::recalcScreenReaderFocusRect()
-{
- if (!m_screenReader || !m_screenReader->getFocusedNode())
- return;
-
- sendScreenReaderFocusRect(this, m_screenReader.get());
+ m_focusedNode->toInputElement()->stepDown(ec);
}
void WebPage::updateScreenReaderFocus(RenderObject* object)
m_screenReader->clearFocus();
else if (!m_screenReader->rendererWillBeDestroyed(object))
return;
-
- sendScreenReaderFocusRect(this, m_screenReader.get());
}
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
#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_SCREEN_READER)
- if (m_screenReader && rect.intersects(m_screenReader->focusedRect()))
- recalcScreenReaderFocusRect();
+#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