Commit Graph

1589 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
ba1fb75fa2 Bug 1897657 - Remove PresShell::mReflowContinueTimer. r=dholbert
In bug 1895870 I (somewhat unintentionally) made this code not called at
all.

Instead of scheduling a 30ms timer if reflow was interrupted, we just
schedule a reflow for the next refresh driver tick via
EnsureLayoutFlush(). Which is what would happen anyways before my change
in presence of other changes (like page loading appending content or
what not).

I think thus that the new behavior is more predictable (the 30ms timer
was never quite measured, it was introduced in bug 499447).

So, just simplify the code.

Differential Revision: https://phabricator.services.mozilla.com/D210890
2024-05-20 06:41:27 +00:00
Ting-Yu Lin
467d0a3a72 Bug 1897135 Part 3 - Change two APIs to ensure root frame is a ViewportFrame. r=dholbert
Move `SetRootFrame()` to nsFrameManager.cpp, because in order to compile
`mRootFrame = aRootFrame` the compiler requires the full definition of
`ViewportFrame` to know that `ViewportFrame` is a subclass of `nsIFrame`

Differential Revision: https://phabricator.services.mozilla.com/D210671
2024-05-17 21:37:02 +00:00
Ting-Yu Lin
3fca23660d Bug 1897135 Part 2 - Remove redundant mFrameManager member in PresShell. r=dholbert
We can just use `mFrameConstructor` to call `GetRootFrame()`. In order to do so
while keeping `PresShell::GetRootFrame()` as a inline method, we need to include
`nsCSSFrameConstructor` header in `PresShell.h`, and remove `PresShell` header
in `nsCSSFrameConstructor.h`. That means we can no longer inline
`RestyleManager()` since it needs to access `PresShell`, but it's OK since
`RestyleManager` is used only in the frame constructor, and is probably not in
the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D210670
2024-05-17 21:37:01 +00:00
Ting-Yu Lin
02535685c4 Bug 1897135 Part 1 - Sort #includes and forward declarations in nsFrameManager, nsCSSFrameConstructor, and PresShell. r=dholbert
Also, delete unused `DEBUG_UNDISPLAYED_MAP` and `DEBUG_DISPLAY_CONTENTS_MAP` in
nsFrameManager.cpp.

Delete the comments between the #includes in PresShell.cpp per coding style
guideline: "Don't place comments between non-conditional includes." in
https://firefox-source-docs.mozilla.org/code-quality/coding-style/coding_style_cpp.html#include-directives

Differential Revision: https://phabricator.services.mozilla.com/D210669
2024-05-17 21:37:01 +00:00
Emilio Cobos Álvarez
fc159ff851 Bug 1896762 - Make animation timing match the spec. r=smaug,firefox-animation-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D210658
2024-05-17 16:33:06 +00:00
Natalia Csoregi
2646ae722f Backed out changeset afcc70a5e871 (bug 1896762) for causing failures on css-transition-cross-document.html CLOSED TREE 2024-05-17 18:50:54 +03:00
Emilio Cobos Álvarez
d554a723e9 Bug 1897322 - More consistently deal with pres shell style observers. r=smaug
Much like we deal with resize events.

Differential Revision: https://phabricator.services.mozilla.com/D210776
2024-05-17 11:56:36 +00:00
Stanca Serban
4edbdf3b0d Backed out changeset 0328321272d7 (bug 1897322) for causing multiple failures. CLOSED TREE 2024-05-17 14:09:21 +03:00
Emilio Cobos Álvarez
9bae74fae2 Bug 1897322 - More consistently deal with pres shell style observers. r=smaug
Much like we deal with resize events.

Differential Revision: https://phabricator.services.mozilla.com/D210776
2024-05-17 10:25:31 +00:00
Emilio Cobos Álvarez
c54d301d5e Bug 1896762 - Make animation timing match the spec. r=smaug,firefox-animation-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D210658
2024-05-17 08:33:36 +00:00
Ting-Yu Lin
b4a0842882 Bug 1824877 Part 3 - Change ScrollContainerFrame's type from Scroll to ScrollContainer. r=dholbert
This effectively changes the `IsScrollFrame()` helper to
`IsScrollContainerFrame()`.

Differential Revision: https://phabricator.services.mozilla.com/D210357
2024-05-15 17:50:49 +00:00
Ting-Yu Lin
27bb908f13 Bug 1824877 Part 2 - Rename nsHTMLScrollFrame to mozilla::ScrollContainerFrame. r=dholbert
Also, change the ScrollContainerFrame::GetFrameName() to return
"ScrollContainer" instead of "HTMLScroll".

Differential Revision: https://phabricator.services.mozilla.com/D210233
2024-05-15 17:50:48 +00:00
Daniel Holbert
af69b59aae Bug 1896711 part 3: Use MakeRefPtr/MakeAndAddRef to reduce boilerplate, in layout/base. r=TYLin
Also remove some unnecessary null-checks for objects that we're allocating
infallibly.

Differential Revision: https://phabricator.services.mozilla.com/D210389
2024-05-15 07:29:20 +00:00
Emilio Cobos Álvarez
0a1d2b49ff Bug 1895870 - Simplify refresh driver observer set-up. r=smaug
There's no call to AddRefreshObserver(FlushType::Layout), so we don't
need to track layout flushes. The only reason we need
mLayoutFlushObservers is so that reflows triggered from the style flush
get processed. But at that point, we can just flush layout directly.

There's no really good distinction between style flushes and layout
flushes with container queries anyways, so this makes the code simpler
to reason about.

Differential Revision: https://phabricator.services.mozilla.com/D209924
2024-05-14 08:12:03 +00:00
Masayuki Nakano
bdc24b132f Bug 1840568 - Make PresShell::HandleEventWithCurrentEventInfo never try to flush pending things if it handled a query content event r=smaug
Query content is used for a part of handling user interaction with IME or
query request from IME via native API.  Therefore, we don't need to flush
pending things at that time since it's not the last chance to do so before
handling next user input.  Additionally, the call may cause same query before
returning the result to IME so that may cause stack overflow crash and
that means we flush layout even if the query request does not want flushing
pending things.  Therefore, we should not do that at handling query content
event.

Differential Revision: https://phabricator.services.mozilla.com/D209990
2024-05-14 01:08:37 +00:00
Masayuki Nakano
33274b20c7 Bug 1891304 - Make APZEventState manage whether the pointerdown was consumed by content or not r=smaug,hiro
The Pointer Events spec defines that:

> Authors can prevent the firing of certain compatibility mouse events by
> canceling the pointerdown event (if the isPrimary property is true).
> <snip>
> Note, however, that this does not prevent the mouseover, mouseenter, mouseout,
> or mouseleave events from firing.
https://w3c.github.io/pointerevents/#the-pointerdown-event

The other browsers conform to this.  Therefore, we should stop dispatching
compatibility mouse events only if the preceding `pointerdown` is consumed by
content.  I.e., we need to keep dispatching touch events and `click` etc which
indicate what should happen on the element.

Currently, `APZEventState` does not manage whether the preceding `pointerdown`
is canceled or not.  So, it dispatches compatibility mouse events via
`APZCCallbackHelper` after the consumed pointer is removed.  Therefore, we
need to make it manage whether the preceding `pointerdown` of the first touch
is consumed or not and `APZCCallbackHelper` needs an option to dispatch the
compatibility mouse events only to chrome (they are required to dispatch
`click` etc).

However, if `APZEventState` is not available like test API used in the
remote process, `TouchManager` needs to manage it instead of `APZEventState`.

I don't think only `TouchManager` should manage it because `APZEventState`
manages complicated state of touch gestures and that can know whether the
synthesizing compatibility mouse events related to the consumed `pointerdown`
or not strictly.  Therefore, this patch makes the `TouchManager` state used
only in the path handling synthesized events for tests.

Differential Revision: https://phabricator.services.mozilla.com/D208706
2024-05-14 01:07:49 +00:00
Emilio Cobos Álvarez
3abe531738 Bug 1895928 - PresShell::ScheduleViewManagerFlush shouldn't set the layout flush bit. r=smaug
A version of the patch in bug 1895870 caused some WPT tests to time out
because document.fonts.ready never resolves.

This is because I made PresShell::HasPendingReflow look at
mNeedLayoutFlush, and nsIFrame::SchedulePaint() calls
PresShell::ScheduleViewManagerFlush() which sets that bit.

So we end up with mNeedLayoutFlush, but without a flush scheduled, and
the ready promise doesn't resolve until something else schedules a
flush. I fixed the original patch to preserve behavior, but requesting a
repaint shouldn't require a layout flush.

This call was added in bug 598482 part 16:

  https://hg.mozilla.org/mozilla-central/rev/71d77495b606fc145bdceabcda29181978bd9405

We only need the layout flush if there are view geometry updates, so
shift the call up to the view manager.

Differential Revision: https://phabricator.services.mozilla.com/D209938
2024-05-10 08:08:42 +00:00
Emilio Cobos Álvarez
8e07c2864f Bug 1890576 - Make root element color-scheme affect widget appearance. r=mstange,mac-reviewers
Instead of relying on the embedder color-scheme directly, use the
color-scheme property to determine the nsCocoaWindow's appearance.

This is more in line with what content does, would've prevented this bug
from existing altogether, and avoids the need for MOZGlobalAppearance.

Differential Revision: https://phabricator.services.mozilla.com/D207050
2024-05-02 15:41:14 +00:00
Dan Robertson
729d142d49 Bug 1863194 - Do not terminate wheel transaction on browsing context change. r=hiro,smaug,webdriver-reviewers,Sasha
We should continue to use a wheel transaction for wheel events when the
browsing context changes from the current context. Avoiding the override
of the event target with the current wheel transaction can halt a page
scroll when the mouse moves over content in a different presentation
context.

Differential Revision: https://phabricator.services.mozilla.com/D205495
2024-04-25 12:16:40 +00:00
Timothy Nikkel
8ac1db6c96 Bug 1892678. Rename pref image.decode-sync.enabled to image.testing.decode-sync.enabled. r=gfx-reviewers,nical
The reason I want to rename this so that it is clear that it is intended for tests only is for bug 1866411. If we see that this pref is set then we can assume that it isn't being flipped during the loading of images, and therefore we can avoid the extra invalidates that sync decode paints would normally incur.

Differential Revision: https://phabricator.services.mozilla.com/D208111
2024-04-24 01:57:41 +00:00
Mike Hommey
eb41ab9b93 Bug 1890926 - Remove unused temporary variable. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D207236
2024-04-16 01:56:53 +00:00
Sandor Molnar
1f76bee7da Backed out changeset f946717df0fd (bug 1863194) for causing wd failures @ webdriver/tests/bidi/input/perform_actions/wheel.py CLOSED TREE 2024-04-16 02:09:18 +03:00
Dan Robertson
e83943cc40 Bug 1863194 - Do not terminate wheel transaction on browsing context change. r=hiro,smaug
We should continue to use a wheel transaction for wheel events when the
browsing context changes from the current context. Avoiding the override
of the event target with the current wheel transaction can halt a page
scroll when the mouse moves over content in a different presentation
context.

Differential Revision: https://phabricator.services.mozilla.com/D205495
2024-04-15 20:45:38 +00:00
Jan-Niklas Jaeschke
6019fb9e6a Bug 1867939, part 5: Integrate find-text-directive algorithm into Document load. r=peterv,farre,dom-core
This patch integrates the algorithm to find a text fragment range
into the document loading mechanism.
Unlike described in the spec, the fragment directive is not stripped
from the URL in the Session History Entry, instead it is stripped when
setting the URI into the Document using `Document::SetURI()`,
as well as when accessing the URL through `Location`.

The `PresShell` class is extended by a new method which sets the
ranges created from the text directives into the FrameSelection as
TargetText selection and scrolls it into view.

Security restrictions like force load at top and cross-origin iframes
are not yet considered in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D195688
2024-04-04 14:39:33 +00:00
Stanca Serban
ce5dc60809 Backed out 6 changesets (bug 1867939) for causing wpt failures in target-text-010.html. CLOSED TREE
Backed out changeset 44101c258e52 (bug 1867939)
Backed out changeset c53267e1b460 (bug 1867939)
Backed out changeset 0748839408e5 (bug 1867939)
Backed out changeset 38631fbd2f2f (bug 1867939)
Backed out changeset d77b9257c842 (bug 1867939)
Backed out changeset 0d269b891421 (bug 1867939)
2024-04-04 00:50:50 +03:00
Jan-Niklas Jaeschke
4117054bb6 Bug 1867939, part 5: Integrate find-text-directive algorithm into Document load. r=peterv,farre,dom-core
This patch integrates the algorithm to find a text fragment range
into the document loading mechanism.
Unlike described in the spec, the fragment directive is not stripped
from the URL in the Session History Entry, instead it is stripped when
setting the URI into the Document using `Document::SetURI()`,
as well as when accessing the URL through `Location`.

The `PresShell` class is extended by a new method which sets the
ranges created from the text directives into the FrameSelection as
TargetText selection and scrolls it into view.

Security restrictions like force load at top and cross-origin iframes
are not yet considered in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D195688
2024-04-03 15:23:02 +00:00
Sandor Molnar
7a867184d3 Backed out 6 changesets (bug 1867939) for causing a top crash in nightly Bug 1889393 CLOSED TREE
Backed out changeset 2110f57e928c (bug 1867939)
Backed out changeset 51890598ecb4 (bug 1867939)
Backed out changeset 839bc1b11a2c (bug 1867939)
Backed out changeset bb88c4d09e82 (bug 1867939)
Backed out changeset 27c76e65cf58 (bug 1867939)
Backed out changeset c3e3c81f9ceb (bug 1867939)
2024-04-03 17:31:56 +03:00
Emilio Cobos Álvarez
dadf0fbdef Bug 1888242 - Simplify viewport handling in RDM. r=bradwerth,devtools-reviewers,ochameau
In particular:

 * Always handle meta viewport in RDM. This fixes bug 1625999 too by
   making touch simulation enabled and disabled consistent.

 * Restore the resolution to 1 when toggling RDM. This is just simpler,
   and we're not keeping around the visual viewport offsets anyways
   so...

 * Deal with the change more easily, at the same point we switch
   scrollbars etc.

Differential Revision: https://phabricator.services.mozilla.com/D206266
2024-04-02 15:21:04 +00:00
Jan-Niklas Jaeschke
a6845cd22c Bug 1867939, part 5: Integrate find-text-directive algorithm into Document load. r=peterv,farre,dom-core
This patch integrates the algorithm to find a text fragment range
into the document loading mechanism.
Unlike described in the spec, the fragment directive is not stripped
from the URL in the Session History Entry, instead it is stripped when
setting the URI into the Document using `Document::SetURI()`,
as well as when accessing the URL through `Location`.

The `PresShell` class is extended by a new method which sets the
ranges created from the text directives into the FrameSelection as
TargetText selection and scrolls it into view.

Security restrictions like force load at top and cross-origin iframes
are not yet considered in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D195688
2024-04-02 13:44:25 +00:00
Cristian Tuns
9a4d6d56af Backed out 6 changesets (bug 1867939) for causing build bustages in Document.h CLOSED TREE
Backed out changeset 0853f9a7a06c (bug 1867939)
Backed out changeset 2279e6577c13 (bug 1867939)
Backed out changeset 1b3af4b6a27b (bug 1867939)
Backed out changeset 2fbe643ca483 (bug 1867939)
Backed out changeset 575873406614 (bug 1867939)
Backed out changeset 82f99c0210b0 (bug 1867939)
2024-04-02 09:15:46 -04:00
Jan-Niklas Jaeschke
9dd5893918 Bug 1867939, part 5: Integrate find-text-directive algorithm into Document load. r=peterv,farre,dom-core
This patch integrates the algorithm to find a text fragment range
into the document loading mechanism.
Unlike described in the spec, the fragment directive is not stripped
from the URL in the Session History Entry, instead it is stripped when
setting the URI into the Document using `Document::SetURI()`,
as well as when accessing the URL through `Location`.

The `PresShell` class is extended by a new method which sets the
ranges created from the text directives into the FrameSelection as
TargetText selection and scrolls it into view.

Security restrictions like force load at top and cross-origin iframes
are not yet considered in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D195688
2024-04-02 11:43:21 +00:00
Emilio Cobos Álvarez
a729842e1e Bug 1888592 - Terminate mOriginalCaret properly, and fix null crash. r=masayuki
We have callers that call RestoreCaret after pres shell shut down.

Differential Revision: https://phabricator.services.mozilla.com/D206120
2024-03-29 21:51:11 +00:00
keithamus
390ef8eb0d Bug 1865589 - Notify PresShell of CustomState changes, so Restyle can invalidate. r=emilio,dshin
Differential Revision: https://phabricator.services.mozilla.com/D202460
2024-03-22 22:18:05 +00:00
Gregory Pappas
388a03bed2 Bug 1885708 - Remove apz.mvm.force-enabled pref r=botond
Differential Revision: https://phabricator.services.mozilla.com/D204839
2024-03-22 20:01:11 +00:00
Emilio Cobos Álvarez
3948b45eb8 Bug 1886506 - Fix caret paint invalidation issues. r=sefeng
The caret position is in the DOM, and sometimes can get out of sync.

While that is an issue, it's not new: The code before the regressing bug
papered over it on a pre-pass before entering DL building.

Instead, deal with it using MarkFramesForDisplay (just like we mark the
caret frame itself, which has the same issue), and invalidate the old
frame more precisely by tracking it in nsCaret directly.

Also, add missing invalidation in PresShell::SetCaret, where the caret
might change and the old caret might not be invalidated properly.

Differential Revision: https://phabricator.services.mozilla.com/D205369
2024-03-22 12:20:14 +00:00
Emilio Cobos Álvarez
494c63e551 Bug 1884631 - Remove macOS native sheet support. r=mac-reviewers,aleca,kaie,bradwerth
Firefox never uses this. TB could use the same approach Firefox uses,
but for now on macOS the sheets become regular modal dialogs, which is
the same as on Windows and Linux.

See bug 1755330 and bug 1737489 for more context.

Differential Revision: https://phabricator.services.mozilla.com/D204209
2024-03-18 10:06:26 +00:00
Masayuki Nakano
657bfed498 Bug 1885259 - Make AutoPointerEventTargetUpdater work without event target frame r=edgar,dom-core
The crash occurs when `PointerEventHandler::DispatchPointerFromMouseOrTouch`
dispatches a pointer event for `eTouchStart`.  In this case, `aFrame` of
the constructor of `AutoPointerEventTargetUpdater` is set to the primary frame
of the event target content [1][2] and the event target may have no frame
because touch targets are considered by `TouchManager` before dispatching
`ePointerDown` [3][4][5].  Therefore, we should make it take event target
content for the case of no event target frame.

I tried to reproduce the crash with removing the target or making the target
`display:contents` at first `pointerdown` or `touchstart` of multi-touch, but
I couldn't reproduce the crash.  Therefore, this patch does not contain new
tests.

1. https://searchfox.org/mozilla-central/rev/109bb25545f0d2df31954dc0a9afbf30d900b6bb/dom/events/PointerEventHandler.cpp#694,701
2. https://searchfox.org/mozilla-central/rev/109bb25545f0d2df31954dc0a9afbf30d900b6bb/layout/base/PresShell.cpp#8319,8341
3. https://searchfox.org/mozilla-central/rev/109bb25545f0d2df31954dc0a9afbf30d900b6bb/layout/base/TouchManager.cpp#115
4. https://searchfox.org/mozilla-central/rev/109bb25545f0d2df31954dc0a9afbf30d900b6bb/layout/base/PresShell.cpp#7400
5. https://searchfox.org/mozilla-central/rev/109bb25545f0d2df31954dc0a9afbf30d900b6bb/layout/base/PresShell.cpp#7198

Differential Revision: https://phabricator.services.mozilla.com/D204632
2024-03-14 23:46:07 +00:00
Masayuki Nakano
a3e8cfa08d Bug 1695574 - Make PresShell::EventHandler::HandleEventUsingCoordinates keep handling touch events after preceding pointer event target is removed r=smaug,edgar,dom-core
As far as investigating the behavior of the other browsers, touch events are
dispatched the same target as the preceding `pointerdown` even after the target
is removed from the DOM tree.  However, the following pointer events are
dispatched on the target as usual (i.e., the element under the pointer except
when the pointer is captured).  However, our code stops handling touch events
if the preceding `pointerdown` removes the target and not dispatching
`touchstart` causes not dispatching the following touch events so that no
`click` event is fired.

This patch makes the touch event dispatching path work without frame and
keep handling even with an orphan event target.

Differential Revision: https://phabricator.services.mozilla.com/D202811
2024-03-12 01:03:44 +00:00
Peter Van der Beken
9e9199880e Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-02 07:50:25 +00:00
Natalia Csoregi
10b9ceb789 Backed out 13 changesets (bug 1640839) for causing bustage on Element.cpp CLOSED TREE
Backed out changeset 179ceb82c9e5 (bug 1640839)
Backed out changeset 73f498a821f0 (bug 1640839)
Backed out changeset dc2d3d0e0365 (bug 1640839)
Backed out changeset ddc989ac0509 (bug 1640839)
Backed out changeset e595bb3feea8 (bug 1640839)
Backed out changeset c85aca04e27f (bug 1640839)
Backed out changeset 98e8e3a4047a (bug 1640839)
Backed out changeset 59ef180517db (bug 1640839)
Backed out changeset af2f5e293662 (bug 1640839)
Backed out changeset 89aa6d9dc598 (bug 1640839)
Backed out changeset 67b722a722f9 (bug 1640839)
Backed out changeset 24a9665c6ced (bug 1640839)
Backed out changeset d93f199385e9 (bug 1640839)
2024-03-01 18:23:08 +02:00
Peter Van der Beken
e0fa109cb0 Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-01 14:31:15 +00:00
Masayuki Nakano
31efb600ee Bug 1880594 - Make PresShell::EventHandler dispatch mouse events as a default action of eTouchEnd if it's dispatched without APZ r=smaug
The mouse events for `eTouchEnd` is currently dispatched by
`APZCCallbackHelper` [1] and currently we don't support async event dispatching
in WPT (bug 1773393).  Therefore, tests of Pointer Events for touch won't work.
This blocks our further work to improve Pointer Events.  Therefore,
`PresShell::EventHandler` should have a fallback path for it.

1. https://searchfox.org/mozilla-central/rev/a7809ff8b0a6d98e6df3183d3ca99c77ef2f983e/gfx/layers/apz/util/APZCCallbackHelper.cpp#553,562-567

Differential Revision: https://phabricator.services.mozilla.com/D202376
2024-02-27 01:25:51 +00:00
Masayuki Nakano
e0f5a9f160 Bug 1879862 - Make PresShell::HandleEvent check whether the frame is alive after flushing synthesized mouse move r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D201673
2024-02-15 23:30:05 +00:00
Masayuki Nakano
1fd161fe7c Bug 1877815 - Make PresShell::EventHandler::DispatchPrecedingPointerEvent update event target after dispatching a pointer event r=smaug
The reason of the bug is, no `mouseup` event is fired after the `pointerup`
event listener removed the target.  Therefore, `nsIFrame::HandleRelease()` does
not run and nobody cleans up the drag state of the `nsFrameSelection`.

This is caused by that `PresShell::EventHandler::DispatchPrecedingPointerEvent()`
updates only event target frame of the following mouse event target if the
pointer event target was removed from the tree, however, the frame may not be
ready.  In this case, `PresShell::GetCurrentContent()` will clear both current
event target content and frame because its composed document (`nullptr`) never
matches with the document for the `PresShell`.  Therefore, it needs to update
the target too.

This patch makes all developers won't create similar bugs, this encapsulate
`EventTargetData::mContent` and `EventTargetData::mFrame` to make their setters
clean up or automatically check the relation.

Differential Revision: https://phabricator.services.mozilla.com/D201053
2024-02-10 01:07:01 +00:00
Sean Feng
faf28dc59b Bug 1878753 - Fix focus gets incorrectly cleared by PresShell::FixUpFocus if the focus is on area element r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D200950
2024-02-08 16:35:02 +00:00
Masayuki Nakano
fb67854d77 Bug 1875424 - Make PresShell::HandleEvent flush pending synthetic mouse move at handling eMouseMove r=smaug
`mouse_boundary_events_after_removing_last_over_element.html` expects that
a `mouseover` should be fired between `click` and `mousemove`, but it's
dispatched by a synthetic mouse move event caused by removing the click target.
The fix of bug 1864654 tried to fix this kind of issues, but it does not flush
pending event at `eMouseMove`.  Therefore, the synthetic mouse move may not be
handled before handling `eMouseMove` which is caused by `pointerMove()` in the
test.

I guess that we need to make it flush before all events which are directly
caused by a user input.  However, I don't want to do it for now because of
the risk.

Depends on D199607

Differential Revision: https://phabricator.services.mozilla.com/D199694
2024-01-26 15:05:37 +00:00
Masayuki Nakano
a8de59b6d4 Bug 1864654 - Make PresShell flush pending synthetic mousemove before dispatching mousedown or mouseup r=smaug,dom-core,extension-reviewers,edgar,robwu
`inert-iframe-hittest.html` expects that `:hover` state should be updated
immediately after a pointer down.  The state is updated by
`EventStateManager::NotifyMouseOver` [1] when we received a real or synthetic
`eMouseMove`.  Therefore, the hover state may have not set yet if no refresh
occurs between the pointer down and checking the result.

Additionally, some WPT for UI Events and Pointer Events expect that `mouseover`
or `mouseout` should be fired before `mouseup`/`pointerup` if a preceding
`mousedown` or `pointerdown` event listener removes the target.  So, this
patch may fix intermittent failures of them if there are.

Therefore, we should flush pending synthetic `mousemove` event for keeping the
event order as same as they happen.  However, simply flushing it causes
unexpected pointer capture state change because
`PointerEventHandler::ProcessPointerCaptureForMouse` handles synthetic
`mousemove` but it should not cause pointer boundary events at the moment (the
pointer boundary events should be fired when the pointer is actually moved, note
that this is different rule from the rules of mouse boundary events).
Therefore, this patch changes
`PointerEventHandler::ShouldGeneratePointerEventFromMouse`.

However, this blocks `lostpointercatpure` event when the capturing content has
already been removed from the DOM tree.  The path is,
`EventHandler::HandleEventWithPointerCapturingContentWithoutItsFrame` stops
dispatching `pointerup` nor `pointercancel` in this case, but
`EventStateManager::PostHandleEvent` is the only handler of implicit pointer
capture release.  Therefore, we need to make it dispatch lostpointercatpure`
event if the canceling event caused `ePointerUp` or `ePointerCancel`.

Finally, this patch fixes a bug of `browser_ext_browserAction_popup_preload.js`.
It tests the pre-loading which starts when `mouseover` before `mousedown` on a
widget.  However, it does not correctly emulate the user input.
* Synthesizing only `mouseover` does not update the internal pointer info and
does not cause dispatching related events.
* Synthesizing `mousedown` without `mousemove` cause `mouseover` before
`mouseup` because at dispatching `mousedown`, `PresShell` stores the cursor [2]
and the mouse boundary events will be dispatched before `mouseup`.

`ext-browserAction.js` assumes the events are fired as this order,
`mouseover` -> `mousedown` -> `mouseup`, but this would not work if the
preceding `mousemove` of `mousedown` is not correctly fired.  I'm not sure
whether `mousemove` is always fired before `mousedown` on any environments,
but it should be rare and it affects only this kind of tricky code.  For now,
fixing this in the test side must be enough.

1. https://searchfox.org/mozilla-central/rev/9a5bf21ea2dd04946734658f67f83f62ca76b0fa/dom/events/EventStateManager.cpp#4874,4913-4914
2. https://searchfox.org/mozilla-central/rev/9a5bf21ea2dd04946734658f67f83f62ca76b0fa/layout/base/PresShell.cpp#6756

Differential Revision: https://phabricator.services.mozilla.com/D193870
2024-01-24 11:07:34 +00:00
Frédéric Wang
b5056e1feb Bug 1765615 - Handle most changes to CSS contain and content-visibility without needing to reconstruct frames. r=layout-reviewers,emilio
Right now, we reconstruct frames in response to a change in the CSS
`contain` property or `content-visibility`. This patch tries to optimize
this a bit:

1. Updates involving style containment change continue to force a
  reconstruction, due to the need to handle counters/quotes.

2. Updates involving paint/layout containment change only force a
   reconstruction if it's needed to handle absolutely/fixed
   positioned descendants or floats (for this one, see also bug 1874826).

3. Other containment changes will only force a reflow and repaint.

Per the CSS contain spec, layout, style and paint containments are
enabled for `content-visibility: hidden` and `content-visibility: auto`.
As a consequence, changing `content-visibility` between `hidden` and
`auto` values no longer requires reconstruction. Changing between these
values and `visible` may need a reconstruction although authors may
generally avoid that in practice by forcing `style` containment.

Differential Revision: https://phabricator.services.mozilla.com/D197043
2024-01-17 08:22:48 +00:00
Emilio Cobos Álvarez
d8e911e1ab Bug 1872154 - Move paint unsuppression and similar code to DidDoReflow. r=dholbert
This can run script, and as such shouldn't run from a container query
update. Instead, let's move the check to DidDoReflow, which deals with
that appropriately already.

I don't know of an easy / reliable way to reproduce this, since paint
unsuppression is very timing-dependent.

While at it, remove the long reflow telemetry check for
GetRootElement(). This comes from a time where we used the root
element's namespace to determine which telemetry counter to use.

Differential Revision: https://phabricator.services.mozilla.com/D197477
2024-01-10 09:56:34 +00:00
Dan Robertson
516dd41c49 Bug 1858984 - Fix ComputeNeedToScroll with large line sizes. r=emilio,devtools-reviewers,ochameau
When the line scroll amount is larger than that of the rectangle to
scroll into view, do not use the line size to determine if we should
scroll.

Depends on D192869

Differential Revision: https://phabricator.services.mozilla.com/D192870
2024-01-03 19:12:22 +00:00