Backed out 3 changesets (bug 290125) for causing build bustages on nsFirstLetterFrame.cpp CLOSED TREE

Backed out changeset 0b6b18ea2634 (bug 290125)
Backed out changeset d8297eee88e7 (bug 290125)
Backed out changeset 3f341b8efb86 (bug 290125)
This commit is contained in:
Cristian Tuns
2022-12-19 12:34:05 -05:00
parent af3db6d9b4
commit 43ec8f0f93
15 changed files with 21 additions and 104 deletions

View File

@@ -14,7 +14,6 @@
#include "mozilla/PresShellInlines.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StaticPrefs_layout.h"
#include "nsIContent.h"
#include "nsLayoutUtils.h"
#include "nsLineLayout.h"
@@ -139,46 +138,6 @@ nsIFrame::SizeComputationResult nsFirstLetterFrame::ComputeSize(
aSizeOverrides, aFlags);
}
bool nsFirstLetterFrame::UseTightBounds() const {
int v = StaticPrefs::layout_css_floating_first_letter_tight_glyph_bounds();
// Check for the simple cases:
// pref value > 0: use legacy gecko behavior
// pref value = 0: use webkit/blink-like behavior
if (v > 0) {
return true;
}
if (v == 0) {
return false;
}
// Pref value < 0: use heuristics to determine whether the page is assuming
// webkit/blink-style behavior:
// If line-height is less than font-size, or there is a negative block-start
// or -end margin, use webkit/blink behavior.
if (nsTextFrame* textFrame = do_QueryFrame(mFrames.FirstChild())) {
RefPtr<nsFontMetrics> fm = textFrame->InflatedFontMetrics();
if (textFrame->ComputeLineHeight() < fm->EmHeight()) {
return false;
}
}
const auto wm = GetWritingMode();
const auto& margin = StyleMargin()->mMargin;
const auto& bStart = margin.GetBStart(wm);
// Currently, we only check for margins with negative *length* values;
// negative percentages seem unlikely to be used/useful in this context.
if (bStart.ConvertsToLength() && bStart.ToLength() < 0) {
return false;
}
const auto& bEnd = margin.GetBEnd(wm);
if (bEnd.ConvertsToLength() && bEnd.ToLength() < 0) {
return false;
}
return true;
}
void nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aMetrics,
const ReflowInput& aReflowInput,
@@ -237,24 +196,11 @@ void nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
// Place and size the child and update the output metrics
LogicalSize convertedSize = kidMetrics.Size(wm);
const bool tightBounds = UseTightBounds();
const nscoord shift =
tightBounds ? 0
// Shift by half of the difference between the line-height
// we're going to use and current height of the kid frame.
: (rs.GetLineHeight() - convertedSize.BSize(wm)) / 2;
kid->SetRect(nsRect(bp.IStart(wm), bp.BStart(wm) + shift,
convertedSize.ISize(wm), convertedSize.BSize(wm)));
kid->SetRect(nsRect(bp.IStart(wm), bp.BStart(wm), convertedSize.ISize(wm),
convertedSize.BSize(wm)));
kid->FinishAndStoreOverflow(&kidMetrics, rs.mStyleDisplay);
kid->DidReflow(aPresContext, nullptr);
if (!tightBounds) {
// Adjust size to account for line-height.
convertedSize.BSize(wm) = rs.GetLineHeight();
}
convertedSize.ISize(wm) += bp.IStartEnd(wm);
convertedSize.BSize(wm) += bp.BStartEnd(wm);
aMetrics.SetSize(wm, convertedSize);

View File

@@ -79,10 +79,6 @@ class nsFirstLetterFrame final : public nsContainerFrame {
nsIFrame** aContinuation,
bool aIsFluid);
// Whether to use tight glyph bounds for a floating first-letter frame,
// or "loose" bounds based on font metrics rather than individual glyphs.
bool UseTightBounds() const;
protected:
nscoord mBaseline;

View File

@@ -52,7 +52,6 @@
#include "nsDisplayList.h"
#include "nsIFrame.h"
#include "nsIMathMLFrame.h"
#include "nsFirstLetterFrame.h"
#include "nsPlaceholderFrame.h"
#include "nsTextFrameUtils.h"
#include "nsTextRunTransformations.h"
@@ -5871,16 +5870,13 @@ void nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
AddStateBits(TEXT_SELECTION_UNDERLINE_OVERFLOWED);
}
nscoord nsTextFrame::ComputeLineHeight() const {
return ReflowInput::CalcLineHeight(GetContent(), Style(), PresContext(),
NS_UNCONSTRAINEDSIZE,
GetFontSizeInflation());
}
gfxFloat nsTextFrame::ComputeDescentLimitForSelectionUnderline(
nsPresContext* aPresContext, const gfxFont::Metrics& aFontMetrics) {
const gfxFloat lineHeight =
gfxFloat(ComputeLineHeight()) / aPresContext->AppUnitsPerDevPixel();
gfxFloat app = aPresContext->AppUnitsPerDevPixel();
nscoord lineHeightApp =
ReflowInput::CalcLineHeight(GetContent(), Style(), PresContext(),
NS_UNCONSTRAINEDSIZE, GetFontSizeInflation());
gfxFloat lineHeight = gfxFloat(lineHeightApp) / app;
if (lineHeight <= aFontMetrics.maxHeight) {
return aFontMetrics.maxDescent;
}
@@ -9710,14 +9706,10 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// The metrics for the text go in here
gfxTextRun::Metrics textMetrics;
gfxFont::BoundingBoxType boundingBoxType = gfxFont::LOOSE_INK_EXTENTS;
if (IsFloatingFirstLetterChild() || IsInitialLetterChild()) {
if (nsFirstLetterFrame* firstLetter = do_QueryFrame(GetParent())) {
if (firstLetter->UseTightBounds()) {
boundingBoxType = gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS;
}
}
}
gfxFont::BoundingBoxType boundingBoxType =
IsFloatingFirstLetterChild() || IsInitialLetterChild()
? gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS
: gfxFont::LOOSE_INK_EXTENTS;
int32_t limitLength = length;
int32_t forceBreak = aLineLayout.GetForcedBreakPosition(this);

View File

@@ -723,8 +723,6 @@ class nsTextFrame : public nsIFrame {
DrawTarget* aDrawTarget, ReflowOutput& aMetrics,
nsReflowStatus& aStatus);
nscoord ComputeLineHeight() const;
bool IsFloatingFirstLetterChild() const;
bool IsInitialLetterChild() const;

View File

@@ -4,7 +4,6 @@
<style type="text/css">
p:first-letter {
float: left;
color: red;
}
</style>
<title>a first-letter testcase</title>

View File

@@ -4,7 +4,6 @@
<style type="text/css">
p:first-letter {
float: left;
color: red;
}
</style>
<title>a first-letter testcase</title>

View File

@@ -5,10 +5,9 @@ div {
height: 3em; width: 8em;
padding: 3px;
background: yellow; color: black;
overflow: hidden;
line-height: 1.0;
}
div::first-letter { font-size: 6em; float: left; }
div::first-letter { font-size: 4em; float: left; }
</style>

View File

@@ -8,7 +8,7 @@ div {
overflow: auto;
line-height: 1.0;
}
div::first-letter { font-size: 6em; float: left; }
div::first-letter { font-size: 4em; float: left; }
</style>

View File

@@ -70,7 +70,7 @@ random-if(gtkWidget) random-if(winWidget&&!d2d) == font-text-styles-floater.html
== inline-height-empty.html inline-height-empty-ref.html
== indic-clusters-1.html indic-clusters-1-ref.html
== overflow-float-nooverflow.html overflow-float-nooverflow-ref.html
!= overflow-float-overflow.html overflow-float-overflow-notref.html
== overflow-float-overflow.html overflow-float-overflow-notref.html
== overflow-inline-nooverflow.html overflow-inline-nooverflow-ref.html
!= overflow-inline-overflow.html overflow-inline-overflow-notref.html
== overflow-inline-overflow.html overflow-inline-overflow-ref.html

View File

@@ -8317,22 +8317,6 @@
mirror: always
rust: true
# Whether to use tight bounds for floating ::first-letter (legacy Gecko behavior)
# or loose bounds based on overall font metrics (WebKit/Blink-like behavior)?
# Values mean:
# 1 legacy Gecko behavior (tight bounds)
# 0 loose typographic bounds (similar to webkit/blink)
# -1 auto behavior: use loose bounds if reduced line-height (<1em) or negative
# block-start margin is present; otherwise use tight bounds.
- name: layout.css.floating-first-letter.tight-glyph-bounds
type: int32_t
#ifdef NIGHTLY_BUILD
value: -1
#else
value: 1
#endif
mirror: always
# Is support for the font-display @font-face descriptor enabled?
- name: layout.css.font-display.enabled
type: RelaxedAtomicBool

View File

@@ -1,2 +1,2 @@
[display-first-line-002.html]
prefs: [layout.css.floating-first-letter.tight-glyph-bounds:0]
expected: FAIL

View File

@@ -1,2 +1,2 @@
prefs: [dom.css_pseudo_element.enabled:true, layout.css.animation-composition.enabled:true, layout.css.floating-first-letter.tight-glyph-bounds:0]
prefs: [dom.css_pseudo_element.enabled:true, layout.css.animation-composition.enabled:true]
leak-threshold: [tab:51200]

View File

@@ -1,2 +1,2 @@
[first-letter-002.html]
fuzzy: maxDifference=0-53;totalPixels=0-3
expected: FAIL

View File

@@ -0,0 +1,2 @@
[first-letter-and-whitespace.html]
expected: FAIL

View File

@@ -0,0 +1,2 @@
[first-letter-opacity-float-001.html]
expected: FAIL