Граф коммитов

52 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 19fbb1a392 Bug 1549925 - Mark all methods of nsIDocumentStateListener as can_run_script r=m_kato
`nsIDocumentStateListener` is a scriptable interface and each method may run
any script.  So, we should mark them as `can_run_script`.  Then, we need to
mark a lot of editing methods because we need to mark
`EditorBase::EndTransactionInternal()` and `EditorBase::DoTransactionInternal()`
as `MOZ_CAN_RUN_SCRIPT`.

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

--HG--
extra : moz-landing-system : lando
2019-05-09 07:37:51 +00:00
Mirko Brodesser 6b88118d6b Bug 1540632: change exception and correct setting selectionStart/End/Direction for type change of '<input>' element r=smaug
- Change exception when setting '<input type="file">'s value according to spec.

- Set 'selectionStart', 'selectionEnd', 'selectionDirection' according
  to https://html.spec.whatwg.org/multipage/input.html#signal-a-type-change.

- Minorly update nsTextEditorState's documentation.

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

--HG--
extra : moz-landing-system : lando
2019-04-09 06:42:15 +00:00
Emilio Cobos Álvarez 39d3da7fd5 Bug 1528644 - Internal value changes shouldn't change validity state. r=masayuki
Even less so on reframe, where it's just unsound to do so. I had to give a value
to eSetValue_Internal, since otherwise I cannot check for its presence. I can
further special-case the reframe case if you prefer.

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

--HG--
extra : moz-landing-system : lando
2019-02-19 09:25:55 +00:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Masayuki Nakano cc3adb8c9e Bug 1504911 - part 2: Make nsTextEditorState::SetValue() dispatch "input" event if it's called for handling part of user input r=smaug
When editor is modified as part of user action, aFlags of
nsTextEditorState::SetValue() includes eSetValue_BySetUserInput.  In this case,
TextEditor (if there is) or the method itself (if there is no editor yet)
should dispatch "input" event by themselves because we will need to initialize
InputEvents more since we're going to implement Input Event specs.

Note that even with this patch, password field stops dispatching "input" event
with call of HTMLInputElement::SetUserInput().  This is caused by a hidden bug
of TextEditRules.   This will be fixed in a following patch.

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

--HG--
extra : moz-landing-system : lando
2018-11-20 22:06:37 +00:00
Masayuki Nakano abe138f771 Bug 1504911 - part 1: Make all "input" event dispatcher in C++ use new utility method r=smaug
Currently, a lot of code dispatch "input" event and some of them dispatch
"input" event with wrong interface and/or values.  Therefore this patch
creates nsContentUtils::DispatchInputEvent() to make all of them dispatch
correct event.

Unfortunately, due to bug 1506439, we cannot set pointer to refcountable
classes of MOZ_CAN_RUN_SCRIPT method to nullptr.  Therefore, this patch
creates temporary RefPtr<TextEditor> a lot even though it makes damage to
the performance if it's in a hot path.

This patch makes eEditorInput event dispatched with
InternalEditorInputEvent when "input" event should be dispatched with
dom::InputEvent.  However, this patch uses WidgetEvent whose message is
eUnidentifiedEvent and setting WidgetEvent::mSpecifiedEventType to
nsGkAtoms::oninput when "input" event should be dispatched with
dom::Event because we need to keep that eEditorInput and
InternalEditorInputEvent are mapped each other.

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

--HG--
extra : moz-landing-system : lando
2018-11-21 03:59:02 +00:00
Boris Zbarsky f82660f831 Bug 1456169 part 2. Remove the now-unnecessary nsITextControlElement::GetPlaceholderNode. r=emilio
MozReview-Commit-ID: FcVbeHEwkMz
2018-04-24 02:17:17 -04:00
Masayuki Nakano 2239a68bf8 Bug 1432528 - part 1: Expose nsTextInputListener as mozilla::TextInputListener with independent header r=m_kato
EditorBase needs to access nsTextInputListener directly for saving runtime
cost of EditorBase::NotifyEditorObservers().  Therefore, it should be
exposed as "mozilla/TextInputLitener.h".

This patch rename it to mozilla::TextInputListener too.

MozReview-Commit-ID: 6PMzNWfTIHW

--HG--
rename : dom/html/nsTextEditorState.cpp => dom/html/TextInputListener.h
extra : rebase_source : 43c685a8f4c023c62bea26b3bf55b4f728ab438e
2018-01-24 11:44:34 +09:00
Emilio Cobos Álvarez b4949a9204 Bug 1401706: Move ownership of editor anon content to nsTextControlFrame. r=Ehsan
MozReview-Commit-ID: 4QpbarX5dvf
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>

--HG--
extra : rebase_source : f2bd73c696bc3e7937a8e6c365c9ef31a6888524
2017-09-22 02:18:30 +02:00
Masayuki Nakano 428b006ab1 Bug 1395146 - part3: nsTextEditorState should cache empty value with mCachedValue r=smaug
nsTextEditorState::GetValue() uses mCachedValue only when the value isn't empty
string.  However, with SetIsVoid() and IsVoid() of nsAString, nsTextEditorState
can cache empty value only with mCachedValue.

MozReview-Commit-ID: AmQDquEn9M8

--HG--
extra : rebase_source : 3acfe765cbe37664ef3e28e640753da240bf38a4
2017-08-30 20:54:45 +09:00
Masayuki Nakano 0356f81706 Bug 1395146 - part2: Make nsTextEditorState cache the value of TextEditor with mCachedValue even when the editor is single line text control r=smaug
Currently, nsTextEditorState caches the value of TextEditor only when it's for
a multi-line text control, i.e., <textarea>.  However, using it for single-line
text control improves the score of attachment 8848015.  Although this might
increase the cost of creating and registering mutation observer, but it may not
make damage to performance of loading pages since editor for each element won't
be initialized until each element gets focus.

MozReview-Commit-ID: DnjEJ5AUh3M

--HG--
extra : rebase_source : 8f45cb57ac03dff9a696acaaa5d0fd35faed0c09
2017-08-30 19:43:00 +09:00
Masayuki Nakano b3c33d13ad Bug 1395146 - part1: Get rid of nsITextControlElement::IsPlainTextControl() and nsTextEditorState::IsPlainTextEditor() r=smaug
nsTextEditorState::GetValue() refers nsITextControlElement::IsPlainTextControl()
via nsTextEditorState::IsPlainTextEditor().  However, it always returns true and
virtual call with QI.  So, we should get rid of these unnecessary methods.

MozReview-Commit-ID: 3gHdGrzlys4

--HG--
extra : rebase_source : a1be33a18e93e64b8cc87e4f12d5e494b14520bf
2017-08-30 18:57:55 +09:00
Ehsan Akhgari 22aa56b6cd Bug 1386222 - Ensure that we always respect the undo/redo transaction history when modifying the <xul:textbox>.value dynamically through script; r=bzbarsky 2017-08-01 13:59:45 -04:00
Masayuki Nakano 7ad4ad3aab Bug 1374207 - part1: nsTextEditorState should use mozilla::TextEditor instead of editor interfaces r=smaug
Using concrete class rather than interface classes (nsI*Editor) will allow to reduce QI and some virtual calls.  Therefore, Editor classes should be used as concrete class as far as possible.

Unfortunately, if classes referring editor are initialized via scriptable interface, we cannot do this because nsI*Editor is still not marked as builtinclass.  Therefore, their editor may be implemented by JS.  E.g., inline nsIInlineSpellChecker.init() and nsIDocShell.editor.  Such remaining cases should be fixed after nsI*Editor classes are marked as builtinclass.

Note that this patch also creates nsIdentifierMapEntry.h which is separated from nsDocument.h because ShadowRoot.h needs the class but exposing nsDocument.h to the global and includes it causes bustage on Linux and Android.  Therefore, for fixing the include hell, this patch touches them and ContentChild.cpp.

MozReview-Commit-ID: i6fLWw6Qeo

--HG--
rename : dom/base/nsDocument.h => dom/base/nsIdentifierMapEntry.h
extra : rebase_source : c57bdfc1c13775acdcfd4732d8157d04d6b6613f
2017-06-20 22:57:08 +09:00
Makoto Kato 23c3e741f1 Bug 1368888 - Don't get previous value twice in input.value setter. r=smaug
We get previous input.value twice in HTMLInputElement::SetValue and nsTextEditorState::SetValue when setting input.value.  Since nsTextEditorState::GetValue uses DocumentEncoder, it is expensive.  So we should use old value as parameter of nsTextEditorState::SetValue if possible.

MozReview-Commit-ID: A1UPfETTVCn

--HG--
extra : rebase_source : f751289b42b4d9d5c389042f688c53bde47d1620
2017-06-14 18:21:01 +09:00
Makoto Kato 66f56b4e7d Bug 1360154 - Part 2. Add fast path to check whether valus is emtpy. r=masayuki
Actually, we use GetValue to check whether value is empty or not for placeholder.  But since GetValue uses TextEditor::OutputToString when on editor, it is expensive.  Since editor has DocumentIsEmpty method, we should use it for this case.

MozReview-Commit-ID: rQX8yjnWQz

--HG--
extra : rebase_source : 25ec89385d704f5c4d2d0a15021c2a59b0201983
2017-05-11 14:04:18 +09:00
Makoto Kato 2b45a511bb Bug 1352799 - Always set maxlength on initializing editor. r=masayuki
maxlength will be set by nsTextControlFrame::AttributeChanged via RestyleManager. If element is display:none, RestyleManager won't call Frame's AttributeChanged. So we should always initialize maxlength when setting focus.

Also, wrap attribute for textarea element will be updated by HTMLTextAreaElement even if display:none.  So this issue doesn't occur.  maxlength might have to be updated by HTMLInputElement.  But it is unnecessary to update editor's maxlength on display:none since this is used on focused editor.

MozReview-Commit-ID: JHODOBTv62v

--HG--
extra : rebase_source : eeabd25f6f7d2802b5a97ae8be225182c6df88de
2017-04-20 10:23:01 +09:00
Boris Zbarsky 29d5ae0bfd Bug 1357206 part 4. Don't move the cursor even if eSetValue_MoveCursorToEndIfValueChanged is set, if the value did not change. r=ehsan 2017-05-01 13:28:54 -04:00
Boris Zbarsky ff31c3ca29 Bug 1357206 part 3. Rename eSetValue_MoveCursorToEnd to eSetValue_MoveCursorToEndIfValueChanged, because those are the semantics we want for it. r=ehsan
No actual behavior change here.
2017-05-01 13:26:21 -04:00
Ray Lin acabd05355 Bug 1340483 - Part 4. Update input visibility accordingly. r=heycam
MozReview-Commit-ID: 7eBhj7w4qhP

--HG--
extra : rebase_source : 3610353fbb4e8d4c1abed57536a0bab3a537b134
2017-03-30 17:38:59 +08:00
Ray Lin 903f54b822 Bug 1340483 - Part 2. Expose chrome-only previewValue attribute. r=baku,heycam
MozReview-Commit-ID: BCu0vXVm6wj

--HG--
extra : rebase_source : 22d67ab3824c0df53daf3e3299a45c17746f62a3
2017-03-21 00:08:01 +08:00
Ray Lin c444b0fb87 Bug 1340483 - Part 1. Create empty anonymous node for autofill preview. r=heycam
MozReview-Commit-ID: GTVgIPoogp9

--HG--
extra : rebase_source : 1dd63792ec76c167473c91bc8dc5ec87cbd93c08
2017-03-20 11:53:40 +08:00
Olli Pettay d5caa7c6c0 Bug 1352687, try to recycle HTMLInputElement's nsTextEditorState, r=baku
--HG--
extra : rebase_source : 05c8dc2bd0c29ce3064548e1cabac2d62803cabc
2017-04-03 20:40:48 +03:00
Boris Zbarsky f80dd7a663 Bug 1345237. Propagate uint32_t deeper into the editor state and text control frame code. r=mystor
MozReview-Commit-ID: KeUo8My6eBJ
2017-03-09 14:44:45 -05:00
Boris Zbarsky 0cf9adf6a5 Bug 1343037 part 18. Implement nsTextEditorState::SetRangeText. r=ehsan
MozReview-Commit-ID: FEo9yv5iu6U
2017-03-09 14:44:06 -05:00
Boris Zbarsky 060aadda89 Bug 1343037 part 16. Implement a version of nsTextEditorState::SetSelectionRange that takes a string for the direction. r=ehsan
MozReview-Commit-ID: E8zYAWolg94
2017-03-09 14:44:06 -05:00
Boris Zbarsky 0270554a22 Bug 1343037 part 15. Implement nsTextEditorState::GetSelectionDirection. r=ehsan
MozReview-Commit-ID: 1bLLYhjmlff
2017-03-09 14:44:06 -05:00
Boris Zbarsky b72fd0bc98 Bug 1343037 part 14. Implement nsTextEditorState::SetSelectionDirection. r=ehsan
This introduces two behavior changes:

1)  In cached mode, we used to treat unknown selection directions as "none".
    Now we treat it like "forward", consistently with the "have an editor" mode.
2)  Before this change, in cached mode, we did not fire "select" events on
    selectionDirection changes.

MozReview-Commit-ID: 4nBCAm3mAiz
2017-03-09 14:44:06 -05:00
Boris Zbarsky e0ef9813e4 Bug 1343037 part 13. Implement nsTextEditorState::SetSelectionEnd. r=ehsan
This introduces three behavior changes:

1)  Before this change, in cached mode, we did not enforce the "start <= end"
    invariant.
2)  Before this change, in cached mode, we did not fire "select" events on
    selectionEnd changes.
3)  Changes the IDL type of HTMLInputElement's selectionEnd attribute to
    "unsigned long" to match the spec and HTMLTextareaElement.

MozReview-Commit-ID: J3Gkhr8VnbS
2017-03-09 14:44:05 -05:00
Boris Zbarsky badbeff5ec Bug 1343037 part 12. Implement nsTextEditorState::SetSelectionStart. r=ehsan
This introduces three behavior changes:

1)  Before this change, in cached mode, we did not enforce the "start <= end"
    invariant.
2)  Before this change, in cached mode, we did not fire "select" events on
    selectionStart changes.
3)  Changes the IDL type of HTMLInputElement's selectionStart attribute to
    "unsigned long" to match the spec and HTMLTextareaElement.

MozReview-Commit-ID: JM9XXMMPUHM
2017-03-09 14:44:05 -05:00
Boris Zbarsky 92746e9a48 Bug 1343037 part 11. Implement a SetSelectionRange function on nsTextEditorState. r=ehsan
MozReview-Commit-ID: 5xUkcnkptwQ
2017-03-09 14:44:05 -05:00
Boris Zbarsky a44c859126 Bug 1343037 part 9. Simplify the setup around the editor state's GetSelectionDirection function. r=ehsan
Really, there are only two cases we need to worry about.  Either
IsSelectionCached(), and then our SelectionProperties has the data we want, or
not and then we have a non-null mSelCon which has the data we want.

MozReview-Commit-ID: AEW9D1zG6sM
2017-03-09 14:44:05 -05:00
Boris Zbarsky 5ae7da9d14 Bug 1343037 part 6. Simplify the setup around the editor state's GetSelectionRange function. r=ehsan
Really, there are only two cases we need to worry about.  Either
IsSelectionCached(), and then our SelectionProperties has the data we want, or
not and then we have a non-null mSelCon which has the data we want.

Since we are now using cached selection state a lot more (instead of
initializing the editor whenever someone asks for selection state), we need to
actually update it more correctly when .value is set.

And since we now update the cached selection state for the case when .value has
been set (to point to the end of the text), we need to change
HTMLInputElement::HasCachedSelection to return false for that case.  Otherwise
we will always do eager editor init on value set.  We handle that by not doing
eager init if the cached selection is collapsed.

The web platform test changes test the "update on .value set" behavior.  They
fail without this patch, pass with it.

MozReview-Commit-ID: DDU8U4MGb23
2017-03-09 14:44:04 -05:00
Boris Zbarsky 2bf2020b52 Bug 1343037 part 4. Fix type changes on an input to properly grab the selection offsets from the old editor before we ask the editor state for them. r=ehsan
MozReview-Commit-ID: IDdt0qedJpT
2017-03-09 14:44:04 -05:00
Boris Zbarsky d2afbdd254 Bug 1342197 part 4. Move GetSelectionRange from nsTextControlFrame to the editor state. r=ehsan
At this point, all this method does is ensure editor initialization and then ask
the editor state for various information.  Let's cut out the middleman.

MozReview-Commit-ID: p491umScJO
2017-02-28 12:41:37 -05:00
Bobby Holley c2cbbe5f56 Bug 1295370 - Stop lazily creating the root node in nsTextEditorState::GetRootFrame. r=ehsan
AFAICT this doesn't change behavior, since all the callers of GetRootNode should
occur after we've already called BindToFrame. However, it makes it easier for
future static analysis to see that we don't trigger node creation from
nsTextControlFrame::AppendAnonymousContentTo.
2016-08-17 12:46:53 -07:00
Decky Coss 08a416fd4e Bug 1283915 - Preserve input selection properties after type change. r=smaug
MozReview-Commit-ID: 7xJKc3vIpTY

--HG--
extra : rebase_source : 6fa36a607efb1e8eec1cc8efbb174d622aa0281f
2016-07-27 11:04:53 -04:00
Decky Coss b69450d2ea Bug 1287655 - place textarea/input cursor at end of text when initialized; r=smaug
MozReview-Commit-ID: 2srGXFmla07

--HG--
extra : transplant_source : %3Cn%D30%86%24%82%90%29%191%9C%8A%EB%0D%5D%E2%20%22%E5
2016-07-21 14:52:49 -04:00
Jonathan Watt b15368cfcb Bug 1279451 - Remove a lot of unnecessary includes of nsAutoPtr.h. rs=sparky 2016-06-07 21:10:18 +01:00
Nicholas Nethercote 2511b2c327 Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj.
It's an annotation that is used a lot, and should be used even more, so a
shorter name is better.

MozReview-Commit-ID: 1VS4Dney4WX

--HG--
extra : rebase_source : b26919c1b0fcb32e5339adeef5be5becae6032cf
2016-04-27 14:16:50 +10:00
Nathan Froyd 64fe772d2f Bug 1132499 - part 2 - convert nsTextEditorState::mValue to be an nsString; r=ehsan
I don't know the full history here; roc asked about this exact thing in
bug 534785 when reviewing the creation of nsTextEditorState.  The answer
then was "historical reasons" (the original code is hg@1)...maybe to try
and save some space?  Regardless, since the only thing we do here is
convert from/to incoming/outgoing nsStrings, which at least sometimes
appear to be causing OOMs, we might as well hold it as an nsString all
the time.  This change will ideally eliminate allocations, as we'll be
able to use nsString's buffer sharing underneath the hood.
2016-03-04 10:29:01 -05:00
Nathan Froyd f0c8d767c9 Bug 1132499 - part 1 - convert nsTextEditorState::mValue to use Maybe instead of heap allocation; r=ehsan
This change is just a minor tidying; we need to distinguish between
"have a value" and "don't have a value" in nsTextEditorState::GetValue,
but we can do better than heap-allocating the string.
2016-03-04 09:56:13 -05:00
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Birunthan Mohanathas a8939590de Bug 1182996 - Fix and add missing namespace comments. rs=ehsan
The bulk of this commit was generated by running:

  run-clang-tidy.py \
    -checks='-*,llvm-namespace-comment' \
    -header-filter=^/.../mozilla-central/.* \
    -fix
2015-07-13 08:25:42 -07:00
Masayuki Nakano ecdd7a7f0f Bug 549674 part.1 Commit composition string at setting value of <input> or <textarea> r=smaug 2015-06-18 23:56:20 +09:00
Andrew McCreight 9e8f4b219e Bug 1152551, part 2 - Fix mode lines in dom/. r=jst 2015-05-03 15:32:37 -04:00
Andrew McCreight 0c176ddcff Bug 1062479 - Use static strings for WeakReference type names. r=ehsan 2015-04-24 09:43:01 -07:00
Ehsan Akhgari 3f3e975f18 Bug 1155469 - Mark nsTextEditorState::mTextCtrlElement as MOZ_NON_OWNING_REF; r=baku 2015-04-17 11:14:46 -04:00
Ehsan Akhgari e7830328c1 Bug 1154336 - Convert nsTextEditorState::mRestoringSelection into a strong reference; r=baku 2015-04-14 15:13:35 -04:00
Ehsan Akhgari 2e58c3092f Bug 1122786 - Make nsTextEditorState::mTextListener an nsRefPtr; r=roc 2015-01-22 23:18:56 -05:00