Commit 94333d9d authored by leviw@chromium.org's avatar leviw@chromium.org

2011-04-06 Levi Weintraub <leviw@chromium.org>

        Reviewed by Ryosuke Niwa.

        Add member functions for determining line/paragraph separation to InlineIterator
        https://bugs.webkit.org/show_bug.cgi?id=57938

        Adding atTextParagraphSeparator and atParagraphSeparator inline convenience functions to
        InlineIterator, where it makes far more sense for them to be. Also moving
        shouldPreserveNewline to RenderObject and renaming it preservesNewline.

        No new tests as this provides no new functionality.

        * rendering/InlineIterator.h:
        (WebCore::InlineIterator::atTextParagraphSeparator):
        (WebCore::InlineIterator::atParagraphSeparator):
        * rendering/RenderBlockLineLayout.cpp:
        (WebCore::RenderBlock::requiresLineBox):
        (WebCore::RenderBlock::findNextLineBreak):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::preservesNewline):


git-svn-id: svn://svn.chromium.org/blink/trunk@83038 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 92d97879
2011-04-06 Levi Weintraub <leviw@chromium.org>
Reviewed by Ryosuke Niwa.
Add member functions for determining line/paragraph separation to InlineIterator
https://bugs.webkit.org/show_bug.cgi?id=57938
Adding atTextParagraphSeparator and atParagraphSeparator inline convenience functions to
InlineIterator, where it makes far more sense for them to be. Also moving
shouldPreserveNewline to RenderObject and renaming it preservesNewline.
No new tests as this provides no new functionality.
* rendering/InlineIterator.h:
(WebCore::InlineIterator::atTextParagraphSeparator):
(WebCore::InlineIterator::atParagraphSeparator):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::requiresLineBox):
(WebCore::RenderBlock::findNextLineBreak):
* rendering/RenderObject.h:
(WebCore::RenderObject::preservesNewline):
2011-04-05 Alexander Pavlov <apavlov@chromium.org> 2011-04-05 Alexander Pavlov <apavlov@chromium.org>
Reviewed by Pavel Feldman. Reviewed by Pavel Feldman.
...@@ -68,6 +68,17 @@ public: ...@@ -68,6 +68,17 @@ public:
void increment(InlineBidiResolver* = 0); void increment(InlineBidiResolver* = 0);
bool atEnd() const; bool atEnd() const;
inline bool atTextParagraphSeparator()
{
return m_obj && m_obj->preservesNewline() && m_obj->isText() && toRenderText(m_obj)->textLength()
&& !toRenderText(m_obj)->isWordBreak() && toRenderText(m_obj)->characters()[m_pos] == '\n';
}
inline bool atParagraphSeparator()
{
return (m_obj && m_obj->isBR()) || atTextParagraphSeparator();
}
UChar current() const; UChar current() const;
ALWAYS_INLINE WTF::Unicode::Direction direction() const; ALWAYS_INLINE WTF::Unicode::Direction direction() const;
......
...@@ -1388,16 +1388,6 @@ static inline bool shouldCollapseWhiteSpace(const RenderStyle* style, bool isLin ...@@ -1388,16 +1388,6 @@ static inline bool shouldCollapseWhiteSpace(const RenderStyle* style, bool isLin
return style->collapseWhiteSpace() || (style->whiteSpace() == PRE_WRAP && (!isLineEmpty || !previousLineBrokeCleanly)); return style->collapseWhiteSpace() || (style->whiteSpace() == PRE_WRAP && (!isLineEmpty || !previousLineBrokeCleanly));
} }
static inline bool shouldPreserveNewline(RenderObject* object)
{
#if ENABLE(SVG)
if (object->isSVGInlineText())
return false;
#endif
return object->style()->preserveNewline();
}
static bool inlineFlowRequiresLineBox(RenderInline* flow) static bool inlineFlowRequiresLineBox(RenderInline* flow)
{ {
// FIXME: Right now, we only allow line boxes for inlines that are truly empty. // FIXME: Right now, we only allow line boxes for inlines that are truly empty.
...@@ -1418,7 +1408,7 @@ bool RenderBlock::requiresLineBox(const InlineIterator& it, bool isLineEmpty, bo ...@@ -1418,7 +1408,7 @@ bool RenderBlock::requiresLineBox(const InlineIterator& it, bool isLineEmpty, bo
return true; return true;
UChar current = it.current(); UChar current = it.current();
return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || shouldPreserveNewline(it.m_obj)) return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline())
&& !skipNonBreakingSpace(it, isLineEmpty, previousLineBrokeCleanly); && !skipNonBreakingSpace(it, isLineEmpty, previousLineBrokeCleanly);
} }
...@@ -1914,7 +1904,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool ...@@ -1914,7 +1904,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
if (hyphenated) if (hyphenated)
goto end; goto end;
} }
if (lBreak.m_obj && shouldPreserveNewline(lBreak.m_obj) && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && !toRenderText(lBreak.m_obj)->isWordBreak() && toRenderText(lBreak.m_obj)->characters()[lBreak.m_pos] == '\n') { if (lBreak.atTextParagraphSeparator()) {
if (!stoppedIgnoringSpaces && pos > 0) { if (!stoppedIgnoringSpaces && pos > 0) {
// We need to stop right before the newline and then start up again. // We need to stop right before the newline and then start up again.
addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1)); // Stop addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1)); // Stop
...@@ -2055,7 +2045,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool ...@@ -2055,7 +2045,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
RenderText* nextText = toRenderText(next); RenderText* nextText = toRenderText(next);
if (nextText->textLength()) { if (nextText->textLength()) {
UChar c = nextText->characters()[0]; UChar c = nextText->characters()[0];
if (c == ' ' || c == '\t' || (c == '\n' && !shouldPreserveNewline(next))) if (c == ' ' || c == '\t' || (c == '\n' && !next->preservesNewline()))
// If the next item on the line is text, and if we did not end with // If the next item on the line is text, and if we did not end with
// a space, then the next text run continues our word (and so it needs to // a space, then the next text run continues our word (and so it needs to
// keep adding to |tmpW|. Just update and continue. // keep adding to |tmpW|. Just update and continue.
......
...@@ -433,6 +433,7 @@ public: ...@@ -433,6 +433,7 @@ public:
bool hasTransform() const { return m_hasTransform; } bool hasTransform() const { return m_hasTransform; }
bool hasMask() const { return style() && style()->hasMask(); } bool hasMask() const { return style() && style()->hasMask(); }
inline bool preservesNewline() const;
void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide, void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
Color, EBorderStyle, int adjbw1, int adjbw2); Color, EBorderStyle, int adjbw1, int adjbw2);
#if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) #if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING)
...@@ -1037,6 +1038,16 @@ inline void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, R ...@@ -1037,6 +1038,16 @@ inline void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, R
last->scheduleRelayout(); last->scheduleRelayout();
} }
inline bool RenderObject::preservesNewline() const
{
#if ENABLE(SVG)
if (isSVGInlineText())
return false;
#endif
return style()->preserveNewline();
}
inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering) inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
{ {
#if !ENABLE(3D_RENDERING) #if !ENABLE(3D_RENDERING)
......
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