Commit Graph

9368 Commits

Author SHA1 Message Date
Masayuki Nakano
0e763a968a Bug 1572681 - part 6: Move TextEditRules::mDidExplicitlySetInterline to HTMLEditRules r=m_kato
`TextEditRules::mDidExplicitlySetInterline` is set to true only by
`HTMLEditRules`, but `TextEditRules::DidDeleteSelection()` refers it.
So, it's enough to make `TextEditRules::DidDeleteSelection()` take the
value and we can move it into `HTMLEditRules`.

Differential Revision: https://phabricator.services.mozilla.com/D41401

--HG--
extra : moz-landing-system : lando
2019-08-13 08:53:45 +00:00
Masayuki Nakano
8870cb5d53 Bug 1572681 - part 5: Get rid of TextEditRules::mDeleteBidiImmediately r=m_kato
`TextEditRules::mDeleteBidiImmediately` is cache of
`bidi.edit.delete_immediately` pref value at creation time of `TextEditRules`.
However, this is referred when user removes selection.  So, there is no
reason to keep same behavior starting from editor creation.  In other words,
it must be better to take same behavior in all editor instances.

Therefore, we should remove it and the pref value should be referred directly
when user tries to remove selection.

Differential Revision: https://phabricator.services.mozilla.com/D41400

--HG--
extra : moz-landing-system : lando
2019-08-13 04:41:51 +00:00
Masayuki Nakano
7759842058 Bug 1572681 - part 4: Get rid of arguments of TextEditRules::BeforeEdit() and TextEditRules::AfterEdit() r=m_kato
`TextEditRules::BeforeEdit()`, `TextEditRules::AfterEdit()`,
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` are always
called with same values as the result of
`EditorBase::GetTopLevelEditSubAction()` and
`EditorBase::GetDirectionOfTopLevelEditSubAction()`.

For making what they do clearer, we should make them access with those
`EditorBase` members for now.  This makes those methods ugly due to increasing
number of long lines.  However, this issue should be solved when we move them
into `TextEditor` and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D41399

--HG--
extra : moz-landing-system : lando
2019-08-13 04:41:18 +00:00
Masayuki Nakano
726b15369f Bug 1572681 - part 3: Change TextEditRules::mLockRulesSniffing to HTMLEditRules::mInitialized r=m_kato
`TextEditRules::mLockRulesSniffing` is set by `AutoLockRulesSniffing`.
It's created during `BeforeEdit()` and `AfterEdit()` are called, and
`HTMLEditRules::Init()` is initializing `mDocChangeRange`.

The purpose of it is, preventing `BeforeEdit()` and `AfterEdit()` to do
something in that time.  For the former cases, we don't need this member
anymore since they won't be nested.  Therefore, we need to manage
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` won't do
anything only while `HTMLEditRules::Init()` is called.  Therefore,
there should be only `HTMLEditRules::mInitialized` instead.

Differential Revision: https://phabricator.services.mozilla.com/D41398

--HG--
extra : moz-landing-system : lando
2019-08-13 04:26:52 +00:00
Masayuki Nakano
a866a356da Bug 1572681 - part 2: Get rid of TextEditRules::mTopLevelEditSubAction and TextEditRules::mActionNesting r=m_kato
`TextEditRules::BeforeEdit()`, `TextEditRules::AfterEdit()`,
`HTMLEditRules::BeforeEdit()` and `HTMLEditRules::AfterEdit()` manages
`TextEditRules::mActionNesting` for preventing that they won't do same thing
per top-level edit sub-action.  However, this has already been checked by
their caller, `AutoTopLevelEditSubActionNotifier`.  So, we can get rid of it.
Then, `TextEditRules::mTopLevelEditSubAction` is also always same as
`EditorBase::GetTopLevelEditSubAction()`.  Therefore, we can get rid of it
too.

Differential Revision: https://phabricator.services.mozilla.com/D41397

--HG--
extra : moz-landing-system : lando
2019-08-13 02:42:25 +00:00
Masayuki Nakano
13b14b9b2f Bug 1572681 - part 1: Move TextEditRules::mCachedSelection* to EditorBase::AutoEditActionDataSetter r=m_kato
Despite of their names, `TextEditRules::mCachedSelectionNode` and
`TextEditRules::mCachedSelectionOffset` are used only for calling
`EditorBase::HandleInlineSpellCheck()` so that they should be renamed to
explain the purpose.

Additionally, they are not necessary to be in the heap since they are
necessary until `TextEditRules::AfterEdit()` is called.  Therefore, we can
move them into `EditorBase::HandleInlineSpellCheck()`.

Finally, `TextEditRules::BeforeEdit()` and `TextEditRules::AfterEdit()` are
called only by `TextEditor::OnStartToHandleTopLevelEditSubAction()` and
`TextEditor::OnEndHandlingTopLevelEditSubAction()`.  Therefore, we can move
the setter to `TextEditor::OnStartToHandleTopLevelEditSubAction()`.

Differential Revision: https://phabricator.services.mozilla.com/D41396

--HG--
extra : moz-landing-system : lando
2019-08-13 01:24:01 +00:00
Mirko Brodesser
81a41b2d7d Bug 1573119: declare more methods around HTMLEditor const/static. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D41524

--HG--
extra : moz-landing-system : lando
2019-08-13 07:34:11 +00:00
Makoto Kato
609348ba4d Bug 1543312 - Tear down editor when PresShell is destroyed. r=masayuki
When browsing reported site (https://minecraft.curseforge.com/), user that uses Android cannot set caret on some editable contents.

GV's IME code uses `NOTIFY_IME_OF_SELECTION_CHANGE` to update selection on native IME.  But GV doesn't receives this notification on this reported site. This notification is fired by editor's selection listener, but when this occurs, this notification is no logner fired unfortunately.  Because selection listener isn't registered by current selection.

At first, editor registers selection listener by `EditorBase::Init`. But like test case, if PresShell is destroyed after editor is created, this registration is no longer used, and we have to register it by new selection again. So we should tear down editor when PresShell is destroyed. (or we have to add a way to re-initialize selection listener?)

This isn't related to Android. Android's IME code depends on this notification, so this occurs easily.

Also, `PresShell::SetCaretEnabled` only works when caret is valid (`PresShell::GetCaret` has caret).  If caret is nothing, it hits assertion.

And, attached test case is reproduced sample.

Differential Revision: https://phabricator.services.mozilla.com/D41356

--HG--
extra : moz-landing-system : lando
2019-08-13 02:00:00 +00:00
Masayuki Nakano
ede2ddb459 Bug 1572375 - part 8: Wrap EditorBase::mPaddingBRElementForEmptyEditor with an inline method r=m_kato
`TextEditRules` and `HTMLEditRules` still refer
`EditorBase::mPaddingBRElementForEmptyEditor` directly but this is really ugly.
Therefore, this patch creates `EditorBase::HasPaddingBRElementForEmptyEditor()`
for wrapping its access.

Differential Revision: https://phabricator.services.mozilla.com/D41162

--HG--
extra : moz-landing-system : lando
2019-08-13 00:57:38 +00:00
Masayuki Nakano
485a59c303 Bug 1572375 - part 7: Get rid of HTMLEditRules::OnModifyDocument() r=m_kato
`HTMLEditRules::OnModifyDocument()` is same as just calling
`EditorBase::EnsureNoPaddingBRElementForEmptyEditor()` and
`EditorBase::MaybeCreatePaddingBRElementForEmptyEditor()` so that this patch
gets rid of the method, then, creates `HTMLEditor::OnModifyDocumentInternal()`
and makes it do same thing.

Differential Revision: https://phabricator.services.mozilla.com/D41161

--HG--
extra : moz-landing-system : lando
2019-08-13 00:56:57 +00:00
Masayuki Nakano
1df80236d6 Bug 1572375 - part 6: Get rid of HTMLEditRules::WillLoadHTML() r=m_kato
`HTMLEditRules::WillLoadHTML()` does exactly same thing as
`EditorBase::EnsureNoPaddingBRElementForEmptyEditor()`.  Therefore, we can
get rid of it and make `HTMLEditor::LoadHTML()` not use `HTMLEditRules`.

Differential Revision: https://phabricator.services.mozilla.com/D41160

--HG--
extra : moz-landing-system : lando
2019-08-13 00:09:46 +00:00
Masayuki Nakano
c1906f614d Bug 1572375 - part 5: Move TextEditRules::CreatePaddingBRElementForEmptyEditorIfNeeded() into EditorBase r=m_kato
`TextEditRules::CreatePaddingBRElementForEmptyEditorIfNeeded()` is used by
both `TextEditor` and `HTMLEditor` so that this moves it into `EditorBase`.

Additionally, making `TextEditor::MaybeChangePaddingBRElementForEmptyEditor()`
call it if there is no content.  Then, we can avoid the dependency of them.

Differential Revision: https://phabricator.services.mozilla.com/D41159

--HG--
extra : moz-landing-system : lando
2019-08-09 10:19:11 +00:00
Masayuki Nakano
3b82fdde10 Bug 1572375 - part 4: Move TextEditRules::RemoveRedundantTrailingBR() into TextEditor r=m_kato
`TextEditRules::RemoveRedundantTrailingBR()` is used only by multiline text
editor (i.e., `<textarea>`).  Therefore, it should be moved into `TextEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D41158

--HG--
extra : moz-landing-system : lando
2019-08-09 09:01:56 +00:00
Masayuki Nakano
d88036fb98 Bug 1572375 - part 3: Get rid of TextEditRules::WillUndo(), TextEditRules::DidUndo(), TextEditRules::WillRedo() and TextEditRules::DidRedo() r=m_kato
`TextEditRules::WillUndo()` and `TextEditRules::WillRedo()` only check whether
the editor is readonly/disabled or not.  So, `TextEditor::UndoAsAction()` and
`TextEditor::RedoAsAction()` should do it first.

`TextEditRules::DidUndo()` and `TextEditRules::DidRedo()` only set or unset
`mPaddingBRElementForEmptyEditor` if it's restored by undo or redo.
Therefore, we can move the code into `TextEditor::UndoAsAction()` and
`TextEditor::RedoAsAction()`.

Note that this patch makes `TextEditor::UndoAsAction()` discard the result of
`TransactionManager::Undo()` because this is inconsistent from what
`TextEditor::RedoAsAction()` does and this was changed by part 5 of bug 1447924.
https://hg.mozilla.org/mozilla-central/rev/869a1445816be7f43f54f7c97f28e4c6273fa75f

Differential Revision: https://phabricator.services.mozilla.com/D41157

--HG--
extra : moz-landing-system : lando
2019-08-09 08:57:00 +00:00
Masayuki Nakano
b0606032ba Bug 1572375 - part 2: Split TextEditRules::WillInsert() r=m_kato
`TextEditRules::WillInsert()` is not used with initial purpose since
`HTMLEditor` always works with `HTMLEditRules` and its `WillDoAction()`
always handles `EditSubAction::eInsertElement`.

Additionally, its name is too generic since it does non-related 3 things.

One is checking whether the editor is readonly or disabled.  However, this
may not be necessary since its callers may have already checked it or
just ignored the result.  So, this should be check by each caller.

Next one is masking password if auto-masking is enabled.  This is `TextEditor`
specific feature so that this patch moves the code into
`TextEditor::MaybeDoAutoPasswordMasking()`.

Final one is removing empty `<br>` element for empty editor if there is.
This is common feature so that this patch moves this code into
`EditorBase::EnsureNoPaddingBRElementForEmptyEditor()`.

Differential Revision: https://phabricator.services.mozilla.com/D41156

--HG--
extra : moz-landing-system : lando
2019-08-09 08:25:37 +00:00
Masayuki Nakano
b25f8b0e06 Bug 1572375 - part 1: Move TextEditRules::mPaddingBRElementForEmptyEditor to EditorBase r=m_kato
`TextEditRules::mPaddingBRElementForEmptyEditor` are used by both `TextEditor`
and `HTMLEditor`.  Therefore, it should be in `EditorBase`.

This patch makes `TextEditRules` and `HTMLEditRules` directly access the
private member of `EditorBase` temporarily.  It'll be fixed by the following
patches.

Differential Revision: https://phabricator.services.mozilla.com/D41155

--HG--
extra : moz-landing-system : lando
2019-08-09 07:03:29 +00:00
Mirko Brodesser
a83f7bfa50 Bug 1572715: part 2) Make some methods around HTMLEditor const-correct. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D41385

--HG--
extra : moz-landing-system : lando
2019-08-12 08:31:04 +00:00
Mirko Brodesser
d0e7afc285 Bug 1572715: part 1) Factor out WSRunScanner from WSRunObject. r=masayuki
This allows users of `WSRunScanner`'s functionality to pass a `const
HTMLEditor*`, allowing themselves to become const-correct.

Differential Revision: https://phabricator.services.mozilla.com/D41384

--HG--
extra : moz-landing-system : lando
2019-08-12 08:30:57 +00:00
Mirko Brodesser
d7dc23922f Bug 1572473: declare a few methods in WSRunObject const. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D41223

--HG--
extra : moz-landing-system : lando
2019-08-09 06:11:46 +00:00
Mirko Brodesser
1274c8140e Bug 1572060: declare a few methods around HTMLEditor static/const. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D40982

--HG--
extra : moz-landing-system : lando
2019-08-07 15:58:41 +00:00
Kannan Vijayan
e53a880b1c Bug 1569262 - Rename nsIDocShellTreeItem::GetRootTreeItem to GetInProcessRootTreeItem for Fission marking. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D41064

--HG--
extra : moz-landing-system : lando
2019-08-07 19:24:00 +00:00
Masayuki Nakano
f3fb0d1af8 Bug 1569613 - Add surrogate pair handling API to nsTextFragment r=hsivonen
We check surrogate pair at specific index in `nsTextFragement` in a lot of
places.  This requires boundary check of the index so that it can cause
security issue and crash reason with simple mistake, and also it steals
your time to understand the code what it does especially when it's a
part of an `if` condition.

Therefore, this patch adds new API to `nsTextFragment` and makes the all
surrogate pair handlers of `nsTextFragument` use new API.

Differential Revision: https://phabricator.services.mozilla.com/D39689

--HG--
extra : moz-landing-system : lando
2019-08-06 05:43:21 +00:00
Nicholas Nethercote
c6ce52db91 Bug 1571621 - Convert VarCache prefs in HTMLEditor.cpp to static prefs. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D40775

--HG--
extra : moz-landing-system : lando
2019-08-06 08:49:32 +00:00
Makoto Kato
79bf4210ee Bug 1565919 - Don't separate words by contextual-based character. r=Ehsan
Original regression was by bug 1362858, and bug 1418629 wasn't enough to fix.

By bug 1362858, we use `CHAR_CLASS_SEPARATOR` in additional to DOM word separator. But some characters such as single quote, `@` and etc are `CHAR_CLASS_SEPARATOR`, so we may check spell by incomplete word.

We shouldn't separate word by characters that is email part, URL part or conditional punctuation.

And I also update test cases for this situation. `<textarea>` is better for spell checking since it can has multiple anonymous text nodes.

Differential Revision: https://phabricator.services.mozilla.com/D39829

--HG--
extra : moz-landing-system : lando
2019-08-03 13:44:56 +00:00
Makoto Kato
1545cbbf19 Bug 1570861 - Editor should store text node in mCachedSelectionNode to pass previous selected node/offset to spell checker r=masayuki
When using `<textarea>`, spell checker sometimes check spell when editing last text node. Because editor passes invalid previous selection node and offset via `HandleInlineSpellCheck`.

Although previous selected node uses `mCachedSelectionNode` that is stored by `BeforeEdit`, when this occurs, it isn't text node.

When editing last text node in `<textarea>`, anchror node might be root node, not current text node. So we should use text node instead when this is inserting text operation.

Differential Revision: https://phabricator.services.mozilla.com/D40368

--HG--
extra : moz-landing-system : lando
2019-08-02 07:44:20 +00:00
Masayuki Nakano
11ae238f0f Bug 1569902 - part 4: Make TextEditor inserts padding <br> element for empty last line after setting flags to NS_PADDING_FOR_EMPTY_LAST_LINE r=m_kato
Stopping using attribute for "moz-br", `IMEContentObserver` cannot know when
new `<br>` element is changed to padding element for empty last line.
Therefore, editor needs to insert padding `<br>` element after setting the
flag properly.  Then, `IMEContentObserver` does not need to recompute the
length of `<br>` element (if it's for padding, it computes the length as 0).

Unfortunately, `TextEditor::InsertBrElementWithTransaction()` is used in too
many places and it already has optional argument.  Therefore, it's difficult
to change it.  However, we should share the preparation before creating `<br>`
element in it with new method.  Therefore, this patch creates
`EditorBase::PrepareToInsertBRElement()` to share the preparation point (almost
just moved from the method).  Then, new method is created as
`EditorBase::InsertPaddingBRElementForEmptyLastLineWithTransaction()` because
it's used both in `TextEditor` and `HTMLEditor`.  Finally, `TextEditor` won't
insert `<br>` element with `InsertBrElementWithTransaction()`.  Therefore, it's
moved to `HTMLEditor` with renaming to `InsertBRElementWithTransaction()`.

Differential Revision: https://phabricator.services.mozilla.com/D39860

--HG--
extra : moz-landing-system : lando
2019-08-02 05:46:41 +00:00
Masayuki Nakano
1d359bd94e Bug 1569902 - part 3: Get rid of TextEditRules::CreateBR() r=m_kato
`TextEditRules::CreateBR()` is used only by
`HTMLEditRules::InsertBRIfNeededInternal()` and it just calls
`TextEditor::InsertBrElementWithTransaction()`.  Therefore, we can get rid of
it.  Then, `CreateBRInternal()` can be renamed to
`CreatePaddingBRElementForEmptyLastLine()` since it's shared only by
`CreateBR()` and `CreatePaddingBRElementForEmptyLastLine()`.

Differential Revision: https://phabricator.services.mozilla.com/D39859

--HG--
extra : moz-landing-system : lando
2019-08-02 05:45:56 +00:00
Masayuki Nakano
23a22c597a Bug 1569902 - part 2: Stop using attribute to consider whether a <br> element is a special node for empty last line or not r=m_kato,smaug
Editor creates a `<br>` element to end of a block if last line
of the block is empty because caret should be placed as there is an empty
line.  Such special `<br>` element has `type` attribute whose value is "_moz".
However, adding/removing the attribute is expensive and such hacky attribute
shouldn't be referred nor changed by web apps.

Therefore, this patch makes `HTMLBRElement` take another specific flag whether
it's a special node for empty last line.  For making the meaning clearer,
this patch calls the such `<br>` elements as "padding `<br>` element for
empty last line" insead of "moz-br".  So, this patch also includes a lot of
renaming methods and variables, and modifying related comments.

Note that with this change, `IMEContentObserver` counts the padding `<br>`
element in `<textarea>` because it's inserted before setting the new flag
and setting the flag does not cause DOM tree mutation.  This issue will be
fixed by the following patches.

Differential Revision: https://phabricator.services.mozilla.com/D39858

--HG--
extra : moz-landing-system : lando
2019-08-02 05:45:18 +00:00
Masayuki Nakano
765e91b497 Bug 1569902 - part 1: Stop using attribute to consider whether a <br> element is an editor bogus node or not r=m_kato,smaug
Editor creates a `<br>` element when it's root element is empty.
Then, it's stored by `TextEditRules::mBogusNode` and used for checking
whether the editor is empty quickly.  However, this `<br>` element has
`mozeditorbogusnode` attribute whose value is `true`.  However, adding or
removing the attribute is not cheap and web apps can refer such illegal
attribute.

Therefore, this patch makes `HTMLBRElement` take a specific flag whether
it's a bogus node or not.  However, this means that this hacky thing will be
exposed outside editor module.  For making what is the bogus node clearer,
this patch calls the such `<br>` elements as "padding `<br>` element for
empty editor".  So, this patch also includes a lot of renaming methods and
variables, and modifying related comments.

Differential Revision: https://phabricator.services.mozilla.com/D39857

--HG--
extra : moz-landing-system : lando
2019-08-02 05:44:40 +00:00
Masayuki Nakano
7037a2b100 Bug 1568777 - Make first argument of nsIEditor.unmask() optional r=m_kato
Currently, if you need to unmask all password characters, you need to call
`nsIEditor.unmask(0)`. However, this is ugly and this must be the most use
case. So, I think that we should make it optional.

Differential Revision: https://phabricator.services.mozilla.com/D39327

--HG--
extra : moz-landing-system : lando
2019-07-29 12:21:02 +00:00
Masayuki Nakano
d1512c277c Bug 1568753 - Make TextEditor::SetUnmaskRangeInternal() return NS_OK if there is no text node and aStart is UINT32_MAX r=m_kato
`aStart` of `TextEditor::SetUnmaskRangeInternal()` may be `UINT32_MAX` if
it's called for stopping unmasking.  However, it returns `NS_ERROR_INVALID_ARG`
if there is no text node and `aStart` is not 0, but this is unexpected behavior.

Differential Revision: https://phabricator.services.mozilla.com/D39326

--HG--
extra : moz-landing-system : lando
2019-07-29 06:30:50 +00:00
Masayuki Nakano
fafe168f04 Bug 1560032 - part 2: Make cut/copy in password field available r=m_kato,smaug
First, we need to make `nsCopySupport::FireClipboardEvent()` keep handling
`eCopy` and `eCut` event even in password field, only if `TextEditor` allows
them.

Then, we need to make `nsPlainTextSerializer::AppendText()` not expose
masked password for making users safer.  Although `TextEditor` does not allow
`eCopy` nor `eCut` when selection is not in unmasked range.  Fortunately,
retrieving masked and unmasked password from `nsTextFragment` has already
been implemented in `ContentEventHandler.cpp`.  This patch moves it into
`EditorUtils` and makes `ContentEventHandler.cpp` and `nsPlaintextSerializer`
share it.

Differential Revision: https://phabricator.services.mozilla.com/D39000

--HG--
extra : moz-landing-system : lando
2019-07-29 06:21:42 +00:00
Masayuki Nakano
ffbb14909f Bug 1560032 - part 1: Make TextEditor for password allow to copy password when selected range is in unmasked range r=m_kato
It does not make sense to copy masked password with mask characters.
Therefore, we should allow users to copy/cut in password fields only when
selected range is in unmasked range.

Note that for web-compat, copy/cut are always enabled in HTML/XHTML document
in content.  Therefore this patch changes the behavior only in chrome's
password fields.

Additionally, only the test uses `nsIEditor.canDelete()`.  Therefore, this
removes it and make the test use `nsIDocShell.isCommandEnabled()` instead.
Unfortunately, `nsIEditor.canCopy()` and `nsIEditor.canCut()` are used by
BlueGriffon, therefore, we cannot get rid of them for now.

Differential Revision: https://phabricator.services.mozilla.com/D38999

--HG--
rename : editor/libeditor/tests/test_bug1067255.html => editor/libeditor/tests/test_cut_copy_delete_command_enabled.html
extra : moz-landing-system : lando
2019-07-29 06:21:14 +00:00
Kannan Vijayan
3fb6190ec6 Bug 1559414 - Rename unaudited pre-fission methods with SameProcess for future audit burndown. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D39378

--HG--
extra : moz-landing-system : lando
2019-07-26 16:48:31 +00:00
Nicholas Nethercote
18fae65f38 Bug 1563139 - Remove StaticPrefs.h. r=glandium
This requires replacing inclusions of it with inclusions of more specific prefs
files.

The exception is that StaticPrefsAll.h, which is equivalent to StaticPrefs.h,
and is used in `Codegen.py` because doing something smarter is tricky and
suitable for a follow-up. As a result, any change to StaticPrefList.yaml will
still trigger recompilation of all the generated DOM bindings files, but that's
still a big improvement over trigger recompilation of every file that uses
static prefs.

Most of the changes in this commit are very boring. The only changes that are
not boring are modules/libpref/*, Codegen.py, and ServoBindings.toml.

Differential Revision: https://phabricator.services.mozilla.com/D39138

--HG--
extra : moz-landing-system : lando
2019-07-26 01:10:23 +00:00
Masayuki Nakano
15fcb38af8 Bug 1548389 - part 10: Make TextEditor::SetUnmaskRangeInternal() expand the range if specified offset is middle of a surrogate pair r=m_kato
Unmasking is an optional style of showing password.  Therefore, if callers of
`nsIEditor::Unmask()` specify middle of surrogate pair(s), it may mean that
they want to expand the unmask range from shorter range which does not include
the high and/or low surrogate.  Therefore, one of the surrogates is in unmasked
range, we unmask the surrogate pair.  However, we handle this in a lot of
places, i..e., we have duplicated code.  This can get rid of these duplicates
with making `nsIEditor::Unmask()` expand the range automatically.

Differential Revision: https://phabricator.services.mozilla.com/D38432

--HG--
extra : moz-landing-system : lando
2019-07-22 03:56:33 +00:00
Masayuki Nakano
9dc8292d3f Bug 1548389 - part 8: Make nsTextFrame::PeekOffsetWord() scan masked text r=jfkthame
Double click, long tap, moving selection with keyboard and deleting text
scan word boundary.  With these changes, the text node has raw password
value even if it's masked visually.  For making safer,
`nsTextFrame::PeekOffsetWord()` should search word boundary in masked text.
Then, we can hide word boundary at masked range, but keep allowing to look
for word boundary only in unmasked range.

Differential Revision: https://phabricator.services.mozilla.com/D38013

--HG--
extra : moz-landing-system : lando
2019-07-22 03:55:53 +00:00
Masayuki Nakano
1c2108934c Bug 1548389 - part 6: Add automated tests for new API and rendering of password fields r=m_kato,Jamie
Differential Revision: https://phabricator.services.mozilla.com/D38010

--HG--
extra : moz-landing-system : lando
2019-07-22 03:55:13 +00:00
Masayuki Nakano
5febecd19b Bug 1548389 - part 5: Make nsTextFrame and related code treat masking password characters as text-transform r=jfkthame
Anonymous text node in password field has `NS_MAYBE_MASKED` flag and
`TextEditor` managing the node has range of unmasking.  This patch makes
`BuildTextRunsScanner::BuildTextRunForFrames()` treat text frame in
password field as `text-transform` applied.  For recording the unmask range,
this patch creates `nsTransformedCharStyle::mMaskPassword` and treats unmask
range start/end edges as different style boundary.  Therefore,
`nsCaseTransformTextRunFactory::TransformString()` can replace each character
with a password mask character with the information.

Note that we need to kill bidi algorithm in password fields with forms.css
because caret position will tell everybody whether the typing character is
an RTL or an LTR character.

Differential Revision: https://phabricator.services.mozilla.com/D38009

--HG--
extra : moz-landing-system : lando
2019-07-22 03:54:50 +00:00
Masayuki Nakano
3102de8053 Bug 1548389 - part 3: Make editor mark text node in password field as "maybe masked" r=smaug
With the previous patches, editor has stopped masking characters in password
field.  Instead, layout code needs to handle it.  However, layout code
especially around `nsTextFrame` is performance critical area.  Therefore,
layout code requires a quick way to check whether a text node in password
field or not.

This patch creates new flag for `CharacterData` node and marks all text nodes
whose characters should be masked with the flag when `EditorBase` or
`nsTextControlFrame` creates them.

Differential Revision: https://phabricator.services.mozilla.com/D38006

--HG--
extra : moz-landing-system : lando
2019-07-22 03:54:16 +00:00
Masayuki Nakano
b8d245a76d Bug 1548389 - part 2: Make TextEditRules use the new editor API to mask/unmask characters in password editor r=m_kato
Now, `TextEditRules` should use the new editor API to mask/unmask characters
if it's for a password editor.  With this change, it does not need to manage
masked characters and unmasked characters separately since the anonymous
text node always have unmasked characters and `nsTextFrame` will mask the
characters at painting time.

Differential Revision: https://phabricator.services.mozilla.com/D38005

--HG--
extra : moz-landing-system : lando
2019-07-22 03:53:58 +00:00
Masayuki Nakano
010cde10c1 Bug 1548389 - part 1: Implement API to get/set unmask-range of password editor r=m_kato
This patch creates editor API to get/set unmask-range of password field.
Its design is similar to `setSelectionRange()` and `selectionStart`/
`selectionEnd` attributes.   The unmasked range is automatically
masked if `aTimeout` of `unmask()` is set to non-zero.
Otherwise, unmasked range won't be masked automatically even after user
or web apps modifies the editor, and inserting new character expands
unmasking range.

The following patch makes `TextEditRules` use these API to implement
delayed masking of password.

Note that editor has never supported dynamic `eEditorPasswordMask` change.
E.g., if you have typed some characters into an editor and toggle the flag,
the characters are not unmasked nor masked.  Then, if you type new characters,
only they are correctly masked or unmasked.  This patch puts `MOZ_ASSERT()`
to reject this feature completely on debug build for making the unmasking
implementation simpler.

Differential Revision: https://phabricator.services.mozilla.com/D38004

--HG--
extra : moz-landing-system : lando
2019-07-22 03:53:36 +00:00
Masayuki Nakano
ca49cc9d2d Bug 1548389 - part 0: Wrap modifying text node in editor with particular methods r=m_kato
In the next patch, we need to update unmasked range when anonymous text node
in `<input type="password">` is modified.  This patch makes editor manage it
easier to update the range.

Note that the next patch also handles text node creation and destruction.

Differential Revision: https://phabricator.services.mozilla.com/D38003

--HG--
extra : moz-landing-system : lando
2019-07-22 03:53:29 +00:00
Mirko Brodesser
1669cc6770 Bug 1566046: rename GetParentOrHostNode to GetParentOrShadowHostNode. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D38078
2019-07-16 09:25:02 +02:00
Mirko Brodesser
2f40f072ab Bug 1565584: move nsIContentUtils::ContentIsDescendantOf to nsINode::IsInclusiveDescendantOf. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D37880
2019-07-15 10:02:21 +02:00
Brendan Dahl
84f1f82f3d Bug 1557371 - Part 1 - Load all XUL reftests with chrome privilege. r=dbaron
This will have two benefits:

1) Align test setup with shipping Firefox - We don't allow content
privilege XUL in shipping versions of Firefox, so having the tests be
chrome would be more realistic to our use case.

2) Support the XUL to XHTML migration. These files will soon become XHTML
files, but will still need to load XUL elements, so they'll need to be
marked as chrome privileged to continue working.

One test (404149-1.xul) is now disabled, since it fails when loaded as
chrome. Bug 1557383 was filed to address this.

Differential Revision: https://phabricator.services.mozilla.com/D33986

--HG--
extra : moz-landing-system : lando
2019-07-09 19:40:33 +00:00
Emilio Cobos Álvarez
c17be889ab Bug 1218456 - Remove nsILinkHandler. r=smaug
Interfaces with just one implementation don't seem very useful.

Differential Revision: https://phabricator.services.mozilla.com/D37406
2019-07-09 23:08:05 +02:00
Emilio Cobos Álvarez
28801c9e84 Bug 1218456 - Allow navigating when there's no pres context. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D37404
2019-07-09 23:07:29 +02:00
Dorel Luca
9925ca654c Backed out 5 changesets (bug 1218456) for Crashtest failures on dom/l10n/tests/mochitest/dom_localization/test_overlay.html. CLOSED TREE
Backed out changeset 31afe89c2d42 (bug 1218456)
Backed out changeset 8bd57ebc4528 (bug 1218456)
Backed out changeset e5d37afff36a (bug 1218456)
Backed out changeset e3da86278ecf (bug 1218456)
Backed out changeset 343046089f8e (bug 1218456)

--HG--
extra : rebase_source : f092d903c8c80581d187493e036b1875d8668b3d
2019-07-09 22:04:13 +03:00
Emilio Cobos Álvarez
23a7cb7a68 Bug 1218456 - Remove nsILinkHandler. r=smaug
Interfaces with just one implementation don't seem very useful.

Differential Revision: https://phabricator.services.mozilla.com/D37406

--HG--
extra : moz-landing-system : lando
2019-07-09 16:17:47 +00:00