Commit Graph

486 Commits

Author SHA1 Message Date
Masayuki Nakano
16398887a4 Bug 1905267 - part 2: Make PresShell not use non-element event target when target frame is destroyed and the event wants Element target r=smaug
When event target frame is destroyed, `PresShell::NotifyDestroyingFrame` updates
current event target content to the frame content.  However, event target of
some DOM events need to be `Element`.  Therefore,
`PresShell::mCurrentEventTarget` needs to store at least the handling
`EventMessage` to consider whether the event target can be non-element content
node or only element node.  So, we need to make `PresShell::EventTargetInfo`
store `EventMessage`.  Then, we can make `PresShell::NotifyDestroyingFrame`
prefer inclusive ancestor element as new event target from the `EventMessage`.

Although I don't understand what's going on the reported case, but I found the
simple case when event target is changed to a `Text` with the assertion in
`PresShell::DispatchEventToDOM`.  Therefore, this patch has a new test.

Note that if target frame is a frame for element, e.g., when event target is
a focused element, `IsForbiddenDispatchingToNonElementContent` result won't
change the behavior.  Therefore, its implementation is not optimized for
non-user input events.

Differential Revision: https://phabricator.services.mozilla.com/D217205
2024-07-30 00:06:10 +00:00
Masayuki Nakano
66321dce9c Bug 1905267 - part 1: Make PresShell manage event target frame and content with a struct r=smaug
`PresShell::mCurrentEventTargetContent` may be update to non-element node
when `PresShell::mCurrentEventTargetFrame` is destroyed.  Therefore, for
avoiding it, I'd like to add `EventMessage` to the group to consider whether
the content needs to be `Element`.  However, adding new members for current
and stack would make `PresShell` members more messy.  Therefore, I'd like to
group the data with the simple struct.

Differential Revision: https://phabricator.services.mozilla.com/D217204
2024-07-30 00:06:09 +00:00
Stanca Serban
b74d1bcd26 Backed out 12 changesets (bug 1831649) for causing multiple failures.
Backed out changeset 501dc3134ae1 (bug 1831649)
Backed out changeset 21235ab42839 (bug 1831649)
Backed out changeset 279fdf36aac1 (bug 1831649)
Backed out changeset 17fb50534fae (bug 1831649)
Backed out changeset b2718b2f730d (bug 1831649)
Backed out changeset a05aa1c75ece (bug 1831649)
Backed out changeset becfb23cd6b4 (bug 1831649)
Backed out changeset 2d0e7e662530 (bug 1831649)
Backed out changeset 22538f7bdc88 (bug 1831649)
Backed out changeset 4ddecb37950f (bug 1831649)
Backed out changeset 1e6ed8b78e8f (bug 1831649)
Backed out changeset 6e96a1a01c24 (bug 1831649)
2024-07-18 06:13:43 +03:00
Hiroyuki Ikezoe
e184f9d681 Bug 1831649 - Trigger MobileViewportManager::RefreshViewportSize in the case where nsDocumentViewport boundaries changes but nsView boundaries unchanges. r=tnikkel,botond
Differential Revision: https://phabricator.services.mozilla.com/D208564
2024-07-18 00:31:14 +00:00
Jan-Niklas Jaeschke
d296498d92 Bug 1906134 - Text Fragments: Ensure to scroll the first text directive on a page into the center of the view. r=emilio
Before this patch, it could happen that `PresShell::GoToAnchor()` was called while loading a document.
This method did not know about text fragments before,
and would scroll the anchor (ie., the first text directive) to the top of the view.
This was noticeable for pages that took longer to load, where the text directive was scrolled to the center first, and then to the top.

This patch saves the desired vertical scroll position as a member in `PresShell` and makes `GoToAnchor()` scroll to the center as well.

Additionally, this patch updates the test file target document to make it more mobile-friendly.

Differential Revision: https://phabricator.services.mozilla.com/D216039
2024-07-16 09:16:48 +00:00
Emilio Cobos Álvarez
5f0c7d9620 Bug 1906132 - Explicitly set bresize bit when doing a measuring reflow. r=dholbert
This doesn't change behavior, but it is more explicit.

Make the two resize code-paths invalidate the same way.

Differential Revision: https://phabricator.services.mozilla.com/D215841
2024-07-05 17:50:40 +00:00
Jan-Niklas Jaeschke
63ac1a307c Bug 1897956 - Text Fragments: Set text fragment as :target. r=farre,dom-core
This patch makes some adjustments to follow the spec more strictly by
separating highlighting a text fragment (ie. adding the ranges to a `eTargetText` Selection)
from scrolling to it.

Scrolling to the text fragment now follows the steps given in [0] more closely,
in particular now the closest common ancestor of the target range is being used
as `:target` element.

This change also sets the focus to the start of the first text fragment, as indicated by the spec.
This resets the normal selection on the page.
The wpt test in /css/css-pseudo/target-text-005.html is based on the idea of having a same-doc
text fragment navigation with a selection.
This test fails with this patch applied, because the selection is reset.
It is currently unclear what behavior is correct here, thus the test is kept for now.

[0]: https://wicg.github.io/scroll-to-text-fragment/#invoking-text-directives

Differential Revision: https://phabricator.services.mozilla.com/D211025
2024-06-19 17:16:39 +00:00
Iulian Moraru
a9377e5b95 Backed out 4 changesets (bug 1898321, bug 1897942, bug 1897956) for causing multiple failures.
Backed out changeset ec3fcdcbfbd7 (bug 1897942)
Backed out changeset 279025d15551 (bug 1898321)
Backed out changeset a239855b02ea (bug 1897942)
Backed out changeset aab98ffe0ee9 (bug 1897956)
2024-06-14 18:43:03 +03:00
Jan-Niklas Jaeschke
8c4f317e30 Bug 1897956 - Text Fragments: Set text fragment as :target. r=farre,dom-core
This patch makes some adjustments to follow the spec more strictly by
separating highlighting a text fragment (ie. adding the ranges to a `eTargetText` Selection)
from scrolling to it.

Scrolling to the text fragment now follows the steps given in [0] more closely,
in particular now the closest common ancestor of the target range is being used
as `:target` element.

This change also sets the focus to the start of the first text fragment, as indicated by the spec.
This resets the normal selection on the page.
The wpt test in /css/css-pseudo/target-text-005.html is based on the idea of having a same-doc
text fragment navigation with a selection.
This test fails with this patch applied, because the selection is reset.
It is currently unclear what behavior is correct here, thus the test is kept for now.

[0]: https://wicg.github.io/scroll-to-text-fragment/#invoking-text-directives

Differential Revision: https://phabricator.services.mozilla.com/D211025
2024-06-14 12:20:47 +00:00
Masayuki Nakano
b3c5045ec1 Bug 1675847 - part 5: Make contextmenu event dispatchers use WidgetPointerEvent or PointerEvent r=smaug,pip-reviewers,devtools-reviewers,nchevobbe,mconley
`eContextMenu` event may be fired from `widget`.  Therefore, different from
`ePointerClick` and `ePointerAuxClick`, they may cross the process boundary,
may be handled by APZ and may be dispatched into the DOM after a delay.
Therefore, this patch is complicated than the previous patch.  This adds
* New IPC message handlers for sending/receiving a `WidgetPointerEvent`
* New `DelayedPointerEvent` class and templated `MouseInput::ToWidgetEvent`
* `PresShell::EventHandler` handles `eContextMenu` as same as `WidgetMouseEvent`

Differential Revision: https://phabricator.services.mozilla.com/D213003
2024-06-14 00:18:48 +00:00
Edgar Chen
0b7dde807f Bug 1883396 - Exit fullscreen when two Escape keyup events occur in a short time; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D209667
2024-06-04 23:38:45 +00:00
Ting-Yu Lin
5cdee429ce Bug 1896516 Part 11 - Remove nsIScrollableFrame usages under layout/, widget/, and toolkit/. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D211498
2024-05-30 06:32:22 +00:00
Ting-Yu Lin
9ff564d485 Bug 1896516 Part 7 - Remove PresShell::GetRootScrollFrameAsScrollable(). r=layout-reviewers,emilio
`PresShell::GetRootScrollFrameAsScrollable()` is equivalent to
`PresShell::GetRootScrollContainerFrame()`.

In ScrollContainerFrame.h, `DecideScrollableLayer()` has two versions, one has
four parameters, and the other has five parameters with the fifth parameter
`aDirtyRectHasBeenOverriden` having a default value `nullptr`. When we switch
the caller from `nsIScrollableFrame` to `ScrollContainerFrame`, we need to
remove the default value for the fifth parameter to avoid ambiguity.

Differential Revision: https://phabricator.services.mozilla.com/D211494
2024-05-30 06:32:20 +00:00
Ting-Yu Lin
2a6ee61abf Bug 1896516 Part 4 - Convert some nsIScrollableFrame usage in PresShell, nsLayoutUtils, and related helpers. r=layout-reviewers,emilio
This patch starts from renaming `PresShell::GetScrollableFrameToScroll()` to
`PresShell::GetScrollContainerFrameToScroll()`, making it return
`ScrollContainerFrame*`, and then fixing other helpers until everything
compiles. As before, we can remove some `do_QueryFrame`.

Differential Revision: https://phabricator.services.mozilla.com/D211491
2024-05-30 06:32:19 +00:00
Ting-Yu Lin
14aebc5bf9 Bug 1896516 Part 1 - Rename PresShell::GetRootScrollFrame(), and make it return ScrollContainerFrame. r=layout-reviewers,emilio
In theory, changing the return type from `nsIFrame*` to `ScrollContainerFrame*`
exposes `ScrollContainerFrame` to the callers who might not needed, but almost
all of the callers in cpp files are already exposed to `nsIScrollableFrame`, as
demonstrated in this patch via replacing the #include from
"nsIScrollableFrame.h" to "ScrollContainerFrame.h", so this is OK.

Some callers can be simplified since we no longer need `do_QueryFrame` to
`nsIScrollableFrame`.

Differential Revision: https://phabricator.services.mozilla.com/D211488
2024-05-30 06:32:17 +00:00
Sebastian Hengst
bf4dfe53f8 Backed out 15 changesets (bug 1896516) for causing scrolling crashes on macOS. a=backout
Backed out changeset fd6904338812 (bug 1896516)
Backed out changeset 2977ff81a23e (bug 1896516)
Backed out changeset c8a6b0e526d6 (bug 1896516)
Backed out changeset 3c06f22da72b (bug 1896516)
Backed out changeset f63b0c4335fe (bug 1896516)
Backed out changeset 6f7ab8adfa6e (bug 1896516)
Backed out changeset 997c9249dbed (bug 1896516)
Backed out changeset c964fccd5180 (bug 1896516)
Backed out changeset 7b481b747b7a (bug 1896516)
Backed out changeset 42e1bbe0ecb6 (bug 1896516)
Backed out changeset 717dac08b607 (bug 1896516)
Backed out changeset 2f0817331dbe (bug 1896516)
Backed out changeset b765169a7a8f (bug 1896516)
Backed out changeset a2d37b98273c (bug 1896516)
Backed out changeset ea9ecb543e66 (bug 1896516)
2024-05-29 11:22:52 +02:00
Ting-Yu Lin
37e9b779f9 Bug 1896516 Part 11 - Remove nsIScrollableFrame usages under layout/, widget/, and toolkit/. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D211498
2024-05-28 04:46:20 +00:00
Ting-Yu Lin
5ac7609fac Bug 1896516 Part 7 - Remove PresShell::GetRootScrollFrameAsScrollable(). r=layout-reviewers,emilio
`PresShell::GetRootScrollFrameAsScrollable()` is equivalent to
`PresShell::GetRootScrollContainerFrame()`.

In ScrollContainerFrame.h, `DecideScrollableLayer()` has two versions, one has
four parameters, and the other has five parameters with the fifth parameter
`aDirtyRectHasBeenOverriden` having a default value `nullptr`. When we switch
the caller from `nsIScrollableFrame` to `ScrollContainerFrame`, we need to
remove the default value for the fifth parameter to avoid ambiguity.

Differential Revision: https://phabricator.services.mozilla.com/D211494
2024-05-28 04:46:19 +00:00
Ting-Yu Lin
509e5ab505 Bug 1896516 Part 4 - Convert some nsIScrollableFrame usage in PresShell, nsLayoutUtils, and related helpers. r=layout-reviewers,emilio
This patch starts from renaming `PresShell::GetScrollableFrameToScroll()` to
`PresShell::GetScrollContainerFrameToScroll()`, making it return
`ScrollContainerFrame*`, and then fixing other helpers until everything
compiles. As before, we can remove some `do_QueryFrame`.

Differential Revision: https://phabricator.services.mozilla.com/D211491
2024-05-28 04:46:17 +00:00
Ting-Yu Lin
6f6e711315 Bug 1896516 Part 1 - Rename PresShell::GetRootScrollFrame(), and make it return ScrollContainerFrame. r=layout-reviewers,emilio
In theory, changing the return type from `nsIFrame*` to `ScrollContainerFrame*`
exposes `ScrollContainerFrame` to the callers who might not needed, but almost
all of the callers in cpp files are already exposed to `nsIScrollableFrame`, as
demonstrated in this patch via replacing the #include from
"nsIScrollableFrame.h" to "ScrollContainerFrame.h", so this is OK.

Some callers can be simplified since we no longer need `do_QueryFrame` to
`nsIScrollableFrame`.

Differential Revision: https://phabricator.services.mozilla.com/D211488
2024-05-28 04:46:16 +00:00
Emilio Cobos Álvarez
d4cd5b3261 Bug 1897752 - Clean up layout telemetry. r=smaug
This telemetry was trying to measure three things:

 * The time spent during style / layout in a tick. This is useful.
 * The times SetNeed{Style,Layout} flush have been called. This is not a
   particularly useful metric, there's not much to learn or change from
   it. Any call is basically free as long as they're consecutive /
   there's no flush in between.
 * The number of times layout / style has been flushed during a tick.
   This is more useful than the above but, similarly, there's not too
   much to be learned here. Number of flushes can be completely
   orthogonal to how expensive it has been.

It also had a number of flaws:

 * It is recorded per-PresShell, so we get multiple pings per tick.
 * Similarly, if a sub-frame dies before the tick, we just never report
   that time.

Instead, refactor it to make it simpler, and just record the first
metric reliably. This simplifies the code substantially, and I don't
think we're losing much.

The histograms are also expired. We might want to renew this, I'll file
a follow-up to either properly renew this if we plan to look at it, or
remove the code entirely from the tree.

Differential Revision: https://phabricator.services.mozilla.com/D210907
2024-05-20 14:30:08 +00:00
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
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
85dd27bb14 Bug 1896586 - Remove FlushType::Display check from PresShell::NeedFlush. r=smaug
PresShell doesn't do anything different if it gets called with
FlushType::Display vs FlushType::Layout. It should be fine to just pass
FlushType::Layout where appropriate and remove the redundant check.

Differential Revision: https://phabricator.services.mozilla.com/D210274
2024-05-14 21:17:17 +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
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
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
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
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
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
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
Frederic Wang
ddfb81b48e Bug 1807253 - unreliable timing for content-visibility:auto, r=emilio
Rewrite implementation of content-visibility: auto as defined in
https://github.com/w3c/csswg-drafts/issues/8542

Differential Revision: https://phabricator.services.mozilla.com/D170394
2023-11-27 08:26:46 +00:00
Natalia Csoregi
9e23519bf8 Backed out changeset 20a5c1f3b35e (bug 1807253) for causing failures on content-visibility-continuations-crash.html. CLOSED TREE 2023-11-22 16:12:27 +02:00
Frederic Wang
28dfc50a7f Bug 1807253 - unreliable timing for content-visibility:auto, r=emilio
Rewrite implementation of content-visibility: auto as defined in
https://github.com/w3c/csswg-drafts/issues/8542

Differential Revision: https://phabricator.services.mozilla.com/D170394
2023-11-22 13:00:36 +00:00
Cathie Chen
4f18bf0a7a Bug 1668136 - Set visible the content relevancy of an element with content-visibility:auto if its descendant is called scrollIntoView, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186943
2023-11-03 15:37:29 +00:00
Sean Feng
2d6e584e05 Bug 1722322 - Implement LargestContentfulPaint r=emilio
Spec: https://w3c.github.io/largest-contentful-paint

Differential Revision: https://phabricator.services.mozilla.com/D151079
2023-11-02 20:53:36 +00:00
Sandor Molnar
d23e2827b7 Backed out 7 changesets (bug 1722322) for causing bp-nu bustages
Backed out changeset 0ebd32e273b8 (bug 1722322)
Backed out changeset 7a75717f127c (bug 1722322)
Backed out changeset c2a6440a83d7 (bug 1722322)
Backed out changeset 9955756855bd (bug 1722322)
Backed out changeset 37fccb407777 (bug 1722322)
Backed out changeset f52b1f28f753 (bug 1722322)
Backed out changeset 0121c8cf5d2f (bug 1722322)
2023-11-02 21:27:24 +02:00
Sean Feng
cacfa492a8 Bug 1722322 - Implement LargestContentfulPaint r=emilio
Spec: https://w3c.github.io/largest-contentful-paint

Differential Revision: https://phabricator.services.mozilla.com/D151079
2023-11-02 17:04:47 +00:00
Norisz Fay
e59d1780b3 Backed out changeset 6e5782df6da1 (bug 1668136) for causing wpt failures on content-visibility-vs-scrollIntoView-003.html CLOSED TREE 2023-11-01 18:02:54 +02:00
Cathie Chen
ddcb98e4d9 Bug 1668136 - Set visible the content relevancy of an element with content-visibility:auto if its descendant is called scrollIntoView, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186943
2023-11-01 12:01:51 +00:00
Natalia Csoregi
b066a3427a Backed out changeset aa66fda02aac (bug 1668136) for causing failures on content-visibility. CLOSED TREE 2023-10-31 06:49:20 +02:00
Cathie Chen
a25f8bba63 Bug 1668136 - Set visible the content relevancy of an element with content-visibility:auto if its descendant is called scrollIntoView, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186943
2023-10-31 01:38:16 +00:00
Emilio Cobos Álvarez
5139b5a4a2 Bug 1857915 - Remove about:PreferenceStyleSheet. r=morgan,devtools-reviewers,nchevobbe
These days, after bug 1853323, about:PreferenceStyleSheet is basically
just an empty sheet for most users. For the ones that isn't, it's either
slightly or completely broken (see below).

If we were to implement this today, we'd do it with privileged env()
variables or media queries, and add a bunch of tests for different
combinations, but I don't think it's worth the effort:

 * There's no UI for any of these prefs.

 * There are no tests for any of these prefs.

 * browser.display.focus_ring_or_anything is not great, it's better
   replaced by browser.display.show_focus_rings, which actually makes
   the :focus-visible pseudo-class work. Otherwise the native controls
   may show no rings even though this pref is set.

 * for browser.display.focus_ring_style = 0, the color used
   (-moz-mac-focusring) is not implemented in any non-macOS platform.

 * The ::-moz-focus-inner rules are completely useless nowadays, because
   ::-moz-focus-inner only works on the windows native theme (which
   isn't used on content).

 * The focus colors are not color-scheme aware.

So given those, and that if you want the specific current behavior,
these are trivially implementable as a web extension (by using a user
stylesheet), I think we should just remove this code altogether.

Differential Revision: https://phabricator.services.mozilla.com/D190464
2023-10-11 17:47:50 +00:00