It is no reason to use custom atom instead of nsGkAtoms now, so we should
use nsGkAtoms instead.
MozReview-Commit-ID: 9slsZtLDNKH
--HG--
extra : histedit_source : 8ad70ff1adfa145bc0e8da3c6f43f3dba9b558f1
There are four things that must be provided for every static atom, two of which
have a macro:
- the atom pointer declaration (no macro);
- the atom pointer definition (no macro);
- the atom char buffer (NS_STATIC_ATOM_BUFFER);
- the StaticAtomSetup struct (NS_STATIC_ATOM_SETUP).
This patch introduces new macros for the first two things: NS_STATIC_ATOM_DECL
and NS_STATIC_ATOM_DEFN, and changes the arguments of the existing two macros
to make them easier to use (e.g. all the '##' concatenation now happens within
the macros).
One consequence of the change is that all static atoms must be within a class,
so the patch adds a couple of classes where necessary (DefaultAtoms, TSAtoms).
The patch also adds a big comment explaining how the macros are used, and what
their expansion looks like. This makes it a lot easier to understand how static
atoms work. Correspondingly, the patch removes some small comments scattered
around the macro use points.
MozReview-Commit-ID: wpRyrEOTHE
--HG--
extra : rebase_source : 9f85d477b4d06c9a9e710c757de1f1476edb6efe
Because it's the type we use to set up static atoms at startup, not the static
atom itself.
The patch accordingly renames some parameters, variables, and NS_STATIC_ATOM,
for consistency.
MozReview-Commit-ID: 1a0KvhYNNw2
--HG--
extra : rebase_source : 5c66e5b2dfe053a368bf3584d957198aec4cce91
Since if the container is not a container node like a text node or the offset
is same as the length, child at the offset can be nullptr.
MozReview-Commit-ID: DCnFwUjNgk7
--HG--
extra : rebase_source : 48823390645d79db391dcaf64dab59e754b680a5
|selChild| should be a node which is at |curOffset| in |curNode|, however,
it's not updated when |curOffset| is updated by a call of CreateBRImpl(). So,
it should be next sibling of the created br node.
MozReview-Commit-ID: IVfTjVMp3lB
--HG--
extra : rebase_source : fbc355e3c0425a495c78c3c028308dac26617283
Editor sometimes extracts atom to string to compare element name.
It is unnecessary to use atom directly.
MozReview-Commit-ID: FEvyiIeaozs
--HG--
extra : rebase_source : 4418d0c82fa4fedd814b914f2cf3a86d74ad9835
When SplitNode returns nullptr, GetAsText causes crash. So we should check
error before casting by GetAsText.
MozReview-Commit-ID: 8E1OPSRZ2x5
--HG--
extra : rebase_source : 48a067bd080e7a68e9d469c07d3b744508dae91f
1405747.html is kind of same issue. But when editing 1405747.html, the crash doesn't occur. So I keep original HTML by jsfuzzy.
MozReview-Commit-ID: 9BcUkWeBlr5
--HG--
extra : rebase_source : 1bac60293d3b4997a380cf625c6492db22f60160
extra : histedit_source : eae38e2d69e0705545acf1ef1f2d04e7977b8899
GetNodesForOperation returns node array from current selection. So some nodes in this array might have no parent node. We should ignore such as orphans.
MozReview-Commit-ID: 3OK0CUv5QOe
--HG--
extra : rebase_source : 59636177113ad5d3f9789ca22a6a96938e4cf486
extra : histedit_source : fd4fd140a24a8dc5a63fceeb25faba827c317683%2C6ed479239be0a9043d05170231c6613b04cb0d26
(Path is actually r=froydnj.)
Bug 1400459 devirtualized nsIAtom so that it is no longer a subclass of
nsISupports. This means that nsAtom is now a better name for it than nsIAtom.
MozReview-Commit-ID: 91U22X2NydP
--HG--
rename : xpcom/ds/nsIAtom.h => xpcom/ds/nsAtom.h
extra : rebase_source : ac3e904a21b8b48e74534fff964f1623ee937c67
Starting from bug 1297414, HTMLEditor treats <div> container as same as <p>
container at inserting a line break. This new behavior is check in WPT.
So, it's better to use the new behavior for compatibility with other browsers.
However, we're still using <br> as default paragraph separator for backward
compatibility even though this is non-standard behavior.
So, although, the old behavior is odd, we should keep treating them differently
in the backward compatibility mode. Actually, this behavior change causes
an incompatibility problem in Gmail, and may be in other web apps.
MozReview-Commit-ID: INCihKYmcPd
--HG--
extra : rebase_source : 874e41ddf7bbedbea2c7af79285ea79fbc48f0f2
This patch adds an overload to nsIContentIterator::Init which accepts
RangeBoundary objects, and modifies the codepath to avoid using the offset of
the start or end nodes to construct the nsIContentIterator.
MozReview-Commit-ID: 5ZqKeiUunoN
This might be regression by bug 1319340, but there is crash signature from old version. We should check whether focus node and anchor node aren't null.
MozReview-Commit-ID: J7npxN5kC9G
--HG--
extra : rebase_source : e2f19690d529abc1a8e2852a5ed826b0caa39244
This is a typo bug of Bug 1053779 Part 2. ConvertListType might return NS_OK
even if ReplaceContainer doesn't return valid value.
So, to clean up code, we should return Element instead of nsresult since out
parameter of this function is Element only.
MozReview-Commit-ID: 44UHETzcdGy
--HG--
extra : rebase_source : ab76486505cb4e7caea3fb99e11fccd606878f02
This patch merges nsAtom into nsIAtom. For the moment, both names can be used
interchangeably due to a typedef. The patch also devirtualizes nsIAtom, by
making it not inherit from nsISupports, removing NS_DECL_NSIATOM, and dropping
the use of NS_IMETHOD_. It also removes nsIAtom's IIDs.
These changes trigger knock-on changes throughout the codebase, changing the
types of lots of things as follows.
- nsCOMPtr<nsIAtom> --> RefPtr<nsIAtom>
- nsCOMArray<nsIAtom> --> nsTArray<RefPtr<nsIAtom>>
- Count() --> Length()
- ObjectAt() --> ElementAt()
- AppendObject() --> AppendElement()
- RemoveObjectAt() --> RemoveElementAt()
- ns*Hashtable<nsISupportsHashKey, ...> -->
ns*Hashtable<nsRefPtrHashKey<nsIAtom>, ...>
- nsInterfaceHashtable<T, nsIAtom> --> nsRefPtrHashtable<T, nsIAtom>
- This requires adding a Get() method to nsRefPtrHashtable that it lacks but
nsInterfaceHashtable has.
- nsCOMPtr<nsIMutableArray> --> nsTArray<RefPtr<nsIAtom>>
- nsArrayBase::Create() --> nsTArray()
- GetLength() --> Length()
- do_QueryElementAt() --> operator[]
The patch also has some changes to Rust code that manipulates nsIAtom.
MozReview-Commit-ID: DykOl8aEnUJ
--HG--
extra : rebase_source : 254404e318e94b4c93ec8d4081ff0f0fda8aa7d1
Removes the nsIDOMHTMLObjectElement XPCOM interface, replacing it with
HTMLObjectElement and FromContent conversion usage.
MozReview-Commit-ID: dmsjSO97uh
--HG--
extra : rebase_source : 9b2c25b8681f754bc34233afccdb6fc5d38f0804
It a stateless wrapper around static methods in nsHTMLTags and nsHTMLElement,
and hence an unnecessary layer of indirection that just adds complexity and
slowness. This patch removes it, cutting almost 300 lines of code.
This requires making nsElementTable.h an exported header, to expose the
nsHTMLElement methods.
--HG--
extra : rebase_source : abbcb8e5001389affbf717092213b898673db07f
Its return value is never used, and most implementations return nullptr anyway.
MozReview-Commit-ID: 8rxC053mmE8
--HG--
extra : rebase_source : 61a0b8b1373396182efd27d3c01b96e5e5541364
After applying part 1 fix, it doesn't pass test_bug430392.html like the following..
1. content is <span contenteditable=false>A</span>[caret] ;
2. [VK_RETURN]
3. content is <span contenteditable=false>A</span><br>; <- whitespace is removed
Since we started to treat readonly text nodes as WSType::special with previous patch, WSRunObject::InsertBreak doesn't convert space (after caret) to NBSP because WSRunObject::InsertBreak does it only when inserted position isn't first text run object.
So even if this is first text run object, space after caret should be converted to NBSP.
MozReview-Commit-ID: Hj0i3wm45c3
--HG--
extra : rebase_source : 2d0ae7c47c6187e56d6c29e8eb48974f7ab7ff72
This bug occurs that WSRunObject::PrepareToDeleteRangePriv() calls WSRunObject::ConvertToNBSP for non-editable text node.
Actually, even if text node isn't editable, WSFragment::mType becomes WSType::text now. So, whitespace only node at the end of contenteditable=false is treated as WSType::normalWS, i.e., treated as editable.
So text node in contenteditable=false should treated as WSType::special which means a non-editable inline object. Then, WSRunObject won't create object chunk of WSType::normalWS for text node in contenteditable=false.
MozReview-Commit-ID: GOjxax8KvDD
--HG--
extra : rebase_source : e5fff30a2710c2021d59ce88bf2698ce4ebe2dfc
With previous change, KeyboardEvent is dispatched even when invisible window
has focus. However, nsRootWindow::GetControllerForCommand() returns controller
for focused window even when the window is invisible because it uses
nsFocusManager::GetFocusedDescendant() to retrieve focused window.
Perhaps, we can assume that users won't expect to do something with invisible
window when they type some keys. Then, nsRootWindow::GetControllerForCommand()
should return controller for visible ancestor window if focused window is
invisible.
This patch makes nsFocusManager::GetFocusedDescendant() can return only visible
descendants. However, it already has a bool argument. Therefore, it should
have a flag instead of adding new flag. Most changes of this patch is replacing
its callers.
Then, nsRootWindow::GetControllerForCommand() and nsRootWindow::GetControllers()
should have a bool flag if it should return controller(s) for visible window.
This patch adds a bool flag for it. Fortunately, the interface isn't scriptable.
Finally, this patch makes nsXBLPrototypeHandler::DispatchXBLCommand() and
EventStateManager::DoContentCommandEvent() retrieve controller for visible
window since they are always handles user input.
MozReview-Commit-ID: GygttTHuKRm
--HG--
extra : rebase_source : 1341273c4606298cb9b890b9312d9f5c8a75d144
Skip tests that are expected to fail in both Stylo and Gecko modes. They would unexpectedly "pass" in styloVsGecko mode when comparing the two failures, which is not a useful result.
MozReview-Commit-ID: 3mOpjU225Q1
--HG--
extra : rebase_source : 22bb5d4e3c5138ef832995eaf5716824f4707ffe
extra : source : d40fb20c9a49d0797c0eeae613a04912b12a28f7
As written, these functions will leak if they are passed strings that don't
match static atoms. In practice, all strings passed *do* match static atoms,
but let's fix it anyway in case that changes in the future.
--HG--
extra : rebase_source : 01685428e7dfc577e63bb6423382817359623151
Skip tests that are expected to fail in both Stylo and Gecko modes. They would unexpectedly "pass" in styloVsGecko mode when comparing the two failures, which is not a useful result.
MozReview-Commit-ID: 3mOpjU225Q1
--HG--
extra : rebase_source : 0c307639c3626af3b6b43e05d3ee73d08b3f47ce
In the old design, EditorBase::mRootElement is initialized when
nsIEditor::GetRootElement() is called. Therefore, EditorBase::GetRoot()
calls if mRootElement is nullptr.
However, mRootElement is now initialized when EditorBase::UpdateRootElement()
is called and it's always initialized when EditorBase::Init() is called.
So, EditorBase::GetRoot() doesn't need to call nsIEditor::GetRootElement()
anymore.
MozReview-Commit-ID: 6dNEJaGNMZe
--HG--
extra : rebase_source : ed29488cfd1434fb200387706ca5a96cb2185090
When using contenteditable with spellchecker (it is by default), spellchecker will be initialized by mozilla::EditorEventListener::Focus. This method will call nsEditorSpellCheck::UpdateCurrentDictionary, but this method seems to be slow.
DictionaryFetcher::Fetch gets nsIContentPrefService2 that is implemented by JavaScript, so we should create nsIContentPrefService2 out of Fetch method.
MozReview-Commit-ID: 1fxug0sqD72
--HG--
extra : rebase_source : c46a54f9fc811aace20c54c4a3e468a83c2530d2
It's a bit strange for the editor to distrust the parser service in this way.
The double-checking seems unnecessary, especially given that it is *buggy*: it
incorrectly includes `col`, `colgroup`, and `legend` as block elements, but
excludes `pre`. (It must only be called in situations where these
incorrectly-classified elements are not passed in, otherwise it would have
triggered by now.) So this patch removes it.
The patch also removes `li` and `pre` from the IsAnyOfHTMLElements() test in
HTMLEditor::NodeIsBlockStatic. Contrary to what the comment in
NodeIsBlockStatic() says, they *are* identified as block elements by the parser
service.
--HG--
extra : rebase_source : c9bb3c9e07320fafed17942229c316f41ac2a0a6
editor/reftests/input-text-onfocus-reframe-ref.html is sometimes failed due to "image comparison, max difference: 1, number of differing pixels: 1".
As long as I check both images, I don't know why focus ring is different. But this is 1 pixel only diff, so we should use fuzz-if.
MozReview-Commit-ID: 5SrjorXEBW
--HG--
extra : rebase_source : d6fbb2f3a5ea2bff5ee6c2b39909831830f5d47c
EditorBase::EndPlaceholderTransaction() has hidden caret. However, it doesn't
do it anymore. However, bug 805697 didn't remove unnecessary code that
retrieves and hold nsIPresShell and nsCaret. This patch removes them.
MozReview-Commit-ID: Eh9pbf8p2bZ
--HG--
extra : rebase_source : e766906089af1cd3c6efa95b82e3b126ae097ab2
GetFirstSelectedCell and GetNextSelectedCell allow that 1st parameter is nullptr when current range is unnecessary. So we should use nullptr when it is unused.
MozReview-Commit-ID: BuI7ds47h0U
--HG--
extra : rebase_source : 4cb67aa15c5b5a7692c7e5eb43976c8e7a7884e4
Except to nsTextServicesDocument.cpp, we replace nsIDOMRange::GetStartContainer and nsIDOMRange::GetEndContainer with nsRange::GetStartContainer and nsRange::GetEndContainer.
Since nsTextServicesDocument.cpp still uses a lot of nsIDOMNode, I will change it by new bug.
MozReview-Commit-ID: 9x1oajmabca
--HG--
extra : rebase_source : c22072a39c907df631025a423c6302df2047e824
Replace it with NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION, because it
has been the same for a while.
MozReview-Commit-ID: 5agRGFyUry1
--HG--
extra : rebase_source : 5388c56b2f6905c6ef969150f0c5b77bf247624d
nsIHTMLEditor's addDefaultProperty(), removeDefaultProperty(),
removeAllDefaultProperties() methods are never used -- not from C++ code or
script, in either mozilla-central or comm-central.
So this patch removes them. This means that HMLTEditor::mDefaultStyles is never
used, so the patch removes it and all the code that manipulates it as well.
--HG--
extra : rebase_source : 76634ce2bb2d94534b8d7f299c4ebd6a83b66637
HTMLEditRules::NormalizeSelection uses nsIDOMNode for node handling, so we replace with nsINode, then use Selection::Extend and Selection::Collapse.
MozReview-Commit-ID: 6Ijo19vTwRi
--HG--
extra : rebase_source : 3171ed5808d9045b268cc76989c7d06ea220d393
extra : histedit_source : f3a1af1f84cceb80200a3965385dfb1d036c9e60
Except to HTMLEditRules::NormalizeSelection, I replace nsISelection::Extend with Selection::Extend.
MozReview-Commit-ID: H83zpvAo5Xa
--HG--
extra : rebase_source : b217dd1d506229d848126b9c2494d1b4f9dc3a35
extra : histedit_source : 8999bc5b1b1edfe7e48a432d52640b8181490624
I would like to remove more dependency of old nsISelection interface from editor if possible. So we can replace nsISelection::GetRangeCount with Selection::RangeCount.
MozReview-Commit-ID: 2Mh5ceQI2om
--HG--
extra : rebase_source : 03c8a5b49e2929b0ce6c6af8b78c9677a55a14c4
extra : histedit_source : ca7741379c7cc5b7b938aad22a57f419a2442fd3
nsISelectionController::SELECTION_* are declared as bit-mask. However, no
methods of nsISelectionController treat them as bit-mask and these
values need a switch statement in nsFrameSelection to convert SelectionType to
array index of nsFrameSelection::mDOMSelections because it's too big to create
an array to do it. Additionally, this conversion appears profile of
attachment 8848015.
So, now, we should declare these values as sequential integer values.
However, only nsTextFrame uses these values as bit-mask. Therefore, this patch
adds new type, SelectionTypeMask and creates new inline method,
ToSelectionTypeMask(SelectionType), to retrieve mask value for a SelectionType.
MozReview-Commit-ID: 5Za8mA6iu4
--HG--
extra : rebase_source : 86617c1f5fa23166458f4353cb834f9e7c5b131b
nsIHTMLEditor has several scriptable methods (addDefaultProperty(),
removeDefaultProperty(), etc.) that have nsIAtom parameters. We're in the
process of deCOMtaminating nsIAtom (bug 1392883) so these methods need to be
changed.
This patch does the following.
- It changes those methods to take an AString instead of an nsIAtom.
- For each existing method, it adds to HTMLEditor a new C++ method of the same
name that takes an nsIAtom parameter.
- It updates TextEditorTest.cpp to use strings instead of atoms, in order to
keep using the XPIDL methods.
- It updates test_bug1140105.html to pass strings instead of atoms to
getInlineProperty(). This removes the use of nsIAtomService.
--HG--
extra : rebase_source : e005c3b5a08207b3d5d5fb55c47c8bc475b33453
There is no reason that SetTextRangeStyle is defined at nsISelectionPrivate. Also, SetTextRangeStyle isn't scriptable, and is called from CompositionTransaction::SetIMESelection only. So we should move this to Selection.
MozReview-Commit-ID: FCOA6wVhvYZ
--HG--
extra : rebase_source : 64eb9e5fb973195b2c87ab4eb296685c8a4d0319
nsIContentIterator::Init() takes nsRange but it's too expensive for some users.
So, there should be another Init() which can be specified a range in DOM tree
with 2 pairs of nsINode* and uint32_t.
MozReview-Commit-ID: 6JXic0KOM2d
--HG--
extra : rebase_source : 28ff355a2aa0dcb5d65495806ef8c67f1da642ea
We should not be declaring forward declarations for nsString classes directly,
instead we should use nsStringFwd.h. This will make changing the underlying
types easier.
--HG--
extra : rebase_source : b2c7554e8632f078167ff2f609392e63a136c299
Since we enable lazy frame construction for editable region, whitespace only node might not have frame even if editable. This test has whitespace only node into contenteditable, we need adjust caret operation for this test.
MozReview-Commit-ID: GQfKiYdYOdi
--HG--
extra : rebase_source : 0685d724f6af050d79c1cf007c7ee48c05da14ac
These are all simple cases, with similarities to previous patches in this
series.
--HG--
extra : rebase_source : 6ef36382df9fef217d5cb737e218d65ac062f90a
When parent node of selected node is null, crash might occur in GetCSSBackgroundColorState. So when parent is null, we should return default value. In this situation, Edge and Blink don't throw error, Gecko shouldn't return error too.
MozReview-Commit-ID: 5C6jSAFkCso
--HG--
extra : rebase_source : 0185f9fb5fde92eee5611e6bb95e8676c10b135c
nsTextFrame stores text as single byte character array if all characters are
less than U+0100. Although, this saves footprint, but retrieving and modifying
text needs converting cost. Therefore, if it's created for a text node in
<input> or <textarea>, it should store text as char16_t array.
MozReview-Commit-ID: 9Z82rketT7g
--HG--
extra : rebase_source : 59f59ac1488c21a57d95d253cc794a011d672c95
EditorBase::GetSelection() sometimes appears in profile. So, it shouldn't be
called in nsIEditor::EndOfDocument() if the callers of
nsIEditor::EndOfDocument() has a pointer to Selection.
This patch adds EditorBase::CollapseSelectionToEnd() for the internal method
and make all callers of nsIEditor::EndOfDocument() use it.
MozReview-Commit-ID: 8H4ThxzdKDf
--HG--
extra : rebase_source : 7436d7f286351fa9c91175b40e686f7ca1f3c69f
In most cases, TextEditRules::CollapseSelectionToTrailingBRIfNeeded() doesn't
use the index anymore. Therefore, it should stop using
EditorBase::GetNodeLocation() and use EditorBase::GetChildOffset() only when
the offset is necessary.
MozReview-Commit-ID: 9vGcLnTUnsu
--HG--
extra : rebase_source : af0cdad3a1905bf2e5654a109aa4037ec70b422b
nsINode::GetChildAt() is too expensive if it's used for next sibling of a node.
This patch makes it use nsINode::GetNextSibling() instead.
MozReview-Commit-ID: CAC7gFNo77w
--HG--
extra : rebase_source : 185457b910e2e09c58a6f02525ae61aff149511c
nsINode::IndexOf() is expensive especially when it's in a hot path, it's too
expensive. So, EditorBase::GetChildOffset() and EditorBase::GetNodeLocation()
should check child's siblings first. If some of them are nullptr, it means
that it's first child or last child of the parent.
Note that EditorBase::GetChildOffset() may return wrong index if it's called
while aChild is being removed from aParent or aParent isn't actual parent of
aChild. However, there are MOZ_ASSERTs to ensure value isn't -1. Therefore,
it's safe to assume that aParent is always the parent of aChild and it won't
be called from ContentRemoved() of mutation observers.
MozReview-Commit-ID: 8JdYWuZbHe5
--HG--
extra : rebase_source : 6ded91a3aa8b00ab4d2d544c2c392d88cb769cef
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is only used in ways that nsCStrings can also be used
(i.e. no null checks or implicit conversions to |char*|).
In every case the patch trivially replaces the nsXPIDLCString with an
nsCString. (Also, there are a couple of unused nsXPIDLCString variables that
the patch simply removes.)
test_bug655636.html refers gBrowser, however, it's available only in chrome
process and it's referred only for listening to "pageshow" event instead of
"load" event of the data URI. So, we must be able to use "unload" event of the
previous URL instead.
Although, this testcase (even without this change) won't cause crash even if
backing out the patch for bug 635636 anymore.
MozReview-Commit-ID: B8qOwVZqZQm
--HG--
extra : rebase_source : d383181886152684a8bf9c2caf7248d5f7582c0a
AutoPlaceHolderBatch can take EditorBase class and its inherited class, AutoEditBatch, can be removed if we implement other constructor which doesn't take transaction name.
Additionally, nsIEditor::(Begin|End)PlaceHolderTransaction() are referred only by AutoPlaceHolderBatch. Therefore, they can be non-public methods and removed from nsIEditor interface.
Note that this patch also repalces "PlaceHolder" with "Placeholder" since it's a word.
MozReview-Commit-ID: 5dw3kcX3bOx
--HG--
extra : rebase_source : e926cc1c2ebea70eb08e43778a8b52912b559b7b
nsITableEditor is now a builtin class. So, it's implemented only by HTMLEditor. Therefore, AutoSelectionSetterAfterTableEdit can use HTMLEditor.
Then, nsITableEditor.setSelectionAfterTableEdit() can be removed from nsITableEditor and moved to HTMLEditor as non-virtual method since nobody uses it from JS.
MozReview-Commit-ID: KnN6Fw4TYyn
--HG--
extra : rebase_source : 48412a5f81f30d9ada47550fdb4d1ee0d88de6f4
This test is turned off by bug 1269209 on e10s. But there is no exactly reason why this test on e10s is turned off.
Although I run this test on e10s now, it seems to pass this. So we should turn on this test even if e10s.
MozReview-Commit-ID: JHQP2ZYvsHL
--HG--
extra : rebase_source : 2bc45f0d2b5cc99bad93267f40191866264af414
nsIHTMLDocument::TearingDownEditor() takes nsIEditor as an argument. However, it's not used in it. So, we can remove it.
MozReview-Commit-ID: KUmIsnVGB6H
--HG--
extra : rebase_source : ddd344b9df18e0b33d54d2f99e6335449f55df81
nsEditingSession should treat editor as HTMLEditor in its internal handling.
MozReview-Commit-ID: 51SfY4oeq3p
--HG--
extra : rebase_source : 90535267e62de17755fff9f21b6a0f74244d849a
Some users of HTMLEditor retrieve pointer to editors with nsIEditingSession::GetEditorForWindow() but it returns nsIEditor. So, there should be a method which returns HTMLEditor*.
MozReview-Commit-ID: Bzc1LIlTSDF
--HG--
extra : rebase_source : f6fb3e5852809487883e3e6fedda9580206b2cb5
This matches the spec and Chrome, and seems to bring us closer to Edge
and WebKit as well. It also matches our own behavior for addRange(),
which was changed in bug 1341137.
For collapse and selectAllChildren, we match the tests and browsers, but
the spec is incorrect at the time of this writing:
https://github.com/w3c/selection-api/pull/86
The removeAllRanges test hadn't been updated for the spec change.
MozReview-Commit-ID: DTK8283k5IP
--HG--
extra : rebase_source : 54701e7136c33ebce651d5f74c3dc1d8b944f9a3
Removes nsIDOMHTMLEmbedElement and all references. HTML elements are
now handled by WebIDL. With the deprecation of extensions, XPCOM
interfaces to HTML elements are no longer needed.
MozReview-Commit-ID: DI4XVvdgPDI
--HG--
extra : rebase_source : 74bd92619e3d1db04c3dd40ec3022474fe1d647c
EditorCommands implements common edit commands. So, we can use TextEditor even if the instance is HTMLEditor.
Then, EditorCommands can use non-virtual methods of the concrete classes.
MozReview-Commit-ID: DgKHqC0osRb
--HG--
extra : rebase_source : e9abd7ef8b48cfdc65bbeb56ebe81dc0548005dd
nsComposerCommands uses some simple getter methods. They can be simpler non-virtual methods. So, we should do it.
Note that this changes that EditorBase::GetIsSelectionEditable() won't return error. However, it has returned error only when selection controller isn't available. That means that the selection controller has been destroyed and the editor will be destroyed. So, this must not be problem since it returns false (non-editable) instead and won't break any behavior since the editor won't be editable by users nor JS anymore.
MozReview-Commit-ID: E9ccFspG6na
--HG--
extra : rebase_source : bcd1314cb386fcaf175adabfefde5885decd87c0
Compiler may can optimize to call virtual methods at build time if we call them with concrete classes because some of them may have final keyword.
Even if not so, we can optimize some methods with creating non-virtual methods.
MozReview-Commit-ID: K3bRlc0URml
--HG--
extra : rebase_source : 4a76635c7aed29501f71ae74f3f73e2b22ca219e
All SetState() methods in nsComposerCommands require HTMLEditor. So, it should take HTMLEditor* rather than nsIEditor*.
MozReview-Commit-ID: AVbnRsMsmeY
--HG--
extra : rebase_source : 23bcc585a045a39620102c4fef9c1a9e12b9ea37
Similar to GetCurrentState(), all ToggleState() methods require HTMLEditor. So, they should take HTMLEditor* instead of nsIEditor*.
MozReview-Commit-ID: BwM6WRKFn6Q
--HG--
extra : rebase_source : 425b7b405b5881b97e8113c3ab88e9d0514b6a07
All GetCurrentState() methods in nsComposerCommands require HTMLEditor but its argument is nsIEditor*. So, it should take HTMLEditor* and it shouldn't be called if given editor isn't HTMLEditor since it's virtual method.
MozReview-Commit-ID: HsvYJN8hIxN
--HG--
extra : rebase_source : f8f9c8de902af5311771b71a96c76d63325970a5
nsIEditor is still first contact with editor class for some modules. They should be accessible to the concrete classes without QI. Therefore, nsIEditor should have As*Editor() methods.
Additionally, this adds AsEditorBase(). That is always implemented but it might be necessary for some files for minimizing its include files.
MozReview-Commit-ID: 8WqkDJLiVDs
--HG--
extra : rebase_source : e51282df244efad62bc6fe04ab449e3beab440f9
CompositionTransaction forgets to call EndBatchChanges when GetSelectionController returns error, so we should use RAII class instead.
MozReview-Commit-ID: HI9kutRVzx6
--HG--
extra : rebase_source : d276f4349c5a64d4610581ae1a76d160841f7d7b
If we make nsIEditor a builtin class, that means that its instance can be only TextEditor or HTMLEditor. Then, users of nsIEditor can use concrete classes such as EditorBase, TextEditor or HTMLEditor instead. Then, the users can reduce unnecessary QI and a lot of virtual calls if we'll create non-virtual methods.
So, let's make editor related interfaces builtin classes.
MozReview-Commit-ID: 93WfsSDuJiJ
--HG--
extra : rebase_source : 39151eb4ffaaf195fec57234ea84c9f4066c58d1
nsXPIDLStrings are marked as VOIDED upon initialization. Most of these local
nsXPIDLString variables are immediately set via getter_Copies(), which will
either assign a string value (using Adopt()) or do SetIsVoid(). These can be
trivially converted to nsString, which will get the same treatment.
The patch suitably converts the remaining nsXPIDLString local variable as well.
--HG--
extra : rebase_source : 5fff9f2c6844559198f601853f8db08564add7d5
CreateAnonymousElement still uses nsIDOMNode, but we should use nsIContent for it.
MozReview-Commit-ID: 2xgzlE6NVra
--HG--
extra : rebase_source : c93a9acb230604da391f705b0038e3cf7fbd4f23
This method can be extremely hot, so we need to remove all sources of XPCOM
overhead from it. This includes the usages of weak pointers (thanks to the
previous parts), refcounting, and QueryInterface.
I kept the callers hold the selection controller alive by assigning the
return value to an nsCOMPtr in places where the methods called on it could
have a remote chance of messing with the lifetime of objects.
Besides some unnecessary copying and malloc overhead that this removes, it
also removes a call to dom::Text::GetData() which we used to only make to
get the old length of the text node before modifying it. Turns out that
this old length was already obtained once in SetTextImpl().
Currently, HTMLEditRules::SplitParagraph() inserts moz-<br> element when split element and/or new element causes empty line. However, PlaintextSerializer ignores moz-<br> elements. Therefore, empty lines which are created by SplitParagraph() will be removed when it's converted to plaintext.
So, it should insert normal <br> element for placeholder of empty lines instead. Note that moz-<br> elements are appeared as normal <br> elements in the result of Element.innerHTML. Additionally, Chromium always inserts a <br> element for empty block elements which are created by Enter key press. Therefore, using normal <br> element in this case shouldn't cause any compatibility problems.
MozReview-Commit-ID: FNV41zEFWqQ
--HG--
extra : rebase_source : ece6c2e275e2a75d9d2871d62ed4204115792b99
After reframe, SetSelectionAfterTableEdit might be called from RAII class, so we should check whether editor is destroyed.
MozReview-Commit-ID: I4r6kvxgRDZ
--HG--
extra : rebase_source : 4bd71775f02f57573af0f0efd5c1946285e4e4f4
HTMLEditor::TabInTable inserts row element, then it selects a cell. But when enabling lazy frame construction for editable node, it selects invalid cell and table.
Because HTMLEditor::SetSelectionAfterTableEdit doesn't select cell correctly on InsertTableRow().
HTMLEditor::SetSelectionAfterTableEdit uses HTMLEditor::GetCellAt, so it depends on frame. So we need flush frame before calling it.
Also, a comment of HTMLEditor::InsertTableRow is invalid now because we don't use nsresult version of CreateElementWithDefualts.
MozReview-Commit-ID: 698TvmMZgwB
--HG--
extra : rebase_source : 95df12f1f870a2c68d02b24b8758dfe6d381a416
This makes the SetTextTransaction transaction behave more similarly to the rest of
the editor transactions, by making sure the inner transactions don't manipulate
the selections themselves and leave it up to the AfterEdit() method to take care of
adjusting the selection when the entire editing operation is finished.
test_bug795418-*.html depends on clipboard. But these tests aren't subsuite=clipboard and are sometimes failure (bug 1334700, bug 1335221, bug 1339430, bug 1343883 and bug 1348093). So we should move these to subsuite=clipboard to try fixing this.
MozReview-Commit-ID: 1m5dFGZ18a
--HG--
extra : rebase_source : 847b1b7842c32e93c61b8ee572cff16c70adc323
nsIDocument::AdoptNode might to remove all properties. So before destroying editor, NAC property might be already removed. So we have to consider that NAC is removed.
MozReview-Commit-ID: DakRRqrzEtF
--HG--
extra : rebase_source : ce972f1b42b6ff7efdf09b9a70cc1a9d27f128fb
I've been having problems with interdiffs on mozreview lately, so for
ease of review, this patch is being submitted as a seperate patch for
review. Once it is r+'d, it will be folded into the first patch in
this set before landing.
MozReview-Commit-ID: CS9MngaXlBd
--HG--
extra : rebase_source : 6a86fd4f7a66e73497a756976a2562d183002a2a
This is similar like the previous patch, but for the 8-bit string variants.
Also, it changes assignment to Adopt() in GetCString() and GetDefaultCString()
to avoid an extra copy.
--HG--
extra : rebase_source : eba805c3a7b809d5ccd6e853b1c9010db9477667
Because we want to remove nsAdoptingString. We have other variants that don't
use nsAdoptingString, which can be used instead. There are three basic
patterns.
1. The easiest case is when we don't check for success.
> nsAdoptingString s = Preferences::GetString("foo");
> foo(s);
becomes:
> nsAutoString s;
> Preferences::GetString("foo", s);
> foo(s);
2. The next case is when we check if the result is empty.
> nsAdoptingString s = Preferences::GetString("foo");
> if (s.IsEmpty()) { ... }
becomes:
> nsAutoString s;
> Preferences::GetString("foo", s);
> if (s.IsEmpty()) { ... }
3. The final case is when we null check the result.
> nsAdoptingString s = Preferences::GetString("foo");
> if (s) { ... }
becomes:
> nsAutoString s;
> nsresult rv = Preferences::GetString("foo", s);
> if (NS_SUCCEEDED(rv)) { ... }
The patch also avoids some UTF8/UTF16 conversions in a few places.
--HG--
extra : rebase_source : f339b1a3dda4dc93979d38c30c001fbe77485b55
This is basically a cosmetic change; references are the normal way to do string
outparams.
--HG--
extra : rebase_source : ffc5945f269bdcd3d4116755b56713e87a44b6cd
This patch replaces four functions of the name AssignWithConversion which
are essentially wrappers around CopyASCIItoUTF16 and LossyCopyUTF16toASCII
with direct calls to the latter two functions. The replaced functions are:
void nsCString::AssignWithConversion( const nsAString& aData )
void nsString::AssignWithConversion( const nsACString& aData )
void nsTString_CharT::AssignWithConversion(
const incompatible_char_type* aData,
int32_t aLength = -1);
The last of the three exists inside the double-included nsTString* world and
so describes two functions, giving four in total.
This has two advantages:
* it removes code
* at the call points, it makes clear (from the replacement name) which
conversion is being carried out. The generic name "AssignWithConversion"
doesn't make that obvious -- one had to infer it from the types.
The patch also removes two commented out lines from
editor/composer/nsComposerCommands.cpp, that appear to be related. They are
at top level, where they would never have compiled. They look like
leftovers from some previous change.
--HG--
extra : rebase_source : fb47bf450771c3c9ee3341dd14520f5da69ec4f5
It is mainly for avoiding other anonymous element being inserted into
<svg:use>, but in general we probably don't want to insert some random
HTML anonymous element into a non-HTML element.
MozReview-Commit-ID: J5kCUzA7K90
--HG--
extra : rebase_source : 1d38cd9297071b9ba8151eb27d74b56ad540cc49
DOM Standard defines that offset of Range is unsigned long. However, nsRange uses int32_t to them.
This patch makes nsRange use uint32_t instead. However, this patch does NOT allow to set over INT32_MAX as offset values since a lot of users of nsRange cannot treat the values as over INT32_MAX because a lot of internal APIs take int32_t as offsets.
For easier to search such points, this patch adds static_cast<int32_t> to uint32_t variables when they are used for int32_t arguments.
And note that nsContentUtils::ComparePoints() behaves odd. It accepts negative offset and compares such value with valid offset simply. This patch still uses int32_t offset variables in nsRange::CompareNodeToRange() even though it may be negative value if nsINode::IndexOf() returns -1 because the caller of it depends on this behavior.
MozReview-Commit-ID: 8RbOgA86JuT
--HG--
extra : rebase_source : 46d526c6d50dfa2f104439b19b8691477b17a4af