Commit 2b307a73 authored by robert@webkit.org's avatar robert@webkit.org

Inline Containing Only Collapsed Whitespace Not Getting a Linebox

https://bugs.webkit.org/show_bug.cgi?id=31397

Reviewed by David Hyatt.

Source/WebCore:

Treat inlines containing only collapsed whitespace as empty. This allows them
to get a linebox.

Test: fast/inline/inline-containing-collapsed-whitespace-treated-as-empty.html

* dom/Position.cpp:
(WebCore::boundingBoxLogicalHeight):
(WebCore):
(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
* rendering/InlineIterator.h:
(WebCore::isEmptyInline):
(WebCore):
(WebCore::bidiNextShared):
(WebCore::bidiFirstSkippingEmptyInlines):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::alwaysRequiresLineBox):
(WebCore::requiresLineBox):
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
* rendering/RenderText.cpp:
* rendering/RenderText.h:
(RenderText):

LayoutTests:

* fast/css/first-letter-capitalized-edit-select-crash-expected.txt:
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-expected.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-vertical-rl-expected.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-vertical-rl.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7d7c2c77
2013-01-22 Robert Hogan <robert@webkit.org>
Inline Containing Only Collapsed Whitespace Not Getting a Linebox
https://bugs.webkit.org/show_bug.cgi?id=31397
Reviewed by David Hyatt.
* fast/css/first-letter-capitalized-edit-select-crash-expected.txt:
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-expected.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-vertical-rl-expected.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty-vertical-rl.html: Added.
* fast/inline/inline-containing-collapsed-whitespace-treated-as-empty.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
2013-01-24 Andrey Lushnikov <lushnikov@chromium.org>
Web Inspector: expand more chunks in DTE
<!DOCTYPE html>
<html>
<body>
<p> https://bugs.webkit.org/show_bug.cgi?id=31397: You should see two orange-filled boxes below. </p>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/></a>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/></a>
</body>
</html>
<!DOCTYPE html>
<html>
<body style="-webkit-writing-mode: vertical-rl;">
<p> https://bugs.webkit.org/show_bug.cgi?id=31397: You should see two orange-filled boxes below. </p>
<a style="padding:5px; border:1px solid silver; background:gold; " href="#"/></a>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/></a>
</body>
</html>
<!DOCTYPE html>
<html>
<body style="-webkit-writing-mode: vertical-rl;">
<p> https://bugs.webkit.org/show_bug.cgi?id=31397: You should see two orange-filled boxes below. </p>
<a style="padding:5px; border:1px solid silver; background:gold; " href="#"/> </a>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/> </a>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p> https://bugs.webkit.org/show_bug.cgi?id=31397: You should see two orange-filled boxes below. </p>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/> </a>
<a style="padding:5px; border:1px solid silver; background:gold;" href="#"/> </a>
</body>
</html>
......@@ -4333,3 +4333,16 @@ webkit.org/b/107341 [ Debug ] inspector/profiler/memory-instrumentation-cached-i
webkit.org/b/107579 [ Debug ] media/track/track-css-matching.html [ Crash ]
webkit.org/b/107579 [ Debug ] media/track/track-css-property-whitelist.html [ Crash ]
# Rebaseline required after https://webkit.org/b/31397
webkit.org/b/107567 svg/batik/text/xmlSpace.svg [ Failure ]
webkit.org/b/107567 fast/text/capitalize-empty-generated-string.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/007.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/006.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlinesWithWS.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1318.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlines.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug113235-3.html [ Failure ]
webkit.org/b/107567 css2.1/t0505-c16-descendant-01-e.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ]
webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ]
......@@ -1815,3 +1815,17 @@ webkit.org/b/107375 fast/css/sticky/sticky-top-zoomed.html [ ImageOnlyFailure ]
# Needs rebaseline after https://bugs.webkit.org/show_bug.cgi?id=14664
webkit.org/b/107476 fast/block/float/024.html [ Failure ]
webkit.org/b/107476 fast/block/margin-collapse/empty-clear-blocks.html [ Failure ]
# Rebaseline required after https://webkit.org/b/31397
webkit.org/b/107567 svg/batik/text/xmlSpace.svg [ Failure ]
webkit.org/b/107567 fast/text/capitalize-empty-generated-string.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/007.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/006.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlinesWithWS.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1318.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlines.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug113235-3.html [ Failure ]
webkit.org/b/107567 css2.1/t0505-c16-descendant-01-e.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ]
webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ]
......@@ -57,6 +57,19 @@ webkit.org/b/103955 fast/repaint/caret-with-transformation.html [ Missing ]
webkit.org/b/107476 fast/block/float/024.html [ Failure ]
webkit.org/b/107476 fast/block/margin-collapse/empty-clear-blocks.html [ Failure ]
# Rebaseline required after https://webkit.org/b/31397
webkit.org/b/107567 svg/batik/text/xmlSpace.svg [ Failure ]
webkit.org/b/107567 fast/text/capitalize-empty-generated-string.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/007.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/006.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlinesWithWS.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1318.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlines.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug113235-3.html [ Failure ]
webkit.org/b/107567 css2.1/t0505-c16-descendant-01-e.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ]
webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ]
#////////////////////////////////////////////////////////////////////////////////////////
# Expected failures
#////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -1288,3 +1288,16 @@ webkit.org/b/107208 fast/regions/overflow-moving-below-floats-in-variable-width-
webkit.org/b/107208 fast/regions/overflow-size-change-in-variable-width-regions.html [ Pass Failure ImageOnlyFailure ]
webkit.org/b/107208 fast/regions/overflow-size-change-with-stacking-context.html [ Pass Failure ImageOnlyFailure ]
# Rebaseline required after https://webkit.org/b/31397
webkit.org/b/107567 svg/batik/text/xmlSpace.svg [ Failure ]
webkit.org/b/107567 fast/text/capitalize-empty-generated-string.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/007.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/006.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlinesWithWS.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1318.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlines.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug113235-3.html [ Failure ]
webkit.org/b/107567 css2.1/t0505-c16-descendant-01-e.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ]
webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ]
......@@ -2543,3 +2543,17 @@ inspector/editor/text-editor-formatter.html
# Needs rebaseline after https://bugs.webkit.org/show_bug.cgi?id=14664
webkit.org/b/107476 fast/block/float/024.html [ Failure ]
webkit.org/b/107476 fast/block/margin-collapse/empty-clear-blocks.html [ Failure ]
# Rebaseline required after https://webkit.org/b/31397
webkit.org/b/107567 svg/batik/text/xmlSpace.svg [ Failure ]
webkit.org/b/107567 fast/text/capitalize-empty-generated-string.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/007.html [ Failure ]
webkit.org/b/107567 fast/text/whitespace/006.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlinesWithWS.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1318.html [ Failure ]
webkit.org/b/107567 fast/inline/drawStyledEmptyInlines.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug113235-3.html [ Failure ]
webkit.org/b/107567 css2.1/t0505-c16-descendant-01-e.html [ Failure ]
webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ]
webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ]
2013-01-22 Robert Hogan <robert@webkit.org>
Inline Containing Only Collapsed Whitespace Not Getting a Linebox
https://bugs.webkit.org/show_bug.cgi?id=31397
Reviewed by David Hyatt.
Treat inlines containing only collapsed whitespace as empty. This allows them
to get a linebox.
Test: fast/inline/inline-containing-collapsed-whitespace-treated-as-empty.html
* dom/Position.cpp:
(WebCore::boundingBoxLogicalHeight):
(WebCore):
(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
* rendering/InlineIterator.h:
(WebCore::isEmptyInline):
(WebCore):
(WebCore::bidiNextShared):
(WebCore::bidiFirstSkippingEmptyInlines):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::alwaysRequiresLineBox):
(WebCore::requiresLineBox):
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
* rendering/RenderText.cpp:
* rendering/RenderText.h:
(RenderText):
2013-01-24 Andrey Lushnikov <lushnikov@chromium.org>
Web Inspector: expand more chunks in DTE
......@@ -28,10 +28,12 @@
#include "CSSComputedStyleDeclaration.h"
#include "HTMLNames.h"
#include "InlineIterator.h"
#include "InlineTextBox.h"
#include "Logging.h"
#include "PositionIterator.h"
#include "RenderBlock.h"
#include "RenderInline.h"
#include "RenderText.h"
#include "RuntimeEnabledFeatures.h"
#include "Text.h"
......@@ -841,13 +843,19 @@ Position Position::downstream(EditingBoundaryCrossingRule rule) const
return lastVisible;
}
static int boundingBoxLogicalHeight(RenderObject *o, const IntRect &rect)
{
return o->style()->isHorizontalWritingMode() ? rect.height() : rect.width();
}
bool Position::hasRenderedNonAnonymousDescendantsWithHeight(RenderObject* renderer)
{
RenderObject* stop = renderer->nextInPreOrderAfterChildren();
for (RenderObject *o = renderer->firstChild(); o && o != stop; o = o->nextInPreOrder())
if (o->nonPseudoNode()) {
if ((o->isText() && toRenderText(o)->linesLogicalBoundingBox().height())
|| (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight()))
if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox()))
|| (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight())
|| (o->isRenderInline() && isEmptyInline(o) && boundingBoxLogicalHeight(o, toRenderInline(o)->linesBoundingBox())))
return true;
}
return false;
......
......@@ -176,6 +176,17 @@ enum EmptyInlineBehavior {
IncludeEmptyInlines,
};
static bool isEmptyInline(RenderObject* object)
{
if (!object->isRenderInline())
return false;
if (!object->firstChild())
return true;
return object->firstChild()->isText() && (object->firstChild() == object->lastChild()) && toRenderText(object->firstChild())->isAllCollapsibleWhitespace();
}
// FIXME: This function is misleadingly named. It has little to do with bidi.
// This function will iterate over inlines within a block, optionally notifying
// a bidi resolver as it enters/exits inlines (so it can push/pop embedding levels).
......@@ -225,7 +236,7 @@ static inline RenderObject* bidiNextShared(RenderObject* root, RenderObject* cur
break;
if (isIteratorTarget(next)
|| ((emptyInlineBehavior == IncludeEmptyInlines || !next->firstChild()) // Always return EMPTY inlines.
|| ((emptyInlineBehavior == IncludeEmptyInlines || isEmptyInline(next)) // Always return EMPTY inlines.
&& next->isRenderInline()))
break;
current = next;
......@@ -265,7 +276,7 @@ static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderObject* root, In
if (o->isRenderInline()) {
notifyObserverEnteredObject(resolver, o);
if (o->firstChild())
if (!isEmptyInline(o))
o = bidiNextSkippingEmptyInlines(root, o, resolver);
else {
// Never skip empty inlines.
......
......@@ -2212,12 +2212,12 @@ static bool requiresLineBoxForContent(RenderInline* flow, const LineInfo& lineIn
return false;
}
static bool alwaysRequiresLineBox(RenderInline* flow)
static bool alwaysRequiresLineBox(RenderObject* flow)
{
// FIXME: Right now, we only allow line boxes for inlines that are truly empty.
// We need to fix this, though, because at the very least, inlines containing only
// ignorable whitespace should should also have line boxes.
return !flow->firstChild() && flow->hasInlineDirectionBordersPaddingOrMargin();
return isEmptyInline(flow) && toRenderInline(flow)->hasInlineDirectionBordersPaddingOrMargin();
}
static bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo = LineInfo(), WhitespacePosition whitespacePosition = LeadingWhitespace)
......@@ -2225,15 +2225,15 @@ static bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo =
if (it.m_obj->isFloatingOrOutOfFlowPositioned())
return false;
if (it.m_obj->isRenderInline() && !alwaysRequiresLineBox(toRenderInline(it.m_obj)) && !requiresLineBoxForContent(toRenderInline(it.m_obj), lineInfo))
if (it.m_obj->isRenderInline() && !alwaysRequiresLineBox(it.m_obj) && !requiresLineBoxForContent(toRenderInline(it.m_obj), lineInfo))
return false;
if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition) || it.m_obj->isBR())
return true;
UChar current = it.current();
return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline())
&& !skipNonBreakingSpace(it, lineInfo);
bool notJustWhitespace = current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline()) && !skipNonBreakingSpace(it, lineInfo);
return notJustWhitespace || isEmptyInline(it.m_obj);
}
bool RenderBlock::generatesLineBoxesForInlineChild(RenderObject* inlineObj)
......@@ -2672,7 +2672,7 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
floatsFitOnLine = false;
} else if (current.m_obj->isRenderInline()) {
// Right now, we should only encounter empty inlines here.
ASSERT(!current.m_obj->firstChild());
ASSERT(isEmptyInline(current.m_obj));
RenderInline* flowBox = toRenderInline(current.m_obj);
......@@ -2680,7 +2680,7 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
// to make sure that we stop to include this object and then start ignoring spaces again.
// If this object is at the start of the line, we need to behave like list markers and
// start ignoring spaces.
bool requiresLineBox = alwaysRequiresLineBox(flowBox);
bool requiresLineBox = alwaysRequiresLineBox(current.m_obj);
if (requiresLineBox || requiresLineBoxForContent(flowBox, lineInfo)) {
// An empty inline that only has line-height, vertical-align or font-metrics will only get a
// line box to affect the height of the line if the rest of the line is not empty.
......
......@@ -1614,13 +1614,6 @@ IntRect RenderText::linesBoundingBox() const
return result;
}
IntRect RenderText::linesLogicalBoundingBox() const
{
IntRect rect = linesBoundingBox();
return style()->isHorizontalWritingMode() ? rect : IntRect(rect.x(), rect.y(), rect.height(), rect.width());
}
LayoutRect RenderText::linesVisualOverflowBoundingBox() const
{
if (!firstTextBox())
......
......@@ -96,7 +96,6 @@ public:
virtual IntRect linesBoundingBox() const;
LayoutRect linesVisualOverflowBoundingBox() const;
IntRect linesLogicalBoundingBox() const;
FloatPoint firstRunOrigin() const;
float firstRunX() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment