From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/rendering/SimpleLineLayout.cpp | 1093 +++++++++++++++++-------- 1 file changed, 766 insertions(+), 327 deletions(-) (limited to 'Source/WebCore/rendering/SimpleLineLayout.cpp') diff --git a/Source/WebCore/rendering/SimpleLineLayout.cpp b/Source/WebCore/rendering/SimpleLineLayout.cpp index b0f0b31af..454e71e5c 100644 --- a/Source/WebCore/rendering/SimpleLineLayout.cpp +++ b/Source/WebCore/rendering/SimpleLineLayout.cpp @@ -33,440 +33,879 @@ #include "HitTestLocation.h" #include "HitTestRequest.h" #include "HitTestResult.h" +#include "Hyphenation.h" #include "InlineTextBox.h" #include "LineWidth.h" +#include "Logging.h" #include "PaintInfo.h" #include "RenderBlockFlow.h" +#include "RenderChildIterator.h" +#include "RenderLineBreak.h" #include "RenderStyle.h" #include "RenderText.h" #include "RenderTextControl.h" -#include "RenderView.h" #include "Settings.h" +#include "SimpleLineLayoutFlowContents.h" #include "SimpleLineLayoutFunctions.h" +#include "SimpleLineLayoutTextFragmentIterator.h" #include "Text.h" #include "TextPaintStyle.h" -#include "break_lines.h" -#include namespace WebCore { namespace SimpleLineLayout { +#ifndef NDEBUG +#define SET_REASON_AND_RETURN_IF_NEEDED(reason, reasons, includeReasons) { \ + reasons |= reason; \ + if (includeReasons == IncludeReasons::First) \ + return reasons; \ + } +#else +#define SET_REASON_AND_RETURN_IF_NEEDED(reason, reasons, includeReasons) { \ + ASSERT_UNUSED(includeReasons, includeReasons == IncludeReasons::First); \ + reasons |= reason; \ + return reasons; \ + } +#endif + + +template AvoidanceReasonFlags canUseForCharacter(CharacterType, bool textIsJustified, IncludeReasons); + +template<> AvoidanceReasonFlags canUseForCharacter(UChar character, bool textIsJustified, IncludeReasons includeReasons) +{ + AvoidanceReasonFlags reasons = { }; + if (textIsJustified) { + // Include characters up to Latin Extended-B and some punctuation range when text is justified. + bool isLatinIncludingExtendedB = character <= 0x01FF; + bool isPunctuationRange = character >= 0x2010 && character <= 0x2027; + if (!(isLatinIncludingExtendedB || isPunctuationRange)) + SET_REASON_AND_RETURN_IF_NEEDED(FlowHasJustifiedNonLatinText, reasons, includeReasons); + } + + if (U16_IS_SURROGATE(character)) + SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasSurrogatePair, reasons, includeReasons); + + UCharDirection direction = u_charDirection(character); + if (direction == U_RIGHT_TO_LEFT || direction == U_RIGHT_TO_LEFT_ARABIC + || direction == U_RIGHT_TO_LEFT_EMBEDDING || direction == U_RIGHT_TO_LEFT_OVERRIDE + || direction == U_LEFT_TO_RIGHT_EMBEDDING || direction == U_LEFT_TO_RIGHT_OVERRIDE + || direction == U_POP_DIRECTIONAL_FORMAT || direction == U_BOUNDARY_NEUTRAL) + SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasDirectionCharacter, reasons, includeReasons); + + return reasons; +} + +template<> AvoidanceReasonFlags canUseForCharacter(LChar, bool, IncludeReasons) +{ + return { }; +} + template -static bool canUseForText(const CharacterType* text, unsigned length, const SimpleFontData& fontData) +static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const FontCascade& fontCascade, std::optional lineHeightConstraint, + bool textIsJustified, IncludeReasons includeReasons) { - // FIXME: