Browse Source

import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1176681 - Make character buffer allocations in the HTML5 tree builder fallible. r=wchen. (f289384f90)
- Bug 1142400 - Separate padding calculation in Get{Min,Pref}ISize and Reflow of nsBulletFrame. r=dbaron (e08bee6a1d)
- Bug 1187432 - Avoid scheduling main-thread paints for scrolls handled by apz. r=tn (422d9e0c64)
- Bug 1172450 - Size and position the dropdown arrow properly in vertical writing modes. r=smontagu (73c1464a6b)
- Bug 1201529 - Ensure that zoomable scrollframes return true from WantAsyncScroll(). r=botond (7adb05b491)
- Bug 1174553 part 1 - Add a new flag (BAIL_IF_REFLOW_NEEDED) for IntrinsicForWM() that makes it return early with a NS_INTRINSIC_WIDTH_UNKNOWN result if a reflow is needed to determine the child's correct BSize. r=dholbert (221b586fe0)
- Bug 1174546 part 1 - Introduce nsLayoutUtils::MinSizeContributionForAxis which calculates an intrinsic size contribution from aFrame's 'min-width' property (or 'min-height' if the given axis is vertical) and the corresponding border, padding and margin values. r=jfkthame (c81d0b5aae)
- Bug 1174553 part 2 - Move the AddPercents function into a static method in the nsLayoutUtils class. r=dholbert (18b1153de7)
- Bug 1151212 part 1 - [css-grid] Introduce a few local structs (GridReflowState, Tracks, TrackSizingFunctions) to make it easier to pass around data. r=dholbert (10d9a635a6)
- Bug 1151212 part 2 - [css-grid] Introduce a local GridItemInfo struct for holding a grid item's GridArea and other things. Put two nsTArrays of those in the grid container frame, one for normal flow items and one for abs.pos. grid-aligned descendants. Add a GridItemIndex method on the grid item iterator to return the index for the current item. r=dholbert (f4df44e43c)
- Bug 1161038 - [css-grid] Make kAutoLine not clash with translated grid lines. r=dholbert (a467a13270)
- Bug 1174546 part 2 - [css-grid] Implement the 'auto' min-sizing function in Grid layout. r=jfkthame (bf6d3ab2b3)
- Bug 1174553 part 3 - [css-grid] Implement the 'min-content' / 'max-content' sizing functions in layout. r=dholbert (152e139615)
- Bug 1151212 part 3 - [css-grid] Implement the "Resolve Intrinsic Track Sizes" algorithm. r=dholbert (710657b5c2)
- Bug 1176619 - [css-grid] Implement the "Maximize Tracks" algorithm. r=dholbert (882da4b57e)
- Bug 1176621 - [css-grid] Implement "Stretch Flexible Tracks" and associated algorithms. r=dholbert (5737f5fb47)
- Bug 1174574 part 1 - [css-grid] Move the guts of nsGridContainerFrame::CalculateTrackSizes into a Tracks method. r=dholbert (871ca8dca6)
- Bug 1174574 part 2 - [css-grid] Implement intrinsic sizing for grid containers (aka GetMinISize/GetPrefISize). r=dholbert (0958f2ad77)
- Bug 1174553 part 5 - [css-grid] Replace the ambiguous Dimension with LogicalAxis. r=dholbert (15afa20c61)
- Bug 1194892 - [css-grid] "span * / span *" should be treated as "auto / auto" for abs.pos. grid items. r=dholbert (9b229d7e07)
- Bug 1194888 - [css-grid] A line outside the existing grid should be treated as 'auto' for abs.pos (10.1). r=dholbert (7bd2426be2)
- Bug 1204585 part 2 - [css-grid] abs.pos. child position reftests. (fbf2d4e37a)
- Bug 1206703 - [css-grid] In an empty grid all lines should be treated as 'auto' for abs.pos. items, i.e. snap to the padding edge. r=dholbert (42aeeb368f)
- Bug 1204585 part 1 - [css-grid] Use the grid area's size when converting to physical coordinates for abs.pos. items. r=dholbert (ad68e0bab1)
- Bug 1164918 - Allow multiple '.' per cell in grid-template-areas. r=dholbert (db6420ebc5)
- [css-grid] Use a smaller font-size to make sure the rendering fits within the reftest snapshot area. (minor test changes only, no bug, r=me) (4868bd81c9)
- Bug 1151212 part 4 - [css-grid] Tests for intrinsic track sizing and intrinsic grid container sizing (bug 1174574). (3b60858334)
- Bug 1176621 part 2 - [css-grid] Tests for flex track sizing. (fb507cae8e)
- Bug 1151212 - [css-grid] Tests for <flex> min-sizing. (a74a1bf328)
- Bug 1174504 - Logical-coordinate versions of nsIFrame::SetSize should maintain the frame's logical position. r=smontagu (f053a277bf)
master
roytam1 2 months ago
parent
commit
e8d74fa3c4
  1. 3
      gfx/layers/apz/test/helper_bug982141.html
  2. 5
      gfx/tests/reftest/1143303-1.svg
  3. 4
      layout/base/FrameLayerBuilder.cpp
  4. 8
      layout/base/ZoomConstraintsClient.cpp
  5. 91
      layout/base/nsLayoutUtils.cpp
  6. 39
      layout/base/nsLayoutUtils.h
  7. 8
      layout/forms/nsComboboxControlFrame.cpp
  8. 5
      layout/generic/nsBlockFrame.cpp
  9. 5
      layout/generic/nsBlockReflowContext.cpp
  10. 37
      layout/generic/nsBulletFrame.cpp
  11. 6
      layout/generic/nsBulletFrame.h
  12. 8
      layout/generic/nsContainerFrame.h
  13. 83
      layout/generic/nsGfxScrollFrame.cpp
  14. 36
      layout/generic/nsGfxScrollFrame.h
  15. 1584
      layout/generic/nsGridContainerFrame.cpp
  16. 172
      layout/generic/nsGridContainerFrame.h
  17. 32
      layout/generic/nsIFrame.h
  18. 19
      layout/generic/nsIScrollableFrame.h
  19. 17
      layout/generic/nsLineLayout.cpp
  20. 108
      layout/reftests/css-grid/grid-abspos-items-001-ref.html
  21. 85
      layout/reftests/css-grid/grid-abspos-items-001.html
  22. 96
      layout/reftests/css-grid/grid-abspos-items-002-ref.html
  23. 75
      layout/reftests/css-grid/grid-abspos-items-002.html
  24. 71
      layout/reftests/css-grid/grid-abspos-items-003-ref.html
  25. 69
      layout/reftests/css-grid/grid-abspos-items-003.html
  26. 73
      layout/reftests/css-grid/grid-abspos-items-004-ref.html
  27. 70
      layout/reftests/css-grid/grid-abspos-items-004.html
  28. 74
      layout/reftests/css-grid/grid-abspos-items-005-ref.html
  29. 71
      layout/reftests/css-grid/grid-abspos-items-005.html
  30. 71
      layout/reftests/css-grid/grid-abspos-items-006-ref.html
  31. 70
      layout/reftests/css-grid/grid-abspos-items-006.html
  32. 61
      layout/reftests/css-grid/grid-abspos-items-007-ref.html
  33. 62
      layout/reftests/css-grid/grid-abspos-items-007.html
  34. 62
      layout/reftests/css-grid/grid-abspos-items-008-ref.html
  35. 63
      layout/reftests/css-grid/grid-abspos-items-008.html
  36. 63
      layout/reftests/css-grid/grid-abspos-items-009-ref.html
  37. 64
      layout/reftests/css-grid/grid-abspos-items-009.html
  38. 62
      layout/reftests/css-grid/grid-abspos-items-010-ref.html
  39. 63
      layout/reftests/css-grid/grid-abspos-items-010.html
  40. 54
      layout/reftests/css-grid/grid-abspos-items-011-ref.html
  41. 61
      layout/reftests/css-grid/grid-abspos-items-011.html
  42. 88
      layout/reftests/css-grid/grid-col-max-sizing-max-content-001-ref.html
  43. 90
      layout/reftests/css-grid/grid-col-max-sizing-max-content-001.html
  44. 92
      layout/reftests/css-grid/grid-col-max-sizing-max-content-002-ref.html
  45. 88
      layout/reftests/css-grid/grid-col-max-sizing-max-content-002.html
  46. 336
      layout/reftests/css-grid/grid-flex-min-sizing-001-ref.html
  47. 338
      layout/reftests/css-grid/grid-flex-min-sizing-001.html
  48. 272
      layout/reftests/css-grid/grid-flex-min-sizing-002-ref.html
  49. 272
      layout/reftests/css-grid/grid-flex-min-sizing-002.html
  50. 90
      layout/reftests/css-grid/grid-max-sizing-flex-001-ref.html
  51. 90
      layout/reftests/css-grid/grid-max-sizing-flex-001.html
  52. 90
      layout/reftests/css-grid/grid-max-sizing-flex-002-ref.html
  53. 89
      layout/reftests/css-grid/grid-max-sizing-flex-002.html
  54. 88
      layout/reftests/css-grid/grid-max-sizing-flex-003-ref.html
  55. 72
      layout/reftests/css-grid/grid-max-sizing-flex-003.html
  56. 120
      layout/reftests/css-grid/grid-max-sizing-flex-004-ref.html
  57. 174
      layout/reftests/css-grid/grid-max-sizing-flex-004.html
  58. 109
      layout/reftests/css-grid/grid-max-sizing-flex-005-ref.html
  59. 109
      layout/reftests/css-grid/grid-max-sizing-flex-005.html
  60. 81
      layout/reftests/css-grid/grid-max-sizing-flex-006-ref.html
  61. 83
      layout/reftests/css-grid/grid-max-sizing-flex-006.html
  62. 98
      layout/reftests/css-grid/grid-min-max-content-sizing-001-ref.html
  63. 105
      layout/reftests/css-grid/grid-min-max-content-sizing-001.html
  64. 1
      layout/reftests/css-grid/grid-order-placement-auto-001-ref.html
  65. 1
      layout/reftests/css-grid/grid-order-placement-auto-001.html
  66. 2
      layout/reftests/css-grid/grid-order-placement-definite-001-ref.html
  67. 2
      layout/reftests/css-grid/grid-order-placement-definite-001.html
  68. 67
      layout/reftests/css-grid/grid-placement-abspos-implicit-001-ref.html
  69. 48
      layout/reftests/css-grid/grid-placement-abspos-implicit-001.html
  70. 1
      layout/reftests/css-grid/grid-placement-auto-col-dense-001-ref.html
  71. 1
      layout/reftests/css-grid/grid-placement-auto-col-dense-001.html
  72. 1
      layout/reftests/css-grid/grid-placement-auto-col-sparse-001-ref.html
  73. 1
      layout/reftests/css-grid/grid-placement-auto-col-sparse-001.html
  74. 2
      layout/reftests/css-grid/grid-placement-auto-implicit-001-ref.html
  75. 2
      layout/reftests/css-grid/grid-placement-auto-implicit-001.html
  76. 1
      layout/reftests/css-grid/grid-placement-auto-row-dense-001-ref.html
  77. 1
      layout/reftests/css-grid/grid-placement-auto-row-dense-001.html
  78. 1
      layout/reftests/css-grid/grid-placement-auto-row-sparse-001-ref.html
  79. 1
      layout/reftests/css-grid/grid-placement-auto-row-sparse-001.html
  80. 1
      layout/reftests/css-grid/grid-placement-definite-001-ref.html
  81. 3
      layout/reftests/css-grid/grid-placement-definite-001.html
  82. 2
      layout/reftests/css-grid/grid-placement-definite-002-ref.html
  83. 2
      layout/reftests/css-grid/grid-placement-definite-002.html
  84. 79
      layout/reftests/css-grid/grid-placement-definite-003-ref.html
  85. 76
      layout/reftests/css-grid/grid-placement-definite-003.html
  86. 2
      layout/reftests/css-grid/grid-placement-definite-implicit-001-ref.html
  87. 2
      layout/reftests/css-grid/grid-placement-definite-implicit-001.html
  88. 139
      layout/reftests/css-grid/grid-track-intrinsic-sizing-001-ref.html
  89. 101
      layout/reftests/css-grid/grid-track-intrinsic-sizing-001.html
  90. 166
      layout/reftests/css-grid/grid-track-intrinsic-sizing-002-ref.html
  91. 190
      layout/reftests/css-grid/grid-track-intrinsic-sizing-002.html
  92. 220
      layout/reftests/css-grid/grid-track-intrinsic-sizing-003-ref.html
  93. 206
      layout/reftests/css-grid/grid-track-intrinsic-sizing-003.html
  94. 247
      layout/reftests/css-grid/grid-track-intrinsic-sizing-004-ref.html
  95. 223
      layout/reftests/css-grid/grid-track-intrinsic-sizing-004.html
  96. 2
      layout/reftests/css-grid/grid-whitespace-handling-2-ref.xhtml
  97. 27
      layout/reftests/css-grid/reftest.list
  98. 2
      layout/reftests/css-grid/rtl-grid-placement-auto-row-sparse-001-ref.html
  99. 2
      layout/reftests/css-grid/rtl-grid-placement-auto-row-sparse-001.html
  100. 1
      layout/reftests/css-grid/rtl-grid-placement-definite-001-ref.html
  101. Some files were not shown because too many files have changed in this diff Show More

3
gfx/layers/apz/test/helper_bug982141.html

@ -5,6 +5,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=982141
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no">
<title>Test for Bug 982141, helper page</title>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript">
@ -87,7 +88,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=982141
}
</script>
</head>
<body style="overflow: hidden;"><!-- Make sure the root frame is not scrollable -->
<body style="overflow: hidden;"><!-- This combined with the user-scalable=no ensures the root frame is not scrollable -->
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=982141">Mozilla Bug 982141</a>
<!-- A scrollable subframe, with enough content to make it have a nonzero scroll range -->
<div style="height: 50px; width: 50px; overflow: scroll">

5
gfx/tests/reftest/1143303-1.svg

@ -4,6 +4,11 @@
-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
width="100%" height="100%">
<!-- There is a bug with MultiTiledContentClient that causes improper painting;
bug 1204076 is on file for this issue. As a temporary workaround, we set
user-scalable=no here so that WantAsyncZoom() returns false and we don't
use a MultiTiledContentClient. Once bug 1204076 is fixed, we can remove this. -->
<meta xmlns="http://www.w3.org/1999/xhtml" name="viewport" content="user-scalable=no"/>
<title>Testcase for small circles</title>
<!--From https://bugzilla.mozilla.org/show_bug.cgi?id=1143303 -->

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 1.2 KiB

4
layout/base/FrameLayerBuilder.cpp

@ -3744,7 +3744,7 @@ GetScrollClipIntersection(nsDisplayListBuilder* aBuilder, const nsIFrame* aAnima
continue;
}
const DisplayItemClip* clip = scrollFrame->ComputeScrollClip(aIsCaret);
Maybe<DisplayItemClip> clip = scrollFrame->ComputeScrollClip(aIsCaret);
if (clip) {
resultClip.IntersectWith(*clip);
}
@ -4656,7 +4656,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
}
FrameMetrics& metrics = info->metrics;
const DisplayItemClip* clip = info->clip;
Maybe<DisplayItemClip> clip = info->clip;
if (clip &&
clip->HasClip() &&

8
layout/base/ZoomConstraintsClient.cpp

@ -187,6 +187,14 @@ ZoomConstraintsClient::RefreshZoomConstraints()
}
}
// We only ever create a ZoomConstraintsClient for an RCD, so the RSF of
// the presShell must be the RCD-RSF (if it exists).
MOZ_ASSERT(mPresShell->GetPresContext()->IsRootContentDocument());
if (nsIScrollableFrame* rcdrsf = mPresShell->GetRootScrollFrameAsScrollable()) {
ZCC_LOG("Notifying RCD-RSF that it is zoomable: %d\n", zoomConstraints.mAllowZoom);
rcdrsf->SetZoomableByAPZ(zoomConstraints.mAllowZoom);
}
ScrollableLayerGuid newGuid(0, presShellId, viewId);
if (mGuid && mGuid.value() != newGuid) {
ZCC_LOG("Clearing old constraints in %p for { %u, %" PRIu64 " }\n",

91
layout/base/nsLayoutUtils.cpp

@ -1080,6 +1080,10 @@ nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
return false;
}
if (currentData && currentData->mMargins == aMargins) {
return true;
}
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(
aMargins, aPriority),
@ -4100,21 +4104,6 @@ nsLayoutUtils::IsViewportScrollbarFrame(nsIFrame* aFrame)
IsProperAncestorFrame(rootScrolledFrame, aFrame));
}
static nscoord AddPercents(nsLayoutUtils::IntrinsicISizeType aType,
nscoord aCurrent, float aPercent)
{
nscoord result = aCurrent;
if (aPercent > 0.0f && aType == nsLayoutUtils::PREF_ISIZE) {
// XXX Should we also consider percentages for min widths, up to a
// limit?
if (aPercent >= 1.0f)
result = nscoord_MAX;
else
result = NSToCoordRound(float(result) / (1.0f - aPercent));
}
return result;
}
// Use only for widths/heights (or their min/max), since it clamps
// negative calc() results to 0.
static bool GetAbsoluteCoord(const nsStyleCoord& aStyle, nscoord& aResult)
@ -4401,7 +4390,8 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
if (GetAbsoluteCoord(aStyleSize, size) ||
GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
PROP_WIDTH, size)) {
result = AddPercents(aType, size + coordOutsideSize, pctOutsideSize);
result = nsLayoutUtils::AddPercents(aType, size + coordOutsideSize,
pctOutsideSize);
} else if (aType == nsLayoutUtils::MIN_ISIZE &&
// The only cases of coord-percent-calc() units that
// GetAbsoluteCoord didn't handle are percent and calc()s
@ -4416,14 +4406,15 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
// the coefficient on the percent is positive and there are no max()
// expressions). However, doing better for percents wouldn't be
// backwards compatible.
result = AddPercents(aType, result, pctTotal);
result = nsLayoutUtils::AddPercents(aType, result, pctTotal);
}
nscoord maxSize = aFixedMaxSize ? *aFixedMaxSize : 0;
if (aFixedMaxSize ||
GetIntrinsicCoord(aStyleMaxSize, aRenderingContext, aFrame,
PROP_MAX_WIDTH, maxSize)) {
maxSize = AddPercents(aType, maxSize + coordOutsideSize, pctOutsideSize);
maxSize = nsLayoutUtils::AddPercents(aType, maxSize + coordOutsideSize,
pctOutsideSize);
if (result > maxSize) {
result = maxSize;
}
@ -4433,13 +4424,14 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
if (aFixedMinSize ||
GetIntrinsicCoord(aStyleMinSize, aRenderingContext, aFrame,
PROP_MIN_WIDTH, minSize)) {
minSize = AddPercents(aType, minSize + coordOutsideSize, pctOutsideSize);
minSize = nsLayoutUtils::AddPercents(aType, minSize + coordOutsideSize,
pctOutsideSize);
if (result < minSize) {
result = minSize;
}
}
min = AddPercents(aType, min, pctTotal);
min = nsLayoutUtils::AddPercents(aType, min, pctTotal);
if (result < min) {
result = min;
}
@ -4456,7 +4448,8 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
: devSize.width);
// GetMinimumWidgetSize() returns a border-box width.
themeSize += aOffsets.hMargin;
themeSize = AddPercents(aType, themeSize, aOffsets.hPctMargin);
themeSize = nsLayoutUtils::AddPercents(aType, themeSize,
aOffsets.hPctMargin);
if (themeSize > result || !canOverride) {
result = themeSize;
@ -4565,6 +4558,9 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis,
#endif
if (MOZ_UNLIKELY(aAxis != ourInlineAxis)) {
// We need aFrame's block-dir size.
if (aFlags & BAIL_IF_REFLOW_NEEDED) {
return NS_INTRINSIC_WIDTH_UNKNOWN;
}
// XXX Unfortunately, we probably don't know this yet, so this is wrong...
// but it's not clear what we should do. If aFrame's inline size hasn't
// been determined yet, we can't necessarily figure out its block size
@ -4716,6 +4712,59 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext* aRenderingContext,
return IntrinsicForAxis(axis, aRenderingContext, aFrame, aType, aFlags);
}
/* static */ nscoord
nsLayoutUtils::MinSizeContributionForAxis(PhysicalAxis aAxis,
nsRenderingContext* aRC,
nsIFrame* aFrame,
IntrinsicISizeType aType,
uint32_t aFlags)
{
NS_PRECONDITION(aFrame, "null frame");
NS_PRECONDITION(aFrame->GetParent(),
"MinSizeContributionForAxis called on frame not in tree");
#ifdef DEBUG_INTRINSIC_WIDTH
nsFrame::IndentBy(stderr, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stderr);
printf_stderr(" %s min-isize for %s WM:\n",
aType == MIN_ISIZE ? "min" : "pref",
aWM.IsVertical() ? "vertical" : "horizontal");
#endif
// If aFrame is a container for font size inflation, then shrink
// wrapping inside of it should not apply font size inflation.
AutoMaybeDisableFontInflation an(aFrame);
PhysicalAxis ourInlineAxis =
aFrame->GetWritingMode().PhysicalAxis(eLogicalAxisInline);
nsIFrame::IntrinsicISizeOffsetData offsets =
ourInlineAxis == aAxis ? aFrame->IntrinsicISizeOffsets()
: aFrame->IntrinsicBSizeOffsets();
nscoord result = 0;
nscoord min = 0;
const nsStylePosition* stylePos = aFrame->StylePosition();
uint8_t boxSizing = stylePos->mBoxSizing;
const nsStyleCoord& style = aAxis == eAxisHorizontal ? stylePos->mMinWidth
: stylePos->mMinHeight;
nscoord minSize;
nscoord* fixedMinSize = nullptr;
if (GetAbsoluteCoord(style, minSize)) {
fixedMinSize = &minSize;
}
result = AddIntrinsicSizeOffset(aRC, aFrame, offsets, aType, boxSizing,
result, min, style, fixedMinSize,
style, fixedMinSize, style, aFlags, aAxis);
#ifdef DEBUG_INTRINSIC_WIDTH
nsFrame::IndentBy(stderr, gNoiseIndent);
static_cast<nsFrame*>(aFrame)->ListTag(stderr);
printf_stderr(" %s min-isize is %d twips.\n",
aType == MIN_ISIZE ? "min" : "pref", result);
#endif
return result;
}
/* static */ nscoord
nsLayoutUtils::ComputeCBDependentValue(nscoord aPercentBasis,
const nsStyleCoord& aCoord)

39
layout/base/nsLayoutUtils.h

@ -79,8 +79,8 @@ struct RectCornerRadii;
} // namespace gfx
namespace layers {
class Layer;
}
}
} // namespace layers
} // namespace mozilla
namespace mozilla {
@ -1308,7 +1308,8 @@ public:
*/
enum IntrinsicISizeType { MIN_ISIZE, PREF_ISIZE };
enum {
IGNORE_PADDING = 0x01
IGNORE_PADDING = 0x01,
BAIL_IF_REFLOW_NEEDED = 0x02, // returns NS_INTRINSIC_WIDTH_UNKNOWN if so
};
static nscoord IntrinsicForAxis(mozilla::PhysicalAxis aAxis,
nsRenderingContext* aRenderingContext,
@ -1323,6 +1324,38 @@ public:
IntrinsicISizeType aType,
uint32_t aFlags = 0);
/**
* Get the contribution of aFrame for the given physical axis.
* This considers the child's 'min-width' property (or 'min-height' if the
* given axis is vertical), and its padding, border, and margin in the
* corresponding dimension.
*/
static nscoord MinSizeContributionForAxis(mozilla::PhysicalAxis aAxis,
nsRenderingContext* aRC,
nsIFrame* aFrame,
IntrinsicISizeType aType,
uint32_t aFlags = 0);
/**
* This function increases an initial intrinsic size, 'aCurrent', according
* to the given 'aPercent', such that the size-increase makes up exactly
* 'aPercent' percent of the returned value. If 'aPercent' is less than
* or equal to zero the original 'aCurrent' value is returned. If 'aPercent'
* is greater than or equal to 1.0 the value nscoord_MAX is returned.
* (We don't increase the size if MIN_ISIZE is passed in, though.)
*/
static nscoord AddPercents(IntrinsicISizeType aType, nscoord aCurrent,
float aPercent)
{
if (aPercent > 0.0f && aType == nsLayoutUtils::PREF_ISIZE) {
// XXX Should we also consider percentages for min widths, up to a
// limit?
return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX
: NSToCoordRound(float(aCurrent) / (1.0f - aPercent));
}
return aCurrent;
}
/*
* Convert nsStyleCoord to nscoord when percentages depend on the
* containing block size.

8
layout/forms/nsComboboxControlFrame.cpp

@ -733,7 +733,7 @@ nsComboboxControlFrame::GetIntrinsicISize(nsRenderingContext* aRenderingContext,
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
scrollbarWidth = scrollable->GetNondisappearingScrollbarWidth(
presContext, aRenderingContext);
presContext, aRenderingContext, GetWritingMode());
}
nscoord displayISize = 0;
@ -848,6 +848,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
// Get the width of the vertical scrollbar. That will be the inline
// size of the dropdown button.
WritingMode wm = aReflowState.GetWritingMode();
nscoord buttonISize;
const nsStyleDisplay *disp = StyleDisplay();
if ((IsThemed(disp) && !aPresContext->GetTheme()->ThemeNeedsComboboxDropmarker()) ||
@ -858,7 +859,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
buttonISize = scrollable->GetNondisappearingScrollbarWidth(
PresContext(), aReflowState.rendContext);
PresContext(), aReflowState.rendContext, wm);
if (buttonISize > aReflowState.ComputedISize()) {
buttonISize = 0;
}
@ -869,8 +870,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// The button should occupy the same space as a scrollbar
WritingMode wm = aReflowState.GetWritingMode();
nsSize containerSize = aReflowState.ComputedSizeAsContainerIfConstrained();
nsSize containerSize = aDesiredSize.PhysicalSize();
LogicalRect buttonRect = mButtonFrame->GetLogicalRect(containerSize);
buttonRect.IStart(wm) =

5
layout/generic/nsBlockFrame.cpp

@ -1632,7 +1632,8 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
aMetrics.SetSize(wm, finalSize);
#ifdef DEBUG_blocks
if (CRAZY_SIZE(aMetrics.Width()) || CRAZY_SIZE(aMetrics.Height())) {
if ((CRAZY_SIZE(aMetrics.Width()) || CRAZY_SIZE(aMetrics.Height())) &&
!GetParent()->IsCrazySizeAssertSuppressed()) {
ListTag(stdout);
printf(": WARNING: desired:%d,%d\n", aMetrics.Width(), aMetrics.Height());
}
@ -4462,7 +4463,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
}
#ifdef DEBUG
{
if (!GetParent()->IsCrazySizeAssertSuppressed()) {
static nscoord lastHeight = 0;
if (CRAZY_SIZE(aLine->BStart())) {
lastHeight = aLine->BStart();

5
layout/generic/nsBlockReflowContext.cpp

@ -302,8 +302,9 @@ nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace,
#ifdef DEBUG
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
if (CRAZY_SIZE(mMetrics.ISize(mWritingMode)) ||
CRAZY_SIZE(mMetrics.BSize(mWritingMode))) {
if ((CRAZY_SIZE(mMetrics.ISize(mWritingMode)) ||
CRAZY_SIZE(mMetrics.BSize(mWritingMode))) &&
!mFrame->GetParent()->IsCrazySizeAssertSuppressed()) {
printf("nsBlockReflowContext: ");
nsFrame::ListTag(stdout, mFrame);
printf(" metrics=%d,%d!\n",

37
layout/generic/nsBulletFrame.cpp

@ -515,20 +515,22 @@ nsBulletFrame::GetListItemText(nsAString& aResult)
#define MIN_BULLET_SIZE 1
void
nsBulletFrame::AppendSpacingToPadding(nsFontMetrics* aFontMetrics)
nsBulletFrame::AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
LogicalMargin* aPadding)
{
mPadding.IEnd(GetWritingMode()) += aFontMetrics->EmHeight() / 2;
aPadding->IEnd(GetWritingMode()) += aFontMetrics->EmHeight() / 2;
}
void
nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
nsRenderingContext *aRenderingContext,
nsHTMLReflowMetrics& aMetrics,
float aFontSizeInflation)
float aFontSizeInflation,
LogicalMargin* aPadding)
{
// Reset our padding. If we need it, we'll set it below.
WritingMode wm = GetWritingMode();
mPadding.SizeTo(wm, 0, 0, 0, 0);
aPadding->SizeTo(wm, 0, 0, 0, 0);
LogicalSize finalSize(wm);
const nsStyleList* myList = StyleList();
@ -550,7 +552,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
mIntrinsicSize.BSize(wm));
aMetrics.SetSize(wm, finalSize);
AppendSpacingToPadding(fm);
AppendSpacingToPadding(fm, aPadding);
AddStateBits(BULLET_FRAME_IMAGE_LOADING);
@ -581,10 +583,10 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
ascent = fm->MaxAscent();
bulletSize = std::max(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
mPadding.BEnd(wm) = NSToCoordRound(float(ascent) / 8.0f);
aPadding->BEnd(wm) = NSToCoordRound(float(ascent) / 8.0f);
finalSize.ISize(wm) = finalSize.BSize(wm) = bulletSize;
aMetrics.SetBlockStartAscent(bulletSize + mPadding.BEnd(wm));
AppendSpacingToPadding(fm);
aMetrics.SetBlockStartAscent(bulletSize + aPadding->BEnd(wm));
AppendSpacingToPadding(fm, aPadding);
break;
}
@ -594,12 +596,12 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
bulletSize = std::max(
nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
NSToCoordRound(0.75f * ascent));
mPadding.BEnd(wm) = NSToCoordRound(0.125f * ascent);
aPadding->BEnd(wm) = NSToCoordRound(0.125f * ascent);
finalSize.ISize(wm) = finalSize.BSize(wm) = bulletSize;
if (!wm.IsVertical()) {
aMetrics.SetBlockStartAscent(bulletSize + mPadding.BEnd(wm));
aMetrics.SetBlockStartAscent(bulletSize + aPadding->BEnd(wm));
}
AppendSpacingToPadding(fm);
AppendSpacingToPadding(fm, aPadding);
break;
default:
@ -629,7 +631,8 @@ nsBulletFrame::Reflow(nsPresContext* aPresContext,
SetFontSizeInflation(inflation);
// Get the base size
GetDesiredSize(aPresContext, aReflowState.rendContext, aMetrics, inflation);
GetDesiredSize(aPresContext, aReflowState.rendContext,
aMetrics, inflation, &mPadding);
// Add in the border and padding; split the top/bottom between the
// ascent and descent to make things look nice
@ -663,8 +666,9 @@ nsBulletFrame::GetMinISize(nsRenderingContext *aRenderingContext)
WritingMode wm = GetWritingMode();
nsHTMLReflowMetrics metrics(wm);
DISPLAY_MIN_WIDTH(this, metrics.ISize(wm));
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
metrics.ISize(wm) += mPadding.IStartEnd(wm);
LogicalMargin padding(wm);
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f, &padding);
metrics.ISize(wm) += padding.IStartEnd(wm);
return metrics.ISize(wm);
}
@ -674,8 +678,9 @@ nsBulletFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
WritingMode wm = GetWritingMode();
nsHTMLReflowMetrics metrics(wm);
DISPLAY_PREF_WIDTH(this, metrics.ISize(wm));
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f);
metrics.ISize(wm) += mPadding.IStartEnd(wm);
LogicalMargin padding(wm);
GetDesiredSize(PresContext(), aRenderingContext, metrics, 1.0f, &padding);
metrics.ISize(wm) += padding.IStartEnd(wm);
return metrics.ISize(wm);
}

6
layout/generic/nsBulletFrame.h

@ -113,11 +113,13 @@ public:
protected:
nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
void AppendSpacingToPadding(nsFontMetrics* aFontMetrics);
void AppendSpacingToPadding(nsFontMetrics* aFontMetrics,
mozilla::LogicalMargin* aPadding);
void GetDesiredSize(nsPresContext* aPresContext,
nsRenderingContext *aRenderingContext,
nsHTMLReflowMetrics& aMetrics,
float aFontSizeInflation);
float aFontSizeInflation,
mozilla::LogicalMargin* aPadding);
void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
nsIDocument* GetOurCurrentDoc() const;

8
layout/generic/nsContainerFrame.h

@ -455,6 +455,14 @@ public:
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OverflowContainersProperty)
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(ExcessOverflowContainersProperty)
#ifdef DEBUG
// Use this to suppress the CRAZY_SIZE assertions.
NS_DECLARE_FRAME_PROPERTY(DebugReflowingWithInfiniteISize, nullptr)
bool IsCrazySizeAssertSuppressed() const {
return Properties().Get(DebugReflowingWithInfiniteISize()) != nullptr;
}
#endif
protected:
explicit nsContainerFrame(nsStyleContext* aContext) : nsSplittableFrame(aContext) {}
~nsContainerFrame();

83
layout/generic/nsGfxScrollFrame.cpp

@ -1041,34 +1041,38 @@ ScrollFrameHelper::GetDesiredScrollbarSizes(nsBoxLayoutState* aState)
}
nscoord
ScrollFrameHelper::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState)
ScrollFrameHelper::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
WritingMode aWM)
{
NS_ASSERTION(aState && aState->GetRenderingContext(),
"Must have rendering context in layout state for size "
"computations");
bool verticalWM = aWM.IsVertical();
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
// We're using overlay scrollbars, so we need to get the width that
// non-disappearing scrollbars would have.
nsITheme* theme = aState->PresContext()->GetTheme();
if (theme &&
theme->ThemeSupportsWidget(aState->PresContext(),
mVScrollbarBox,
verticalWM ? mHScrollbarBox
: mVScrollbarBox,
NS_THEME_SCROLLBAR_NON_DISAPPEARING)) {
LayoutDeviceIntSize size;
bool canOverride = true;
theme->GetMinimumWidgetSize(aState->PresContext(),
mVScrollbarBox,
verticalWM ? mHScrollbarBox
: mVScrollbarBox,
NS_THEME_SCROLLBAR_NON_DISAPPEARING,
&size,
&canOverride);
if (size.width) {
return aState->PresContext()->DevPixelsToAppUnits(size.width);
}
return aState->PresContext()->
DevPixelsToAppUnits(verticalWM ? size.height : size.width);
}
}
return GetDesiredScrollbarSizes(aState).LeftRight();
nsMargin sizes(GetDesiredScrollbarSizes(aState));
return verticalWM ? sizes.TopBottom() : sizes.LeftRight();
}
void
@ -1103,9 +1107,26 @@ static bool IsFocused(nsIContent* aContent)
}
#endif
void
ScrollFrameHelper::SetZoomableByAPZ(bool aZoomable)
{
if (mZoomableByAPZ != aZoomable) {
// We might be changing the result of WantAsyncScroll() so schedule a
// paint to make sure we pick up the result of that change.
mZoomableByAPZ = aZoomable;
mOuter->SchedulePaint();
}
}
bool
ScrollFrameHelper::WantAsyncScroll() const
{
// If zooming is allowed, and this is a frame that's allowed to zoom, then
// we want it to be async-scrollable or zooming will not be permitted.
if (mZoomableByAPZ) {
return true;
}
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
uint32_t directions = mOuter->GetScrollTargetFrame()->GetPerceivedScrollingDirections();
bool isVScrollable = !!(directions & nsIScrollableFrame::VERTICAL) &&
@ -1801,8 +1822,6 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mResolution(1.0)
, mScrollPosForLayerPixelAlignment(-1, -1)
, mLastUpdateImagesPos(-1, -1)
, mAncestorClip(nullptr)
, mAncestorClipForCaret(nullptr)
, mNeverHasVerticalScrollbar(false)
, mNeverHasHorizontalScrollbar(false)
, mHasVerticalScrollbar(false)
@ -1828,6 +1847,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mIgnoreMomentumScroll(false)
, mScaleToResolution(false)
, mTransformingByAPZ(false)
, mZoomableByAPZ(false)
, mVelocityQueue(aOuter->PresContext())
{
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
@ -2225,7 +2245,7 @@ void ScrollFrameHelper::MarkRecentlyScrolled()
}
}
void ScrollFrameHelper::ScrollVisual(nsPoint aOldScrolledFramePos)
void ScrollFrameHelper::ScrollVisual()
{
// Mark this frame as having been scrolled. If this is the root
// scroll frame of a content document, then IsAlwaysActive()
@ -2244,7 +2264,6 @@ void ScrollFrameHelper::ScrollVisual(nsPoint aOldScrolledFramePos)
MarkRecentlyScrolled();
}
mOuter->SchedulePaint();
}
/**
@ -2418,15 +2437,35 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsIAtom* aOri
mListeners[i]->ScrollPositionWillChange(pt.x, pt.y);
}
nsPoint oldScrollFramePos = mScrolledFrame->GetPosition();
nsRect oldDisplayPort;
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &oldDisplayPort);
oldDisplayPort.MoveBy(-mScrolledFrame->GetPosition());
// Update frame position for scrolling
mScrolledFrame->SetPosition(mScrollPort.TopLeft() - pt);
mLastScrollOrigin = aOrigin;
mLastSmoothScrollOrigin = nullptr;
mScrollGeneration = ++sScrollGenerationCounter;
// We pass in the amount to move visually
ScrollVisual(oldScrollFramePos);
ScrollVisual();
if (LastScrollOrigin() == nsGkAtoms::apz) {
// If this was an apz scroll and the displayport (relative to the
// scrolled frame) hasn't changed, then this won't trigger
// any painting, so no need to schedule one.
nsRect displayPort;
DebugOnly<bool> usingDisplayPort =
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &displayPort);
NS_ASSERTION(usingDisplayPort, "Must have a displayport for apz scrolls!");
displayPort.MoveBy(-mScrolledFrame->GetPosition());
if (!displayPort.IsEqualEdges(oldDisplayPort)) {
mOuter->SchedulePaint();
}
} else {
mOuter->SchedulePaint();
}
if (mOuter->ChildrenHavePerspective()) {
// The overflow areas of descendants may depend on the scroll position,
@ -2762,8 +2801,8 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
// Clear the scroll port clip that was set during the last paint.
mAncestorClip = nullptr;
mAncestorClipForCaret = nullptr;
mAncestorClip = Nothing();
mAncestorClipForCaret = Nothing();
// We put non-overlay scrollbars in their own layers when this is the root
// scroll frame and we are a toplevel content document. In this situation,
@ -3004,7 +3043,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// Capture the clip state of the parent scroll frame. This will be saved
// on FrameMetrics for layers with this frame as their animated geoemetry
// root.
mAncestorClipForCaret = aBuilder->ClipState().GetCurrentCombinedClip(aBuilder);
mAncestorClipForCaret = ToMaybe(aBuilder->ClipState().GetCurrentCombinedClip(aBuilder));
// Add the non-caret content box clip here so that it gets picked up by
// mAncestorClip.
@ -3017,7 +3056,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
clipStateNonCaret->ClipContainingBlockDescendants(*contentBoxClipForNonCaretContent);
}
}
mAncestorClip = aBuilder->ClipState().GetCurrentCombinedClip(aBuilder);
mAncestorClip = ToMaybe(aBuilder->ClipState().GetCurrentCombinedClip(aBuilder));
// If we are using a display port, then ignore any pre-existing clip
// passed down from our parents. The pre-existing clip would just defeat
@ -3097,12 +3136,12 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
scrolledContent.MoveTo(aLists);
}
const DisplayItemClip*
Maybe<DisplayItemClip>
ScrollFrameHelper::ComputeScrollClip(bool aIsForCaret) const
{
const DisplayItemClip* ancestorClip = aIsForCaret ? mAncestorClipForCaret : mAncestorClip;
const Maybe<DisplayItemClip>& ancestorClip = aIsForCaret ? mAncestorClipForCaret : mAncestorClip;
if (!mShouldBuildScrollableLayer || mIsScrollableLayerInRootContainer) {
return nullptr;
return Nothing();
}
return ancestorClip;
@ -3124,7 +3163,7 @@ ScrollFrameHelper::ComputeFrameMetrics(Layer* aLayer,
needsParentLayerClip = false;
}
const DisplayItemClip* ancestorClip = aIsForCaret ? mAncestorClipForCaret : mAncestorClip;
const Maybe<DisplayItemClip>& ancestorClip = aIsForCaret ? mAncestorClipForCaret : mAncestorClip;
nsPoint toReferenceFrame = mOuter->GetOffsetToCrossDoc(aContainerReferenceFrame);
bool isRootContent = mIsRoot && mOuter->PresContext()->IsRootContentDocument();

36
layout/generic/nsGfxScrollFrame.h

@ -222,7 +222,7 @@ public:
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange, nsIAtom* aOrigin = nullptr);
void ScrollVisual(nsPoint aOldScrolledFramePosition);
void ScrollVisual();
/**
* @note This method might destroy the frame, pres shell and other objects.
*/
@ -304,7 +304,8 @@ public:
}
nsMargin GetActualScrollbarSizes() const;
nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState);
nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
mozilla::WritingMode aVerticalWM);
bool IsLTR() const;
bool IsScrollbarOnRight() const;
bool IsScrollingActive(nsDisplayListBuilder* aBuilder) const;
@ -359,6 +360,8 @@ public:
bool IsTransformingByAPZ() const {
return mTransformingByAPZ;
}
void SetZoomableByAPZ(bool aZoomable);
bool UsesContainerScrolling() const;
void ScheduleSyntheticMouseMove();
@ -381,7 +384,7 @@ public:
Layer* aLayer, nsIFrame* aContainerReferenceFrame,
const ContainerLayerParameters& aParameters,
bool aIsForCaret) const;
virtual const mozilla::DisplayItemClip* ComputeScrollClip(bool aIsForCaret) const;
virtual mozilla::Maybe<mozilla::DisplayItemClip> ComputeScrollClip(bool aIsForCaret) const;
// nsIScrollbarMediator
void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
@ -460,9 +463,9 @@ public:
FrameMetrics::ViewID mScrollParentID;
// The scroll port clip. Only valid during painting.
const DisplayItemClip* mAncestorClip;
const DisplayItemClip* mAncestorClipForCaret;
// The scroll port clip.
Maybe<DisplayItemClip> mAncestorClip;
Maybe<DisplayItemClip> mAncestorClipForCaret;
bool mNeverHasVerticalScrollbar:1;
bool mNeverHasHorizontalScrollbar:1;
@ -533,6 +536,9 @@ public:
// (as best as we can tell on the main thread, anyway).
bool mTransformingByAPZ:1;
// True if the APZ is allowed to zoom this scrollframe.
bool mZoomableByAPZ:1;
mozilla::layout::ScrollVelocityQueue mVelocityQueue;
protected:
@ -691,9 +697,9 @@ public:
return GetDesiredScrollbarSizes(&bls);
}
virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC) override {
nsRenderingContext* aRC, mozilla::WritingMode aWM) override {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();
@ -844,7 +850,7 @@ public:
{
return mHelper.ComputeFrameMetrics(aLayer, aContainerReferenceFrame, aParameters, aIsForCaret);
}
virtual const mozilla::DisplayItemClip* ComputeScrollClip(bool aIsForCaret) const
virtual mozilla::Maybe<mozilla::DisplayItemClip> ComputeScrollClip(bool aIsForCaret) const override
{
return mHelper.ComputeScrollClip(aIsForCaret);
}
@ -921,6 +927,9 @@ public:
bool IsTransformingByAPZ() const override {
return mHelper.IsTransformingByAPZ();
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
@ -1095,9 +1104,9 @@ public:
return GetDesiredScrollbarSizes(&bls);
}
virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
nsRenderingContext* aRC) override {
nsRenderingContext* aRC, mozilla::WritingMode aWM) override {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();
@ -1244,7 +1253,7 @@ public:
{
return mHelper.ComputeFrameMetrics(aLayer, aContainerReferenceFrame, aParameters, aIsForCaret);
}
virtual const mozilla::DisplayItemClip* ComputeScrollClip(bool aIsForCaret) const
virtual mozilla::Maybe<mozilla::DisplayItemClip> ComputeScrollClip(bool aIsForCaret) const override
{
return mHelper.ComputeScrollClip(aIsForCaret);
}
@ -1329,6 +1338,9 @@ public:
bool IsTransformingByAPZ() const override {
return mHelper.IsTransformingByAPZ();
}
void SetZoomableByAPZ(bool aZoomable) override {
mHelper.SetZoomableByAPZ(aZoomable);
}
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;

1584
layout/generic/nsGridContainerFrame.cpp

File diff suppressed because it is too large Load Diff

172
layout/generic/nsGridContainerFrame.h

@ -9,6 +9,7 @@
#ifndef nsGridContainerFrame_h___
#define nsGridContainerFrame_h___
#include "mozilla/TypeTraits.h"
#include "nsContainerFrame.h"
#include "nsHashKeys.h"
#include "nsTHashtable.h"
@ -32,6 +33,9 @@ public:
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) override;
nscoord GetMinISize(nsRenderingContext* aRenderingContext) override;
nscoord GetPrefISize(nsRenderingContext* aRenderingContext) override;
void MarkIntrinsicISizesDirty() override;
virtual nsIAtom* GetType() const override;
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
@ -50,8 +54,35 @@ public:
static const nsRect& GridItemCB(nsIFrame* aChild);
struct TrackSize {
void Initialize(nscoord aPercentageBasis,
const nsStyleCoord& aMinCoord,
const nsStyleCoord& aMaxCoord);
bool IsFrozen() const { return mState & eFrozen; }
#ifdef DEBUG
void Dump() const;
#endif
enum StateBits : uint16_t {
eAutoMinSizing = 0x1,
eMinContentMinSizing = 0x2,
eMaxContentMinSizing = 0x4,
eMinOrMaxContentMinSizing = eMinContentMinSizing | eMaxContentMinSizing,
eIntrinsicMinSizing = eMinOrMaxContentMinSizing | eAutoMinSizing,
eFlexMinSizing = 0x8,
eAutoMaxSizing = 0x10,
eMinContentMaxSizing = 0x20,
eMaxContentMaxSizing = 0x40,
eAutoOrMaxContentMaxSizing = eAutoMaxSizing | eMaxContentMaxSizing,
eIntrinsicMaxSizing = eAutoOrMaxContentMaxSizing | eMinContentMaxSizing,
eFlexMaxSizing = 0x80,
eFrozen = 0x100,
eSkipGrowUnlimited1 = 0x200,
eSkipGrowUnlimited2 = 0x400,
eSkipGrowUnlimited = eSkipGrowUnlimited1 | eSkipGrowUnlimited2,
};
nscoord mBase;
nscoord mLimit;
StateBits mState;
};
// @see nsAbsoluteContainingBlock::Reflow about this magic number
@ -67,10 +98,18 @@ protected:
typedef mozilla::LogicalRect LogicalRect;
typedef mozilla::WritingMode WritingMode;
typedef mozilla::css::GridNamedArea GridNamedArea;
typedef nsLayoutUtils::IntrinsicISizeType IntrinsicISizeType;
class GridItemCSSOrderIterator;
struct TrackSizingFunctions;
struct Tracks;
struct GridReflowState;
friend nsContainerFrame* NS_NewGridContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
explicit nsGridContainerFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
explicit nsGridContainerFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mCachedMinISize(NS_INTRINSIC_WIDTH_UNKNOWN)
, mCachedPrefISize(NS_INTRINSIC_WIDTH_UNKNOWN)
{}
/**
* A LineRange can be definite or auto - when it's definite it represents
@ -145,6 +184,11 @@ protected:
*/
void ToPositionAndLength(const nsTArray<TrackSize>& aTrackSizes,
nscoord* aPos, nscoord* aLength) const;
/**
* Given an array of track sizes, return the length of the tracks in this
* line range.
*/
nscoord ToLength(const nsTArray<TrackSize>& aTrackSizes) const;
/**
* Given an array of track sizes and a grid origin coordinate, adjust the
* abs.pos. containing block along an axis given by aPos and aLength.
@ -170,8 +214,38 @@ protected:
uint32_t mEnd;
int32_t mUntranslatedEnd;
};
protected:
LineRange() {}
};
/**
* Helper class to construct a LineRange from translated lines.
* The ctor only accepts translated definite line numbers.
*/
struct TranslatedLineRange : public LineRange {
TranslatedLineRange(uint32_t aStart, uint32_t aEnd)
{
MOZ_ASSERT(aStart < aEnd && aEnd <= kTranslatedMaxLine);
mStart = aStart;
mEnd = aEnd;
}
};
/**
* Return aLine if it's inside the aMin..aMax range (inclusive), otherwise
* return kAutoLine. If the range is empty (aMin == aMax, i.e. there are
* no tracks in the grid) then aLine is outside.
*/
static int32_t
AutoIfOutside(int32_t aLine, int32_t aMin, int32_t aMax)
{
MOZ_ASSERT(aMin <= aMax);
if (aLine < aMin || aLine > aMax || aMin == aMax) {
return kAutoLine;
}
return aLine;
}
/**
* A GridArea is the area in the grid for a grid item.
* The area is represented by two LineRanges, both of which can be auto
@ -207,6 +281,23 @@ protected:
nsTArray<nsTArray<Cell>> mCells;
};
struct GridItemInfo {
explicit GridItemInfo(const GridArea& aArea)
: mArea(aArea)
{
mIsFlexing[0] = false;
mIsFlexing[1] = false;
}
GridArea mArea;
bool mIsFlexing[2]; // does the item span a flex track? (LogicalAxis index)
static_assert(mozilla::eLogicalAxisBlock == 0, "unexpected index value");
static_assert(mozilla::eLogicalAxisInline == 1, "unexpected index value");
#ifdef DEBUG
nsIFrame* mFrame;
#endif
};
enum LineRangeSide {
eLineRangeSideStart, eLineRangeSideEnd
};
@ -352,11 +443,8 @@ protected:
* Place all child frames into the grid and expand the (implicit) grid as
* needed. The allocated GridAreas are stored in the GridAreaProperty
* frame property on the child frame.
* @param aIter a grid item iterator
* @param aStyle the StylePosition() for the grid container
*/
void PlaceGridItems(GridItemCSSOrderIterator& aIter,
const nsStylePosition* aStyle);
void PlaceGridItems(GridReflowState& aState);
/**
* Initialize the end lines of the Explicit Grid (mExplicitGridCol[Row]End).
@ -382,10 +470,9 @@ protected:
/**
* Calculate track sizes.
*/
void CalculateTrackSizes(const mozilla::LogicalSize& aPercentageBasis,
const nsStylePosition* aStyle,
nsTArray<TrackSize>& aColSizes,
nsTArray<TrackSize>& aRowSizes);
void CalculateTrackSizes(GridReflowState& aState,
const mozilla::LogicalSize& aContentBox,
IntrinsicISizeType aConstraint);
/**
* Helper method for ResolveLineRange.
@ -420,57 +507,53 @@ protected:
return areas && areas->Contains(aName);
}
NS_DECLARE_FRAME_PROPERTY(GridAreaProperty, DeleteValue<GridArea>)
/**
* A convenience method to get the stored GridArea* for a frame.
*/
static GridArea* GetGridAreaForChild(nsIFrame* aChild) {
return static_cast<GridArea*>(aChild->Properties().Get(GridAreaProperty()));
}
/**
* Return the containing block for a grid item occupying aArea.
* @param aColSizes column track sizes
* @param aRowSizes row track sizes
*/
LogicalRect ContainingBlockFor(const WritingMode& aWM,
const GridArea& aArea,
const nsTArray<TrackSize>& aColSizes,
const nsTArray<TrackSize>& aRowSizes) const;
LogicalRect ContainingBlockFor(const GridReflowState& aState,
const GridArea& aArea) const;
/**
* Return the containing block for an abs.pos. grid item occupying aArea.
* Any 'auto' lines in the grid area will be aligned with grid container
* containing block on that side.
* @param aColSizes column track sizes
* @param aRowSizes row track sizes
* @param aGridOrigin the origin of the grid
* @param aGridCB the grid container containing block (its padding area)
*/
LogicalRect ContainingBlockForAbsPos(const WritingMode& aWM,
const GridArea& aArea,
const nsTArray<TrackSize>& aColSizes,
const nsTArray<TrackSize>& aRowSizes,
const LogicalPoint& aGridOrigin,
const LogicalRect& aGridCB) const;
LogicalRect ContainingBlockForAbsPos(const GridReflowState& aState,
const GridArea& aArea,
const LogicalPoint& aGridOrigin,
const LogicalRect& aGridCB) const;
/**
* Reflow and place our children.
*/
void ReflowChildren(GridItemCSSOrderIterator& aIter,
const LogicalRect& aContentArea,
const nsTArray<TrackSize>& aColSizes,
const nsTArray<TrackSize>& aRowSizes,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void ReflowChildren(GridReflowState& aState,
const LogicalRect& aContentArea,
nsHTMLReflowMetrics& aDesiredSize,
nsReflowStatus& aStatus);
/**
* Helper for GetMinISize / GetPrefISize.
*/
nscoord IntrinsicISize(nsRenderingContext* aRenderingContext,
IntrinsicISizeType aConstraint);
#ifdef DEBUG
void SanityCheckAnonymousGridItems() const;
#endif // DEBUG
private:
/**
* Info about each (normal flow) grid item.
*/
nsTArray<GridItemInfo> mGridItems;
/**
* Info about each grid-aligned abs.pos. child.
*/
nsTArray<GridItemInfo> mAbsPosItems;
/**
* State for each cell in the grid.
*/
@ -501,6 +584,12 @@ private:
uint32_t mExplicitGridOffsetCol;
uint32_t mExplicitGridOffsetRow;
/**
* Cached values to optimize GetMinISize/GetPrefISize.
*/
nscoord mCachedMinISize;
nscoord mCachedPrefISize;
/**
* True iff the normal flow children are already in CSS 'order' in the
* order they occur in the child frame list.
@ -508,4 +597,9 @@ private:
bool mIsNormalFlowInCSSOrder : 1;
};
namespace mozilla {
template <>
struct IsPod<nsGridContainerFrame::TrackSize> : TrueType {};
}
#endif /* nsGridContainerFrame_h___ */

32
layout/generic/nsIFrame.h

@ -149,6 +149,12 @@ typedef uint32_t nsSplittableType;
// if any are changed to be a value other than NS_UNCONSTRAINEDSIZE
// at least update AdjustComputedHeight/Width and test ad nauseum
// 1 million CSS pixels less than our max app unit measure.
// For reflowing with an "infinite" available inline space per [css-sizing].
// (reflowing with an NS_UNCONSTRAINEDSIZE available inline size isn't allowed
// and leads to assertions)
#define INFINITE_ISIZE_COORD nscoord(NS_MAXSIZE - (1000000*60))
//----------------------------------------------------------------------
enum nsSelectionAmount {