[Title] Improved the routine for getting text style state.
[Issue#] N_SE-41795, WEB-3055
[Problem] Overhead occurs when key event is handled.
[Cause] Request sync message fer getting text style state too often.
[Solution] Removed syne message for getting text style state and
Moved the routine for getting text style state to EditorStateChanged message.
Change-Id: Ie1c132e64f0511d04bfe8c52e95c304afa214253
encoder->encode(editorRect);
encoder->encode(updateEditorRectOnly);
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ encoder->encode(underlineState);
+ encoder->encode(italicState);
+ encoder->encode(boldState);
encoder->encode(bgColor);
encoder->encode(color);
+ encoder->encode(fontSize);
#endif
#endif
return false;
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ if (!decoder->decode(result.underlineState))
+ return false;
+
+ if (!decoder->decode(result.italicState))
+ return false;
+
+ if (!decoder->decode(result.boldState))
+ return false;
+
if (!decoder->decode(result.bgColor))
return false;
if (!decoder->decode(result.color))
return false;
+
+ if (!decoder->decode(result.fontSize))
+ return false;
#endif
#endif
#endif
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
, updateEditorRectOnly(false)
+ , underlineState(0)
+ , italicState(0)
+ , boldState(0)
#endif
#if PLATFORM(QT)
, cursorPosition(0)
WebCore::IntRect editorRect;
bool updateEditorRectOnly;
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ int underlineState;
+ int italicState;
+ int boldState;
WTF::String bgColor;
WTF::String color;
+ WTF::String fontSize;
#endif
#endif
#if PLATFORM(QT)
}
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
-{
- WebCore::IntPoint startPoint, endPoint;
- WebCore::IntRect leftRect, rightRect;
-
- WebCore::IntRect caretRect;
- m_viewImpl->page()->getCaretPosition(caretRect);
- if (!caretRect.isEmpty()) {
- startPoint.setX(caretRect.x());
- startPoint.setY(caretRect.y() + caretRect.height());
-
- endPoint.setX(caretRect.x() + caretRect.width());
- endPoint.setY(caretRect.y() + caretRect.height());
- }
-#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
- startPoint.setX(leftRect.x());
- startPoint.setY(leftRect.y() + leftRect.height());
-
- endPoint.setX(rightRect.x() + rightRect.width());
- endPoint.setY(rightRect.y() + rightRect.height());
- }
-#endif
-
- startPoint.scale(scaleFactor(), scaleFactor());
- endPoint.scale(scaleFactor(), scaleFactor());
-
- int viewPositionX, viewPositionY;
- evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
-
- startPoint.move(-scrollPosition().x(), -scrollPosition().y());
- startPoint.move(viewPositionX, viewPositionY);
-
- endPoint.move(-scrollPosition().x(), -scrollPosition().y());
- endPoint.move(viewPositionX, viewPositionY);
-
- ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
-}
-#endif
-
void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
{
ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
void setBackgroundColor(double red, double green, double blue, double alpha);
TIZEN_VIRTUAL bool makeContextCurrent() { return true; }
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
-#endif
virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
int b;
int a;
} color;
+
+ const char* fontSize;
+ Eina_Bool hasComposition;
};
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-Ewk_Text_Style* ewkTextStyleCreate(int underlineState, int italicState, int boldState, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint, const String& bgColor, const String& color)
+Ewk_Text_Style* ewkTextStyleCreate(const EditorState editorState, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint)
{
Ewk_Text_Style* textStyle = new Ewk_Text_Style;
- textStyle->underlineState = static_cast<Ewk_Text_Style_State>(underlineState);
- textStyle->italicState = static_cast<Ewk_Text_Style_State>(italicState);
- textStyle->boldState = static_cast<Ewk_Text_Style_State>(boldState);
+ textStyle->underlineState = static_cast<Ewk_Text_Style_State>(editorState.underlineState);
+ textStyle->italicState = static_cast<Ewk_Text_Style_State>(editorState.italicState);
+ textStyle->boldState = static_cast<Ewk_Text_Style_State>(editorState.boldState);
textStyle->position.startPoint.x = startPoint.x();
textStyle->position.startPoint.y = startPoint.y();
// for example - rgba(255, 255, 255, 255)
// for example - rgb(255, 255, 255)
- if (equalIgnoringCase(bgColor.left(3), "rgb")) {
- size_t startPos = bgColor.find("(");
- size_t endPos = bgColor.find(")");
+ if (equalIgnoringCase(editorState.bgColor.left(3), "rgb")) {
+ size_t startPos = editorState.bgColor.find("(");
+ size_t endPos = editorState.bgColor.find(")");
- String value = bgColor.substring(startPos + 1, endPos - startPos - 1);
+ String value = editorState.bgColor.substring(startPos + 1, endPos - startPos - 1);
Vector<String> colorValues;
value.split(",", colorValues);
textStyle->bgColor.r = colorValues[0].toInt();
textStyle->bgColor.g = colorValues[1].toInt();
textStyle->bgColor.b = colorValues[2].toInt();
- if (equalIgnoringCase(bgColor.left(4), "rgba"))
+ if (equalIgnoringCase(editorState.bgColor.left(4), "rgba"))
textStyle->bgColor.a = colorValues[3].toInt();
else
textStyle->bgColor.a = 255;
}
- if (equalIgnoringCase(color.left(3), "rgb")) {
- size_t startPos = color.find("(");
- size_t endPos = color.find(")");
+ if (equalIgnoringCase(editorState.color.left(3), "rgb")) {
+ size_t startPos = editorState.color.find("(");
+ size_t endPos = editorState.color.find(")");
- String value = color.substring(startPos + 1, endPos - startPos - 1);
+ String value = editorState.color.substring(startPos + 1, endPos - startPos - 1);
Vector<String> colorValues;
value.split(",", colorValues);
textStyle->color.r = colorValues[0].toInt();
textStyle->color.g = colorValues[1].toInt();
textStyle->color.b = colorValues[2].toInt();
- if (equalIgnoringCase(color.left(4), "rgba"))
+ if (equalIgnoringCase(editorState.color.left(4), "rgba"))
textStyle->color.a = colorValues[3].toInt();
else
textStyle->color.a = 255;
}
+ textStyle->fontSize = eina_stringshare_add(editorState.fontSize.utf8().data());
+ textStyle->hasComposition = editorState.hasComposition;
+
return textStyle;
}
{
EINA_SAFETY_ON_NULL_RETURN(textStyle);
+ if (textStyle->fontSize)
+ eina_stringshare_del(textStyle->fontSize);
+
delete textStyle;
}
#endif
return false;
#endif
}
+
+const char* ewk_text_style_font_size_get(Ewk_Text_Style* textStyle)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(textStyle, 0);
+ return textStyle->fontSize;
+}
+
+Eina_Bool ewk_text_style_has_composition_get(Ewk_Text_Style* textStyle)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(textStyle, false);
+ return textStyle->hasComposition;
+}
EAPI Eina_Bool ewk_text_style_position_get(Ewk_Text_Style* text_style, Evas_Point* start_point, Evas_Point* end_point);
EAPI Eina_Bool ewk_text_style_bg_color_get(Ewk_Text_Style* textStyle, int* r, int* g, int* b, int* a);
EAPI Eina_Bool ewk_text_style_color_get(Ewk_Text_Style* textStyle, int* r, int* g, int* b, int* a);
+EAPI const char* ewk_text_style_font_size_get(Ewk_Text_Style* textStyle);
+EAPI Eina_Bool ewk_text_style_has_composition_get(Ewk_Text_Style* textStyle);
#ifdef __cplusplus
}
}
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
+void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
{
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
EditorState editorState = impl->page()->editorState();
-
- Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint, editorState.bgColor, editorState.color);
+ Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
ewkTextStyleDelete(textStyle);
}
#endif
#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint);
-Ewk_Text_Style* ewkTextStyleCreate(int underlineState, int italicState, int boldState, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint, const String& bgColor, const String& color);
+void ewkViewTextStyleState(Evas_Object* ewkView, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint);
+Ewk_Text_Style* ewkTextStyleCreate(const WebKit::EditorState editorState, const WebCore::IntPoint& startPoint, const WebCore::IntPoint& endPoint);
void ewkTextStyleDelete(Ewk_Text_Style* textStyle);
#endif
if (editorState.updateEditorRectOnly)
return;
+#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ if (!editorState.shouldIgnoreCompositionSelectionChange)
+ informTextStyleState();
+#endif
+
if (isTextSelectionMode()) {
if (!editorState.selectionIsRange) {
if (editorState.isContentEditable && !evas_object_focus_get(m_viewImpl->view())) {
setIsTextSelectionMode(false);
}
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- m_viewImpl->page()->getTextStyleStateForSelection();
-#endif
} else {
if (!isTextSelectionDowned() && !isTextSelectionHandleDowned()) {
updateHandlers();
showContextMenu();
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- m_viewImpl->page()->getTextStyleStateForSelection();
-#endif
- }
- }
- }
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- else {
- if (editorState.isContentEditable && !editorState.selectionIsRange) {
- WebCore::IntRect caretRect;
- m_viewImpl->page()->getCaretPosition(caretRect);
- if (!caretRect.isEmpty()) {
- m_viewImpl->page()->getTextStyleStateForSelection();
}
}
}
-#endif
}
void TextSelection::setIsTextSelectionMode(bool isTextSelectionMode)
{
hideMagnifier();
showContextMenu();
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- m_viewImpl->page()->getTextStyleStateForSelection();
-#endif
}
bool TextSelection::isMagnifierVisible()
showContextMenu();
} else if (!isStartedTextSelectionFromOutside)
setIsTextSelectionMode(false);
-
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- m_viewImpl->page()->getTextStyleStateForSelection();
-#endif
}
#if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
position.setY(position.y() - handleRect.height());
}
}
+
+#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+void TextSelection::informTextStyleState()
+{
+ WebCore::IntPoint startPoint, endPoint;
+ WebCore::IntRect leftRect, rightRect;
+
+ WebCore::IntRect caretRect;
+ m_viewImpl->page()->getCaretPosition(caretRect);
+ if (!caretRect.isEmpty()) {
+ startPoint.setX(caretRect.x());
+ startPoint.setY(caretRect.y() + caretRect.height());
+
+ endPoint.setX(caretRect.x() + caretRect.width());
+ endPoint.setY(caretRect.y() + caretRect.height());
+ }
+ else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
+ startPoint.setX(leftRect.x());
+ startPoint.setY(leftRect.y() + leftRect.height());
+
+ endPoint.setX(rightRect.x() + rightRect.width());
+ endPoint.setY(rightRect.y() + rightRect.height());
+ }
+
+ AffineTransform toEvasTransform = m_viewImpl->transformToScene();
+ WebCore::IntPoint startEvasPoint = toEvasTransform.mapPoint(startPoint);
+ WebCore::IntPoint endEvasPoint = toEvasTransform.mapPoint(endPoint);
+
+ ewkViewTextStyleState(m_viewImpl->view(), startEvasPoint, endEvasPoint);
+}
+#endif
} // namespace WebKit
#endif // TIZEN_WEBKIT2_TEXT_SELECTION
static Eina_Bool showTimerCallback(void* data);
void showHandlesAndContextMenu();
+#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ void informTextStyleState();
+#endif
+
private:
EwkViewImpl* m_viewImpl;
TextSelectionHandle* m_leftHandle;
void didRenderFrame();
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- void getTextStyleStateForSelection();
- void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
-#endif
-
#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
void widgetMapped(uint64_t nativeWindowId);
#endif
SetBackgroundColor(double red, double green, double blue, double alpha)
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- DidGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
-#endif
-
#if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
LockOrientation(int32_t orientation) -> (bool result)
UnlockOrientation()
}
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
-void WebPageProxy::getTextStyleStateForSelection()
-{
- process()->send(Messages::WebPage::GetTextStyleStateForSelection(), m_pageID, 0);
-}
-
-void WebPageProxy::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
-{
- static_cast<PageClientImpl*>(m_pageClient)->didGetTextStyleStateForSelection(underlineState, italicState, boldState);
-}
-#endif
-
#if ENABLE(TIZEN_ICON_DATABASE)
void WebPageProxy::didReceiveIcon()
{
result.hasComposition = frame->editor()->hasComposition();
result.shouldIgnoreCompositionSelectionChange = frame->editor()->ignoreCompositionSelectionChange();
-#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) || ENABLE(TIZEN_ISF_PORT)
+#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
+ if (!result.shouldIgnoreCompositionSelectionChange) {
+ result.underlineState = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline");
+ result.italicState = frame->editor()->selectionHasStyle(CSSPropertyFontStyle, "italic");
+ result.boldState = frame->editor()->selectionHasStyle(CSSPropertyFontWeight, "bold");
+ result.bgColor = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyBackgroundColor);
+ result.color = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyColor);
+ result.fontSize = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyFontSize);
+ }
+#endif
+
+#if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
Element* rootEditableElement = frame->selection()->rootEditableElement();
if (!rootEditableElement)
return result;
result.editorRect = nodeRect(rootEditableElement);
-
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- result.bgColor = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyBackgroundColor);
- result.color = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyColor);
-#endif
#endif
#if ENABLE(TIZEN_ISF_PORT)
WebCore::HTTPHeaderMap customHeaders();
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- void getTextStyleStateForSelection();
-#endif
-
#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
#endif
CreatePagesToPDF(WebCore::IntSize surfaceSize, WebCore::IntSize contentsSize, WTF::String fileName)
#endif
-#if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- GetTextStyleStateForSelection()
-#endif
-
#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
WidgetMapped(int64_t id)
#endif
}
#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)
{