Commit Graph

9948 Commits

Author SHA1 Message Date
Masayuki Nakano
379f838107 Bug 1646325 - part 1-3: Rewrite remaining part of WSRunScanner::GetRuns() with early-return style r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D80313
2020-06-24 01:22:45 +00:00
Masayuki Nakano
cc4a5ebe14 Bug 1646325 - part 1-2: Rewrite the new if block in WSRunScanner::GetRuns() with early-return style r=m_kato
Depends on D80311

Differential Revision: https://phabricator.services.mozilla.com/D80312
2020-06-23 05:13:58 +00:00
Masayuki Nakano
86e3ff72ea Bug 1646325 - part 1-1: Make WSRunScanner::GetRuns() handle the case not starting from hard line break first r=m_kato
Part 1-* rewrite `WSRunScanner::GetRuns()` with early-return style, but it's
hard to review if changing it with a patch.

This just swaps the `if` and `else` block because the `else` block is
shorter than the `if` block.

Depends on D79973

Differential Revision: https://phabricator.services.mozilla.com/D80311
2020-06-23 04:46:20 +00:00
Butkovits Atila
7916df7f02 Backed out changeset 5614bcd268d1 (bug 1337953) for bustage at FuzzyLayer.cpp. CLOSED TREE 2020-06-23 11:01:37 +03:00
Chris Fronk
cea9cef934 Bug 1337953 - Make nsDeque templated on pointer type r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D79629
2020-06-23 00:58:13 +00:00
Masayuki Nakano
fcdef2c8b9 Bug 1646890 - Add automated test for bug 1645983 r=m_kato
This patch adds new test which is based on actual scenario in
Gmail composer.

Differential Revision: https://phabricator.services.mozilla.com/D80310
2020-06-22 14:48:47 +00:00
Masayuki Nakano
6b7588bbe2 Bug 1646296 - part 8: Make stack only classes to group start/end boundary information of WSRunScanner r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D79973
2020-06-22 14:48:15 +00:00
Kagami Sascha Rosylight
166f2891a2 Bug 1643464 - Part 1: Rename eLeft/eRight to ePrimary/eSecondary r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D80331
2020-06-19 18:02:41 +00:00
tkhan
6ccabd4784 Bug 1602668 - M(1) manifest and test changes. r=kmag,karlt,necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D70362
2020-06-22 19:09:49 +00:00
Masayuki Nakano
8243db7082 Bug 1646296 - part 7: Make WSRunScanner::InitializeRange*() template methods r=m_kato
Depends on D79971

Differential Revision: https://phabricator.services.mozilla.com/D79972
2020-06-22 08:12:37 +00:00
Masayuki Nakano
196304c105 Bug 1646296 - part 6: Make WSRunScanner::InitializeRange*() stop using the loops which are rarely run twice and more r=m_kato
With the previous patches, we know that the loops in
`WSRunScanner::InitializeRangeStart()` and `WSRunScanner::InitializeRangeEnd()`
rarely run twice and more.  Therefore, we can make use recursive calls instead
of the loop.

Depends on D79970

Differential Revision: https://phabricator.services.mozilla.com/D79971
2020-06-22 06:05:16 +00:00
Masayuki Nakano
c1be8ae82a Bug 1646296 - part 5: Make the last else block in the loops of WSRunScanner::InitializeRange*() handled before the text node case r=m_kato
Similar to the previous patch, this patch moves the last `else` block of
the loops in `WSRunScanner::InitializeRangeStart()` and
`WSRunScanner::InitializeRangeEnd()` to before the text node handling case.
This makes that clearer that the loops are continued only when text node
has no text or only white-spaces.

Depends on D79969

Differential Revision: https://phabricator.services.mozilla.com/D79970
2020-06-22 02:40:41 +00:00
Masayuki Nakano
7666461289 Bug 1646296 - part 4: Make the loops in WSRunScanner::InitializeRange*() handle topmost else block first r=m_kato
Their topmost `else` blocks mean there is no visible content before/after the
point.  In this case, the initialization is simpler.  So, they should be
handled first, and make the other blocks outdented.

Depends on D79966

Differential Revision: https://phabricator.services.mozilla.com/D79969
2020-06-22 02:11:30 +00:00
Masayuki Nakano
0847d6a6c2 Bug 1646296 - part 3: Create helper methods of WSRunScanner::InitializeRange*() to scan a text node r=m_kato
There are duplicated code in both `WSRunScanner::InitializeRangeStart()`
and `WSRunScanner::InitializeRangeEnd()`.  They scan text node to store
first and last NBSP positions and initialize start/end with found visible
character position.  This patch makes the loop clearer.

Depends on D79965

Differential Revision: https://phabricator.services.mozilla.com/D79966
2020-06-19 09:25:35 +00:00
Kagami Sascha Rosylight
f424c247ba Bug 1640276 - Part 11: Mark nsINode as const in IsPointInSelection() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D80177
2020-06-19 00:58:40 +00:00
Masayuki Nakano
abe7626ff4 Bug 1646296 - part 2: Split WSRunScanner::GetWSNodes() r=m_kato
Despite the name, it stores range of white-space sequence and/or start/end
reason.  Initializing start and end are completely independent.  Therefore,
we can move them into independent methods.

Depends on D79964

Differential Revision: https://phabricator.services.mozilla.com/D79965
2020-06-18 07:20:54 +00:00
Masayuki Nakano
a852a50071 Bug 1646296 - part 1: Make WSRunScanner::FindNearestRun() return const WSFragment* instead of WSFragment* r=m_kato
The result should never be modified so that it should return `const`-pointer.

Differential Revision: https://phabricator.services.mozilla.com/D79964
2020-06-18 06:02:47 +00:00
Gijs Kruitbosch
222e2d1158 Bug 1644863 - fix trailing whitespace in cross-tree tests, r=emilio,marionette-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D79202
2020-06-17 22:45:31 +00:00
Kris Maglione
3bda67deab 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-17 17:17:16 +00:00
Masayuki Nakano
d2108a7fcd Bug 1645983 - Check whether EditorDOMPointInText is set before calling IsCharASCIISpace() r=m_kato
I guess that the `Maybe` is `mOffset` of `EditorDOMPointBase` because new
`Maybe::value()`s are called with checking `Maybe::isSome()`.  So, accessing
`EditorDOMPointBase::mOffset` newly should cause the assertion.

Then, I found a new caller `IsCharASCIISpace()` which calls `Char()` without
validation here:
https://hg.mozilla.org/mozilla-central/diff/289c293af80b12744b5d35c5b8427ba8d8ebf13e/editor/libeditor/WSRunObject.cpp#l1.383

That could be unset, but I cannot reproduce it, but I succeeded to reproduce
similar assertion hit with using empty text node (see the crashtest).  I hope
this fixes the original crash too.

Differential Revision: https://phabricator.services.mozilla.com/D79816
2020-06-17 07:03:25 +00:00
Masayuki Nakano
e51cdb3ca3 Bug 1642594 - part 5: Implement first version of new white-space normalizer which simulates Blink's one r=m_kato
This patch tries to implement Blink-compat white-space normalizer for
`HTMLEditor`.

It's difficult to list up our traditional white-space normalization rules
because `WSRunObject` touches white space sequence only when there is not
acceptable case, e.g., an ASCII white-spaces will be adjacent to another
one, and replaces only unacceptable white-space only.  Therefore, whether
white-space sequence may start with either an ASCII white-space or an NBSP.
On the other hand, Blink and WebKit makes white-space sequence always
starts with an NBSP or an ASCII white-space (unfortunately, they behave
differently!).  So, for web-compat, we should simulate Blink's behavior
because either behavior is reasonable but Blink have more market share.

This patch simply adds new white-space normalization path for the new one,
and it's switchable with a pref, and still disabled by default.

The other reason why we should do this is, our traditional white-space
normalizer touches the DOM a lot of times per edit action, and the timing
is both before and after touches the DOM tree.  Therefore, it's difficult
to compute actual deleting range for `InputEvent.getTargetRanges()` and
touching a lot of times causes running mutation event listeners a lot and
creates a lot of transaction class instances.  So, new one have a lot of
merits:

1. Improve web-compat
2. Improve the peformance
3. Improve the security
4. Improve the footprint (but this is now worse then traditional one)
5. Simplify the implementation

The new normalizer is mostly implemented with only 3 `HTMLEditor` methods.

One is `HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces()`.  This is
semi-public method for the edit action handlers.  This takes a range with
2 `EditorDOMPoinInText` to delete the range simply.  This also replaces
surrounding white-space sequence if necessary.  For inserting text case,
this method also handles only white-space normalization when it's called
with collapsed range, i.e., same `EditorDOMPointInText`.  This tries to use
`RepaceTextWithTransaction()` as far as possible to reduce creation cost of
transaction classes and the footprint.

Another one is `HTMLEditor::ExtendRangeToDeleteWithNormalizingWhiteSpaces()`.
This tries to extend the given range to normalize surrounding white-spaces.
This is currently not optimized for footprint because this may include
white-spaces which do not need to be replaced.  This optimization should be
done before shipping, but for now, enabling `InputEvent.getTargetRanges()` in
Nightly channel is more important.  So that it should be done in a follow-up
bug.

The other is `HTMLEditor::GenerateWhitepaceSequence()`.  This creates
normalized white-space sequence with surrounding character information.
For keeping this method simple as far as possible, we shouldn't optimize
the range of generation even in follow-ups.

Finally, the white-space sequence is not tested in mochitests, so that we
can enable this new normalizer when we run mochitests under
`editor/libeditor/tests`.  However, WPT has some tests.  We should keep
them running with current normalizer for checking regression.  Instead,
we should enable the pref only for the new WPT added by the previous patch.

Depends on D78655

Differential Revision: https://phabricator.services.mozilla.com/D78656
2020-06-15 07:37:56 +00:00
Masayuki Nakano
e01c0de610 Bug 1642594 - part 4: Stop using "whitespace" in under libeditor r=m_kato
I realized that there is no word "whitespace" in formal English.  This patch
replaces it with "white-space" in comments, and change method names to use
"WhiteSpace".

Depends on D78654

Differential Revision: https://phabricator.services.mozilla.com/D78655
2020-06-10 13:44:10 +00:00
Masayuki Nakano
3d4e1bc4bb Bug 1642594 - part 2: Make WSRunObject::ReplaceASCIIWhitespacesWithOneNBSP() take range of collapsible ASCII whitespaces instead of a position in it r=m_kato
This patch makes the method not smart intentionally because we need only the
range without DOM mutation.

Differential Revision: https://phabricator.services.mozilla.com/D77987
2020-06-08 11:31:37 +00:00
Masayuki Nakano
5cfc474a9c Bug 1642594 - part 1: Split WSRunObject::GetASCIIWhitespacesBounds() and redesign them r=m_kato
Callers of `WSRunObject::GetASCIIWhitespacesBounds()` may want to scan only
previous or next whitespaces.  Therefore, we can split it to save creation
cost of `EditorDOMPointInText`.

Additionally, this makes them scan whitespace sequence in a text node until
hitting its end for avoiding to use expensive API of `WSRunScanner`.

Differential Revision: https://phabricator.services.mozilla.com/D77986
2020-06-08 11:30:37 +00:00
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