Commit Graph

449 Commits

Author SHA1 Message Date
Ting-Yu Lin
2969a5e0cb Bug 1909995 Part 2 - Add IntrinsicISize() as a helper to implement GetMinISize() and GetPrefISize(). r=layout-reviewers,emilio
Most frame types have identical or very similar implementation for GetMinISize()
and GetPrefISize(), and many of them already have `IntrinsicISize()` to unify
the implementation. This patch introduces nsIFrame::IntrinsicISize() so that
derived classes only need to override one method.

`nsBlockFrame`, `ColumnSetWrapperFrame`, and `nsColumnSetFrame` are the only
three classes where their `GetMinISize()` and `GetPrefISize()` have significant
differences. Therefore, we rename `GetMinISize()` and `GetPrefISize()` to
`MinISize()` and `PrefISize`, respectively, and use them as helpers to implement
their `IntrinsicISize()`.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D217790
2024-07-26 20:54:56 +00:00
Ting-Yu Lin
e67b56ee4c Bug 1909995 Part 1 - Unify MinISizeFromInline and PrefISizeFromInline in nsLayoutUtils, and move it into nsIFrame. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D217789
2024-07-26 20:54:56 +00:00
Jonathan Kew
759158947b Bug 1892262 - Trim leading letter-spacing at start of line. r=layout-reviewers,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D215015
2024-06-27 15:13:33 +00:00
Jonathan Kew
b22d16002e Bug 385615 - Revert backout changeset 709248f1fc69, to re-land the original patch stack. (no review)
This reverts the backout, effectively re-landing all the original patches here and the test-manifest
followups that were pushed after the original landing.

Differential Revision: https://phabricator.services.mozilla.com/D212698
2024-06-10 16:58:43 +00:00
Jonathan Kew
64b9727f2c Bug 385615 - Backed out 9 changesets (aec1be189f68, f9c2e5707d43, fe82d67b63ef, 07004e2608f3, f6022837406b, 36fc4e06713d, 30718580670d, 82242b2d942d, 5cd51f055a1a) due to reported regressions.
Differential Revision: https://phabricator.services.mozilla.com/D212435
2024-06-03 15:50:57 +00:00
Jonathan Kew
1b4dfde53d Bug 385615 - patch 3 - Implement nsTextFrame::SetFirstLetterLength to constrain first-letter during intrinsic-size calculation. r=layout-reviewers,emilio
This is an alternative version of SetLength to be used for the child of an nsFirstLetterFrame,
when we may need to create continuations in order to separate the first-letter from its
following text.

With this, the intrinsic sizes of first-letter should be computed correctly.

Differential Revision: https://phabricator.services.mozilla.com/D211597
2024-05-28 09:08:14 +00:00
Jonathan Kew
fe4894cfd4 Bug 385615 - patch 2 - Determine extent of ::first-letter range during intrinsic-width computation. r=layout-reviewers,emilio
If we're querying the intrinsic widths of a first-letter and its continuation
before they have been reflowed, we need to check the extent of the first-letter
text (similarly to what nsTextFrame::ReflowText does) to avoid measuring too
much of the content using the first-letter styling.

This patch checks the first-letter length during intrinsic size computation,
but does not actually work in most cases because nsTextFrame::SetLength will
bail out if there is not already a next-in-flow frame. The following patch
will address that.

Differential Revision: https://phabricator.services.mozilla.com/D211596
2024-05-28 09:08:13 +00:00
Jonathan Kew
6a750b0653 Bug 385615 - patch 1 - Factor out a GetContentNewLineOffset() helper in nsTextFrame. r=layout-reviewers,emilio
No behavior change here, just factoring out a helper that will be wanted
for the following patch.

Differential Revision: https://phabricator.services.mozilla.com/D211595
2024-05-28 09:08:12 +00:00
Robert Longson
034f3b85c8 Bug 1816628 Part 2 - Make text-shadow react to stroke properties and fill opacity r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D200436
2024-02-28 18:51:23 +00:00
Stanca Serban
1b062c0f39 Backed out 2 changesets (bug 1816628) for causing OS X mochitests-plain failures in test_bug1426594.html.
Backed out changeset e32deae0b0b4 (bug 1816628)
Backed out changeset 3ee753e740b9 (bug 1816628)
2024-02-24 06:38:52 +02:00
Robert Longson
74a41ace0a Bug 1816628 Part 2 - Make text-shadow react to stroke properties and fill opacity r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D200436
2024-02-23 23:48:24 +00:00
Stanca Serban
7235cac1d4 Backed out 2 changesets (bug 1816628) for linux related wr failures in SVGTextFrame.cpp. CLOSED TREE
Backed out changeset d58d91582a84 (bug 1816628)
Backed out changeset ddaf27e9243d (bug 1816628)
2024-02-23 21:37:04 +02:00
Robert Longson
06bad336c9 Bug 1816628 Part 2 - Make text-shadow react to stroke properties and fill opacity r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D200436
2024-02-23 16:58:58 +00:00
Edgar Chen
7c3453d032 Bug 1878976 - Remove plugin-related code in EventStateManager; r=emilio
`nsIFrame::GetCursor()` can never return `Nothing()` after bug 1687239, which
removes `nsPluginFrame`. Therefore `mLastFrameConsumedSetCursor` in
`EventStateManager` can never be true.

Differential Revision: https://phabricator.services.mozilla.com/D200890
2024-02-07 12:35:27 +00:00
Ting-Yu Lin
5c884d5335 Bug 1874897 - Revert Bug 1873530 Part 3 to fix performance regression. r=dholbert
This reverts commit https://hg.mozilla.org/mozilla-central/rev/dfcfa98a7e21
without any additional modification.

Differential Revision: https://phabricator.services.mozilla.com/D198764
2024-01-17 05:14:35 +00:00
Ting-Yu Lin
1c5fd05aca Bug 1873530 Part 3 - Unify continuation linking operations by removing SetPrevContinuation() and SetPrevInFlow(). r=jfkthame
SetNextContinuation() and SetPrevContinuation() are almost always called
together when setting up a continuation link, but the callers don't call them in
particular order. We should unify them as one method so that it's more
ergonomics and robust, especially when we do more complex work such as caching
continuations. Same reason for SetNextInFlow() and SetPrevInFlow().

We choose to merge the SetPrevContinuation() code into SetNextContinuation() for
the symmetry of SetNextSibling(). (Yes, we don't have SetPrevSibling().)

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D197966
2024-01-11 19:50:58 +00:00
Emilio Cobos Álvarez
c27730d3df Bug 1364813 - Remove IsFrameOfType, use non-virtual checks. r=jwatt
Extend the per-frame-class bit we have to devirtualize IsLeaf to also
devirtualize IsFrameOfType. That is, move this data to FrameClasses.py.

This was done by going through all the frame classes, trying to preserve
behavior.

The only quirky thing is that I had to add two more trivial frame
classes, `nsAudioFrame` for audio elements, and
`nsFloatingFirstLetterFrame`. That's because these frame classes were
returning different answers at runtime, but they do this only on
conditions that trigger frame reconstruction (floating, and being an
audio element, respectively).

Differential Revision: https://phabricator.services.mozilla.com/D194703
2023-11-26 22:17:28 +00:00
Ting-Yu Lin
bdf33c51d4 Bug 1361580 - Move the initialization of nsTextFrame members to where they are declared. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D194408
2023-11-22 21:56:24 +00:00
Emilio Cobos Álvarez
6c324c6d1b Bug 1851868 - Refactor nsIFrame::Destroy to pass a single DestroyContext parameter. r=dholbert
This shouldn't change behavior, but it packs the two arguments to
DestroyFrom into a single thing, and makes nsIFrame::Destroy not so easy
to call without a previous context.

This is a prerequisite to pass aDestroyContext to various things that
right now just mint one, which can cause badness, see bug 1851787 and
related bugs.

It's also a bit nicer to add things there if we need to in the future.

Differential Revision: https://phabricator.services.mozilla.com/D187578
2023-09-07 11:46:30 +00:00
Narcis Beleuzu
33592fec5e Backed out changeset 55052ae7d067 (bug 1851868) for reftest failure on 1153695.html . CLOSED TREE 2023-09-07 02:42:25 +03:00
Emilio Cobos Álvarez
0698c96bd1 Bug 1851868 - Refactor nsIFrame::Destroy to pass a single DestroyContext parameter. r=dholbert
This shouldn't change behavior, but it packs the two arguments to
DestroyFrom into a single thing, and makes nsIFrame::Destroy not so easy
to call without a previous context.

This is a prerequisite to pass aDestroyContext to various things that
right now just mint one, which can cause badness, see bug 1851787 and
related bugs.

It's also a bit nicer to add things there if we need to in the future.

Differential Revision: https://phabricator.services.mozilla.com/D187578
2023-09-06 22:34:35 +00:00
Jan-Niklas Jaeschke
1f364d2e38 Bug 1838262, part 3: Removed ServoStyleSet::ProbeHighlightPseudoElementStyle(). r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D184709
2023-07-31 13:47:55 +00:00
Jan-Niklas Jaeschke
c821b10ef4 Bug 1811823, part 2: Add correct prioritization for custom highlights. r=emilio
Due to the prioritization rules for custom highlights, it is not feasible to rely on cascading.
Instead, highlights need to be stacked by their priority (and order of insertion).
Text and background color of the highest-prioritized highlight which defines that property should be used.

Since highlights are implemented as special `Selection`s, the algorithm that determines the prevailing selection for a text frame needed to be adapted to instead return a list of selections.

Differential Revision: https://phabricator.services.mozilla.com/D181143
2023-06-23 15:22:44 +00:00
Jonathan Kew
a5c21d1079 Bug 1253840 - patch 2 - When justifying, the full advance of any trimmable end-of-line whitespace needs to be hung into the margin. r=emilio
Depends on D178210

Differential Revision: https://phabricator.services.mozilla.com/D178211
2023-05-21 13:17:42 +00:00
Stanca Serban
e0248465e4 Backed out 4 changesets (bug 1253840) for causing multiple failures in nsLineLayout.cpp. CLOSED TREE
Backed out changeset 1a47c4ddf44c (bug 1253840)
Backed out changeset 816a9266d111 (bug 1253840)
Backed out changeset 7ce24f83240a (bug 1253840)
Backed out changeset cf6eff426d61 (bug 1253840)
2023-05-20 00:49:29 +03:00
Jonathan Kew
39322ae348 Bug 1253840 - patch 2 - When justifying, the full advance of any trimmable end-of-line whitespace needs to be hung into the margin. r=emilio
Depends on D178210

Differential Revision: https://phabricator.services.mozilla.com/D178211
2023-05-19 16:44:10 +00:00
David Shin
cd09d0a351 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-17 12:56:54 +00:00
Sandor Molnar
3faee50252 Backed out 3 changesets (bug 1809568) for causing build bustages in layout/generic/nsLineLayout.cpp CLOSED TREE
Backed out changeset 6c5bbcbafce9 (bug 1809568)
Backed out changeset b518133a5c34 (bug 1809568)
Backed out changeset 2407088e9b49 (bug 1809568)
2023-05-17 01:34:42 +03:00
David Shin
33ec2490df Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-16 20:48:18 +00:00
Sandor Molnar
146a43a1bc Backed out 3 changesets (bug 1809568) for causing node devtools failures in devtools/client/debugger/src/components/test/QuickOpenModal.spec.js CLOSED TREE
Backed out changeset 56ce741da8f5 (bug 1809568)
Backed out changeset 5a91ce4870e4 (bug 1809568)
Backed out changeset cc00422f050a (bug 1809568)
2023-05-16 22:22:31 +03:00
David Shin
970986fac9 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-16 19:02:11 +00:00
Cristian Tuns
aa3e994c56 Backed out 3 changesets (bug 1809568) for causing build bustages on nsLineLayout.cpp CLOSED TREE
Backed out changeset e862b1560caa (bug 1809568)
Backed out changeset 0a20b91de67b (bug 1809568)
Backed out changeset 6060fc7d49d4 (bug 1809568)
2023-05-15 13:03:03 -04:00
David Shin
6f868ef403 Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-15 14:34:26 +00:00
Cosmin Sabou
44343a085c Backed out 3 changesets (bug 1809568) for causing build bustages on nsBlockFrame.cpp. CLOSED TREE
Backed out changeset eaa7fe280317 (bug 1809568)
Backed out changeset ab0f2bcb2d9b (bug 1809568)
Backed out changeset a481bf06452b (bug 1809568)
2023-05-01 21:42:14 +03:00
David Shin
65b6b0c69f Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-01 17:04:27 +00:00
Iulian Moraru
babc5faa23 Backed out 3 changesets (bug 1809568) for causing build bustages on nsLineLayout.cpp. CLOSED TREE
Backed out changeset 573dc0bd9554 (bug 1809568)
Backed out changeset b8401947aea0 (bug 1809568)
Backed out changeset 7ecabe895121 (bug 1809568)
2023-05-01 17:59:21 +03:00
David Shin
9e2157483e Bug 1809568 - Part 2: Provide GetNaturalBaselineBOffset with baseline export context. r=emilio
Some baseline exports are context-sensitive. One example: In line-layout scenario,
the last baseline of a scroll container is always the margin-end. In other (e.g.
flex, grid) scenarios, it's the border-box clamped offset to the last line in the
container.
This enables the required 3 different behaviours for `inline-block` scroll containers
for 3 different `baseline-source` values:
- `auto`: Last baseline, margin-end
- `first`: Border-box clamped offset to the first line
- `last`: Border-box clamped offset to the last line

Differential Revision: https://phabricator.services.mozilla.com/D173886
2023-05-01 13:44:43 +00:00
Jonathan Kew
9535408f9b Bug 1712703 - Record the "hangable" advance of trailing whitespace in a textframe property, and use this in nsLineLayout to adjust inline positioning. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D174728
2023-04-05 23:58:08 +00:00
Noemi Erli
914b175f1f Backed out 3 changesets (bug 1712703) for causing nsLineLayout related crashes CLOSED TREE
Backed out changeset 18c753fda684 (bug 1712703)
Backed out changeset e54195c66f87 (bug 1712703)
Backed out changeset fa98b4c11d52 (bug 1712703)
2023-04-06 00:12:05 +03:00
Jonathan Kew
72ac0f18a6 Bug 1712703 - Record the "hangable" advance of trailing whitespace in a textframe property, and use this in nsLineLayout to adjust inline positioning. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D174728
2023-04-05 20:28:08 +00:00
Jonathan Kew
9bf21859c3 Bug 1819957 - Split out nsTextPaintStyle into its own source file. r=emilio
This lets us instantiate it on the stack in nsDisplayText::Paint.

Differential Revision: https://phabricator.services.mozilla.com/D171635
2023-03-05 22:24:10 +00:00
Jonathan Kew
9449d3c3d1 Bug 1818654 - Don't give up on clipping to the visible rect in nsDisplayText when selection or shadow is present. r=emilio
Although I haven't been able to reproduce the reporter's OOM crash here, I hope this will avoid
the issue; it certainly improves performance characteristics in my local build.

On the example here, my laptop happily scrolls the text field at 60fps when nothing is selected;
but if the text is selected it can only manage around 40fps, because we lose the clipping
optimization here.

With this change, it maintains 60fps regardless of whether the text is selected (or text-shadow
is present), and memory footprint is substantially reduced.

Differential Revision: https://phabricator.services.mozilla.com/D171318
2023-03-01 11:37:27 +00:00
David Shin
2b6c1b9ffd Bug 1811311 - Part 3: Refactor GetNaturalBaselineBOffset to return Maybe<nscoord>. r=layout-reviewers,emilio
Changed from returning `bool` & taking an out parameter.

Differential Revision: https://phabricator.services.mozilla.com/D168998
2023-02-23 14:53:27 +00:00
David Shin
ea283b961b Bug 1811311 - Part 1: Unite baseline-related functions in nsIFrame into one. r=emilio
Before, there existed 3 virtual functions that calculated baselines:

- `GetLogicalBaseline`
- `GetVerticalAlignBaseline`
- `GetNaturalBaselineBOffset`

Each of them had slightly different behaviours:

- `GetLogicalBaseline` would synthesize a baseline if there is no baseline.
  Others would simply return `false`.
- `GetNaturalBaselineBOffset` requires the caller to pick which of first/last
  baseline to calculate. Others pick on on their own.
- `GetNaturalBaselineBOffset`'s result can be either offset from border box
   start/end edge, depending on the caller-supplied baseline. Others always
   return offset from border box start edge.

Now:

- `GetNaturalBaselineBOffset` is the sole virtual function.
- `GetLogicalBaseline` exists to support its use, with 2 virtual helper functions:
  - `SynthesizeFallbackBaseline` to generate a baseline for elements that
    doesn't have one.
  - `GetBaselineSharingGroup` to preserve the default baseline picking behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D167990
2023-02-23 14:53:26 +00:00
Jonathan Kew
6a1ee76c3c Bug 1818172 - Use nsTextFrame::ResolveSelections and a SelectionRangeIterator to optimize PaintTextSelectionDecorations. r=emilio
With this, the old SelectionIterator that expects a per-character array of
SelectionDetails pointers is no longer used anywhere.

Differential Revision: https://phabricator.services.mozilla.com/D170588
2023-02-23 11:14:27 +00:00
Jonathan Kew
de7b2e0cbc Bug 1816927 - Improve performance of nsTextFrame::PaintTextWithSelectionColors on very large textframes. r=emilio
This significantly improves performance and reduces memory usage when painting a very long textframe
with some or all of the text selected.

Differential Revision: https://phabricator.services.mozilla.com/D170530
2023-02-23 09:36:13 +00:00
Jan-Niklas Jaeschke
aef95a5286 Bug 1803355: Basic implementation of Custom Highlight API. r=edgar,emilio
Added WebIDL interfaces as per spec, added some necessary changes to support maplike and setlike structures to be accessed from C++.

Added `::highlight(foo)` pseudo element to CSS engine.

Implemented Highlight as new kind of `Selection` using `HighlightType::eHighlight`. This implies Selections being added/removed during runtime (one `Selection` object per highlight identifier), therefore a dynamic container for highlight `Selection` objects was added to `nsFrameSelection`. Also, the painting code queries the highlight style for highlight Selections.

Implementation is currently hidden behind a pref `dom.customHighlightAPI.enabled`.

Differential Revision: https://phabricator.services.mozilla.com/D164203
2023-01-27 11:42:18 +00:00
Sandor Molnar
cd459846bb Backed out changeset d7f27aa40260 (bug 1803355) for causing win build bustage. 2023-01-24 18:07:50 +02:00
Jan-Niklas Jaeschke
393f250021 Bug 1803355: Basic implementation of Custom Highlight API. r=edgar,emilio
Added WebIDL interfaces as per spec, added some necessary changes to support maplike and setlike structures to be accessed from C++.

Added `::highlight(foo)` pseudo element to CSS engine.

Implemented Highlight as new kind of `Selection` using `HighlightType::eHighlight`. This implies Selections being added/removed during runtime (one `Selection` object per highlight identifier), therefore a dynamic container for highlight `Selection` objects was added to `nsFrameSelection`. Also, the painting code queries the highlight style for highlight Selections.

Implementation is currently hidden behind a pref `dom.customHighlightAPI.enabled`.

Differential Revision: https://phabricator.services.mozilla.com/D164203
2023-01-24 11:46:28 +00:00
Sandor Molnar
618c0b7888 Backed out changeset 54771a1963b6 (bug 1803355) for causing win build bustage. CLOSED TREE 2023-01-24 12:17:49 +02:00