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
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
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
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
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
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