mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1098151 - Make empty editable blocks at least one line-height tall. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D68586 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
675035d9f5
commit
f846b9b159
@ -39,8 +39,8 @@ function runTests() {
|
||||
var editor5 = document.getElementById("editor5");
|
||||
var editor6 = document.getElementById("editor6");
|
||||
|
||||
ok(editor1.getBoundingClientRect().height - editor0.getBoundingClientRect().height > 1,
|
||||
"an editor having a <br> element and an empty editor shouldn't be same height");
|
||||
is(editor1.getBoundingClientRect().height, editor0.getBoundingClientRect().height,
|
||||
"an editor having a <br> element and an empty editor should be same height");
|
||||
ok(Math.abs(editor1.getBoundingClientRect().height - editor2.getBoundingClientRect().height) <= 1,
|
||||
"an editor having only a <br> element and an editor having \"a\" should be same height");
|
||||
|
||||
|
@ -3010,48 +3010,53 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowInput& aState) {
|
||||
}
|
||||
|
||||
// Handle an odd-ball case: a list-item with no lines
|
||||
if (HasOutsideMarker() && mLines.empty()) {
|
||||
ReflowOutput metrics(aState.mReflowInput);
|
||||
nsIFrame* marker = GetOutsideMarker();
|
||||
WritingMode wm = aState.mReflowInput.GetWritingMode();
|
||||
ReflowOutsideMarker(
|
||||
marker, aState, metrics,
|
||||
aState.mReflowInput.ComputedPhysicalBorderPadding().top);
|
||||
NS_ASSERTION(!MarkerIsEmpty() || metrics.BSize(wm) == 0,
|
||||
"empty ::marker frame took up space");
|
||||
if (mLines.empty()) {
|
||||
if (HasOutsideMarker()) {
|
||||
ReflowOutput metrics(aState.mReflowInput);
|
||||
nsIFrame* marker = GetOutsideMarker();
|
||||
WritingMode wm = aState.mReflowInput.GetWritingMode();
|
||||
ReflowOutsideMarker(
|
||||
marker, aState, metrics,
|
||||
aState.mReflowInput.ComputedPhysicalBorderPadding().top);
|
||||
NS_ASSERTION(!MarkerIsEmpty() || metrics.BSize(wm) == 0,
|
||||
"empty ::marker frame took up space");
|
||||
|
||||
if (!MarkerIsEmpty()) {
|
||||
// There are no lines so we have to fake up some y motion so that
|
||||
// we end up with *some* height.
|
||||
// (Note: if we're layout-contained, we have to be sure to leave our
|
||||
// ReflowOutput's BlockStartAscent() (i.e. the baseline) untouched,
|
||||
// because layout-contained frames have no baseline.)
|
||||
if (!aState.mReflowInput.mStyleDisplay->IsContainLayout() &&
|
||||
metrics.BlockStartAscent() == ReflowOutput::ASK_FOR_BASELINE) {
|
||||
nscoord ascent;
|
||||
WritingMode wm = aState.mReflowInput.GetWritingMode();
|
||||
if (nsLayoutUtils::GetFirstLineBaseline(wm, marker, &ascent)) {
|
||||
metrics.SetBlockStartAscent(ascent);
|
||||
} else {
|
||||
metrics.SetBlockStartAscent(metrics.BSize(wm));
|
||||
if (!MarkerIsEmpty()) {
|
||||
// There are no lines so we have to fake up some y motion so that
|
||||
// we end up with *some* height.
|
||||
// (Note: if we're layout-contained, we have to be sure to leave our
|
||||
// ReflowOutput's BlockStartAscent() (i.e. the baseline) untouched,
|
||||
// because layout-contained frames have no baseline.)
|
||||
if (!aState.mReflowInput.mStyleDisplay->IsContainLayout() &&
|
||||
metrics.BlockStartAscent() == ReflowOutput::ASK_FOR_BASELINE) {
|
||||
nscoord ascent;
|
||||
WritingMode wm = aState.mReflowInput.GetWritingMode();
|
||||
if (nsLayoutUtils::GetFirstLineBaseline(wm, marker, &ascent)) {
|
||||
metrics.SetBlockStartAscent(ascent);
|
||||
} else {
|
||||
metrics.SetBlockStartAscent(metrics.BSize(wm));
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetInflatedFontMetricsForFrame(this);
|
||||
|
||||
nscoord minAscent = nsLayoutUtils::GetCenteredFontBaseline(
|
||||
fm, aState.mMinLineHeight, wm.IsLineInverted());
|
||||
nscoord minDescent = aState.mMinLineHeight - minAscent;
|
||||
|
||||
aState.mBCoord += std::max(minAscent, metrics.BlockStartAscent()) +
|
||||
std::max(minDescent, metrics.BSize(wm) -
|
||||
metrics.BlockStartAscent());
|
||||
|
||||
nscoord offset = minAscent - metrics.BlockStartAscent();
|
||||
if (offset > 0) {
|
||||
marker->SetRect(marker->GetRect() + nsPoint(0, offset));
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetInflatedFontMetricsForFrame(this);
|
||||
|
||||
nscoord minAscent = nsLayoutUtils::GetCenteredFontBaseline(
|
||||
fm, aState.mMinLineHeight, wm.IsLineInverted());
|
||||
nscoord minDescent = aState.mMinLineHeight - minAscent;
|
||||
|
||||
aState.mBCoord +=
|
||||
std::max(minAscent, metrics.BlockStartAscent()) +
|
||||
std::max(minDescent, metrics.BSize(wm) - metrics.BlockStartAscent());
|
||||
|
||||
nscoord offset = minAscent - metrics.BlockStartAscent();
|
||||
if (offset > 0) {
|
||||
marker->SetRect(marker->GetRect() + nsPoint(0, offset));
|
||||
}
|
||||
} else if (!Style()->IsAnonBox() &&
|
||||
StyleUI()->mUserModify != StyleUserModify::ReadOnly) {
|
||||
aState.mBCoord += aState.mMinLineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user