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: https://svn.webkit.org/repository/webkit/trunk@83038
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+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>
Reviewed by Pavel Feldman.
void increment(InlineBidiResolver* = 0);
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;
ALWAYS_INLINE WTF::Unicode::Direction direction() const;
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)
{
// FIXME: Right now, we only allow line boxes for inlines that are truly empty.
return true;
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);
}
if (hyphenated)
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) {
// We need to stop right before the newline and then start up again.
addMidpoint(lineMidpointState, InlineIterator(0, o, pos - 1)); // Stop
RenderText* nextText = toRenderText(next);
if (nextText->textLength()) {
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
// a space, then the next text run continues our word (and so it needs to
// keep adding to |tmpW|. Just update and continue.
bool hasTransform() const { return m_hasTransform; }
bool hasMask() const { return style() && style()->hasMask(); }
+ inline bool preservesNewline() const;
void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
Color, EBorderStyle, int adjbw1, int adjbw2);
#if HAVE(PATH_BASED_BORDER_RADIUS_DRAWING)
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)
{
#if !ENABLE(3D_RENDERING)