This patch adds new rules of TextEditRules and HTMLEditRules about
NS_ERROR_EDITOR_DESTROYED.
Additionally, this patch moves some method explanation in each .cpp file to .h
file.
MozReview-Commit-ID: JqZFrWyrND8
--HG--
extra : rebase_source : d86385d9c26bb23adae1eca3b1be1a868c20e353
Additionally, it creates AutoSelectionRestorer. So, this patch adds
CanHandleEditAction() check after its caller since even if it returns
NS_OK, the editor might have been gone.
MozReview-Commit-ID: BgIbpHFFPE1
--HG--
extra : rebase_source : 010befdb34f8269f6f7fc24d1ae13eba4575aa69
And this patch creates a new method, OutdentAroundSelection(), to check if
restoring Selection with AutoSelectionRestorer causes destroying the editor.
However, this does NOT change any logic in the new method except changing some
else-if blocks to if blocks with early-return style.
MozReview-Commit-ID: JMIo4kUOkwx
--HG--
extra : rebase_source : 0d628ebb866d7b63f8b78e6d701c27378a82dfb6
And this patch renames it to SplitRangeOffFromBlockAndRemoveMiddleContainer()
for making the name explain what it does.
MozReview-Commit-ID: 546dnCeoGOV
--HG--
extra : rebase_source : 7f0762cfa377a07d28342a1092ad0a7ee70fa108
And this patch renames it to SplitRangeOffFromBlock() for making the name
explain what it does since "split" is used as splitting to two nodes widely
in editor.
MozReview-Commit-ID: GrRu5sI4yrP
--HG--
extra : rebase_source : 3ec27bce3769af518d3f1c317559fd89d379c539
Additionally, this patch renames it to MaybeDeleteTopMostEmptyAncestor() for
making its name explain what it does.
MozReview-Commit-ID: 1i7zeq9In2T
--HG--
extra : rebase_source : 8d9de9e6154038a993be636c3cedf950a6efd179
PromoteRange() related methods do not change Selection nor the DOM tree.
Therefore, they must be safe. However, only PromoteRange() takes an nsRange
instance and modifies it. If it's in Selection, that causes selectionchange
event. Therefore, we should check if given range is in Selection with
MOZ_ASSERT().
MozReview-Commit-ID: AXkmHFB4P08
--HG--
extra : rebase_source : 539b39d0217a7dc06f76e70546096d30b2734c02
Despite of the name of GetNodesForOperation() and related methods, it changes
the DOM tree if their aTouchContent is TouchContent::yes (by default).
Therefore, they should return NS_ERROR_EDITOR_DESTROYED if they cause destroying
the editor and all callers should check the result. Therefore, this patch mark
them as MOZ_MUST_USE.
Additionally, because of importance of aTouchContent, this patch makes the
arguments not optional. This change must make other developers being careful
to use them. (Although TouchContent does not feel dangerous. We should rename
it to make its risk clearer.)
On the other hand, this patch removes aTouchContent from
GetParagraphFormatNodes() since it's always called with TouchContent::no.
Therefore, this method is always safe.
Although I tried to document those methods, but I have not understood them
completely yet. Perhaps, we should redesign them in another bug both to
learn them and making them faster and simpler.
MozReview-Commit-ID: 4vknJGUdwEe
--HG--
extra : rebase_source : 486949005283548697e6eeb7175f6189a66defaa
Unfortunately, we need to make it take out argument for returning new first
child point of right node. If we can create JoinNodesResult which have
nsresult and EditorDOMPoint, we can avoid that, but EditorBase::JoinNodes()
does not want it. So, even if we create such class, only 2 callers of the
methods are its users...
MozReview-Commit-ID: 1zwVZ0FriwN
--HG--
extra : rebase_source : 1f7867774f9a30bec78596b0282717435e7223c0
And this patch renames it to
InsertBRElementToEmptyListItemsAndTableCellsInChangedRange().
MozReview-Commit-ID: 1DGhcI93YAk
--HG--
extra : rebase_source : caa675a5b02c18e9ca57171294bdaf48e7563dc0
And this patch renames it to RemoveEmptyNodesInChangedRange().
MozReview-Commit-ID: Kr2xmUOH1ZZ
--HG--
extra : rebase_source : 59a0a70360c6e0d426c329f4be757c2c0eac96c4
Additionally, this patch renames its specific enum class from ContentsOnly
to ResetAlignOf for making its target clearer.
MozReview-Commit-ID: KD4ndAsMClN
--HG--
extra : rebase_source : 302598397cf32893c7db18a6a014d0db862cb8f6
Additionally, this patch renames it to ChangeMarginStart() for making its
job clearer and add two inline wrapper methods.
MozReview-Commit-ID: L2GfLKhT6sa
--HG--
extra : rebase_source : d1d293f742214048ce5dfbbb7ebd50b0cbeed881
This patch also makes aCancel of TextEditRules::WillInsert() optional since
a lot of callers need to ignore the result.
MozReview-Commit-ID: JrvycxMQ9Mm
--HG--
extra : rebase_source : 9ecdc0fd363d9da33c12409f2993da9c58553598
This patch creates internal method for it as DeleteSelectionWithTransaction()
because it needs to create SelectionBatcher and destruction of it may cause
destroying the editor. Therefore, unfortunately, all callers of
DeleteSelectionWithTransaction() needs to check CanHandleEditAction()
manually. If we could use try-catch, we could make it safer, though.
MozReview-Commit-ID: 13enOQjEzNn
--HG--
extra : rebase_source : 5a902026bcc507fbf9f1949fdcf33a98aabd9a0b
And also this patch removes unnecessary arguments from the method.
MozReview-Commit-ID: UKscK4vFVX
--HG--
extra : rebase_source : 7f6b9405824a3f175f165a2d7d75a293108278f3
Note that HTMLEditRules::DocumentModifiedWorker() is a runnable method.
So, it cannot return nsresult. Therefore, it just checks the result
only with NS_WARNING_ASSERTION().
MozReview-Commit-ID: KBSpv5H5KGU
--HG--
extra : rebase_source : b356ab04d0459214df9dbb3dbfb0e3eecc686348
And also this patch marks it as MOZ_MUST_USE. All callers have to check if
the result is NS_ERROR_EDITOR_DESTROYED at least.
MozReview-Commit-ID: H4DfU1asPpe
--HG--
extra : rebase_source : c11cc00500aad44bd542147fb971e3cce4d634e2
First, this patch changes TextEditRules::CreateBRInternal() to a private method
for making any callers use CreateBR() or CreateMozBR() instead.
Then, this patch makes TextEditRules::CreateBRInternal() return both nsresult
and created <br> element with CreateElementResult class.
Finally, this patch makes all callers of them check if they don't return an
error code including NS_ERROR_EDITOR_DESTROYED.
MozReview-Commit-ID: 18OvPmbDVHK
--HG--
extra : rebase_source : 328a91146539763cec317105b92aa3ce5d4b8233
This patch defines NS_ERROR_EDITOR_DESTROYED error code as an editor module
specific error code.
And creates TextEditRules::CanHandleEditAction() to check if the instance
can keep handling edit action.
MozReview-Commit-ID: 4qECwNBO0yz
--HG--
extra : rebase_source : a925a9b6840d4d06e2792b9fe276e062288b0806
Now RulesInfo uses nsAString, but old comment is "XXX Struct should store
a nsAReadable*". We can remove unnecessary local variable of nsString.
MozReview-Commit-ID: C7gnTG7xTjU
--HG--
extra : rebase_source : e141bbcefd75d90b836668f710350d4362d66c76
CanPasteTransferable and PreDestroy aren't used from script (inc. comm-central
and bluegriffon), so we should move these to out of nsIEditor.
MozReview-Commit-ID: GRfBobAm2qi
--HG--
extra : rebase_source : 812792ff43da24bfd9cb99c4b3127e6acdc43ba1
Using concrete class types with static IIDs in QueryInterface methods is a
pretty common pattern which isn't supported by any existing helper macros.
That's lead to separate ad-hoc implementations, with varying degrees of
dodginess, being scattered around the tree.
This patch adds a helper macro with a canonical (and safe) implementation, and
updates existing ad-hoc users to use it.
MozReview-Commit-ID: HaTGF7MN5Cv
--HG--
extra : rebase_source : ace930129d85960d22bc3048ca3bb19bbbd4a63e
extra : histedit_source : 03a87f746d957789d41381e4e1bfcc4fd7eebaf2%2C9c5bae9feeeef7721105db67be0f83e0ded66bb7
Some Did*() of TextEditRules and HTMLEditRules do nothing except returning
NS_OK. Let's remove them since there is no reason to keep them.
MozReview-Commit-ID: Jcdh5rnm5Yc
--HG--
extra : rebase_source : 54aedd8187edfa244bc8fbe8f560fb6ee064e9cf
Now, each protected/private method of TextEditRules and HTMLEditRules can
retrieve Selection instance safely and quickly. Therefore, their pointer or
reference of Selection arguments are not necessary. Therefore, this patch
removes them.
MozReview-Commit-ID: 1SPmKXmd7kz
--HG--
extra : rebase_source : 32dfd2d5e8b0667318a5b3766a8a7d8594bba8e7
After this patch applies, most methods of TextEditRules and HTMLEditRules
don't need to take Selection as their arguments. Therefore, next patch will
remove them.
MozReview-Commit-ID: 99r3ZkfG2In
--HG--
extra : rebase_source : 8666ded8f2e6954f2e3cf6bb1ba1cf3313f65e70
Although, this patch removes first check of mHTMLEditor in each method. If
this causes some security issues, we should add now. However, automated
tests don't indicate it.
Anyway, it should be fixed by bug 1454900 in same cycle.
MozReview-Commit-ID: 3LAtOQHyR5J
--HG--
extra : rebase_source : 48b78cb9477c6c47d23a864404ce95ca9edb8588
This patch adds a debug methods to check if AutoSafeEditorData as expected and
inserting top of each method whose mTextEditor is replaced with TextEditorRef().
MozReview-Commit-ID: 8yjHsypLMRx
--HG--
extra : rebase_source : 0c07d18d102d6ffe6f4bc0cf50ad0dfca1f8bd4d
Except HTMLEditRules::WillJoinNodes(), observer methods of HTMLEditRules
accesses mHTMLEditor. Therefore, we need to make them create AutoSafeEditorData
instance in the stack.
Note that for reducing EditorBase::GetSelection() calls, this patch adds
Selection& argument to all of them.
MozReview-Commit-ID: 6mjuD2gZwVp
--HG--
extra : rebase_source : 56f16747a80927f0477b9b54f6088be719ed7b01
This patch creates a stack class in TextEditRules, its name is
AutoSafeEditorData and make all public methods (except editor observer methods)
which may change DOM tree, fire some DOM events or calling some XPCOM listeners
create its instance in the stack. Then, it grabs associated editor instance
and its selection instance.
Next patch will make remaining public methods create AutoSafeEditorData.
MozReview-Commit-ID: 8oshdhL3ONQ
--HG--
extra : rebase_source : 591db71e45fe28ca93cbebd9bb7da8c16eae4466
SplitNodeDeepWithTransaction will split nodes until better point. But
this test case becomes that node is orphan into loop. So I would like to
add more check whether parent is nothing.
MozReview-Commit-ID: EroSV4uVBVL
--HG--
extra : rebase_source : f594bdf7cd9efac7d10e6e05a8f87dadfc761295
Now that BeginUpdate is useless for the UPDATE_STYLE case, we don't need the
update mechanism at all. Just ensure that ApplicableStylesChanged is called on
the pres shell via the relevant RuleChanged, etc. notifications.
There's a big hidden gotcha here. nsIDocument::BeginUpdate does put a script
blocker on the stack for these updates. However it's not needed, since no script
can run during these notifications (only the stylesheet events we post for
devtools, but those use AsyncEventDispatcher and PostDOMEvents, so they don't
try to run immediately).
nsIDocument::BeginUpdate also does XBL binding attached queue stuff, but we
can't change bindings during these notifications anyway, so it also doesn't
matter.
MozReview-Commit-ID: HJvK6zQfloh
It's been removed for a while on Nightly without any known regressions. This
gives us a full beta cycle of telemetry and two nightly cycles without the API
before shipping.
This only removes the API, followup work will replace serialization by Servo's,
and remove the remaining DOM interfaces.
MozReview-Commit-ID: 2m1taYg5xEr
Gecko has some built-in UIs:
* to edit size of objects like <img>, <table> and absolute positioned elements.
* to edit position of absolute positioned elements.
* to add/remove table columns and rows.
Currently, those UIs are available in both designMode editor and contenteditable
editor only on Gecko. I.e., the other browsers' users cannot modify as such
without web apps implement such function. So, for compatibility with the
other browsers, we should hide those UIs by default. On the other hand, if
this is too risky for backward compatibility, we should not do that.
So, before doing that, we should collect actual usage data of object resizers,
inline table editing UI, positioning UI of absolute positioned elements with
telemetry probes.
This patch adds 3 sets of probes for each UI. One is percentage of showing
each UI in all instantiated HTMLEditor. The other is number of user interaction
of each UI in HTMLEditors which has shown the UI.
This patch makes all new probes as "opt-out" because they are really important
data since used for deciding whether those UIs are necessary or unnecessary.
MozReview-Commit-ID: B9Y6GTiCPw6
--HG--
extra : rebase_source : 00e49f31712e24cb269ad3aa65c7d13b7cccb3a5
Use fatal MOZ_ASSERT or non-fatal NS_ASSERTION instead.
MozReview-Commit-ID: 1QAsgoWpXDn
--HG--
extra : source : 9ca972b6b3e7d3b576e20a0bf412df51d82aad9f
extra : intermediate-source : a909a9d7bc9a53095e963a4bea45f4fc4aa85b72
It is unnecessary to keep virtual method for
mozInlineSpellChecker::SpellCheckAfterEditorChange, so we should remove virtual
keyword.
MozReview-Commit-ID: 2ry5uhMTFVC
--HG--
extra : rebase_source : ba86bb7c4e47598f83e3869733a238a740cef6b2
This also removes any redundant Ci.nsISupports elements in the interface
lists.
This was done using the following script:
acecb401b7/processors/chromeutils-generateQI.jsm
MozReview-Commit-ID: AIx10P8GpZY
--HG--
extra : rebase_source : a29c07530586dc18ba040f19215475ac20fcfb3b
The patch is a bit large because all these methods except
SswitchTableCellHeaderType call each other; doing it piecemeal would have
required introducing, then removing, a bunch of QIs.
The work to migrate to Sqlite.jsm seems to have caused a timing problem
in our tests where shutdown the content process while this IPC message
is still unresolved. This causes us to destroy RemoteSpellCheckingEngineChild
without it having processed its RecvNotiy..., leading to the promise being
leaked. As far as I can tell this resolves all of our leak issues on try.
MozReview-Commit-ID: GdwVIp5dj1m
--HG--
extra : rebase_source : b7bf5838c53e40b49bea17df123028a2dbd26e5e
Currently, EditorBase handles most composition events. However, only
eCompositionChange event handler is in TextEditor and it's the main event
of handling composition. Therefore, we should make all composition event
handlers in one place for easier to read, and make them non-virtual.
MozReview-Commit-ID: BYDhiPyGKvo
--HG--
extra : rebase_source : ed9db0f49d7ae268c85359e48015e86584f9c999
This is simple mistake of bug 1451672.
EditorBase::CloneAttributesWithTransaction() sets both sourceElement and
destElement to aDestElement, but of course, it should set sourceElement to
aSourceElement.
Additionally, this patch adds mozilla specific web-platform tests to check
attribute cloning with basic edit operation.
MozReview-Commit-ID: GM1VjRHG7C3
--HG--
extra : rebase_source : 95427853442454525232df519ce5b5ad7bb12693
No one uses outputToStream even if c-c and BlueGriffon. We should remove this.
MozReview-Commit-ID: LEUtfc89DBe
--HG--
extra : rebase_source : f0c5aa918f577ca8a285afd2414fe3da6545fefc
No one uses postCreate from script even if c-c and BlueGriffon. So we should
devirtualize this
MozReview-Commit-ID: D3FKVEvG7Go
--HG--
extra : rebase_source : 9915a93ea8ae18bee251507a4c94fe66c0f03d0f
No one uses syncRealTimeSpell from script even if c-c and BlueGriffon. So
we should devirtualize this
MozReview-Commit-ID: AoOb165dOFa
--HG--
extra : rebase_source : e1a9dcdfa6cfe6c918a06a2738c38a6cb9441a1d
HTMLEditor::InsertElementAtSelection() doesn't check if selection is in
native anonymous subtree. Therefore, it could insert element into <input>
element etc.
This patch adds new API to EditorDOMPointBase to compute ancestor point which
is not in native-anonymous subtree and make
HTMLEditor::GetBetterInsertionPointFor() use it to not return point in any
native-anonymous subtrees.
Like this adds new comments into the method, we should optimize the method
since it may create a lot of transactions and dispatch a lot of mutation
events.
MozReview-Commit-ID: FknJfu6QCjS
--HG--
extra : rebase_source : 39dc110b1101134f7c704e64dbff89171fe50e47
According to existing comments, TextEditor::TypedText() and
HTMLEditor::TypedText() are intentional bottleneck to debug. However, only
for that purpose, it and its internal methods are made virtual. This really
doesn't make sense.
So, this patch creates TextEditor::OnInputText() for callers of TypedText()
with non-empty string, TextEditor::OnInputParagraphSeparator() for callers
of TypedText() with eTypeBreak (Enter key or insertParagraphSeparator),
HTMLEditor::OnInputLineBreak() for callers of TypedText() with eTypeBR
(Shift + Enter or insertLineBreak). Additionally, this creates internal
non-virtual methods for XPCOM methods which are used as internal methods of
TypedText(). One is InsertTextAsAction() for nsIPlatintextEditor.insertText().
the other is InsertParagraphSeparator() for nsIPlaintextEditor.insertLineBreak().
Although those new methods are not have "WithTransaction" postfix, they must
be clearer they'll use transactions since user input and actions should be
undo-able.
MozReview-Commit-ID: AmOkMqovIKA
--HG--
extra : rebase_source : 9c0f4b25fa2a36ad2f3394f72eb290824c31d82a
TextEditor::CreateBR() is just a wrapper of TextEditor::CreateBRImpl() for
automatically retrieving Selection of the editor.
And TextEditor::CreateBRImpl() should be renamed to
TextEditor::InsertBrElementWithTransaction() for making it clearer what
it does.
MozReview-Commit-ID: D8sjVdLrVrd
--HG--
extra : rebase_source : f269f5c3ce598d221d7263c111475dab0dd5f19f
Similar to EditorBase::ReplaceContainerWithTransaction(),
EditorBase::InsertContainerAbove() may set an attribute to newly created element
if it's specified. However, for avoiding the null check, let's make them
as references rather than pointers and treat nsGkAtoms::_empty as nullptr for
making the code safer.
This patch removes "Above" from the method name since it's redundant.
"Insert" sounds like inserting a node, and "Container" means to keep existing
children with new element in EditorBase.
MozReview-Commit-ID: 6EnkKHynYSP
--HG--
extra : rebase_source : d4b4c1a611c46a0f4d86389aab3331af565199d2
This patch renames EditorBase::MoveNode() to
EditorBase::MoveNodeWithTransaction() and redesign its parameters including
replacing a set of container node and offset in it to EditorDOMPointBase.
However, it takes magic number -1 as meaning end of the container.
Therefore, this patch adds MoveNodeToEndWithTransaction() for keeping the
callers simple.
MozReview-Commit-ID: BeTq5c7GQNN
--HG--
extra : rebase_source : b3a617a5a1a493cb0fcbefe2d9a9708b0257b1a8
The parameters of EditorBase::ReplaceContainer() are complicated. For example,
if it's specified as cloning all attributes, aAttribute and aValue are ignored
because CloneAttributes() removes all existing attributes but ReplaceContainer()
sets attributes before calling CloneAttributes(). This method has 3 modes:
1. Just replaces aOldContainer with new element.
2. #1 and clones all attributes from aOldContainer to the new element.
3. #1 and sets aAttribute of the new element to aValue.
Therefore, this patch creates 3 inline wrappers of the renamed method.
MozReview-Commit-ID: IsPu2uZuU8f
--HG--
extra : rebase_source : 02a23f48a91e0c9558126552a4c8d4b12c8b76bc
First, EditorBase::DeleteSelection() is never used since
TextEditor::DeleteSelection() overrides it but does not call it. So, this patch
makes EditorBase::DeleteSelection() only returns NS_ERROR_NOT_IMPLEMENTED.
Next, EditorBase::DeleteSelectionImpl() actually removes content for
TextEditor::DeleteSelection(). So, it should be named as
DeleteSelectionWithTransaction(). However, it'll be done in the following
patch. On the other hand, its callers are EditorBase::HandleKeyPressEvent()
and EditorBase::DeleteSelectionAndPrepareToCreateNode(). Fortunately, they
can be moved to TextEditor simply. Therefore this patch moves the methods
to TextEditor for making related methods in a place.
Then, we can make the implementation of nsIEditor::TextEditor() as a non-virtual
method, TextEditor::DeleteSelectionAsAction().
MozReview-Commit-ID: KXFDhW3G9lA
--HG--
extra : rebase_source : 15986979279b2cae3b61cda1bf6bf3d9e4987f3f
EditorBase::SplitNodeImpl() is called by SplitNodeTransaction::DoTransaction()
for actually splitting a node. However, "WithoutTransaction" postfix is really
redundant. Perhaps, just naming DoSplitNode() is better since "Impl" isn't
unclear and not useful if somebody wants to use it as a utility method and
there has already been EditorBase::SplitNode() which is an override of
nsIEditor::SplitNode(). It must not be good to use same name for different
purpose (EditorBase::SplitNode() creates a transaction).
MozReview-Commit-ID: Akjeyp52vVv
--HG--
extra : rebase_source : dcb29cec2749431b59068b670b68e5cd61b18588
This patch renames:
EditorBase::SplitNode() -> EditorBase::SplitNodeWithTransaction()
EditorBase::SplitNodeDeep() -> EditorBase::SplitNodeDeepWithTransaction()
HTMLEditRules::MaybeSplitAncestorsForInsert() ->
HTMLEditRules::MaybeSplitAncestorsForInsertWithTransaction()
Note it might be that some callers of those methods should be renamed too.
However, we should do it in follow up bug after landing those patches since
we can investigate it with searchfox.org after landing patches.
MozReview-Commit-ID: FfxCfaI85z5
--HG--
extra : rebase_source : 143960de45791c72dbf4d436f65e55452b4f7b10
EditorBase::CreateNode() creates an element node with transaction. I.e., it's
undoable. So, if somebody would use this method as a helper method for changing
the DOM tree, that would cause unexpected undoable transaction. So, we should
make the method name clearer to avoid such bug.
MozReview-Commit-ID: GZsOGBfqog
--HG--
extra : rebase_source : 8b7539a680ee88f3557acb0837fe1a021d842323
So, this patch replaces the setter with non-virtual method and removing the
getter since where is already non-virtual getter method.
MozReview-Commit-ID: Is19Yriz8t8
--HG--
extra : rebase_source : bb2f49f380ddb2e2f96e8690effd8d47d24ae0ae
This crash is that HTMLEditor::ClearStyle returns nullptr for aNode even if
successful.
When current start node and offset isn't within ancestor limiter,
HTMLEditor::ClearStyle will return nullptr for split node even if successful.
Because SplitNodeTransation returns error since Selection::Collapse is failed.
Then, SplitNodeDeep in HTMLEditor::SplitStyleAvovePoint returns error. But
this error is ignored. So node will becomes null even if successful.
CreateStyleForInsertText will set new selection when there is split node, so
we shouldn't set selection on ClearStyle.
Also, InsertNodeTransation is ignored for error when Collapse is failed, but
SplitNodeTransaction isn't ignored. We should create a rule when collapse is
failed on transaction.
And at feature, we shouldn't set selection in CreateStyleForInsertText, and
then, it should return new insertion point for InsertText instead of setting
new selection.
MozReview-Commit-ID: BRKWLqTfrvC
--HG--
extra : rebase_source : 2cd025e9d40688f643a843b39512dccc2bb7c4a2
This patch goes through and changes a bunch of places in our tree which mention
this bug to use the new feature, making the methods more strongly typed.
There are probably more places in tree which could be changed, but I didn't try
to find them.
It is unnecessary to get PresShell for nsStyleText, so we can return bool
instead of nsresult and can change it to static method.
MozReview-Commit-ID: LGrdcaJuLO
--HG--
extra : rebase_source : bb6b6d990741c7b478e9699ae84cc6b89a765bf7
Bug 768765 isn't enough for fix. Since Selection::GetAnchorFocusRange can
return nullptr, we should consider this condition.
And I cannot reproduce this using crash test, so I add mochitest for this.
MozReview-Commit-ID: 8Ei5YBIBuWv
--HG--
extra : rebase_source : cd11517f73179d949479716a83baec0e1f492eca
This is regression of bug 1423835.
When I fixed the bug, I accidentally changed the result of
HTMLEditRules::JoinNodesSmart() to use new API. However, it was simple
misunderstand. The original code sets the initial value of result to
{ aRightNode - aLeftNode.Length() } but I understood it as
{ aRightNode - aRightNode.Length() }. Therefore, this patch backs out the
patch only for this line.
MozReview-Commit-ID: 5rD7YFij8v
--HG--
extra : rebase_source : c11770892ab7416b9bf5d3329fc8b7b413387747
This method is not a virtual call, and also looks nicer.
This patch was mostly generated by a Python script, but I manually
cleaned up the code in a few places where statements didn't need to be
split across multiple lines any more.
MozReview-Commit-ID: 8JExxqSRc59
--HG--
extra : rebase_source : df6330a89e8d65dfe7a6fda0c8cb9f9732302efc
We should not use nsIDOMDocument if unnecessary. Because it needs QI to access
nsIDocument.
MozReview-Commit-ID: CMF3tmvBTB9
--HG--
extra : rebase_source : e832023be8d59a2c1e01bd423e6f058b0708dfe9
Also switch the XPCOM-y version of EventTarget::AddEventListner to a
Nullable<bool> for aWantsUntrusted.
The three-arg overload of AddEventListener in ContentFrameMessageManager was
never called, so all the AddEventListener overloads there are not needed.
MozReview-Commit-ID: 4IhqHmPVWzE
We can't have a null content in
ScrollbarActivity::StopListeningForScrollAreaEvents, because only viewport
frames have a null GetContent().
MozReview-Commit-ID: 9iAg0ivVqqG
For nsCSSAnonBoxes.cpp, nsCSSPseudoElements.cpp, nsDirectoryService.cpp, the
corresponding .h file includes nsStaticAtom.h. For the other files in this
patch, nsStaticAtom.h is not needed at all.
MozReview-Commit-ID: IpMmbXwZHhu
--HG--
extra : rebase_source : 46d0a6b40a41ee233adad7c205cf907fa27de34a
This is a simple bug of internal API of HTMLEditor. HTMLEditor::GetBlock()
tries to retrieve nearest ancestor block node (including itself) of a node.
HTMLEditor::GetBlock() may have ancestor limiter typically it's active
editing host to prevent to modify editing host or its ancestor accidentally.
However, it forgets to call HTMLEditor::GetBlockNodeParent() with the given
ancestor limit node. Therefore, if editing host is an inline element and
its parent is a block element, the editing host is split accidentally.
MozReview-Commit-ID: Ermmxdnk4KB
--HG--
extra : rebase_source : c9b57c5bb28cd63b6f16702317f7ddb7fb5a26f6
To reduce QI, I would like to replace nsIDOMNode with nsINode. And some
parameters in *DataTransder.cpp's methods is unused (it uses as nullptr),
so we should remove these parameters.
Also nsIDOMNodeList is unused now, so we should remove this including.
MozReview-Commit-ID: 1QTIkxDazjJ
--HG--
extra : rebase_source : 3961e897fcaa96975facc822821f1e223cab358d
nsIClipboardDragDropHooks and nsIClipboardDragDropHookList allow XUL apps
to customize drag and drop operation and paste operation. However, this
feature was used only by ChatZilla and it doesn't work on Gecko anymore.
So, we can get rid of them from our tree.
MozReview-Commit-ID: Ibs3V1gI8Ry
--HG--
extra : rebase_source : 83428293d59aaca432d76c71b214aa7799f7f9de
nsIEditor.numberOfUndoItems and nsIEditor.numberOfRedoItems are shortcut
property for nsITransactionManager.numberOfUndoItems and
nsITransactionManager.numberOfRedoItems of the editor. However, anybody
uses nsITransactionManager directly. So, we can get rid of them.
MozReview-Commit-ID: 70J0bsxDNCC
--HG--
extra : rebase_source : fd0847687fe595b257b0256a5f1faa5f2df5f972
nsITransactionListener::AddListener() and
nsITransactionListener::RemoveListener() are of course virtual methods.
Additionally, they are safe to call without grabbing the TransactionManager's
instance with local variable. Therefore, if EditorBase has methods to
add/remove transaction listener to/from its transaction manager, we don't
need EditorBase::GetTransactionManager() anymore.
So, this patch adds AddTransactionListener() and RemoveTransactionListener() to
EditorBase and TransactionManager, and remove
EditorBase::GetTransactionManager() (not nsIEditor's one).
MozReview-Commit-ID: FkPa1YgfagD
--HG--
extra : rebase_source : 8ef7796136804e3d7604c5ca5417fb3379606b93
nsIEditor::EnableUndo() and nsITransactionManager::Clear(),
nsITransactionManager::SetMaxTransactionCount() are called a lot but they are
virtual and some of or all of them are called once. There should be each
non-virtual method to do what each root caller wants. Therefore, this patch
adds EditorBase::EnableUndoRedo(), EditorBase::DisableUndoRedo(),
EditorBase::ClearUndoRedo(), TransactionManager::EnableUndoRedo(),
TransactionManager::DisableUndoRedo() and TransactionManager::ClearUndoRedo().
Note that this patch makes TransactionManager won't clear mUndoStack nor
mRedoStack if mDoStack is not empty. This is checked only by
TransactionManager::SetMaxTransactionCount() but according to the comment,
TransactionManager::Clear(), TransactionManager::UndoStack() and
TransactionManager::RedoStack() should check it too.
MozReview-Commit-ID: 6qBZOQNwdhw
--HG--
extra : rebase_source : 3249137f7acca0b4698713ab732774140bcc27e8
EditorBase::Undo() and EditorBase::Redo() implement only undo/redo function.
TextEditor::Undo() and TextEditor::Redo() call them with calling some
notification methods. However, this causes redundant AutoRules instance
creation and doesn't make sense to separate them under current design.
Therefore this patch merges them into TextEditor. Unfortunately, they are
XPCOM methods but we cannot implement proper overloads of non-virtual since
they are already minimized design. Fortunately, reducing only one virtual
call per undo/redo isn't so effective. So, let's keep simpler design.
Additionally, this patch makes them stop committing composition because
Chrome does not commit composition even if "undo"/"redo" is requested with
execCommand() during composition and it doesn't make sense to try to
undo/redo after committing composition since first undoable transaction
becomes the committing composition and committing composition causes
removing all transactions from redo transaction queue.
MozReview-Commit-ID: 78qlV2I9Lzk
--HG--
extra : rebase_source : 545c787d47fe02bf7e085be9d3ae028816750e69
Now, both TransactionManager.h and TransactionStack.h are exposed. So,
TransactionManager::GetNumberOfUndoItems() and
TransactionManager::GetNumberOfRedoItems() can be rewritten with non-virtual
inline methods because they just return mUndoStack.GetSize() and
mRedoStack.GetSize(). Then, we can implement EditorBase::NumbeOfUndoItems(),
EditorBase::NumberOfRedoItems(), EditorBase::CanUndo() and
EditorBase::CanRedo() as inline methods.
MozReview-Commit-ID: 3CJd0VrlvFY
--HG--
extra : rebase_source : 6848d80a395f1c161e10bfb50d15bd63de288095
Then, all classes in editor/txmgr is now in mozilla namespace and all
headers which are included by other directory are now exposed. So,
we can remote local includes from other directories now.
MozReview-Commit-ID: Kdb1c4Hp9Sy
--HG--
rename : editor/txmgr/nsTransactionStack.cpp => editor/txmgr/TransactionStack.cpp
rename : editor/txmgr/nsTransactionStack.h => editor/txmgr/TransactionStack.h
extra : rebase_source : 75035e9e618680af9188820595ab050b612a456f
A lot of methods take |const EditorRawDOMPoint&| as their argument. However,
some of them are called with EditorDOMPoint::AsRaw(). This is not good for
performance because:
1. Needs to create temporary instance of EditorRawDOMPoint.
2. EditorRawDOMPoint::AsRaw() may be used by simple mistake.
3. Such methods may call EditorRawDOMPoint::Offset(), however, it's not copied
to the original EditorDOMPoint instance. So, callers may need to compute
offset again.
So, such methods should be changed to template methods if they are not virtual
method and AsRaw() should be gotten rid of for prevent it looking not expensive.
MozReview-Commit-ID: DAqqW4a2EMS
--HG--
extra : rebase_source : 120b920477fe6e7231271411a00994325acdb842
This patch basically does:
* remove StyleSetHandle and its corresponding files
* revisit #includes of related header files and change correspondingly
* change nsIPresShell::mStyleSet to be UniquePtr<ServoStyleSet>
* change the creating path of ServoStyleSet to pass UniquePtr
* change other mentions of StyleSetHandle to ServoStyleSet*
* remove AsServo() calls on ServoStyleSet
Some unfortunate bits:
* some methods of (Servo)StyleSet only accepts ServoStyleSheet while
many places call into the methods with StyleSheet, so there are many
->AsServo() added to sheets
MozReview-Commit-ID: K4zYnuhOurA
--HG--
extra : rebase_source : 459e8efeb171adad089d94272e143e8c244bd279
extra : source : 65ba2f174fcf7dba4e59c00ee8908b1bd0820a48
When calling UninitSpellChecker during calling UpdateDictionary, this crash
occurs. Since Thunderbird calls UninitSpellChecker by [Recheck Text] button,
this only occurs on Thunderbird.
After calling UninitSpellChecker, we should not update dictionary.
MozReview-Commit-ID: K4SPJ5FDo8n
--HG--
extra : rebase_source : d760c6472f56cef520c399e8c1f20536c3a22e36
When calling UninitSpellChecker during calling UpdateDictionary, this crash
occurs. Since Thunderbird calls UninitSpellChecker by [Recheck Text] button,
this only occurs on Thunderbird.
After calling UninitSpellChecker, we should not update dictionary.
MozReview-Commit-ID: K4SPJ5FDo8n
--HG--
extra : rebase_source : 67fa439e2a4767502ca84095754150d513a939b2
extra : amend_source : 1b065ebe275cefc02809478eb7d6d807f19dbbee
The DOMMatrix.cpp changes are because it was sneaking in headers via another
unified file.
MozReview-Commit-ID: GPp9WOywI5D
--HG--
rename : dom/base/nsGenericDOMDataNode.cpp => dom/base/CharacterData.cpp
rename : dom/base/nsGenericDOMDataNode.h => dom/base/CharacterData.h
We'll start to dispatch keydown event and keyup event even during composition.
So, for testing those events won't break our UI, we should make
EventUtils.synhtesizeComposition() and EventUtils.synthesizeCompositionChange()
dispatch keydown event and keyup event even if callers don't specify keyboard
event explicitly.
Typically, "keydown" event is marked as "processed by IME", i.e., keyCode
value is set to DOM_VK_PROCESSKEY and key is set to "Process", with our
widget which handles native IME and key input. On the other hand, "keyup"
is NOT marked as so.
Therefore, this patch makes TextInputProcessor emulates this behavior without
any new special flags. And for making possible to emulate special cases,
this patch adds two flags to nsITextInputProcessor. One is
KEY_DONT_MARK_KEYDOWN_AS_PROCESSED. The other is KEY_MARK_KEYUP_AS_PROCESSED.
Unfortunately, those flags have opposite meaning but this must be better than
making necessary to one flag for emulating usual keydown/keyup events.
Finally, this makes some tests specify better keyboard information to
synthesizeComposition() and synthesizeCompositionChange() to emulate
actual keyboard events during composition.
MozReview-Commit-ID: ItYaXILkNQE
--HG--
extra : rebase_source : e50cc77c1efbc12686d7ea334d41926c7392b30d
Except table access and XPCOM methods for c-c, tests and etc, we can remove
more nsIDOMElement usages to avoid QI.
MozReview-Commit-ID: HO5kAaZAs6Q
--HG--
extra : rebase_source : 41ede0bace33504ad852dc4e0016ea346cd7bdee
Before bug 1413181, HTMLEditRules::SplitMailCites() receives left node of
split node with |leftCite| from SplitNodeDeep(). However, the out argument
was removed by the bug and now, it can be retrieved with
SplitNodeResult::GetPreviousNode(). Its result is used for creating <br>
element etc, but not set to |leftCite| but HTMLEditRules::SplitMailCites()
still checks if |leftCite| is empty to remove it from the DOM tree.
So, now, both |leftCite| and |rightCite| are not necessary and
HTMLEditRules::SplitMailCites() should use |previousNodeOfSplitPoint|
instead of |leftCite|.
MozReview-Commit-ID: 408MJt6X1IV
--HG--
extra : rebase_source : fa6095ccc972d33afe8deb0f124adffea7371f4e
EditorBase::GetStartNodeAndOffset() and EditorBase::GetEndNodeAndOffset() are
just wrappers of EditorBase::GetStartPoint() and EditorBase::GetEndPoint().
They may *compute* offset in the container node even if some callers don't
need the offset. Therefore, we should get rid of them and make all callers
use EditorBase::GetStartPoint() or EditorBase::GetEndPoint() directly.
Note that EditorBase::GetStartNodeAndOffset() and
EditorBase::GetEndNodeAndOffset() returns NS_ERROR_FAILURE if
EditorBase::GetStartPoint() or EditorBase::GetEndPoint() returns not set point.
Therefore, checking the result is set equals checking the old nsresult as
an error.
MozReview-Commit-ID: JLwqRMFLjHC
--HG--
extra : rebase_source : 0eb6bf4ba80e8139c6b9f36723d77d23f2b9099e
There are 2 callers of TextEditRules::CheckBidiLevelForDeletion(). One of them
will start to use EditorRawDOMPoint. Therefore, making it take
|const EditorRawDOMPoint&| instead of |nsINode*| and offset in it keeps the
caller simpler.
MozReview-Commit-ID: DRJXo8gnzba
--HG--
extra : rebase_source : a64d1033699245f54a8f8e6a9b93457e12f33e6c