Closed Bug 1543966 Opened 3 years ago Closed 3 years ago

Make all edit command classes singleton


(Core :: DOM: Editor, task, P3)




Tracking Status
firefox68 --- fixed


(Reporter: masayuki, Assigned: masayuki)


(Blocks 1 open bug)



(2 files)

Most edit command classes are created per editor instance. This means that we have not reasonable runtime cost to allocate them when there are too many editors. Fortunately, most classes are stateless, and the statefull classes can be changed to stateless. Therefore, we can make them singleton.

If we make them singleton, we might be able to access them from nsHTMLDocument::ExecCommand() directly.

Type: defect → task
Priority: -- → P3

Different from the comment in EditorCommands.h, editing commands and
editor commands are instantiated for each editable document or each
HTMLInputElement or HTMLTextareaElement. Therefore, even though they
are stateless, we allocate too many instances of them. We should make
them singleton classes to reduce the footprint and save runtime allocation

Some "HTML editor commands" are stateful due to storing tag name to handle it
with specific command. However, we can make it stateless with retrieving
tag name from command name once per command only when it's necessary. The
runtime cost must be really cheap since we can map it with hash table.

This patch makes them stateless and singleton classes. So, we can save
footprint and allocation runtime cost with this change.

Pushed by
part 1: Make "editing commands" and "editor commands" singleton classes r=m_kato
part 2: Make "HTML editor commands" and "document state commands" singleton classes r=m_kato
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.