Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Unified Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 23855004: Refactoring LineBreaker and RenderTextInfo out of RenderBlock.h (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixing silly mistake. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlockLineLayout.cpp
diff --git a/Source/core/rendering/RenderBlockLineLayout.cpp b/Source/core/rendering/RenderBlockLineLayout.cpp
index 075c6caccf6fc41f673c9863b4519540352cb61a..13c3c37d835be0ad6975db57c26cfb34a9be4f8f 100644
--- a/Source/core/rendering/RenderBlockLineLayout.cpp
+++ b/Source/core/rendering/RenderBlockLineLayout.cpp
@@ -54,6 +54,43 @@ namespace WebCore {
// We don't let our line box tree for a single line get any deeper than this.
const unsigned cMaxLineDepth = 200;
+struct RenderTextInfo {
+ // Destruction of m_layout requires TextLayout to be a complete type, so the constructor and destructor are made non-inline to avoid compilation errors.
+ RenderTextInfo();
+ ~RenderTextInfo();
+
+ RenderText* m_text;
+ OwnPtr<TextLayout> m_layout;
+ LazyLineBreakIterator m_lineBreakIterator;
+ const Font* m_font;
+};
+
+class LineBreaker {
+public:
+ LineBreaker(RenderBlock* block)
+ : m_block(block)
+ {
+ reset();
+ }
+
+ InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, RenderTextInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements&);
+
+ bool lineWasHyphenated() { return m_hyphenated; }
+ const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; }
+ EClear clear() { return m_clear; }
+private:
+ void reset();
+
+ InlineIterator nextSegmentBreak(InlineBidiResolver&, LineInfo&, RenderTextInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements&);
+ void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
+ void skipLeadingWhitespace(InlineBidiResolver&, LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
+
+ RenderBlock* m_block;
+ bool m_hyphenated;
+ EClear m_clear;
+ Vector<RenderBox*> m_positionedObjects;
+};
+
static LayoutUnit logicalHeightForLine(const RenderBlock* block, bool isFirstLine, LayoutUnit replacedHeight = 0)
{
if (!block->document().inNoQuirksMode() && replacedHeight)
@@ -1601,13 +1638,13 @@ void RenderBlock::layoutRunsAndFloats(LineLayoutState& layoutState, bool hasInli
repaintDirtyFloats(layoutState.floats());
}
-RenderBlock::RenderTextInfo::RenderTextInfo()
+RenderTextInfo::RenderTextInfo()
: m_text(0)
, m_font(0)
{
}
-RenderBlock::RenderTextInfo::~RenderTextInfo()
+RenderTextInfo::~RenderTextInfo()
{
}
@@ -2524,7 +2561,7 @@ bool RenderBlock::generatesLineBoxesForInlineChild(RenderObject* inlineObj)
// object iteration process.
// NB. this function will insert any floating elements that would otherwise
// be skipped but it will not position them.
-void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator, const LineInfo& lineInfo)
+void LineBreaker::skipTrailingWhitespace(InlineIterator& iterator, const LineInfo& lineInfo)
{
while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhitespace)) {
RenderObject* object = iterator.m_obj;
@@ -2536,7 +2573,7 @@ void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
}
}
-void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo& lineInfo,
+void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo& lineInfo,
FloatingObject* lastFloatFromPreviousLine, LineWidth& width)
{
while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), lineInfo, LeadingWhitespace)) {
@@ -2688,14 +2725,14 @@ void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMid
}
}
-void RenderBlock::LineBreaker::reset()
+void LineBreaker::reset()
{
m_positionedObjects.clear();
m_hyphenated = false;
m_clear = CNONE;
}
-InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
+InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
{
ShapeInsideInfo* shapeInsideInfo = m_block->layoutShapeInsideInfo();
@@ -2750,7 +2787,7 @@ static inline bool iteratorIsBeyondEndOfRenderCombineText(const InlineIterator&
return iter.m_obj == renderer && iter.m_pos >= renderer->textLength();
}
-InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
+InlineIterator LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
{
reset();
@@ -3014,7 +3051,7 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
// Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
// words with their trailing space, then subtract its width.
- float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0;
+ float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(RenderBlock::constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0;
UChar lastCharacter = renderTextInfo.m_lineBreakIterator.lastCharacter();
UChar secondToLastCharacter = renderTextInfo.m_lineBreakIterator.secondToLastCharacter();
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698