haikuwebkit/Source/WebCore/rendering/line/LineInfo.h

74 lines
2.9 KiB
C
Raw Permalink Normal View History

/*
* Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "LineWidth.h"
namespace WebCore {
Move BreakingContext and LineBreaker into their own files <https://webkit.org/b/124336> Reviewed by David Hyatt. In this change I introduced 'line' subdirectory inside 'rendering', this directory will contain all the classes which have been refactored from RenderBlockLineLayout.cpp. This change contains the separation of BreakingContext, and the separation of LineBreaker classes. Since I wanted to keep the helper functions organized, I also added a new file called LineInlineHeaders.h, which contains the functions which used in LineBreaker.h and BreakingContext.h. I moved LineInfo class into line directory. It was necessary this time, since I added a cpp for it. I'll move the rest of the line layout related helper classes later. (I wanted to minimize merge conflicts.) No new tests, no behavior change. * CMakeLists.txt: * GNUmakefile.am: * GNUmakefile.list.am: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.vcxproj/WebCoreCommon.props: * WebCore.xcodeproj/project.pbxproj: * rendering/RenderBlockLineLayout.cpp: (WebCore::createRun): * rendering/line/BreakingContextInlineHeaders.h: Added. (WebCore::WordMeasurement::WordMeasurement): (WebCore::TrailingObjects::TrailingObjects): (WebCore::TrailingObjects::setTrailingWhitespace): (WebCore::TrailingObjects::clear): (WebCore::TrailingObjects::appendBoxIfNeeded): (WebCore::deprecatedAddMidpoint): (WebCore::startIgnoringSpaces): (WebCore::stopIgnoringSpaces): (WebCore::ensureLineBoxInsideIgnoredSpaces): (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes): (WebCore::BreakingContext::BreakingContext): (WebCore::BreakingContext::currentObject): (WebCore::BreakingContext::lineBreak): (WebCore::BreakingContext::lineBreakRef): (WebCore::BreakingContext::lineWidth): (WebCore::BreakingContext::atEnd): (WebCore::BreakingContext::clearLineBreakIfFitsOnLine): (WebCore::BreakingContext::commitLineBreakAtCurrentWidth): (WebCore::BreakingContext::initializeForCurrentObject): (WebCore::BreakingContext::increment): (WebCore::BreakingContext::handleBR): (WebCore::borderPaddingMarginStart): (WebCore::borderPaddingMarginEnd): (WebCore::shouldAddBorderPaddingMargin): (WebCore::previousInFlowSibling): (WebCore::inlineLogicalWidth): (WebCore::BreakingContext::handleOutOfFlowPositioned): (WebCore::BreakingContext::handleFloat): (WebCore::shouldSkipWhitespaceAfterStartObject): (WebCore::BreakingContext::handleEmptyInline): (WebCore::BreakingContext::handleReplaced): (WebCore::firstPositiveWidth): (WebCore::updateSegmentsForShapes): (WebCore::iteratorIsBeyondEndOfRenderCombineText): (WebCore::nextCharacter): (WebCore::updateCounterIfNeeded): (WebCore::measureHyphenWidth): (WebCore::textWidth): (WebCore::ensureCharacterGetsLineBox): (WebCore::tryHyphenating): (WebCore::BreakingContext::handleText): (WebCore::textBeginsWithBreakablePosition): (WebCore::BreakingContext::canBreakAtThisPosition): (WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded): (WebCore::checkMidpoints): (WebCore::BreakingContext::handleEndOfLine): * rendering/line/LineBreaker.cpp: Added. (WebCore::LineBreaker::reset): (WebCore::LineBreaker::skipTrailingWhitespace): (WebCore::LineBreaker::skipLeadingWhitespace): * rendering/line/LineBreaker.h: Added. (WebCore::LineBreaker::LineBreaker): (WebCore::LineBreaker::lineWasHyphenated): (WebCore::LineBreaker::positionedObjects): (WebCore::LineBreaker::clear): * rendering/line/LineInfo.cpp: Added. (WebCore::LineInfo::setEmpty): * rendering/line/LineInfo.h: Renamed from Source/WebCore/rendering/LineInfo.h. (WebCore::LineInfo::LineInfo): (WebCore::LineInfo::isFirstLine): (WebCore::LineInfo::isLastLine): (WebCore::LineInfo::isEmpty): (WebCore::LineInfo::previousLineBrokeCleanly): (WebCore::LineInfo::floatPaginationStrut): (WebCore::LineInfo::runsFromLeadingWhitespace): (WebCore::LineInfo::resetRunsFromLeadingWhitespace): (WebCore::LineInfo::incrementRunsFromLeadingWhitespace): (WebCore::LineInfo::setFirstLine): (WebCore::LineInfo::setLastLine): (WebCore::LineInfo::setPreviousLineBrokeCleanly): (WebCore::LineInfo::setFloatPaginationStrut): * rendering/line/LineInlineHeaders.h: Added. (WebCore::hasInlineDirectionBordersPaddingOrMargin): (WebCore::lineStyle): (WebCore::requiresLineBoxForContent): (WebCore::shouldCollapseWhiteSpace): (WebCore::skipNonBreakingSpace): (WebCore::alwaysRequiresLineBox): (WebCore::requiresLineBox): (WebCore::setStaticPositions): Canonical link: https://commits.webkit.org/142621@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-11-15 21:40:59 +00:00
class RenderBlock;
class LineInfo {
public:
LineInfo()
: m_isFirstLine(true)
, m_isLastLine(false)
, m_isEmpty(true)
, m_previousLineBrokeCleanly(true)
, m_floatPaginationStrut(0)
, m_runsFromLeadingWhitespace(0)
{ }
bool isFirstLine() const { return m_isFirstLine; }
bool isLastLine() const { return m_isLastLine; }
bool isEmpty() const { return m_isEmpty; }
bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; }
LayoutUnit floatPaginationStrut() const { return m_floatPaginationStrut; }
unsigned runsFromLeadingWhitespace() const { return m_runsFromLeadingWhitespace; }
void resetRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace = 0; }
void incrementRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace++; }
void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; }
void setLastLine(bool lastLine) { m_isLastLine = lastLine; }
Move BreakingContext and LineBreaker into their own files <https://webkit.org/b/124336> Reviewed by David Hyatt. In this change I introduced 'line' subdirectory inside 'rendering', this directory will contain all the classes which have been refactored from RenderBlockLineLayout.cpp. This change contains the separation of BreakingContext, and the separation of LineBreaker classes. Since I wanted to keep the helper functions organized, I also added a new file called LineInlineHeaders.h, which contains the functions which used in LineBreaker.h and BreakingContext.h. I moved LineInfo class into line directory. It was necessary this time, since I added a cpp for it. I'll move the rest of the line layout related helper classes later. (I wanted to minimize merge conflicts.) No new tests, no behavior change. * CMakeLists.txt: * GNUmakefile.am: * GNUmakefile.list.am: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.vcxproj/WebCoreCommon.props: * WebCore.xcodeproj/project.pbxproj: * rendering/RenderBlockLineLayout.cpp: (WebCore::createRun): * rendering/line/BreakingContextInlineHeaders.h: Added. (WebCore::WordMeasurement::WordMeasurement): (WebCore::TrailingObjects::TrailingObjects): (WebCore::TrailingObjects::setTrailingWhitespace): (WebCore::TrailingObjects::clear): (WebCore::TrailingObjects::appendBoxIfNeeded): (WebCore::deprecatedAddMidpoint): (WebCore::startIgnoringSpaces): (WebCore::stopIgnoringSpaces): (WebCore::ensureLineBoxInsideIgnoredSpaces): (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes): (WebCore::BreakingContext::BreakingContext): (WebCore::BreakingContext::currentObject): (WebCore::BreakingContext::lineBreak): (WebCore::BreakingContext::lineBreakRef): (WebCore::BreakingContext::lineWidth): (WebCore::BreakingContext::atEnd): (WebCore::BreakingContext::clearLineBreakIfFitsOnLine): (WebCore::BreakingContext::commitLineBreakAtCurrentWidth): (WebCore::BreakingContext::initializeForCurrentObject): (WebCore::BreakingContext::increment): (WebCore::BreakingContext::handleBR): (WebCore::borderPaddingMarginStart): (WebCore::borderPaddingMarginEnd): (WebCore::shouldAddBorderPaddingMargin): (WebCore::previousInFlowSibling): (WebCore::inlineLogicalWidth): (WebCore::BreakingContext::handleOutOfFlowPositioned): (WebCore::BreakingContext::handleFloat): (WebCore::shouldSkipWhitespaceAfterStartObject): (WebCore::BreakingContext::handleEmptyInline): (WebCore::BreakingContext::handleReplaced): (WebCore::firstPositiveWidth): (WebCore::updateSegmentsForShapes): (WebCore::iteratorIsBeyondEndOfRenderCombineText): (WebCore::nextCharacter): (WebCore::updateCounterIfNeeded): (WebCore::measureHyphenWidth): (WebCore::textWidth): (WebCore::ensureCharacterGetsLineBox): (WebCore::tryHyphenating): (WebCore::BreakingContext::handleText): (WebCore::textBeginsWithBreakablePosition): (WebCore::BreakingContext::canBreakAtThisPosition): (WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded): (WebCore::checkMidpoints): (WebCore::BreakingContext::handleEndOfLine): * rendering/line/LineBreaker.cpp: Added. (WebCore::LineBreaker::reset): (WebCore::LineBreaker::skipTrailingWhitespace): (WebCore::LineBreaker::skipLeadingWhitespace): * rendering/line/LineBreaker.h: Added. (WebCore::LineBreaker::LineBreaker): (WebCore::LineBreaker::lineWasHyphenated): (WebCore::LineBreaker::positionedObjects): (WebCore::LineBreaker::clear): * rendering/line/LineInfo.cpp: Added. (WebCore::LineInfo::setEmpty): * rendering/line/LineInfo.h: Renamed from Source/WebCore/rendering/LineInfo.h. (WebCore::LineInfo::LineInfo): (WebCore::LineInfo::isFirstLine): (WebCore::LineInfo::isLastLine): (WebCore::LineInfo::isEmpty): (WebCore::LineInfo::previousLineBrokeCleanly): (WebCore::LineInfo::floatPaginationStrut): (WebCore::LineInfo::runsFromLeadingWhitespace): (WebCore::LineInfo::resetRunsFromLeadingWhitespace): (WebCore::LineInfo::incrementRunsFromLeadingWhitespace): (WebCore::LineInfo::setFirstLine): (WebCore::LineInfo::setLastLine): (WebCore::LineInfo::setPreviousLineBrokeCleanly): (WebCore::LineInfo::setFloatPaginationStrut): * rendering/line/LineInlineHeaders.h: Added. (WebCore::hasInlineDirectionBordersPaddingOrMargin): (WebCore::lineStyle): (WebCore::requiresLineBoxForContent): (WebCore::shouldCollapseWhiteSpace): (WebCore::skipNonBreakingSpace): (WebCore::alwaysRequiresLineBox): (WebCore::requiresLineBox): (WebCore::setStaticPositions): Canonical link: https://commits.webkit.org/142621@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-11-15 21:40:59 +00:00
void setEmpty(bool empty, RenderBlock* block = 0, LineWidth* lineWidth = 0);
void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }
void setFloatPaginationStrut(LayoutUnit strut) { m_floatPaginationStrut = strut; }
private:
bool m_isFirstLine;
bool m_isLastLine;
bool m_isEmpty;
bool m_previousLineBrokeCleanly;
LayoutUnit m_floatPaginationStrut;
unsigned m_runsFromLeadingWhitespace;
};
} // namespace WebCore