Open Bug 900787 Opened 9 years ago Updated 3 years ago

When scanning for after-a-deadkey expansions, Windows' kbd driver is left in unknown state


(Core :: DOM: UI Events & Focus Handling, defect)

20 Branch
Windows 7
Not set





(Reporter: nospam-abuse, Unassigned)


(Blocks 1 open bug)



(1 file, 1 obsolete file)

This is a companion to bug  (The chunks of code in question are similar, and bugs are similar.)  One of these bugs (I have no clue which one) causes the testable regression mentioned below.  This bug is split from

Here I comment on

The sad truth is that most of assumptions there are more or less wrong.  This explains at least the second bug in


1046       // Dead-key can pair only with such key that produces exactly one base
1047       // character.

This is wrong.  Dead key will pair with everything.

1057         // Depending on the character the followed the dead-key, the keyboard
1058         // driver can produce one composite character, or a dead-key character
1059         // followed by a second character.

The first part is wrong.  A partially recognized combination may produce up to four
16-bit wcharacters.

The second part is wrong.  An unrecognized combination may produce a dead-key character
followed by up to four 16-bit wcharacters produced by the second keypress.

1074             ret = ::ToUnicodeEx(virtualKey, 0, kbdState, (LPWSTR)baseChars,
1075                                 ArrayLength(baseChars), 0, mKeyboardLayout);
1076             NS_ASSERTION(ret == 1, "One base character expected");
1082             deadKeyActive = false;

This assertion is not substantiated.  What follows a dead key is not considered for its “deadness”.  So if it produces a defined combination AFTER a dead key, it still may be a dead key when used standalone (as above).

AFAIU, this causes the second bug in

##### The solution: depending on ret, set a correct state of deadKeyActive.
[One needs to call EnsureDeadKeyActive(false).]
Blocks: 880971
Only two LOCs are changed.  The rest fixes comments.
Attachment #784729 - Flags: review?(masayuki)
Actually, in my patch I overlooked one regression: as mentioned,

1852             ret = ::ToUnicodeEx(virtualKey, 0, kbdState, (LPWSTR)baseChars,
1853                                 ArrayLength(baseChars), 0, mKeyboardLayout);
1854             NS_ASSERTION(ret == 1, "One base character expected");
1855             if (ret == 1 && entries < aMaxEntries &&
1856                 AddDeadKeyEntry(baseChars[0], compositeChars[0],
1857                                 aDeadKeyArray, entries)) {
1858               entries++;
1859             }
1860             deadKeyActive = false;

does not make any sense.  ret may be arbitrary!
Attachment #784729 - Attachment is obsolete: true
Attachment #784729 - Flags: review?(masayuki)
Attachment #784743 - Flags: review?(masayuki)
Comment on attachment 784743 [details] [diff] [review]
diff_scan_after_dead should fix all the issues mentioned in the bug report

-'ing until tested.
Attachment #784743 - Flags: review?(masayuki) → review-
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.