Reviewed by Justin Garcia.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 05:49:44 +0000 (05:49 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 05:49:44 +0000 (05:49 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=15781
        REGRESSION: Ligatures fail to form when typing in Devanagari (because WebKit can't handle
        a marked range that covers half of a composed character sequence)

        Test: platform/mac/editing/input/devanagari-ligature.html

        This fix is somewhat of a hack, as it asks editing commands to work with invalid selections.
        However, this is not entirely new for them, as Roman accents are typed in a similar manner.

        In the future, we probably want to make commands work with ranges (or Positions explicitly).

        * editing/Editor.cpp:
        (WebCore::Editor::selectComposition): Force selection to composition range.
        * editing/InsertTextCommand.cpp:
        (WebCore::InsertTextCommand::input): Force ending selection to inserted text range.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27809 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/input/devanagari-ligature.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/Editor.cpp
WebCore/editing/InsertTextCommand.cpp

index 51b0dd09a7c943c42287040e00000c0b1789faba..5f992e8ca596ea4b3807ad291844c166fe1521e2 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-14  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Justin Garcia.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15781
+        REGRESSION: Ligatures fail to form when typing in Devanagari (because WebKit can't handle
+        a marked range that covers half of a composed character sequence)
+
+        * platform/mac/editing/input/devanagari-ligature-expected.checksum: Added.
+        * platform/mac/editing/input/devanagari-ligature-expected.png: Added.
+        * platform/mac/editing/input/devanagari-ligature-expected.txt: Added.
+        * platform/mac/editing/input/devanagari-ligature.html: Added.
+
 2007-11-14  Antti Koivisto  <antti@apple.com>
 
         Try to make this test less timing dependent.
diff --git a/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.checksum b/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.checksum
new file mode 100644 (file)
index 0000000..692bd89
--- /dev/null
@@ -0,0 +1 @@
+f4bfe4e63b32e5e0aa83be58bc6d9a4e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.png b/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.png
new file mode 100644 (file)
index 0000000..ca8ba94
Binary files /dev/null and b/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.txt b/LayoutTests/platform/mac/editing/input/devanagari-ligature-expected.txt
new file mode 100644 (file)
index 0000000..e4450e3
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 11x18
+          text run at (0,0) width 11: "\x{915}\x{94D}\x{937}"
+caret: position 3 of child 0 {#text} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/input/devanagari-ligature.html b/LayoutTests/platform/mac/editing/input/devanagari-ligature.html
new file mode 100644 (file)
index 0000000..6f8be0b
--- /dev/null
@@ -0,0 +1,31 @@
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<div id="test" contenteditable></div>
+<script type="text/javascript">
+
+    document.getElementById("test").focus();
+
+    if (window.layoutTestController) {
+        
+        try {
+        
+            textInputController.insertText("क");
+            textInputController.setMarkedText("्", 1, 0);
+            textInputController.setMarkedText("", 0, 0);
+            textInputController.insertText("्ष");
+
+        } catch (ex) {
+            document.write("Exception: " + ex.description);
+        }
+    } else {
+        document.write("To reproduce manually:<br>");
+        document.write("1. Enable Devanagari keyboard layout.<br>");
+        document.write("2. Type a key sequence K D Shift-comma.<br>");
+        document.write("The result should be a single character.");
+    }
+</script>
+</body>
+</html>
index 087057816da9a8923c32ad39129f6ec82d9aef20..a81a3e48de644ed22c0870b66314279dc8d97533 100644 (file)
@@ -1,3 +1,23 @@
+2007-11-14  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Justin Garcia.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15781
+        REGRESSION: Ligatures fail to form when typing in Devanagari (because WebKit can't handle
+        a marked range that covers half of a composed character sequence)
+
+        Test: platform/mac/editing/input/devanagari-ligature.html
+
+        This fix is somewhat of a hack, as it asks editing commands to work with invalid selections.
+        However, this is not entirely new for them, as Roman accents are typed in a similar manner.
+
+        In the future, we probably want to make commands work with ranges (or Positions explicitly).
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::selectComposition): Force selection to composition range.
+        * editing/InsertTextCommand.cpp:
+        (WebCore::InsertTextCommand::input): Force ending selection to inserted text range.
+
 2007-11-14  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Hyatt.
index 2906b8d640b861d2d41e984da18789b33e555f2c..6ab582ea89e6e6226c41b62e5ca644c7ce0f3001 100644 (file)
@@ -1665,7 +1665,12 @@ void Editor::selectComposition()
     RefPtr<Range> range = compositionRange();
     if (!range)
         return;
-    m_frame->selectionController()->setSelectedRange(range.get(), DOWNSTREAM, false);
+    
+    // The composition can start inside a composed character sequence, so we have to override checks.
+    // See <http://bugs.webkit.org/show_bug.cgi?id=15781>
+    Selection selection;
+    selection.setWithoutValidation(range->startPosition(), range->endPosition());
+    m_frame->selectionController()->setSelection(selection, false, false);
 }
 
 void Editor::confirmComposition()
index 5de48d96d5ec793155396a295905833f90ccd57d..8be8d1e52ed93ac50a4369bb7fb24b8f7722d955 100644 (file)
@@ -142,7 +142,12 @@ void InsertTextCommand::input(const String& originalText, bool selectInsertedTex
         m_charactersAdded += text.length();
     }
 
-    setEndingSelection(Selection(startPosition, endPosition, DOWNSTREAM));
+    // We could have inserted a part of composed character sequence,
+    // so we are basically treating ending selection as a range to avoid validation.
+    // <http://bugs.webkit.org/show_bug.cgi?id=15781>
+    Selection forcedEndingSelection;
+    forcedEndingSelection.setWithoutValidation(startPosition, endPosition);
+    setEndingSelection(forcedEndingSelection);
 
     // Handle the case where there is a typing style.
     // FIXME: Improve typing style.