Unfortunately, `EventChainVisitor` does not grab the `nsPresContext` with
`RefPtr` by itself. Therefore, there is no guarantee of the lifetime without
checking the origin when its subclasses are instantiated. This patch changes
it and subclasses to `MOZ_STACK_CLASS` since only `EventDispatcher::Dispatch()`
creates them in the stack with given `nsPresContext`. Additionally, it's
already been marked as MOZ_CAN_RUN_SCRIPT_BOUNDARY`. Therefore, the
`nsPresContext` instance has already been guaranteed its lifetime by the
caller. For making this fact stronger, this patch marks their constructors
as `MOZ_CAN_RUN_SCRIPT`. Therefore, nobody can create those instances without
guaranteeing the lifetime of `nsPresContext` and `dom::Event`. Note that
it may look like that `mPresContext` of `EventChainPostVisitor` is not
guaranteed. However, `EventChainPreVisitor` which gives `nsPresContext` to it
is also a stack only class. So, it won't be deleted before
`EventChainPostVisitor` instance.
Differential Revision: https://phabricator.services.mozilla.com/D30010
--HG--
extra : moz-landing-system : lando
This patch changes remaining things under `layout/`. However, there are some
places which still need to use `nsIPresShell`. That will be fixed in a
follow up bug.
Differential Revision: https://phabricator.services.mozilla.com/D27477
--HG--
extra : moz-landing-system : lando
The added crashtest still crashes on Android verify runs (TV) for
unknown reasons, so skip it.
Differential Revision: https://phabricator.services.mozilla.com/D16395
--HG--
extra : moz-landing-system : lando
By disallowing flushing layout in AccessibleCaret's callbacks, we don't
need to worry about dead PresShell affect other callbacks in the system.
Differential Revision: https://phabricator.services.mozilla.com/D15537
--HG--
extra : moz-landing-system : lando
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.
Overall it's not a very interesting patch I think.
nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.
I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.
While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
Currently, if the "layout.accessiblecaret.allow_script_change_updates"
pref is false, we always hide accessible carets when the selection
changes due to JS calls (e.g. setSelectionRange(0, 1)). If the pref is
true, instead, we update the accessible carets if they are already
visible. In either case, we never show the carets if they're invisible.
However for testing purposes, it's useful to make it so we do try to
show the carets if they're invisible. This patch replaces that pref with
the new integer pref "layout.accessiblecaret.script_change_update_mode",
which can be 0 or 1, which correspond to the old pref, or the value 2,
which introduces this new behavior of always showing the carets.
MozReview-Commit-ID: Bf1gPpIzcyb
--HG--
extra : rebase_source : 5eaba6c18d800da425d5e21f61af880678d7fe3c
This feature is B2G only. Remove it to make AccessibleCaret simpler to
maintain.
MozReview-Commit-ID: 7JZw5XtaUeU
--HG--
extra : rebase_source : aba249d361723feeaf769a3b802564dbcd6ca9ea
The accessible caret manager is owned by the event hub, that is owned by the
shell.
All the callers of methods that call FlushLayout on the AccessibleCaretManager
should hold an external reference to the event hub.
Flushing pending notifications can run arbitrary script, that can call Destroy()
on the pres shell (and thus tear down the accessible caret event hub, and the
manager with him).
I don't know why before my change this wasn't crashing badly, but the code as it
was just doesn't look sound to me at all either (maybe I'm misunderstanding
something and I should just revert that patch and give up on having nice
invariants during our flushes..., but I don't think it's the case).
This also adds some sanity-checking that we don't die under our flush.
MozReview-Commit-ID: 4s0UT0fD3TI
Fix warning: the parameter 'aHints' is copied for each invocation but only
used as a const reference; consider making it a const reference
MozReview-Commit-ID: 6CyT6gxVgES
--HG--
extra : rebase_source : e93f4eee24a2ef1e27dcfc43725fb5600f1b2d5b
Fix warning: use '= default' to define a trivial destructor
I added #include "nsDocShell.h" because I got an error "incomplete type
'nsDocShell' used in nested name specifier." After that, some files like
nsCanvasFrame.cpp fails to compile because they include
AccessibleCaretEventHub.h. Hence the moz.build changes.
MozReview-Commit-ID: BYZx7txvkSn
--HG--
extra : rebase_source : 2a4e8c25eb1c596486d540f2a5a34a00dc675881
The issue is: when we hit some failure conditions in DragCaretInternal()
such as the frame is not selectable, or no frame is under the point, etc.,
we'll early return so that the auto scroll code is not being executed.
The logic in StartSelectionAutoScrollTimer() is similar to how
nsFrame::HandleDrag() handles the auto scrolling.
MozReview-Commit-ID: FtXZ8BWp3BX
--HG--
extra : rebase_source : 9526c10987286316ac76c536cc9086de65931797
Per description in bug 1361072, this is the standard idiom to assign
outparam pointers of refcounted types.
MozReview-Commit-ID: 6kmDslMs94j
--HG--
extra : rebase_source : c151f0e6050cfd3ce1cf914eeb350166c539d160
The feature is controlled by pref layout.accessiblecaret.timeout_ms, and has been disabled in bug 1268410.
It's time to remove relevant code from the tree.
MozReview-Commit-ID: LLu8RiQcTpm
--HG--
extra : rebase_source : 906299afe9fbcb4bad2c74c83f19eb98b8815882
Override OnScrollPositionChanged() in ScrollState because we want to update
carets during scrolling in subframes without APZ.
Due to the observation in bug 1273045 comment 8, we do not distinguish
PositionChangedResult::NotChanged and PositionChangedResult::Changed.
Instead, we always update caret even if its position is not changed.
To avoid excessive CaretStateChangedEvents are dispatched in
OnScrollPositionChanged(), we add IsScrollStarted to distinguish whether
OnScrollStart() is called or not.
MozReview-Commit-ID: KNi9Mct4dSk
--HG--
extra : rebase_source : 61d29fb0e1b6b91971217d3f45a791c456fa4f07
Part 2 is going to add a new hint which will use with RespectOldAppearance.
Hence this patch.
Remove #include "mozilla/WeakPtr.h" and "nsWeakReference.h" because they're
not used in the header.
MozReview-Commit-ID: KiNv0M0v8iO
--HG--
extra : rebase_source : 0969fc5accf11ac69bc97e3a51569b063172ffe3
When the user switches back to a tab which has the selection highlight on
the document, call UpdateCarets() to bring the carets back.
MozReview-Commit-ID: LxNoNRl4FHZ
--HG--
extra : rebase_source : f6fdc9b5c646b064bbe1e27456bbeaac063bd04c
That is, exclude the text overlay to fix the double clicking and triple
clicking on a word in editable text area.
MozReview-Commit-ID: 5bELcNSRo2A
--HG--
extra : rebase_source : 4664e186b13b3170022c0fe294f580cd15650271
Add a pref "layout.accessiblecaret.always_show_when_scrolling" defaults
to true on all platforms except b2g. When it is set to false, the carets
will be hidden during scrolling, which is the current behavior before
applying this change.
The pref "layout.accessiblecaret.extendedvisibility" was added for
Fennec to keep ActionBar open when carets temporarily hiding during
panning or zooming. Now we make carets always show by default, so the
pref can be removed. However, the floating toolbar still need to be
notified when the scrolling begins, so we dispatch "scroll" instead.
In gtest, the preference changes were in the middle of the test
function. To make the preference change clearer, I add new pref changes
or move the existing ones to the beginning of the test functions.
The 250ms transition effect added in ua.css is per request of UX
designer in bug 1249201 comment 12.
MozReview-Commit-ID: 8NGvDLPbtNY
--HG--
extra : rebase_source : 3f7a9ebdf4c70b0282dbf9e8f18cbe5cca656dbe
This behavior matches the Android convension and the built-in selection
on all desktop platforms.
MozReview-Commit-ID: 2kNm8UZnqH0
--HG--
extra : rebase_source : 097918c7c49e7cd545af52e9b3f3c540475ec589
FindFirstNodeWithFrame() and CompareRangeWithContentOffset() share a lot
of code duplication. I refactor and rename the two functions to improve
the readability.
MozReview-Commit-ID: CyetLHOGT23
--HG--
extra : rebase_source : e026acc87347253bcc795538ea06cbbd68634227
This patch use the union of all child scrollable overflow frame rects to
clamp the caret dragging point.
MozReview-Commit-ID: GEF9BpQkQNd
--HG--
extra : rebase_source : 3722e8a0f32a45439fed753b7d5f9a76add4553f
This is to support Firefox Android L style carets assets that the two
carets always look like tilt.
This patch is derived from a WIP patch by Mark Capella
<markcapella@twcny.rr.com>
MozReview-Commit-ID: H3nKLz6HcpM
--HG--
extra : rebase_source : b3a77b0bb8aaea8f010002f54fde075c9d469711
After calling FlushLayout(), PresShell::Destroy() might be called and we
should consider PresShell and other resources will be no longer valid.
Before this patch, AccessibleCaretManager and AccessibleCaret(s) are
deallocated in PresShell::Destroy(). However FlushLayout() are all
invoked in AccessibleCaretManager, we need to keep manager alive to
clean up after PresShell::Destroy().
This patch makes AccessibleCaretManager live after PresShell::Destroy(),
and use IsTerminated() to check whether PreShell is vaild after each
FlushLayout() calls.
Note that event though AccessibleCaretEventHub will be unref in
PresShell::Destroy(), all the callers to AccessibleCaretEventHub's
public methods already add a ref to AccessibleCaretEventHub. So we don't
need to worry about AccessibleCaretEventHub and AccessibleCaretManager
die immediately after PresShell::Destroy().
MozReview-Commit-ID: DDpXZ7v3zyo
--HG--
extra : rebase_source : 280e2512fb9f28d933f5b8d65a9f303ac81c58e5
extra : source : 10e71da98b144fbf42aaa81a1056910a3766a6cb
Fennec enables sCaretsExtendedVisibility which uses
Appearance::NormalNotShown instead of Appearance::None to keep actionbar
shown during scrolling. This breaks selection mode update when the
positions of the carets are not changed after scrolling.
To fix this, we need to implement appearance recovering for selection
mode scrolling like we did for cursor mode in bug 1212732, and make
UpdateCaretsForSelectionMode() respects UpdateCaretsHint.
MozReview-Commit-ID: LkfUIGKHL0h
--HG--
extra : rebase_source : 0ef8d28ce55c3ddd29ea32ee6888ee7fe14c34ad
extra : source : bc3e37b63defca87d0de165fe167ef7f8a7db651
After calling FlushLayout(), PresShell::Destroy() might be called and we
should consider PresShell and other resources will be no longer valid.
Before this patch, AccessibleCaretManager and AccessibleCaret(s) are
deallocated in PresShell::Destroy(). However FlushLayout() are all
invoked in AccessibleCaretManager, we need to keep manager alive to
clean up after PresShell::Destroy().
This patch makes AccessibleCaretManager live after PresShell::Destroy(),
and use IsTerminated() to check whether PreShell is vaild after each
FlushLayout() calls.
Note that event though AccessibleCaretEventHub will be unref in
PresShell::Destroy(), all the callers to AccessibleCaretEventHub's
public methods already add a ref to AccessibleCaretEventHub. So we don't
need to worry about AccessibleCaretEventHub and AccessibleCaretManager
die immediately after PresShell::Destroy().
MozReview-Commit-ID: DDpXZ7v3zyo
--HG--
extra : rebase_source : 2698f0313e394b64ff8caacf21493c874510a7ce
Fennec enables sCaretsExtendedVisibility which uses
Appearance::NormalNotShown instead of Appearance::None to keep actionbar
shown during scrolling. This breaks selection mode update when the
positions of the carets are not changed after scrolling.
To fix this, we need to implement appearance recovering for selection
mode scrolling like we did for cursor mode in bug 1212732, and make
UpdateCaretsForSelectionMode() respects UpdateCaretsHint.
MozReview-Commit-ID: LkfUIGKHL0h
--HG--
extra : rebase_source : 2e68786e09046967f7c6af16fa6b393f133dc12c
Per request in bug 1240917 comment 15, we decided not to show caret when
single press on an empty input. This effectively reverts the work in Bug
1230582.
--HG--
extra : commitid : IjKGpqAR6zP
extra : rebase_source : d476618b4f419cf2d96bb33264cfd8ccb6e3fa61