Commit Graph

9924 Commits

Author SHA1 Message Date
Ping Chen
c055ecfef2 Bug 1636971 - Load EditorOverride.css in HTMLEditor->Init to fix image styles in editor. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D79285
2020-06-12 12:22:12 +00:00
Emilio Cobos Álvarez
ef3d21048d Bug 1640623 - Use enum classes for LookAndFeel int and float IDs. r=jmathies,geckoview-reviewers,esawin
Differential Revision: https://phabricator.services.mozilla.com/D76694
2020-06-11 11:27:43 +00:00
Simon Giesecke
82dc9b2271 Bug 1642949 - Replace uses of RemoveElementAt by RemoveLastElement/PopLastElement where possible. r=necko-reviewers,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D78027
2020-06-10 10:46:14 +00:00
Butkovits Atila
e3dce68834 Backed out 3 changesets (bug 1643289, bug 1642949) for causing failure at test_headless_screenshot.html. CLOSED TREE
Backed out changeset 98c420f73380 (bug 1643289)
Backed out changeset 9447ea8910aa (bug 1643289)
Backed out changeset 0c827da9d847 (bug 1642949)
2020-06-10 10:07:23 +03:00
Simon Giesecke
d419f0ff08 Bug 1642949 - Replace uses of RemoveElementAt by RemoveLastElement/PopLastElement where possible. r=necko-reviewers,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D78027
2020-06-10 05:49:28 +00:00
Kagami Sascha Rosylight
c883340a3b Bug 1643495 - Revert contextmenu change in test_bug417418 r=masayuki
This change was only needed when the previous version of the patch for Bug 1632425 wanted to move things into contextmenu event handler. This patch reverts the change as 1) the suggested behavior never landed and 2) opening context menu in a test can cause conflict with other tests.

Differential Revision: https://phabricator.services.mozilla.com/D78673
2020-06-08 23:35:53 +00:00
Masayuki Nakano
72a41b4a70 Bug 1636855 - Disallow to paste longer text than maxlength value except in Nightly channel and early Beta r=emilio
Fix of bug 1320229 allowed to paste longer text than `maxlength` attribute of
`<input>` and `<textarea>` because it was thought that the longer text causes
"too long" invalidate state, makes users notified and prevent to submit
form data.

However, according to Bug 1636855 comment 7 (*1), it breaks a major enterprise
web app, SAP, at least because it sends form data without checking validity of
each form data and discards invalid data on server side silently.

According to bug 1636855 comment 24 (*2), one of new behavior's fault is
on Gecko side too.  The style of `<input>` element or `<textarea>` element
which has too long text after pasting is changed when it loses focus.
Therefore, users can post the data before they know pasted data is too
long if sending the form data with `Enter` key or something immediately
after pasting (i.e., without moving focus) web apps handle it by themselves.

On the other hand, the original bug report, bug 1320229, should be solved in
the future especially in password field because users may register password
which is cut by `maxlength` silently and they don't use builtin password
manager, only the pasted password is saved, and then, they won't be able to
login as the account.  This is really long standing issue of the web forms.
An article (*3) warned this to web developers in 2011.  Therefore, we should
keep going advance for solving this issue at least in Nightly channel to get
more feedback from testers and web developers.

1 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c7
2 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c24
3 https://www.christophermanning.org/writing/dont-use-maxlength-on-password-inputs

Differential Revision: https://phabricator.services.mozilla.com/D78613
2020-06-07 21:29:48 +00:00
Bogdan Tara
86d1eef7a6 Backed out changeset 6e99a3e6c77b (bug 1642588) for test_bug1642588.html failures CLOSED TREE 2020-06-06 02:45:52 +03:00
Masayuki Nakano
bb4b3d4e9d Bug 1642270 - Make EditorBase::MaybeHasMutationEventListeners() always return true in debug build for testing complicated path r=m_kato
According to the telemetry data, almost all web apps in the word do not use
mutation event listeners, but if they are used, editor needs to check
whether modifying node is modified by web apps.  The checking cost may not
cheap in some cases.  Therefore, we check whether the window has at least one
mutation event listeners or not before non-cheap checking.

However, like actual web apps, most our mochitests and WPT do not add
mutation event listeners.  Therefore, such additional checking code is not
tested even though they should work as exactly same as the case when
there are mutation event listeners but they don't touch the DOM.

This patch makes it always return only in debug build for checking the
complicated path.

Differential Revision: https://phabricator.services.mozilla.com/D78173
2020-06-05 19:25:18 +00:00
Kagami Sascha Rosylight
e29858d3ad Bug 1642588 - Make Triple click only select within editing host r=masayuki,emilio
Differential Revision: https://phabricator.services.mozilla.com/D78315
2020-06-05 22:45:30 +00:00
Bogdan Tara
1ba73a9900 Backed out changeset 094a2fc0fc50 (bug 1642588) for test_bug1642588.html failures CLOSED TREE 2020-06-05 21:50:36 +03:00
Kagami Sascha Rosylight
d02396bd67 Bug 1642588 - Make Triple click only select within editing host r=masayuki,emilio
Differential Revision: https://phabricator.services.mozilla.com/D78315
2020-06-05 13:41:26 +00:00
Kagami Sascha Rosylight
45b185573f Bug 1632425 - Part 3: Triple click to select anchors r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D77683
2020-06-03 23:47:55 +00:00
Kagami Sascha Rosylight
c948a3aa98 Bug 1632425 - Part 2: Mark const methods as such r=masayuki
Depends on D77812

Differential Revision: https://phabricator.services.mozilla.com/D77942
2020-06-03 03:08:58 +00:00
Kagami Sascha Rosylight
60c853771e Bug 1632425 - Part 1: Add EditorUtils::IsPointInSelection() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D77812
2020-06-03 03:08:05 +00:00
Razvan Maries
a36bb7751f Backed out 3 changesets (bug 1638153) for perma failures on cross-origin-objects.html. CLOSED TREE
Backed out changeset f7aedc92d396 (bug 1638153)
Backed out changeset 07ec713926c6 (bug 1638153)
Backed out changeset 5a656842e241 (bug 1638153)
2020-06-01 23:51:35 +03:00
Kris Maglione
b3fcd970ec Bug 1638153: Part 2 - Fix uses of .rootTreeItem to get top browser window. r=geckoview-reviewers,nika,snorp
Differential Revision: https://phabricator.services.mozilla.com/D75429
2020-06-01 17:59:01 +00:00
Emilio Cobos Álvarez
54fd961a29 Bug 1641245 - Make string comparators not virtual. r=froydnj,necko-reviewers,geckoview-reviewers,jgilbert,agi,valentin
There's no use case for stateful comparators, so they can be just plain
function pointers.

This is used in some hot places like CSS selector matching.

Differential Revision: https://phabricator.services.mozilla.com/D77084
2020-05-27 18:11:12 +00:00
Emilio Cobos Álvarez
525520f10b Bug 1640601 - Also reframe the closest non-anonymous root when switching anonymous content from display: none to something else. r=mats
We were dealing with it correctly when switching display from e.g. block
to inline, or such. But we were not dealing with it when the node was
undisplayed.

Handle it properly, and free one frame bit while at it. We can't really
do this for ManualNAC (the editor resizers) because they request a
reframe explicitly.

Differential Revision: https://phabricator.services.mozilla.com/D76679
2020-05-25 23:54:10 +00:00
Emilio Cobos Álvarez
89958b377a Bug 1640605 - Remove IsInAnonymousSubtree / IsRootOfAnonymousSubtree. r=edgar
In favor of the NativeAnonymous versions which they forward to.

Done automatically with:

  rg -l 'IsInAnonymousSubtree' | xargs sed -i 's/IsInAnonymousSubtree/IsInNativeAnonymousSubtree/g'

And removing the function definitions afterwards.

Differential Revision: https://phabricator.services.mozilla.com/D76681
2020-05-25 11:43:51 +00:00
Kagami Sascha Rosylight
bc670252a1 Bug 1640276 - Part 7: Mark nsINode as const in IsVisibleBRElement() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76570
2020-05-23 12:40:08 +00:00
Kagami Sascha Rosylight
c9c8185160 Bug 1640276 - Part 6: Mark nsINode as const in GetNext/PreviousHTMLElementOrText*() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76569
2020-05-23 12:39:48 +00:00
Kagami Sascha Rosylight
6cafaa3128 Bug 1640276 - Part 5: Mark nsINode as const in GetNext/PreviousGetNextHTMLElementOrTextInternal() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76567
2020-05-23 12:39:36 +00:00
Kagami Sascha Rosylight
6af0a00410 Bug 1640276 - Part 4: Mark nsINode as const in GetNext/Previous*Node() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76565
2020-05-23 12:39:16 +00:00
Kagami Sascha Rosylight
866889e825 Bug 1640276 - Part 3: Mark nsINode as const in GetNext/PreviousNodeInternal() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76564
2020-05-23 12:39:03 +00:00
Kagami Sascha Rosylight
83c35c9040 Bug 1640276 - Part 2: Mark nsINode as const in Find*Node() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76563
2020-05-23 12:38:50 +00:00
Kagami Sascha Rosylight
9eac56104b Bug 1640276 - Part 1: Mark nsINode as const in Is*Root() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D76562
2020-05-23 12:38:38 +00:00
Masayuki Nakano
dd8eff26c2 Bug 1639161 - part 3: Get rid of nsIEditActionListener::DidDeleteText() r=m_kato
It's not used by mozilla-central, comm-central nor BlueGriffon, and it cannot
work with replacing content, mutation event listener's changes.  Therefore,
we should remove this for now. If we need to support this **feature** in some
business reasons, we should provide better API than this anyway.

Differential Revision: https://phabricator.services.mozilla.com/D76080
2020-05-21 08:23:04 +00:00
Masayuki Nakano
30d14b828d Bug 1639161 - part 2: Make WSRunObject use HTMLEditor::ReplaceTextWithTransaction() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D76079
2020-05-21 08:22:20 +00:00
Masayuki Nakano
58e73430fb Bug 1639161 - part 1: Create ReplaceTextTransaction class r=m_kato
Currently, when `HTMLEditor` replaces text in a text node, `HTMLEditor`
creates a set of `DeleteTextTransaction` and `InsertTextTransaction`.
However, this has bad impact for footprint and causes the callers messy.

This patch creates `ReplaceTextTransaction` instead and
`HTMLEditor::ReplaceTextWithTransaction()` as its wrapper.  Unfortunately,
this becomes not calling `nsIEditActionListener::DidDeleteText()`, however,
this is not used by mozilla-central, comm-central nor BlueGriffon.  IIRC,
it was not removed for some legacy addons of Thunderbird.  Therefore, it
must be okay to remove it.

Differential Revision: https://phabricator.services.mozilla.com/D76078
2020-05-21 02:30:09 +00:00
Olli Pettay
9a394a854e Bug 1637712 - Consider to move *Ancestor* API to nsINode r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D75169
2020-05-20 14:55:15 +00:00
Masayuki Nakano
1a48bee3ed Bug 1627175 - part 19: Move EditorBase::IsPreformatted() to EditorUtils r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D75889
2020-05-20 04:45:42 +00:00
Masayuki Nakano
a97bc5aea1 Bug 1639074 - Don't call EditorDOMPoint::GetPreviousSiblingOfChild() if the container is not a container element r=m_kato
For warning the potential of callers' bug, `GetPreviousSiblingOfChild()` outputs
warning into the console when its container is not a container element, e.g.,
it's odd trying to get previous sibling of child if the container is a text
node.  Therefore, this patch makes the new caller,
`WSRunScanner::GetPreviousEditableCharPoint()`, check
`CanContainerHaveChildren()` before calling it.

Differential Revision: https://phabricator.services.mozilla.com/D75888
2020-05-20 07:11:17 +00:00
Masayuki Nakano
89060f115e Bug 1637865 - part 5: Clean up WSRunObject::CheckTrailingNBSPOfRun() r=m_kato
This patch makes it use early-return style and adds some comments.  Its behavior
should be changed as soon as possible for web-compat.  Therefore, I don't
write current behavior as comment at declaration.

Differential Revision: https://phabricator.services.mozilla.com/D75476
2020-05-19 01:17:10 +00:00
Masayuki Nakano
0fa915de33 Bug 1637865 - part 4: Rename rightCheck in WSRunObject::CheckTrailingNBSPOfRun() r=m_kato
Although the new name is not true when neither
`maybeNBSPFollowingVisibleContent` nor `isPreviousCharASCIIWhitespace` is true.

Differential Revision: https://phabricator.services.mozilla.com/D75475
2020-05-18 13:00:25 +00:00
Masayuki Nakano
0ff40045be Bug 1637865 - part 3: Rename leftCheck in WSRunObject::CheckTrailingNBSPOfRun() r=m_kato
Then, the last `if` block runs obviously only when the preceding `if` block
runs.  Therefore, this patch moves it.

Differential Revision: https://phabricator.services.mozilla.com/D75474
2020-05-18 12:59:26 +00:00
Masayuki Nakano
b42c1f1076 Bug 1637865 - part 2: Rename spaceNBSP in WSRUnObject::CheckTrailingNBSPOfRun() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D75473
2020-05-18 11:37:37 +00:00
Masayuki Nakano
dafe3c5aa7 Bug 1637865 - part 1: Clean up WSRunObject::ReplacePreviousNBSPIfUnnecessary() and WSRunObject::CheckLeadingNBSP() r=m_kato
They are complicated because of not using early-return style.

Differential Revision: https://phabricator.services.mozilla.com/D75472
2020-05-18 08:33:10 +00:00
Masayuki Nakano
c7249ef506 Bug 1637856 - part 2: Get rid of WSRunScanner::mNodeArray r=m_kato
`WSRunScanner` scans around given point in `GetWSNodes()` at construction with
using `HTMLEditUtils` methods and caches editable text nodes between
`mStartReasonContent` and `mEndReasonContent`.  However, it's used only by
`GetNextCharPoint()` and `GetPreviousCharPoint()`, and they shouldn't be
referred after changing the DOM tree.  Therefore, we can scan it directly
only when it needs to scan.

The patch rewrites `GetNextCharPoint()` and `GetPreviousCharPoint()` without
`mNodeArray` and removes `mNodeArray` from its member.  This may increase the
cost of scanning next/previous text node, but improves the scan performance
when it does not treat so wide range and they are called with a point whose
container is not a text node.

This patch unexpectedly changes the behavior of them, that causes the fix of
2 failures in `insertlinebreak.html` and `insertparagraph.html`.  According to
debugger, previously GetNextCharPoint()` in
`ScanNextVisibleNodeOrBlockBoundaryFrom()` called point at `<br>` element
returned no next char, then, `ScanNextVisibleNodeOrBlockBoundaryFrom()` returned
end point which is block boundary of `<listing>` element (it is legacy HTML2
element and treated as `<pre>` element internally).  Therefore, the inserted
`<br>` element was misunderstood as invisible `<br>` at end of a block and
inserted another `<br>` element for making it visible.  However, the redesigned
one fixed this bug with searching correct text node.  Therefore, I cannot
keep the buggy behavior in the new designed methods.

Depends on D75470

Differential Revision: https://phabricator.services.mozilla.com/D75471
2020-05-18 06:46:00 +00:00
Masayuki Nakano
714518769f Bug 1637856 - part 1: Move WSRunObject::DeleteRange() to HTMLEditor r=m_kato
`WSRunObject::DeleteRange()` removes only text nodes which are stored when
`WSRunObject` is created.  Although it removes text nodes if it's removed,
this patch does not take care about it in the new method.  The reason is
the following patch will remove `mNodeArray` and anyway DOM tree modifiers
can check whether they are in proper position before access if it's needed.

Differential Revision: https://phabricator.services.mozilla.com/D75470
2020-05-18 05:12:16 +00:00
Honza Bambas
ba42858183 Bug 1535792 - Remove no longer applicable condition disabling test_richtext2.html on linux32 debug, r=jmaher
Differential Revision: https://phabricator.services.mozilla.com/D75162
2020-05-13 18:22:13 +00:00
Emilio Cobos Álvarez
b9c1bf761c Bug 312971 - Unprefix -moz-read-write / -moz-read-only. r=edgar
And remove some duplicated tests from WPT.

Differential Revision: https://phabricator.services.mozilla.com/D75231
2020-05-14 16:46:08 +00:00
Mirko Brodesser
91fe215251 Bug 1635709: part 17) Annotate CellIndexes's methods with MOZ_CAN_RUN_SCRIPT. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D75099
2020-05-14 10:08:44 +00:00
Mirko Brodesser
1f8f4485a5 Bug 1635709: part 16) Replace GetTableCellLocationFromRange with GetTableSelectionMode. r=masayuki
The location wasn't used from the caller of
`GetTableCellLocationFromRange`.

However, `GetTableCellLocationFromRange`
included flushing frames, this is now done in
`HTMLEditor::CellIndexes::Update`.

Differential Revision: https://phabricator.services.mozilla.com/D75098
2020-05-14 10:08:32 +00:00
Masayuki Nakano
6644f1805c Bug 1627175 - part 18: Move WSRunScanner::GetNextWSNode() and WSRunScanner::GetPreviousWSNode() to HTMLEditUtils r=m_kato
They are returning same meaning value as
`HTMLEditUtils::GetNextLeafContentOrNextBlockElement()` and
`HTMLEditUtils::GetPreviousLeafContentOrPreviousBlockElement()` so that
they can be renamed to same name to overload them.

Depends on D74805

Differential Revision: https://phabricator.services.mozilla.com/D74806
2020-05-12 16:23:08 +00:00
Masayuki Nakano
e561b5131a Bug 1627175 - part 17: Move WSRunScanner::GetPreviousWSNodeInner() to HTMLEditUtils r=m_kato
Similar to the previous patch, this patch moves it into `HTMLEditUtils` with
renaming it to `GetPreviousLeafContentOrPreviousBlockElement()`.

Depends on D74804

Differential Revision: https://phabricator.services.mozilla.com/D74805
2020-05-12 16:14:32 +00:00
Masayuki Nakano
79f63fcc8b Bug 1636747 - Backout the 1st patch of bug 503838 r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D75032
2020-05-13 09:09:32 +00:00
Masayuki Nakano
b75955132b Bug 1627175 - part 16: Move WSRunScanner::GetNextWSNodeInner() to HTMLEditUtils r=m_kato
It looks for next leaf content or next block element for finding "end reason
node" of `WSRunScanner`.  Especially for clearing the latter case, this
patch renames it to `GetNextLeafContentOrNextBlockElement()`.

Differential Revision: https://phabricator.services.mozilla.com/D74804
2020-05-12 15:43:06 +00:00
Masayuki Nakano
e317a8bfb7 Bug 1622231 - Make HTMLEditor::SetInlinePropertyAsAction() override property if it's called for XUL cmd_fontFace with a magic value "tt" r=m_kato
`FontFaceStateCommand::SetState()` called
`HTMLEditor::SetInlinePropertyAsAction()` with `nsGkAtoms::tt` when given value
is "tt".
https://searchfox.org/mozilla-central/rev/bc5737c51b8da4e758cf4db0ddb606f0aea81a7d/editor/libeditor/HTMLEditorCommands.cpp#626-627

However, I accidentally not ported this to
`HTMLEditor::SetInlinePropertyAsAction()`.  Therefore, this patch restores the
old code for the magic value.

Differential Revision: https://phabricator.services.mozilla.com/D74379
2020-05-11 07:30:47 +00:00
Masayuki Nakano
8c859f8589 Bug 1627175 - part 15: Create HTMLEditUtils::GetFirstLeafChild() instead of EditorBase::GetLeftmostChild() r=m_kato
This is used by `TextEditor::UndoAsAction()` too, so, it might be better to be
in `EditorUtils`.  However, it is completely designed for `HTMLEditor` and
ideally, `UndoAsAction` should be overridden by `HTMLEditor` too and
`TextEditor` should use faster path because of its content is in anonymous
subtree. But we don't have any merit to do that instead of avoiding virtual
call.

Differential Revision: https://phabricator.services.mozilla.com/D74362
2020-05-08 09:49:19 +00:00