10382 Commits

Author SHA1 Message Date
Mirko Brodesser
9c5b92954c Bug 1649121: part 74) Pass Document instead of HTMLEditor to CreateDocumentFragmentFromPaste. r=masayuki
`CreateDocumentFragmentFromPaste` doesn't need to know about
`HTMLEditor`, `Document` suffices.

Differential Revision: https://phabricator.services.mozilla.com/D88118
2020-08-28 10:27:30 +00:00
Mirko Brodesser
355bcdd416 Bug 1652557: remove failure expectation for "test_resizers_resizing_elements.html" when xorigin iframes and fission are enabled. r=hsivonen
Fixed by bug 1653160.

Differential Revision: https://phabricator.services.mozilla.com/D88563
2020-08-28 09:59:39 +00:00
Masayuki Nakano
5bca4199fb Bug 1660378 - part 9: Avoid QI for getting nsStyledElement pointer r=smaug
The editor modules does QI too many times when it sets or removes some style
with `execCommand` or XPCOM API.  Therefore, there should be an API to
retrieve `nsStyledElement` pointer from `nsINode*`.

Differential Revision: https://phabricator.services.mozilla.com/D87990
2020-08-26 05:29:06 +00:00
Masayuki Nakano
b500d7d549 Bug 1660378 - part 8: Make HTMLEditor::IsSimpleModifiableNode() take Element& instead of nsIContent* r=m_kato
Although it starts to return error if it causes destroying the editor, but
it should not occur because it modifies new and orphan node and it shouldn't
kick any mutation event listeners.  Therefore, this patch makes the callers
handle error as-is rather than ignoring errors except
`NS_ERROR_EDITOR_DESTROYED`.

Differential Revision: https://phabricator.services.mozilla.com/D87989
2020-08-26 04:48:36 +00:00
Masayuki Nakano
bc279d2448 Bug 1660378 - part 7: Make CSSEditUtils::SetCSSEquivalentToHTMLStyle() take nsStyledElement& instead of Element* r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87988
2020-08-26 04:48:32 +00:00
Masayuki Nakano
decd85f7d6 Bug 1660378 - part 6: Make CSSEditUtils::SetCSSProperty() and its callers take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87987
2020-08-26 04:48:28 +00:00
Masayuki Nakano
d03e0e65d8 Bug 1660378 - part 5: Make CSSEditUtils::RemoveCSSInlineStyle() take nsStyledElement& instead of nsINode& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87986
2020-08-26 04:48:25 +00:00
Masayuki Nakano
67e64be5b4 Bug 1660378 - part 4: Make CSSEditUtils::DoElementsHaveSameStyle() take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87985
2020-08-26 04:48:22 +00:00
Masayuki Nakano
2a4a68855c Bug 1660378 - part 3: Make CSSEditUtils::RemoveCSSEquivalentToHTMLStyle() take nsStyledElement& instead of Element* r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87984
2020-08-26 04:48:19 +00:00
Masayuki Nakano
801ca86f89 Bug 1660378 - part 2: Make CSSEditUtils::RemoveCSSPoperty() take nsStyledElement& instead of Element& r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87983
2020-08-26 04:48:16 +00:00
Masayuki Nakano
5d36739f8b Bug 1660378 - part 1: Get rid of CSSEditUtils::GetInlineStyles() r=m_kato
It should take `nsStyledElement&` instead of `const Element&`.  Then, it won't
fail and will just return the result of `nsStyleElement::Style()`.  Therefore,
we can get rid of it.

Note that this patch makes all its callers keep using strong pointer because
I'm not sure whether the layout APIs which are called with them are safe or
not.

Differential Revision: https://phabricator.services.mozilla.com/D87982
2020-08-26 04:48:12 +00:00
Masayuki Nakano
f75a7ec162 Bug 1658536 - part 8: Make AutoBlockElementsJoiner::HandleDeleteCollapsedSelectionAtOtherBlockBoundary() creates another instance of AutoDeleteRangesHandler by itself r=m_kato
When it returns `EditActionIgnored()`,
`AutoDeleteRangesHandler::HandleDeleteAroundCollapsedRanges()` creates another
`AutoDeleteRangesHandler` instance to delete leaf content node in another
block element.  However, this dependency makes developers understand the
behavior harder.  Therefore, we should make the method do it instead.

Differential Revision: https://phabricator.services.mozilla.com/D87439
2020-08-24 03:06:03 +00:00
Masayuki Nakano
68e817dd75 Bug 1658536 - part 7: Make HTMLEditor::HandleDeleteSelection() stop calling DeleteRangesWithTransaction() a fallback when AutoDeleteRangesHandler::Run() returns "ignored" r=m_kato
For avoiding infinite recursive calls, `AutoDeleteRangesHandler` returns
`EditActionIgnored()` when it needs to fall it back to
`DeleteRangesWithTransaction()` after modifying the DOM tree or the ranges
to delete.  However, this makes developers understand the code harder.
And now, with making constructor of `AutoDeleteRangesHandler` manage the
recursive call state, we can make `HandleDeleteSelection()` stop handling
the fallback path.

Differential Revision: https://phabricator.services.mozilla.com/D87438
2020-08-24 03:06:00 +00:00
Masayuki Nakano
fd1b043de1 Bug 1658536 - part 6: Move AutoEmptyBlockAncestorDeleter into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87437
2020-08-24 03:05:56 +00:00
Masayuki Nakano
cf5d24e31e Bug 1658536 - part 5: Move HTMLEditor::HandleDeleteSelectionInternal() into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87436
2020-08-24 03:05:53 +00:00
Masayuki Nakano
0a484e2bdb Bug 1658536 - part 4: Move some methods used only in AutoDeleteRangesHandler into the class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87435
2020-08-24 00:53:32 +00:00
Masayuki Nakano
7a2da49ab3 Bug 1658536 - part 3: Move HTMLEditor::SelectionWasCollapsed into AutoDeleteRangesHandler r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87434
2020-08-24 00:53:13 +00:00
Masayuki Nakano
05434c1073 Bug 1658536 - part 2: Move AutoBlockElementsJoiner and AutoInclusiveAncestorBlockElementsJoiner into AutoDeleteRangesHandler r=m_kato
Even though their method names in stack trace become too long, but we can
guarantee that they are used only at handling deletion.

Differential Revision: https://phabricator.services.mozilla.com/D87433
2020-08-24 00:52:58 +00:00
Masayuki Nakano
cfc4ba0b10 Bug 1658536 - part 1: Move methods called by HTMLEditor::HandleDeleteSelectionInternal() to AutoDeleteRangesHandler r=m_kato
This patch just moves them into the new stack only class and make each of them
take `HTMLEditor&` as their first argument.

Differential Revision: https://phabricator.services.mozilla.com/D87432
2020-08-24 00:52:44 +00:00
Masayuki Nakano
4405418105 Bug 1659717 - Make AutoSetTemporaryAncestorLimiter update cached ranges if selection limiter is updated r=m_kato
If `AutoSetTemporaryAncestorLimiter` sets ancestor limiter of the `Selection`,
existing range which is already cached by `AutoRangeArray` may be changed
into the new limiter.

Therefore, this patch makes `AutoSetTemporaryAncestorLimiter` take
`AutoRangeArray` optionally and reset it only when it sets new limiter for
the performance.

Differential Revision: https://phabricator.services.mozilla.com/D87820
2020-08-24 08:54:56 +00:00
Masayuki Nakano
19c23d725f Bug 1659276 - Make AutoPlaceholderBatch choose whether do or do not ScrollSelectionIntoView r=m_kato
The root cause of this bug is a bug of async `ScrollSelectionIntoView` that
is what it won't be canceled even if web app changes scroll position with
any API.  Fixing it is really risky and this bug affects an existing website.
Therefore, this patch makes the constructors of `AutoPlaceholderBatch` take
whether do or do not `ScrollSelectionIntoView` when it's destructed.  And
makes `HTMLEditor::SetInlinePropertyAsAction()` not request
`ScrollSelectionIntoView` for taking back the traditional behavior.

Note that this patch does not make it an optional argument because it's hard to
guess that it'll run `ScrollSelectionIntoView` automatically.

Differential Revision: https://phabricator.services.mozilla.com/D87819
2020-08-24 06:39:50 +00:00
Chris Fronk
3b7a1daba2 Bug 1647536 - Support ref counted pointers in nsDeque r=froydnj
Adds a new specialization of nsDeque, nsRefPtrDeque for use with
reference counted pointers.

Differential Revision: https://phabricator.services.mozilla.com/D84766
2020-08-22 15:47:59 +00:00
Simon Giesecke
cfd7d0ea9c Bug 1659923 - Avoid unnecessary copies around Base64Encode. r=xpcom-reviewers,necko-reviewers,froydnj,valentin
This also adds some more variants of Base64Encode and Base64EncodeAppend.

Differential Revision: https://phabricator.services.mozilla.com/D87559
2020-08-19 17:45:16 +00:00
Masayuki Nakano
37a2794486 Bug 1655388 - part 7: Split off the check whether <hr> element should be removed or not from HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87035
2020-08-19 06:48:31 +00:00
Masayuki Nakano
d84d4847b0 Bug 1655388 - part 6: Get rid of unnecessary arguments of HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() and HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement() r=m_kato
Depends on D87033

Differential Revision: https://phabricator.services.mozilla.com/D87034
2020-08-19 05:39:36 +00:00
Masayuki Nakano
c9bee9126b Bug 1655388 - part 5: Split the special handling for <hr> element off from HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() r=m_kato
Depends on D87032

Differential Revision: https://phabricator.services.mozilla.com/D87033
2020-08-19 02:15:01 +00:00
Masayuki Nakano
416bf2f5ad Bug 1655388 - part 4: Get rid of WhiteSpaceVisiblityKeeper::PrepareToDeleteNode() r=m_kato
Now, the new method is only user of it.  So, we can get rid of it.

Depends on D87031

Differential Revision: https://phabricator.services.mozilla.com/D87032
2020-08-18 23:03:08 +00:00
Masayuki Nakano
e844854c69 Bug 1655388 - part 3: Make HTMLEditor::HandleDeleteSelectionInternal() use the new method when it removes an invisible <br> element r=m_kato
Even though it hasn't normalize white-spaces before invisible `<br>` element,
it needs to do it for making them visible.  Therefore, we should make it
use the new method in this case too.

Depends on D87030

Differential Revision: https://phabricator.services.mozilla.com/D87031
2020-08-18 09:23:16 +00:00
Masayuki Nakano
9494d7d9c7 Bug 1655388 - part 2: Make deleting <br> element after <hr> element in HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() use the new method r=m_kato
Although it does not need to join text nodes around the `<br>` element since
its previous node is `<hr>`, it can use
`WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt()` too.

Depends on D87029

Differential Revision: https://phabricator.services.mozilla.com/D87030
2020-08-18 08:17:17 +00:00
Masayuki Nakano
07e4f0f69d Bug 1655388 - part 1: Move the last part of HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() into WhiteSpaceVisibilityKeeper r=m_kato
It works with the traditional white-space normalizer.  Therefore, it should
be moved into `WhiteSpaceVisibilityKeeper`.

Depends on D86910

Differential Revision: https://phabricator.services.mozilla.com/D87029
2020-08-18 08:16:33 +00:00
Sonia Singla
5f5c9fd7f2 Bug 1659267 - Remove usages of -moz-user-select across the Firefox codebase. r=emilio,marionette-reviewers,geckoview-reviewers,preferences-reviewers,whimboo,agi
Differential Revision: https://phabricator.services.mozilla.com/D87499
2020-08-18 23:37:51 +00:00
Masayuki Nakano
3da9fc2299 Bug 1658534 - part 2: Avoid infinite recursive calls at removing an invisible <br> element r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86910
2020-08-18 07:26:02 +00:00
Masayuki Nakano
e21079f1fd Bug 1658534 - part 1: Split the removing invisible <br> element part off from HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent() r=m_kato
Depends on D86886

Differential Revision: https://phabricator.services.mozilla.com/D86909
2020-08-18 05:35:39 +00:00
Masayuki Nakano
d550a723f8 Bug 1658472 - part 6: Make some utility methods for AutoInclusiveAncestorBlockElementsJoiner r=m_kato
This patch changes the behavior in the following 2 points:
* When both content is in same block element, won't return error
* When `<hr>` element has block children accidentally, this solves its container

The former case must not change actual behavior because
`AutoBlockElementsJoiner` is used with content nodes which are in different
blocks.

Differential Revision: https://phabricator.services.mozilla.com/D86886
2020-08-17 10:57:47 +00:00
Masayuki Nakano
909288b9a6 Bug 1658472 - part 5: Split AutoInclusiveAncestorBlockElementsJoiner::Run() to computation part and touching the DOM tree part r=m_kato
Depends on D86884

Differential Revision: https://phabricator.services.mozilla.com/D86885
2020-08-17 10:51:44 +00:00
Masayuki Nakano
5d03594318 Bug 1658472 - part 4: Make AutoInclusiveAncestorBlockElementsJoiner store new list element tag name with its member r=m_kato
Depends on D86883

Differential Revision: https://phabricator.services.mozilla.com/D86884
2020-08-17 10:24:13 +00:00
Masayuki Nakano
3e0a1d8d61 Bug 1658472 - part 3: Make AutoInclusiveAncestorBlockElementsJoiner store left block element and right block element as its members r=m_kato
Depends on D86882

Differential Revision: https://phabricator.services.mozilla.com/D86883
2020-08-17 09:54:49 +00:00
Masayuki Nakano
3496851ec0 Bug 1658472 - part 2: Make AutoInclusiveAncestorBlockElementsJoiner store left content and right content at construction r=m_kato
Depends on D86881

Differential Revision: https://phabricator.services.mozilla.com/D86882
2020-08-17 09:34:11 +00:00
Masayuki Nakano
1a08039730 Bug 1658472 - part 1: Move HTMLEditor::TryToJoinBlocksWithTransaction() into new nested class of AutoBlockElementsJoiner r=m_kato
Now all users of the method is methods of `AutoBlockElementsJoiner`.
Therefore, we can move it into the nested class.  And for splitting the
method in the following patch, it should be a nested class of
`AutoBlockElementJoiner`.

Depends on D86791

Differential Revision: https://phabricator.services.mozilla.com/D86881
2020-08-17 09:22:19 +00:00
Masayuki Nakano
33a78c310f Bug 1655392 - part 6: Split the text deletion part of start and/or end of range off from HandleDeleteNonCollapsedRanges r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86791
2020-08-17 00:26:24 +00:00
Masayuki Nakano
21d81f986c Bug 1655392 - part 5: Split the part removing contents in each range off from HandleDeleteNonCollapsedRanges() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86790
2020-08-16 04:33:39 +00:00
Masayuki Nakano
9d1482c813 Bug 1655392 - part 4: Give independent mode and handler for the next block of AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges() r=m_kato
And now, `HTMLEditor::JoinNodesDeepWithTransaction()` is used only by
`AutoBlockElementsJoiner`.  Therefore, this patch moves it to the
stack only class.

Differential Revision: https://phabricator.services.mozilla.com/D86789
2020-08-16 04:20:38 +00:00
Masayuki Nakano
aa3497a28e Bug 1655392 - part 3: Give independent mode and handler for first case of AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86788
2020-08-13 11:54:21 +00:00
Masayuki Nakano
fa6c54cc66 Bug 1655392 - part 2: Make AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRange() initialize mLeftContent and mRightContent with inclusive ancestor block elements of start and end of first range r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86787
2020-08-13 11:17:24 +00:00
Masayuki Nakano
7d56bc1b36 Bug 1655392 - part 1: Move some part of HTMLEditor::HandleDeleteNonCollapsedRanges() to AutoBlockElementsJoiner r=m_kato
For making the following review easier, this patch just moves some part of
`HandleDeleteNonCollapsedRanges()` into `AutoBlockElementJoiner`.

Differential Revision: https://phabricator.services.mozilla.com/D86786
2020-08-13 10:12:13 +00:00
Mihai Alexandru Michis
fb644eda26 Backed out changeset 5838f8b581ed (bug 1647536) for causing failures in browser_active_mediasession_among_tabs.js
CLOSED TREE
2020-08-14 19:42:51 +03:00
Chris Fronk
8770c8a332 Bug 1647536 - Support ref counted pointers in nsDeque r=froydnj
Adds a new specialization of nsDeque, nsRefPtrDeque for use with
reference counted pointers.

Differential Revision: https://phabricator.services.mozilla.com/D84766
2020-08-14 15:19:48 +00:00
Mirko Brodesser
21078a7903 Bug 1652557: don't skip test_bug767684.html when xorigin iframes and fission are enabled. r=masayuki
The test failed neither locally nor on try, hence enabling it again.

Differential Revision: https://phabricator.services.mozilla.com/D86706
2020-08-12 02:02:49 +00:00
Masayuki Nakano
220db95ff0 Bug 1657269 - part 2: Make HTMLEditor::HandleDeleteSelectionInternal() take AutoRangeArray instead of referring Selection ranges r=m_kato
Now, only when deleting table cell contents, `HandleDeleteSelectionInternal()`
depends on `Selection`.  However, this can be moved to `HandleDeleteSelection()`
because recursive callers expects `Selection` is collapsed by its previous job.

Differential Revision: https://phabricator.services.mozilla.com/D86183
2020-08-11 09:35:42 +00:00
Masayuki Nakano
d5ed562a13 Bug 1657269 - part 1: Move EditorBase::ExtendSelectionForDelete() into AutoRangeArray r=m_kato
This patch moves `EditorBase::ExtendSelectionForDelete()` into `AutoRangeArray`
and make it stop modifying `Selection`.

The method extends anchor-focus range with `nsFrameSelection` and it refers
bidi information in it too.  Therefore, it needs to be called before modifying
anchor-focus range of `Selection`.  Unfortunately, this makes the code messy,
but for now, we should take this.  In the future, we should make the API of
`nsFrameSelection` free from `Selection`.

Differential Revision: https://phabricator.services.mozilla.com/D86182
2020-08-11 06:11:10 +00:00