Closed Bug 1306549 Opened 8 years ago Closed 8 years ago

Clean up KeyboardLayout::InitNativeKey()

Categories

(Core :: Widget: Win32, defect, P2)

All
Windows
defect

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

(Whiteboard: tpi:+)

Attachments

(10 files)

58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
58 bytes, text/x-review-board-request
m_kato
: review+
Details
KeyboardLayout::InitNativeKey() handles a lot of cases with accessing a lot of members. This is not easier to understand what it does.

Let's clean up it with wrapping each part of the method with new methods.
Comment on attachment 8796994 [details]
Bug 1306549 part.1 KeyboardLayout::InitNativeKey() should use KeyboardLayout::IsDeadKey()

https://reviewboard.mozilla.org/r/82610/#review81268
Attachment #8796994 - Flags: review?(m_kato) → review+
Comment on attachment 8796995 [details]
Bug 1306549 part.2 Create overload methods which take ModifierKeyState instead of VirtualKey::ShiftState

https://reviewboard.mozilla.org/r/82612/#review81286
Attachment #8796995 - Flags: review?(m_kato) → review+
Comment on attachment 8796996 [details]
Bug 1306549 part.3 KeyboardLayout::InitNativeKey() should use GetUniCharsAndModifiers() instead of using VirtualKey::GetUniChars() directly

https://reviewboard.mozilla.org/r/82614/#review81302
Attachment #8796996 - Flags: review?(m_kato) → review+
Comment on attachment 8796997 [details]
Bug 1306549 part.4 Create KeyboardLayout::GetNativeUniCharsAndModifiers() for wrapping VirtualKey::GetNativeUniChars()

https://reviewboard.mozilla.org/r/82616/#review81328
Attachment #8796997 - Flags: review?(m_kato) → review+
Comment on attachment 8796998 [details]
Bug 1306549 part.5 Create KeyboardLayout::GetCompositeChar() for wrapping VirtualKey::GetCompositeChar()

https://reviewboard.mozilla.org/r/82618/#review81346
Attachment #8796998 - Flags: review?(m_kato) → review+
Comment on attachment 8796999 [details]
Bug 1306549 part.6 Create KeyboardLayout::ActivateDeadKeyState()

https://reviewboard.mozilla.org/r/82620/#review81358
Attachment #8796999 - Flags: review?(m_kato) → review+
Comment on attachment 8797000 [details]
Bug 1306549 part.7 Create KeyboardLayout::MaybeInitNativeKeyAsDeadKey()

https://reviewboard.mozilla.org/r/82622/#review81620
Attachment #8797000 - Flags: review?(m_kato) → review+
Comment on attachment 8797001 [details]
Bug 1306549 part.8 Get rid of |virtualKey| and |isKeyDown| from KeyboardLayout::InitNativeKey() and KeyboardLayout::MaybeInitNativeKeyAsDeadKey()

https://reviewboard.mozilla.org/r/82624/#review81622
Attachment #8797001 - Flags: review?(m_kato) → review+
Comment on attachment 8797002 [details]
Bug 1306549 part.9 Create KeyboardLayout::IsInDeadKeySequence() which returns true while it's in a dead key sequence

https://reviewboard.mozilla.org/r/82626/#review81624
Attachment #8797002 - Flags: review?(m_kato) → review+
Comment on attachment 8797003 [details]
Bug 1306549 part.10 Reorder member declaration of KeyboardLayout class

https://reviewboard.mozilla.org/r/82628/#review81628

::: widget/windows/KeyboardLayout.h:748
(Diff revision 1)
> +  int32_t mActiveDeadKey;                 // -1 = no active dead-key
> +  VirtualKey::ShiftState mDeadKeyShiftState;
> +
> +  bool mIsOverridden : 1;
> +  bool mIsPendingToRestoreKeyboardLayout : 1;
> +

It is unnecessary to use bit fields such as "bool mIsOverrideen : 1".  Since most platform uses aligned allocation (32bit is 4, 64bit is 8), It doesn't reduce allocation size when bool member is smaller than 4/8.

Also, bit fields requires more code to bit to int.  So it should use bit fields for heap size if a lot of this objects are created.
Comment on attachment 8797003 [details]
Bug 1306549 part.10 Reorder member declaration of KeyboardLayout class

https://reviewboard.mozilla.org/r/82628/#review81632
Attachment #8797003 - Flags: review?(m_kato) → review+
Comment on attachment 8797003 [details]
Bug 1306549 part.10 Reorder member declaration of KeyboardLayout class

https://reviewboard.mozilla.org/r/82628/#review81628

> It is unnecessary to use bit fields such as "bool mIsOverrideen : 1".  Since most platform uses aligned allocation (32bit is 4, 64bit is 8), It doesn't reduce allocation size when bool member is smaller than 4/8.
> 
> Also, bit fields requires more code to bit to int.  So it should use bit fields for heap size if a lot of this objects are created.

Good catch! I'll stop using the bit fields before landing.
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/54940e9b9a1b
part.1 KeyboardLayout::InitNativeKey() should use KeyboardLayout::IsDeadKey() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/bb92cb94dcac
part.2 Create overload methods which take ModifierKeyState instead of VirtualKey::ShiftState r=m_kato
https://hg.mozilla.org/integration/autoland/rev/2e45f263fb19
part.3 KeyboardLayout::InitNativeKey() should use GetUniCharsAndModifiers() instead of using VirtualKey::GetUniChars() directly r=m_kato
https://hg.mozilla.org/integration/autoland/rev/fd077161e636
part.4 Create KeyboardLayout::GetNativeUniCharsAndModifiers() for wrapping VirtualKey::GetNativeUniChars() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/adba65212c35
part.5 Create KeyboardLayout::GetCompositeChar() for wrapping VirtualKey::GetCompositeChar() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/9be247c306a1
part.6 Create KeyboardLayout::ActivateDeadKeyState() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/489e11449d8e
part.7 Create KeyboardLayout::MaybeInitNativeKeyAsDeadKey() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/7dbd5e61db37
part.8 Get rid of |virtualKey| and |isKeyDown| from KeyboardLayout::InitNativeKey() and KeyboardLayout::MaybeInitNativeKeyAsDeadKey() r=m_kato
https://hg.mozilla.org/integration/autoland/rev/be15fd5862d3
part.9 Create KeyboardLayout::IsInDeadKeySequence() which returns true while it's in a dead key sequence r=m_kato
https://hg.mozilla.org/integration/autoland/rev/0bf2bbd0c300
part.10 Reorder member declaration of KeyboardLayout class r=m_kato
Priority: -- → P2
Whiteboard: tpi:+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: