1/*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003-2017 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#pragma once
26
27#include "InlineIterator.h"
28#include "LineInfo.h"
29#include "LineInlineHeaders.h"
30#include <wtf/Vector.h>
31
32namespace WebCore {
33
34class RenderText;
35class TextLayout;
36
37struct RenderTextInfo {
38 RenderText* text { nullptr };
39 std::unique_ptr<TextLayout, TextLayoutDeleter> layout;
40 LazyLineBreakIterator lineBreakIterator;
41 const FontCascade* font { nullptr };
42};
43
44class LineBreaker {
45public:
46 friend class BreakingContext;
47
48 explicit LineBreaker(RenderBlockFlow& block)
49 : m_block(block)
50 {
51 reset();
52 }
53
54 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, RenderTextInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements&);
55
56 bool lineWasHyphenated() { return m_hyphenated; }
57 const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; }
58 Clear clear() { return m_clear; }
59
60private:
61 void reset();
62
63 void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
64 void skipLeadingWhitespace(InlineBidiResolver&, LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
65
66 FloatingObject* insertFloatingObject(RenderBox& floatBox) { return m_block.insertFloatingObject(floatBox); }
67 bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
68 {
69 return m_block.positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width);
70 }
71
72 RenderBlockFlow& m_block;
73 bool m_hyphenated;
74 Clear m_clear;
75 Vector<RenderBox*> m_positionedObjects;
76};
77
78} // namespace WebCore
79