Skip to content

Commit

Permalink
Bug 1628770 - Restrict "empty editable block" bits to contenteditable…
Browse files Browse the repository at this point in the history
… roots. r=jfkthame

This is what other UAs do.

Differential Revision: https://phabricator.services.mozilla.com/D70423
  • Loading branch information
emilio committed Apr 10, 2020
1 parent a858603 commit 428f8ad
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
3 changes: 1 addition & 2 deletions layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3056,8 +3056,7 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowInput& aState) {
marker->SetRect(marker->GetRect() + nsPoint(0, offset));
}
}
} else if (!Style()->IsPseudoOrAnonBox() &&
StyleUI()->mUserModify != StyleUserModify::ReadOnly) {
} else if (ShouldHaveLineIfEmpty()) {
aState.mBCoord += aState.mMinLineHeight;
}
}
Expand Down
7 changes: 7 additions & 0 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4686,6 +4686,13 @@ bool nsIFrame::IsSelectable(StyleUserSelect* aSelectStyle) const {
return style != StyleUserSelect::None;
}

bool nsIFrame::ShouldHaveLineIfEmpty() const {
if (Style()->IsPseudoOrAnonBox()) {
return false;
}
return IsEditingHost(this);
}

/**
* Handles the Mouse Press Event for the frame
*/
Expand Down
6 changes: 6 additions & 0 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -3405,6 +3405,12 @@ class nsIFrame : public nsQueryFrame {
*/
bool IsSelectable(mozilla::StyleUserSelect* aSelectStyle) const;

/**
* Returns whether this frame should have the content-block-size of a line,
* even if empty.
*/
bool ShouldHaveLineIfEmpty() const;

/**
* Called to retrieve the SelectionController associated with the frame.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<title>Test reference</title>
<div>
Foo
<div></div>
Bar
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<title>contenteditable doesn't cause inner empty blocks to grow.</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:[email protected]">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1628770">
<link rel="match" href="contenteditable-with-empty-block-ref.html">
<div contenteditable>
Foo
<div></div>
Bar
</div>

0 comments on commit 428f8ad

Please sign in to comment.