Home | History | Annotate | Download | only in line
      1 /*
      2  * Copyright (C) 2000 Lars Knoll (knoll (at) 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 Adobe Systems Incorporated.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  *
     22  */
     23 
     24 #ifndef LineInfo_h
     25 #define LineInfo_h
     26 
     27 namespace WebCore {
     28 
     29 class LineInfo {
     30 public:
     31     LineInfo()
     32         : m_isFirstLine(true)
     33         , m_isLastLine(false)
     34         , m_isEmpty(true)
     35         , m_previousLineBrokeCleanly(true)
     36         , m_floatPaginationStrut(0)
     37         , m_runsFromLeadingWhitespace(0)
     38     { }
     39 
     40     bool isFirstLine() const { return m_isFirstLine; }
     41     bool isLastLine() const { return m_isLastLine; }
     42     bool isEmpty() const { return m_isEmpty; }
     43     bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; }
     44     LayoutUnit floatPaginationStrut() const { return m_floatPaginationStrut; }
     45     unsigned runsFromLeadingWhitespace() const { return m_runsFromLeadingWhitespace; }
     46     void resetRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace = 0; }
     47     void incrementRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace++; }
     48 
     49     void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; }
     50     void setLastLine(bool lastLine) { m_isLastLine = lastLine; }
     51     void setEmpty(bool empty, RenderBlock* block = 0, LineWidth* lineWidth = 0)
     52     {
     53         if (m_isEmpty == empty)
     54             return;
     55         m_isEmpty = empty;
     56         if (!empty && block && floatPaginationStrut()) {
     57             block->setLogicalHeight(block->logicalHeight() + floatPaginationStrut());
     58             setFloatPaginationStrut(0);
     59             lineWidth->updateAvailableWidth();
     60         }
     61     }
     62 
     63     void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }
     64     void setFloatPaginationStrut(LayoutUnit strut) { m_floatPaginationStrut = strut; }
     65 
     66 private:
     67     bool m_isFirstLine;
     68     bool m_isLastLine;
     69     bool m_isEmpty;
     70     bool m_previousLineBrokeCleanly;
     71     LayoutUnit m_floatPaginationStrut;
     72     unsigned m_runsFromLeadingWhitespace;
     73 };
     74 
     75 }
     76 
     77 #endif // LineInfo_h
     78