151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)/*
251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All right reserved.
451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Copyright (C) 2010 Google Inc. All rights reserved.
551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Copyright (C) 2013 Adobe Systems Incorporated.
651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) *
751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * This library is free software; you can redistribute it and/or
851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * modify it under the terms of the GNU Library General Public
951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * License as published by the Free Software Foundation; either
1051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * version 2 of the License, or (at your option) any later version.
1151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) *
1251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * This library is distributed in the hope that it will be useful,
1351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of
1451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Library General Public License for more details.
1651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) *
1751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * You should have received a copy of the GNU Library General Public License
1851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * along with this library; see the file COPYING.LIB.  If not, write to
1951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) * Boston, MA 02110-1301, USA.
2151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) *
2251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) */
2351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
2451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#ifndef LineInfo_h
2551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#define LineInfo_h
2651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
2709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/rendering/line/LineWidth.h"
2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
29c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
3051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
3151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)class LineInfo {
3251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)public:
3351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    LineInfo()
3451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        : m_isFirstLine(true)
3551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        , m_isLastLine(false)
3651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        , m_isEmpty(true)
3751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        , m_previousLineBrokeCleanly(true)
3851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        , m_floatPaginationStrut(0)
3951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        , m_runsFromLeadingWhitespace(0)
4051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    { }
4151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
4251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool isFirstLine() const { return m_isFirstLine; }
4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool isLastLine() const { return m_isLastLine; }
4451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool isEmpty() const { return m_isEmpty; }
4551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; }
4651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    LayoutUnit floatPaginationStrut() const { return m_floatPaginationStrut; }
4751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    unsigned runsFromLeadingWhitespace() const { return m_runsFromLeadingWhitespace; }
4851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void resetRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace = 0; }
4951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void incrementRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace++; }
5051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
5151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; }
5251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setLastLine(bool lastLine) { m_isLastLine = lastLine; }
5351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setEmpty(bool empty, RenderBlock* block = 0, LineWidth* lineWidth = 0)
5451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    {
5551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        if (m_isEmpty == empty)
5651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)            return;
5751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        m_isEmpty = empty;
5851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        if (!empty && block && floatPaginationStrut()) {
5951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)            block->setLogicalHeight(block->logicalHeight() + floatPaginationStrut());
6051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)            setFloatPaginationStrut(0);
6151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)            lineWidth->updateAvailableWidth();
6251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)        }
6351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    }
6451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
6551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }
6651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    void setFloatPaginationStrut(LayoutUnit strut) { m_floatPaginationStrut = strut; }
6751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
6851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)private:
6951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool m_isFirstLine;
7051b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool m_isLastLine;
7151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool m_isEmpty;
7251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    bool m_previousLineBrokeCleanly;
7351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    LayoutUnit m_floatPaginationStrut;
7451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    unsigned m_runsFromLeadingWhitespace;
7551b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)};
7651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
7751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)}
7851b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)
7951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)#endif // LineInfo_h
80