encoder->encode(inputMethodHints);
encoder->encode(surroundingText);
encoder->encode(cursorPosition);
+ encoder->encode(selectionRect);
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
if (!decoder->decode(result.cursorPosition))
return false;
+
+ if (!decoder->decode(result.selectionRect))
+ return false;
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
WTF::String inputMethodHints;
WTF::String surroundingText;
unsigned cursorPosition;
+ WebCore::IntRect selectionRect;
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
WebCore::IntRect editorRect;
// caret position can be outside of visible rect.
// we need to consider it.
- IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
+ IntRect selectionRect = impl->pageProxy->editorState().selectionRect;
IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
#if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
selectionRect.scale(newScaleFactor);
if (isTextSelectionMode()) {
if (!editorState.selectionIsRange) {
if (editorState.isContentEditable && !evas_object_focus_get(m_viewImpl->view())) {
- WebCore::IntRect caretRect;
- m_viewImpl->page()->getCaretPosition(caretRect);
+ const EditorState& editor = m_viewImpl->page()->editorState();
+ IntRect caretRect;
+ if (!editor.selectionIsNone && !editor.selectionIsRange)
+ caretRect = editor.selectionRect;
+
if (!caretRect.isEmpty())
return;
} else {
point = leftRect.center();
#endif
} else if (editorState.isContentEditable) {
- WebCore::IntRect caretRect;
- m_viewImpl->page()->getCaretPosition(caretRect);
+ const EditorState& editor = m_viewImpl->page()->editorState();
+ IntRect caretRect;
+ if (!editor.selectionIsNone && !editor.selectionIsRange)
+ caretRect = editor.selectionRect;
if (caretRect.isEmpty())
return;
WebCore::IntPoint startPoint, endPoint;
WebCore::IntRect leftRect, rightRect;
- WebCore::IntRect caretRect;
- m_viewImpl->page()->getCaretPosition(caretRect);
+ const EditorState& editor = m_viewImpl->page()->editorState();
+ IntRect caretRect;
+ if (!editor.selectionIsNone && !editor.selectionIsRange)
+ caretRect = editor.selectionRect;
+
if (!caretRect.isEmpty()) {
startPoint.setX(caretRect.x());
startPoint.setY(caretRect.y() + caretRect.height());
#endif
#if ENABLE(TIZEN_TEXT_CARET_HANDLING_WK2)
void setCaretPosition(const WebCore::IntPoint&);
- void getCaretPosition(WebCore::IntRect&);
#endif
bool scrollMainFrameBy(const WebCore::IntSize&);
void scrollMainFrameTo(const WebCore::IntPoint&);
#if ENABLE(TIZEN_ISF_PORT)
void prepareKeyDownEvent();
- int getCursorOffset();
- void getSurroundingTextAndCursorOffset(String&, int&);
- WebCore::IntRect getSelectionRect(bool);
void deleteSurroundingText(int, int);
void didCancelComposition();
if (!inputMethodContext->m_viewImpl->page()->focusedFrame() || !inputMethodContext->m_focused || (!text && !offset))
return false;
- String surroundingText;
- int cursorOffset;
- inputMethodContext->m_viewImpl->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
+ const EditorState& editor = inputMethodContext->m_viewImpl->page()->editorState();
if (text) {
- CString utf8Text(surroundingText.utf8());
+ CString utf8Text(editor.surroundingText.utf8());
size_t length = utf8Text.length();
*text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
}
if (offset)
- *offset = cursorOffset;
+ *offset = editor.cursorPosition;
return true;
}
inputMethodContext->requestFakeKeyEvent();
+ const EditorState& editor = inputMethodContext->m_viewImpl->page()->editorState();
PageClientImpl* pageClient = inputMethodContext->m_viewImpl->pageClient.get();
IntRect caretRect;
- page->getCaretPosition(caretRect);
- caretRect.scale(pageClient->scaleFactor());
+ if (!editor.selectionIsNone && !editor.selectionIsRange) {
+ caretRect = editor.selectionRect;
+ caretRect.scale(pageClient->scaleFactor());
+ }
int viewX, viewY;
evas_object_geometry_get(inputMethodContext->m_viewImpl->view(), &viewX, &viewY, 0, 0);
process()->send(Messages::WebPage::PrepareKeyDownEvent(), m_pageID);
}
-int WebPageProxy::getCursorOffset()
-{
- if (!isValid())
- return 0;
-
- int offset = 0;
- process()->sendSync(Messages::WebPage::GetCursorOffset(), Messages::WebPage::GetCursorOffset::Reply(offset), m_pageID);
- return offset;
-}
-
-void WebPageProxy::getSurroundingTextAndCursorOffset(String& text, int& offset)
-{
- if (!isValid())
- return;
-
- process()->sendSync(Messages::WebPage::GetSurroundingTextAndCursorOffset(), Messages::WebPage::GetSurroundingTextAndCursorOffset::Reply(text, offset), m_pageID);
-}
-
-IntRect WebPageProxy::getSelectionRect(bool isOnlyEditable)
-{
- IntRect rect;
- process()->sendSync(Messages::WebPage::GetSelectionRect(isOnlyEditable), Messages::WebPage::GetSelectionRect::Reply(rect), m_pageID);
- return rect;
-}
-
void WebPageProxy::deleteSurroundingText(int offset, int count)
{
if (!isValid())
process()->send(Messages::WebPage::SetCaretPosition(pos), m_pageID);
}
-
-void WebPageProxy::getCaretPosition(WebCore::IntRect& rect)
-{
- if (!isValid())
- return;
-
- process()->sendSync(Messages::WebPage::GetCaretPosition(), Messages::WebPage::GetCaretPosition::Reply(rect), m_pageID);
-}
#endif
#if ENABLE(TIZEN_PLUGIN_CUSTOM_REQUEST)
}
#endif
-#if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+#if ENABLE(TIZEN_ISF_PORT)
Element* rootEditableElement = frame->selection()->rootEditableElement();
if (!rootEditableElement)
return result;
- result.editorRect = nodeRect(rootEditableElement);
-#endif
+ updateEditorStateRect(frame, result);
-#if ENABLE(TIZEN_ISF_PORT)
if (!result.shouldIgnoreCompositionSelectionChange && result.isContentEditable) {
result.inputMethodContextID = reinterpret_cast<uintptr_t>(rootEditableElement);
result.inputMethodHints = "search";
else
result.inputMethodHints = type;
-
- result.surroundingText = formControl->value();
}
Position base = frame->selection()->base();
Node* baseNode = base.containerNode();
- if (baseNode)
- result.cursorPosition = baseNode->isTextNode() ? base.offsetInContainerNode() : 0;
+ if (baseNode && baseNode->isTextNode()) {
+ result.surroundingText = baseNode->nodeValue();
+ result.cursorPosition = base.offsetInContainerNode();
+ }
}
#endif
#if PLATFORM(EFL)
#if ENABLE(TIZEN_TEXT_CARET_HANDLING_WK2)
bool setCaretPosition(const WebCore::IntPoint&);
- void getCaretPosition(WebCore::IntRect&);
#endif
#if ENABLE(TIZEN_ISF_PORT)
void didCancelComposition(WebCore::Node*);
void prepareKeyDownEvent();
void swapKeyPressCommands(Vector<OwnPtr<KeyPressCommand> >&);
- void getCursorOffset(int&);
- void getSurroundingTextAndCursorOffset(String&, int&);
- void getSelectionRect(bool, WebCore::IntRect&);
void deleteSurroundingText(int, int);
#endif
void scrollMainFrameBy(const WebCore::IntSize&);
#if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
void dumpMemorySnapshot();
#endif
+
+#if ENABLE(TIZEN_ISF_PORT)
+ void updateEditorStateRect(const WebCore::Frame*, EditorState&) const;
+#endif
+
OwnPtr<WebCore::Page> m_page;
RefPtr<WebFrame> m_mainFrame;
RefPtr<InjectedBundleBackForwardList> m_backForwardList;
#if PLATFORM(EFL) && OS(TIZEN)
#if ENABLE(TIZEN_TEXT_CARET_HANDLING_WK2)
SetCaretPosition(WebCore::IntPoint pos)
- GetCaretPosition() -> (WebCore::IntRect rect)
#endif
#if ENABLE(TIZEN_ISF_PORT)
PrepareKeyDownEvent()
- GetCursorOffset() -> (int offset)
- GetSurroundingTextAndCursorOffset() -> (String text, int offset)
- GetSelectionRect(bool isOnlyEditable) -> (WebCore::IntRect rect)
DeleteSurroundingText(int offset, int count)
#endif
#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)
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)
+ state.editorRect = nodeRect(frame->selection()->rootEditableElement());
+#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_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));
}