Bug 1497746 - part 6: Add static_assert for preventing TextEditor to grow up again r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 26 Nov 2018 06:33:28 +0000
changeset 507169 fb45231e386d90110cdc7b93297e609e02c2b2a7
parent 507168 324232a1330c2a0661973d49f54ab5d29ca30a64
child 507170 e9588334915f1358fa47b9747f469285a3b52398
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1497746
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497746 - part 6: Add static_assert for preventing TextEditor to grow up again r=m_kato TextEditor instance is created per <input> element which has text editor and <textarea> element. Therefore, we should keep TextEditor slim as far as possible. Currently, TextEditor class size is 400 bytes on Win64. So, we should keep 512 bytes border. Differential Revision: https://phabricator.services.mozilla.com/D12404
editor/libeditor/TextEditor.cpp
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -79,16 +79,20 @@ TextEditor::TextEditor()
   , mInitTriggerCounter(0)
   , mNewlineHandling(nsIPlaintextEditor::eNewlinesPasteToFirst)
 #ifdef XP_WIN
   , mCaretStyle(1)
 #else
   , mCaretStyle(0)
 #endif
 {
+  // printf("Size of TextEditor: %zu\n", sizeof(TextEditor));
+  static_assert(sizeof(TextEditor) <= 512,
+    "TextEditor instance should be allocatable in the quantum class bins");
+
   // check the "single line editor newline handling"
   // and "caret behaviour in selection" prefs
   GetDefaultEditorPrefs(mNewlineHandling, mCaretStyle);
 }
 
 TextEditor::~TextEditor()
 {
   // Remove event listeners. Note that if we had an HTML editor,