19bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)/* 29bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 39bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * 49bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 59bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * modification, are permitted provided that the following conditions 69bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * are met: 79bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * 89bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * 1. Redistributions of source code must retain the above 99bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * copyright notice, this list of conditions and the following 109bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * disclaimer. 119bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above 129bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * copyright notice, this list of conditions and the following 139bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * disclaimer in the documentation and/or other materials 149bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * provided with the distribution. 159bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * 169bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 199bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 209bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 219bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 229bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 239bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 249bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 259bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 269bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 279bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) * OF THE POSSIBILITY OF SUCH DAMAGE. 289bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) */ 299bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 309bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)#ifndef LineWidth_h 319bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)#define LineWidth_h 329bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 33bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "platform/LayoutUnit.h" 349bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 35c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 369bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 37bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)class FloatingObject; 38bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)class RenderObject; 39bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)class RenderRubyRun; 40f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)class RenderBlockFlow; 41bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles) 429bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)enum IndentTextOrNot { DoNotIndentText, IndentText }; 43197021e6b966cfb06891637935ef33fff06433d1Ben Murdochenum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; 449bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 459bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)class LineWidth { 469bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)public: 47f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) LineWidth(RenderBlockFlow&, bool isFirstLine, IndentTextOrNot shouldIndentText); 489bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 49a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + LayoutUnit::epsilon()); } 50a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_availableWidth + LayoutUnit::epsilon()); } 51197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const 52197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 53197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trailingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon()); 54197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 559bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 569bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } 579bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) // FIXME: We should eventually replace these three functions by ones that work on a higher abstraction. 589bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float uncommittedWidth() const { return m_uncommittedWidth; } 599bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float committedWidth() const { return m_committedWidth; } 609bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float availableWidth() const { return m_availableWidth; } 61197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } 629bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 639bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void updateAvailableWidth(LayoutUnit minimumHeight = 0); 649bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject*); 659bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } 669bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void commit(); 679bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer); 68d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void fitBelowFloats(bool isFirstLine = false); 69197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = width; } 709bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 719bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) bool shouldIndentText() const { return m_shouldIndentText == IndentText; } 729bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 739bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)private: 749bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) void computeAvailableWidthFromLeftAndRight(); 75d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, const float& newLineLeft, const float& newLineRight); 76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void wrapNextToShapeOutside(bool isFirstLine); 779bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 78f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) RenderBlockFlow& m_block; 799bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_uncommittedWidth; 809bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_committedWidth; 819bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_overhangWidth; // The amount by which |m_availableWidth| has been inflated to account for possible contraction due to ruby overhang. 82197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch float m_trailingWhitespaceWidth; 839bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_left; 849bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_right; 859bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) float m_availableWidth; 869bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) bool m_isFirstLine; 879bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) IndentTextOrNot m_shouldIndentText; 889bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)}; 899bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 909bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)} 919bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles) 929bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)#endif // LineWidth_h 93