1/* 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All right reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2013 ChangSeok Oh <shivamidow@gmail.com> 6 * Copyright (C) 2013 Adobe Systems Inc. All right reserved. 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public License 19 * along with this library; see the file COPYING.LIB. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 * 23 */ 24 25#ifndef LineBreaker_h 26#define LineBreaker_h 27 28#include "InlineIterator.h" 29#include "LineInfo.h" 30#include "LineInlineHeaders.h" 31#include "TextBreakIterator.h" 32#include <wtf/Vector.h> 33 34namespace WebCore { 35 36class RenderText; 37 38struct RenderTextInfo { 39 // Destruction of m_layout requires TextLayout to be a complete type, so the constructor and destructor are made non-inline to avoid compilation errors. 40 RenderTextInfo(); 41 ~RenderTextInfo(); 42 43 RenderText* m_text; 44 OwnPtr<TextLayout> m_layout; 45 LazyLineBreakIterator m_lineBreakIterator; 46 const Font* m_font; 47}; 48 49class LineBreaker { 50public: 51 friend class BreakingContext; 52 LineBreaker(RenderBlockFlow& block) 53 : m_block(block) 54 { 55 reset(); 56 } 57 58 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, RenderTextInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements&); 59 60 bool lineWasHyphenated() { return m_hyphenated; } 61 const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; } 62 EClear clear() { return m_clear; } 63 64private: 65 void reset(); 66 67 InlineIterator nextSegmentBreak(InlineBidiResolver&, LineInfo&, RenderTextInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements&); 68 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); 69 void skipLeadingWhitespace(InlineBidiResolver&, LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&); 70 71 FloatingObject* insertFloatingObject(RenderBox& floatBox) { return m_block.insertFloatingObject(floatBox); } 72 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) 73 { 74 return m_block.positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width); 75 } 76 77 RenderBlockFlow& m_block; 78 bool m_hyphenated; 79 EClear m_clear; 80 Vector<RenderBox*> m_positionedObjects; 81}; 82 83} 84 85#endif // LineBreaker_h 86