mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 400813. Text with font-size:0 should not make a line be treated as empty. r+sr=dbaron
This commit is contained in:
parent
bad778d3f2
commit
05225fa949
@ -395,6 +395,7 @@ nsLineLayout::NewPerSpanData(PerSpanData** aResult)
|
||||
psd->mLastFrame = nsnull;
|
||||
psd->mContainsFloat = PR_FALSE;
|
||||
psd->mZeroEffectiveSpanBox = PR_FALSE;
|
||||
psd->mHasNonemptyContent = PR_FALSE;
|
||||
|
||||
#ifdef DEBUG
|
||||
mSpansAllocated++;
|
||||
@ -862,11 +863,14 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
||||
pfd->mJustificationNumSpaces = mTextJustificationNumSpaces;
|
||||
pfd->mJustificationNumLetters = mTextJustificationNumLetters;
|
||||
|
||||
// XXX See if the frame is a placeholderFrame and if it is process
|
||||
// the float.
|
||||
// See if the frame is a placeholderFrame and if it is process
|
||||
// the float. At the same time, check if the frame has any non-collapsed-away
|
||||
// content.
|
||||
PRBool placedFloat = PR_FALSE;
|
||||
PRBool hasNoncollapsedContent = PR_TRUE;
|
||||
if (frameType) {
|
||||
if (nsGkAtoms::placeholderFrame == frameType) {
|
||||
hasNoncollapsedContent = PR_FALSE;
|
||||
pfd->SetFlag(PFD_SKIPWHENTRIMMINGWHITESPACE, PR_TRUE);
|
||||
nsIFrame* outOfFlowFrame = nsLayoutUtils::GetFloatFromPlaceholder(aFrame);
|
||||
if (outOfFlowFrame) {
|
||||
@ -887,11 +891,12 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
||||
else if (nsGkAtoms::textFrame == frameType) {
|
||||
// Note non-empty text-frames for inline frame compatibility hackery
|
||||
pfd->SetFlag(PFD_ISTEXTFRAME, PR_TRUE);
|
||||
// XXX An empty text frame at the end of the line seems not
|
||||
// to have zero width.
|
||||
if (metrics.width) {
|
||||
nsTextFrame* textFrame = static_cast<nsTextFrame*>(pfd->mFrame);
|
||||
if (!textFrame->HasNoncollapsedCharacters()) {
|
||||
hasNoncollapsedContent = PR_FALSE;
|
||||
} else {
|
||||
pfd->SetFlag(PFD_ISNONEMPTYTEXTFRAME, PR_TRUE);
|
||||
nsIContent* content = pfd->mFrame->GetContent();
|
||||
nsIContent* content = textFrame->GetContent();
|
||||
|
||||
const nsTextFragment* frag = content->GetText();
|
||||
if (frag) {
|
||||
@ -916,13 +921,21 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nsGkAtoms::letterFrame==frameType) {
|
||||
pfd->SetFlag(PFD_ISLETTERFRAME, PR_TRUE);
|
||||
}
|
||||
else if (nsGkAtoms::brFrame == frameType) {
|
||||
pfd->SetFlag(PFD_SKIPWHENTRIMMINGWHITESPACE, PR_TRUE);
|
||||
} else {
|
||||
if (nsGkAtoms::letterFrame==frameType) {
|
||||
pfd->SetFlag(PFD_ISLETTERFRAME, PR_TRUE);
|
||||
}
|
||||
if (pfd->mSpan &&
|
||||
!pfd->mSpan->mHasNonemptyContent && pfd->mFrame->IsSelfEmpty()) {
|
||||
hasNoncollapsedContent = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasNoncollapsedContent) {
|
||||
psd->mHasNonemptyContent = PR_TRUE;
|
||||
}
|
||||
|
||||
mSpaceManager->Translate(-tx, -ty);
|
||||
|
||||
@ -2059,7 +2072,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
||||
}
|
||||
}
|
||||
if (applyMinLH) {
|
||||
if ((psd->mX != psd->mLeftEdge) || preMode || foundLI) {
|
||||
if (psd->mHasNonemptyContent || preMode || foundLI) {
|
||||
#ifdef NOISY_VERTICAL_ALIGN
|
||||
printf(" [span]==> adjusting min/maxY: currentValues: %d,%d", minY, maxY);
|
||||
#endif
|
||||
|
@ -468,6 +468,7 @@ protected:
|
||||
PRPackedBool mChangedFrameDirection;
|
||||
PRPackedBool mZeroEffectiveSpanBox;
|
||||
PRPackedBool mContainsFloat;
|
||||
PRPackedBool mHasNonemptyContent;
|
||||
|
||||
nscoord mLeftEdge;
|
||||
nscoord mX;
|
||||
|
@ -58,6 +58,10 @@
|
||||
class nsTextPaintStyle;
|
||||
class PropertyProvider;
|
||||
|
||||
// This state bit is set on frames that have some non-collapsed characters after
|
||||
// reflow
|
||||
#define TEXT_HAS_NONCOLLAPSED_CHARACTERS 0x02000000
|
||||
|
||||
class nsTextFrame : public nsFrame {
|
||||
public:
|
||||
friend class nsContinuingTextFrame;
|
||||
@ -189,6 +193,14 @@ public:
|
||||
*/
|
||||
PRBool IsAtEndOfLine() const;
|
||||
|
||||
/**
|
||||
* Call this only after reflow the frame. Returns true if non-collapsed
|
||||
* characters are present.
|
||||
*/
|
||||
PRBool HasNoncollapsedCharacters() const {
|
||||
return (GetStateBits() & TEXT_HAS_NONCOLLAPSED_CHARACTERS) != 0;
|
||||
}
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
||||
#endif
|
||||
|
@ -145,7 +145,7 @@
|
||||
|
||||
#define TEXT_REFLOW_FLAGS \
|
||||
(TEXT_FIRST_LETTER|TEXT_START_OF_LINE|TEXT_END_OF_LINE|TEXT_HYPHEN_BREAK| \
|
||||
TEXT_TRIMMED_TRAILING_WHITESPACE)
|
||||
TEXT_TRIMMED_TRAILING_WHITESPACE|TEXT_HAS_NONCOLLAPSED_CHARACTERS)
|
||||
|
||||
// Cache bits for IsEmpty().
|
||||
// Set this bit if the textframe is known to be only collapsible whitespace.
|
||||
@ -5513,6 +5513,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
|
||||
// frame to accumulate with trimmable width from this frame.)
|
||||
if (transformedCharsFit > 0) {
|
||||
lineLayout.SetTrimmableWidth(NSToCoordFloor(trimmableWidth));
|
||||
AddStateBits(TEXT_HAS_NONCOLLAPSED_CHARACTERS);
|
||||
}
|
||||
if (charsFit > 0 && charsFit == length &&
|
||||
HasSoftHyphenBefore(frag, mTextRun, offset, end)) {
|
||||
@ -5860,7 +5861,7 @@ nsIAtom*
|
||||
nsTextFrame::GetType() const
|
||||
{
|
||||
return nsGkAtoms::textFrame;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ PRBool
|
||||
nsTextFrame::IsEmpty()
|
||||
|
@ -2,7 +2,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<div style="height:100px; background-color:blue;"></div>
|
||||
<div style="height:200px;"></div>
|
||||
<div style="padding:100px 0; opacity:0;">blank line</div>
|
||||
<div style="height:100px; background-color:blue;"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css"> p { margin: 5px 1em; width: 0; white-space: nowrap; } p > span { background-color: silver; } </style>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css"> p { margin: 5px 1em; width: 0; } p > span { background-color: silver; } </style>
|
||||
|
Loading…
Reference in New Issue
Block a user