Title: [155014] trunk
Revision
155014
Author
enr...@apple.com
Date
2013-09-03 18:13:08 -0700 (Tue, 03 Sep 2013)

Log Message

Can't select Katakana word by double-clicking.
<rdar://problem/14654926>

Reviewed by Alexey Proskuryakov and Ryosuke Niwa.

Source/WebCore: 

For some languages, like Japanese we need
to use more context for word breaking.

New test: editing/selection/doubleclick-japanese-text.html

* platform/text/TextBoundaries.h:
(WebCore::requiresContextForWordBoundary):

Source/WTF: 

For some languages, like Japanese we need
to use more context for word breaking.
I've renamed the function to better reflect its use
and remove the unused hasLineBreakingPropertyComplexContextOrIdeographic.

* wtf/unicode/icu/UnicodeIcu.h:
(WTF::Unicode::requiresComplexContextForWordBreaking):

LayoutTests: 

Added new test for this scenario.

* editing/selection/doubleclick-japanese-text-expected.txt: Added.
* editing/selection/doubleclick-japanese-text.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (155013 => 155014)


--- trunk/LayoutTests/ChangeLog	2013-09-04 00:26:57 UTC (rev 155013)
+++ trunk/LayoutTests/ChangeLog	2013-09-04 01:13:08 UTC (rev 155014)
@@ -1,3 +1,15 @@
+2013-09-03  Enrica Casucci  <enr...@apple.com>
+
+        Can't select Katakana word by double-clicking.
+        <rdar://problem/14654926>
+
+        Reviewed by Alexey Proskuryakov and Ryosuke Niwa.
+
+        Added new test for this scenario.
+
+        * editing/selection/doubleclick-japanese-text-expected.txt: Added.
+        * editing/selection/doubleclick-japanese-text.html: Added.
+
 2013-09-03  Benjamin Poulain  <benja...@webkit.org>
 
         Try unskipping compositing/images/positioned-image-content-rect.html

Added: trunk/LayoutTests/editing/selection/doubleclick-japanese-text-expected.txt (0 => 155014)


--- trunk/LayoutTests/editing/selection/doubleclick-japanese-text-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/doubleclick-japanese-text-expected.txt	2013-09-04 01:13:08 UTC (rev 155014)
@@ -0,0 +1,10 @@
+This tests that double-clicking on Japanese text.
+
+例えばオーストラリア
+Passed for offset 55
+Passed for offset 70
+Passed for offset 85
+Passed for offset 100
+Passed for offset 115
+Passed for offset 130
+

Added: trunk/LayoutTests/editing/selection/doubleclick-japanese-text.html (0 => 155014)


--- trunk/LayoutTests/editing/selection/doubleclick-japanese-text.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/doubleclick-japanese-text.html	2013-09-04 01:13:08 UTC (rev 155014)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script>
+if (window.testRunner)
+     testRunner.dumpAsText();
+
+function getPositionOfNode(id)
+{
+    var n = document.getElementById(id);
+    var pos = {x: 0, y: 0};
+
+    while (n) {
+        pos.x += n.offsetLeft + n.clientLeft;
+        pos.y += n.offsetTop + n.clientTop;
+        n = n.offsetParent;
+    }
+    return pos;
+}
+
+function doubleClickNode(id, offset)
+{
+    var pos = getPositionOfNode(id);
+    eventSender.mouseMoveTo(pos.x + offset, pos.y + 2);
+    eventSender.mouseDown();
+    eventSender.leapForward(1);
+    eventSender.mouseUp();
+    eventSender.leapForward(100);
+    eventSender.mouseDown();
+    eventSender.leapForward(1);
+    eventSender.mouseUp();
+}
+
+function doTest(testId, offset, expectedText)
+{
+    // Simulate a double click.
+    doubleClickNode(testId, offset);
+
+    // Get the text of the current selection.
+    var sel = window.getSelection();
+    var actualText = sel.getRangeAt(0).toString();
+
+    if (expectedText == actualText) {
+        log("Passed for offset " + offset);
+    } else {
+        log("Failed for offset " + offset);
+        log("  Expected: " + expectedText);
+        log("  Actual: " + actualText);
+    }
+
+}
+
+function runTests()
+{
+    if (window.testRunner) {
+        doTest("test1", 55, "オーストラリア");
+        doTest("test1", 70, "オーストラリア");
+        doTest("test1", 85, "オーストラリア");
+        doTest("test1", 100, "オーストラリア");
+        doTest("test1", 115, "オーストラリア");
+        doTest("test1", 130, "オーストラリア");
+    }
+}
+
+function log(msg)
+{
+    var l = document.getElementById('log');
+    l.appendChild(document.createTextNode(msg));
+    l.appendChild(document.createElement('br'));
+}
+
+</script>
+</head>
+<body _onload_="runTests()">
+<p>
+This tests that double-clicking on Japanese text.
+</p>
+
+<div>
+<span id=test1>例えばオーストラリア</span>
+</div>
+
+<pre id=log>
+</pre>
+
+</body>
+</html>

Modified: trunk/Source/WTF/ChangeLog (155013 => 155014)


--- trunk/Source/WTF/ChangeLog	2013-09-04 00:26:57 UTC (rev 155013)
+++ trunk/Source/WTF/ChangeLog	2013-09-04 01:13:08 UTC (rev 155014)
@@ -1,3 +1,18 @@
+2013-09-03  Enrica Casucci  <enr...@apple.com>
+
+        Can't select Katakana word by double-clicking.
+        <rdar://problem/14654926>
+
+        Reviewed by Alexey Proskuryakov and Ryosuke Niwa.
+
+        For some languages, like Japanese we need
+        to use more context for word breaking.
+        I've renamed the function to better reflect its use
+        and remove the unused hasLineBreakingPropertyComplexContextOrIdeographic.
+
+        * wtf/unicode/icu/UnicodeIcu.h:
+        (WTF::Unicode::requiresComplexContextForWordBreaking):
+
 2013-09-03  Andreas Kling  <akl...@apple.com>
 
         Support Vector<Ref<T>>.

Modified: trunk/Source/WTF/wtf/unicode/icu/UnicodeIcu.h (155013 => 155014)


--- trunk/Source/WTF/wtf/unicode/icu/UnicodeIcu.h	2013-09-04 00:26:57 UTC (rev 155013)
+++ trunk/Source/WTF/wtf/unicode/icu/UnicodeIcu.h	2013-09-04 01:13:08 UTC (rev 155014)
@@ -188,15 +188,12 @@
     return !!u_ispunct(c);
 }
 
-inline bool hasLineBreakingPropertyComplexContext(UChar32 c)
-{
-    return u_getIntPropertyValue(c, UCHAR_LINE_BREAK) == U_LB_COMPLEX_CONTEXT;
-}
+#define WK_LB_CONDITIONAL_JAPANESE_STARTER 37
 
-inline bool hasLineBreakingPropertyComplexContextOrIdeographic(UChar32 c)
+inline bool requiresComplexContextForWordBreaking(UChar32 c)
 {
     int32_t prop = u_getIntPropertyValue(c, UCHAR_LINE_BREAK);
-    return prop == U_LB_COMPLEX_CONTEXT || prop == U_LB_IDEOGRAPHIC;
+    return prop == U_LB_COMPLEX_CONTEXT || prop == WK_LB_CONDITIONAL_JAPANESE_STARTER || prop == U_LB_IDEOGRAPHIC;
 }
 
 inline UChar32 mirroredChar(UChar32 c)

Modified: trunk/Source/WebCore/ChangeLog (155013 => 155014)


--- trunk/Source/WebCore/ChangeLog	2013-09-04 00:26:57 UTC (rev 155013)
+++ trunk/Source/WebCore/ChangeLog	2013-09-04 01:13:08 UTC (rev 155014)
@@ -1,3 +1,18 @@
+2013-09-03  Enrica Casucci  <enr...@apple.com>
+
+        Can't select Katakana word by double-clicking.
+        <rdar://problem/14654926>
+
+        Reviewed by Alexey Proskuryakov and Ryosuke Niwa.
+
+        For some languages, like Japanese we need
+        to use more context for word breaking.
+
+        New test: editing/selection/doubleclick-japanese-text.html
+
+        * platform/text/TextBoundaries.h:
+        (WebCore::requiresContextForWordBoundary):
+
 2013-09-03  Mark Lam  <mark....@apple.com>
 
         Converting StackIterator to a callback interface.

Modified: trunk/Source/WebCore/platform/text/TextBoundaries.h (155013 => 155014)


--- trunk/Source/WebCore/platform/text/TextBoundaries.h	2013-09-04 00:26:57 UTC (rev 155013)
+++ trunk/Source/WebCore/platform/text/TextBoundaries.h	2013-09-04 01:13:08 UTC (rev 155014)
@@ -30,9 +30,12 @@
 
 namespace WebCore {
 
+    // FIXME: this function won't be needed together with the function
+    // it calls when https://bugs.webkit.org/show_bug.cgi?id=120656
+    // will be fixed.
     inline bool requiresContextForWordBoundary(UChar32 ch)
     {
-        return WTF::Unicode::hasLineBreakingPropertyComplexContext(ch);
+        return WTF::Unicode::requiresComplexContextForWordBreaking(ch);
     }
 
     int endOfFirstWordBoundaryContext(const UChar* characters, int length);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to