Diff
Modified: trunk/Source/WebCore/ChangeLog (237288 => 237289)
--- trunk/Source/WebCore/ChangeLog 2018-10-19 16:41:58 UTC (rev 237288)
+++ trunk/Source/WebCore/ChangeLog 2018-10-19 16:51:44 UTC (rev 237289)
@@ -1,5 +1,37 @@
2018-10-19 Zalan Bujtas <za...@apple.com>
+ [LFC][IFC] Remove the previous version of inline content handling.
+ https://bugs.webkit.org/show_bug.cgi?id=190716
+
+ Reviewed by Antti Koivisto.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/Verification.cpp:
+ (WebCore::Layout::areEssentiallyEqual):
+ (WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded):
+ (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
+ * layout/inlineformatting/InlineFormattingState.h:
+ (WebCore::Layout::InlineFormattingState::inlineContent):
+ (WebCore::Layout::InlineFormattingState::addLayoutRuns): Deleted.
+ (WebCore::Layout::InlineFormattingState::layoutRuns const): Deleted.
+ * layout/inlineformatting/text/TextUtil.cpp: Renamed from Source/WebCore/layout/inlineformatting/textlayout/TextUtil.cpp.
+ (WebCore::Layout::TextUtil::TextUtil):
+ (WebCore::Layout::TextUtil::width const):
+ (WebCore::Layout::TextUtil::hyphenPositionBefore const):
+ (WebCore::Layout::TextUtil::textWidth const):
+ (WebCore::Layout::TextUtil::fixedPitchWidth const):
+ * layout/inlineformatting/text/TextUtil.h: Renamed from Source/WebCore/layout/inlineformatting/textlayout/TextUtil.h.
+ * layout/inlineformatting/textlayout/Runs.h: Removed.
+ * layout/inlineformatting/textlayout/TextContentProvider.cpp: Removed.
+ * layout/inlineformatting/textlayout/TextContentProvider.h: Removed.
+ * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp: Removed.
+ * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h: Removed.
+ * layout/inlineformatting/textlayout/simple/SimpleTextRunGenerator.cpp: Removed.
+ * layout/inlineformatting/textlayout/simple/SimpleTextRunGenerator.h: Removed.
+
+2018-10-19 Zalan Bujtas <za...@apple.com>
+
[LFC][IFC] Add generic inline content handling.
https://bugs.webkit.org/show_bug.cgi?id=190713
Modified: trunk/Source/WebCore/Sources.txt (237288 => 237289)
--- trunk/Source/WebCore/Sources.txt 2018-10-19 16:41:58 UTC (rev 237288)
+++ trunk/Source/WebCore/Sources.txt 2018-10-19 16:51:44 UTC (rev 237289)
@@ -1262,10 +1262,7 @@
layout/inlineformatting/InlineLineBreaker.cpp
layout/inlineformatting/InlineRunProvider.cpp
layout/inlineformatting/Line.cpp
-layout/inlineformatting/textlayout/TextContentProvider.cpp
-layout/inlineformatting/textlayout/TextUtil.cpp
-layout/inlineformatting/textlayout/simple/SimpleTextRunGenerator.cpp
-layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp
+layout/inlineformatting/text/TextUtil.cpp
layout/layouttree/LayoutBlockContainer.cpp
layout/layouttree/LayoutBox.cpp
layout/layouttree/LayoutContainer.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (237288 => 237289)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-10-19 16:41:58 UTC (rev 237288)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-10-19 16:51:44 UTC (rev 237289)
@@ -5879,8 +5879,6 @@
11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; };
11E067EB1E62461300162D16 /* SimpleLineLayoutCoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutCoverage.cpp; sourceTree = "<group>"; };
11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutCoverage.h; sourceTree = "<group>"; };
- 11EA57FB20FFAFB600311EBB /* SimpleTextRunGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleTextRunGenerator.cpp; sourceTree = "<group>"; };
- 11EA57FC20FFAFB700311EBB /* SimpleTextRunGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleTextRunGenerator.h; sourceTree = "<group>"; };
11FF02D520BA3C810083F25B /* Verification.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Verification.cpp; sourceTree = "<group>"; };
12F75A9A86EA03DAF24B7971 /* ISOProtectionSystemSpecificHeaderBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOProtectionSystemSpecificHeaderBox.h; sourceTree = "<group>"; };
1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappableInlines.h; sourceTree = "<group>"; };
@@ -9079,8 +9077,6 @@
6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContext.cpp; sourceTree = "<group>"; };
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; };
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContext.cpp; sourceTree = "<group>"; };
- 6F8304C920FBA5E1004AD5D1 /* SimpleLineBreaker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineBreaker.cpp; sourceTree = "<group>"; };
- 6F8304CA20FBA5E1004AD5D1 /* SimpleLineBreaker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleLineBreaker.h; sourceTree = "<group>"; };
6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLQuery.idl; sourceTree = "<group>"; };
6F995A0A1A7070E600A735F4 /* WebGLSampler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLSampler.idl; sourceTree = "<group>"; };
6F995A0B1A7070E600A735F4 /* WebGLSync.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLSync.idl; sourceTree = "<group>"; };
@@ -9109,9 +9105,6 @@
6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
- 6FCD19C120F9727A00FD4529 /* TextContentProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextContentProvider.h; sourceTree = "<group>"; };
- 6FCD19C720F9727D00FD4529 /* TextContentProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextContentProvider.cpp; sourceTree = "<group>"; };
- 6FCF975220F02B3500214960 /* Runs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Runs.h; sourceTree = "<group>"; };
6FE198132178397B00446F08 /* InlineLineBreaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLineBreaker.cpp; sourceTree = "<group>"; };
6FE198152178397C00446F08 /* InlineLineBreaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBreaker.h; sourceTree = "<group>"; };
6FE7CFA02177EEF1005B1573 /* InlineItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineItem.h; sourceTree = "<group>"; };
@@ -16059,11 +16052,7 @@
115CFA9A208BC140001E6991 /* inlineformatting */ = {
isa = PBXGroup;
children = (
- 6F219D742178D37100BB033C /* InlineRun.h */,
- 6F219D762178D37100BB033C /* Line.cpp */,
- 6FE198132178397B00446F08 /* InlineLineBreaker.cpp */,
- 6FE198152178397C00446F08 /* InlineLineBreaker.h */,
- 6FE7DDDD20EC6E8B008B5B4E /* textlayout */,
+ 6FE7DDDD20EC6E8B008B5B4E /* text */,
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
115CFA7D208B8E10001E6991 /* InlineFormattingState.cpp */,
@@ -16071,8 +16060,12 @@
1123AFDD209ABBBA00736ACC /* InlineInvalidation.cpp */,
1123AFDC209ABBBA00736ACC /* InlineInvalidation.h */,
6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
+ 6FE198132178397B00446F08 /* InlineLineBreaker.cpp */,
+ 6FE198152178397C00446F08 /* InlineLineBreaker.h */,
+ 6F219D742178D37100BB033C /* InlineRun.h */,
6F5217C62177F5A6006583BB /* InlineRunProvider.cpp */,
6F5217C42177F5A6006583BB /* InlineRunProvider.h */,
+ 6F219D762178D37100BB033C /* Line.cpp */,
);
path = inlineformatting;
sourceTree = "<group>";
@@ -19916,17 +19909,6 @@
tabWidth = 4;
usesTabs = 0;
};
- 6F13A12320F9949C001C025A /* simple */ = {
- isa = PBXGroup;
- children = (
- 6F8304C920FBA5E1004AD5D1 /* SimpleLineBreaker.cpp */,
- 6F8304CA20FBA5E1004AD5D1 /* SimpleLineBreaker.h */,
- 11EA57FB20FFAFB600311EBB /* SimpleTextRunGenerator.cpp */,
- 11EA57FC20FFAFB700311EBB /* SimpleTextRunGenerator.h */,
- );
- path = simple;
- sourceTree = "<group>";
- };
6FCFC055212DACC2007695D2 /* floats */ = {
isa = PBXGroup;
children = (
@@ -19942,17 +19924,13 @@
path = floats;
sourceTree = "<group>";
};
- 6FE7DDDD20EC6E8B008B5B4E /* textlayout */ = {
+ 6FE7DDDD20EC6E8B008B5B4E /* text */ = {
isa = PBXGroup;
children = (
6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */,
6FB11B5921783FCF00E2A574 /* TextUtil.h */,
- 6F13A12320F9949C001C025A /* simple */,
- 6FCF975220F02B3500214960 /* Runs.h */,
- 6FCD19C720F9727D00FD4529 /* TextContentProvider.cpp */,
- 6FCD19C120F9727A00FD4529 /* TextContentProvider.h */,
);
- path = textlayout;
+ path = text;
sourceTree = "<group>";
};
71025EC11F99F096004A250C /* animation */ = {
@@ -28845,6 +28823,8 @@
11310CF820BA4A6A0065A8D0 /* InlineInvalidation.h in Headers */,
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
+ 6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */,
+ 6F219D772178D37200BB033C /* InlineRun.h in Headers */,
6F5217C72177F5A7006583BB /* InlineRunProvider.h in Headers */,
AA4C3A770B2B1679002334A2 /* InlineStyleSheetOwner.h in Headers */,
BCEA485A097D93020094C9E4 /* InlineTextBox.h in Headers */,
@@ -29504,7 +29484,6 @@
A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */,
571F21891DA57C54005C9EFD /* JSSubtleCrypto.h in Headers */,
B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */,
- 6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */,
24D9129213CA951E00D21915 /* JSSVGAltGlyphDefElement.h in Headers */,
6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */,
24D9129613CA956100D21915 /* JSSVGAltGlyphItemElement.h in Headers */,
@@ -30153,7 +30132,6 @@
A88DD4870B4629A300C02990 /* PathTraversalState.h in Headers */,
2D5002FC1B56D7990020AAF7 /* PathUtilities.h in Headers */,
A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */,
- 6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */,
B22279710D00BF220071B782 /* PatternAttributes.h in Headers */,
A1677E08213E024C00A08C34 /* PayerErrorFields.h in Headers */,
1A8A643A1D19FC5300D0E00F /* Payment.h in Headers */,
@@ -30458,7 +30436,6 @@
A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */,
436708CD12D9CA4B00044234 /* RenderSVGResource.h in Headers */,
436708CF12D9CA4B00044234 /* RenderSVGResourceClipper.h in Headers */,
- 6F219D772178D37200BB033C /* InlineRun.h in Headers */,
436708D112D9CA4B00044234 /* RenderSVGResourceContainer.h in Headers */,
436708D312D9CA4B00044234 /* RenderSVGResourceFilter.h in Headers */,
436708D512D9CA4B00044234 /* RenderSVGResourceFilterPrimitive.h in Headers */,
@@ -31221,6 +31198,7 @@
29FAF4B6195AB08900A522DC /* TextUndoInsertionMarkupMac.h in Headers */,
498770F11242C535002226BA /* Texture.h in Headers */,
CD9D82761C7AE535006FF066 /* TextureCacheCV.h in Headers */,
+ 6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */,
BCE658FF0EA9248A007E4533 /* Theme.h in Headers */,
310D71961B335C9E009C7B73 /* ThemeCocoa.h in Headers */,
44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */,
Modified: trunk/Source/WebCore/layout/Verification.cpp (237288 => 237289)
--- trunk/Source/WebCore/layout/Verification.cpp 2018-10-19 16:41:58 UTC (rev 237288)
+++ trunk/Source/WebCore/layout/Verification.cpp 2018-10-19 16:51:44 UTC (rev 237289)
@@ -40,6 +40,14 @@
namespace WebCore {
namespace Layout {
+static bool areEssentiallyEqual(float a, LayoutUnit b)
+{
+ if (a == b.toFloat())
+ return true;
+
+ return ::abs(a - b.toFloat()) <= 4 * LayoutUnit::epsilon();
+}
+
static bool outputMismatchingSimpleLineInformationIfNeeded(TextStream& stream, const LayoutContext& layoutContext, const RenderBlockFlow& blockFlow, const Container& inlineFormattingRoot)
{
auto* lineLayoutData = blockFlow.simpleLineLayout();
@@ -48,12 +56,12 @@
return true;
}
- auto& inlineFormattingState = const_cast<LayoutContext&>(layoutContext).establishedFormattingState(inlineFormattingRoot);
+ auto& inlineFormattingState = layoutContext.establishedFormattingState(inlineFormattingRoot);
ASSERT(is<InlineFormattingState>(inlineFormattingState));
- auto& layoutRuns = downcast<InlineFormattingState>(inlineFormattingState).layoutRuns();
+ auto& inlineRunList = downcast<InlineFormattingState>(inlineFormattingState).inlineRuns();
- if (layoutRuns.size() != lineLayoutData->runCount()) {
- stream << "Mismatching number of runs: simple runs(" << lineLayoutData->runCount() << ") layout runs(" << layoutRuns.size() << ")";
+ if (inlineRunList.size() != lineLayoutData->runCount()) {
+ stream << "Mismatching number of runs: simple runs(" << lineLayoutData->runCount() << ") inline runs(" << inlineRunList.size() << ")";
stream.nextLine();
return true;
}
@@ -61,12 +69,15 @@
auto mismatched = false;
for (unsigned i = 0; i < lineLayoutData->runCount(); ++i) {
auto& simpleRun = lineLayoutData->runAt(i);
- auto& layoutRun = layoutRuns[i];
+ auto& inlineRun = inlineRunList[i];
- if (simpleRun.start == layoutRun.start() && simpleRun.end == layoutRun.end() && simpleRun.logicalLeft == layoutRun.left() && simpleRun.logicalRight == layoutRun.right())
+ auto matchingRuns = areEssentiallyEqual(simpleRun.logicalLeft, inlineRun.logicalLeft()) && areEssentiallyEqual(simpleRun.logicalRight, inlineRun.logicalRight());
+ if (matchingRuns)
+ matchingRuns = (simpleRun.start == inlineRun.textContext()->position() && simpleRun.end == (inlineRun.textContext()->position() + inlineRun.textContext()->length()));
+ if (matchingRuns)
continue;
- stream << "Mismatching: simple run(" << simpleRun.start << ", " << simpleRun.end << ") (" << simpleRun.logicalLeft << ", " << simpleRun.logicalRight << ") layout run(" << layoutRun.start() << ", " << layoutRun.end() << ") (" << layoutRun.left() << ", " << layoutRun.right() << ")";
+ stream << "Mismatching: simple run(" << simpleRun.start << ", " << simpleRun.end << ") (" << simpleRun.logicalLeft << ", " << simpleRun.logicalRight << ") layout run(" << inlineRun.textContext()->position() << ", " << inlineRun.textContext()->position() + inlineRun.textContext()->length() << ") (" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
stream.nextLine();
mismatched = true;
}
@@ -75,32 +86,45 @@
static bool outputMismatchingComplexLineInformationIfNeeded(TextStream& stream, const LayoutContext& layoutContext, const RenderBlockFlow& blockFlow, const Container& inlineFormattingRoot)
{
- auto& inlineFormattingState = const_cast<LayoutContext&>(layoutContext).establishedFormattingState(inlineFormattingRoot);
+ auto& inlineFormattingState = layoutContext.establishedFormattingState(inlineFormattingRoot);
ASSERT(is<InlineFormattingState>(inlineFormattingState));
- auto& layoutRuns = downcast<InlineFormattingState>(inlineFormattingState).layoutRuns();
+ auto& inlineRunList = downcast<InlineFormattingState>(inlineFormattingState).inlineRuns();
auto mismatched = false;
- unsigned layoutRunIndex = 0;
+ unsigned runIndex = 0;
for (auto* rootLine = blockFlow.firstRootBox(); rootLine; rootLine = rootLine->nextRootBox()) {
for (auto* lineBox = rootLine->firstChild(); lineBox; lineBox = lineBox->nextOnLine()) {
- if (!is<InlineTextBox>(lineBox))
- continue;
-
- if (layoutRunIndex >= layoutRuns.size()) {
+ if (runIndex >= inlineRunList.size()) {
// FIXME: <span>foobar</span>foobar generates 2 inline text boxes while we only generate one layout run (which is much better, since it enables us to do kerning across inline elements).
- stream << "Mismatching number of runs: layout runs(" << layoutRuns.size() << ")";
+ stream << "Mismatching number of runs: inline runs(" << inlineRunList.size() << ")";
stream.nextLine();
return true;
}
- auto& layoutRun = layoutRuns[layoutRunIndex];
- auto& inlineTextBox = downcast<InlineTextBox>(*lineBox);
- if (inlineTextBox.start() == layoutRun.start() && inlineTextBox.end() == layoutRun.end() && inlineTextBox.logicalLeft() == layoutRun.left() && inlineTextBox.logicalRight() == layoutRun.right()) {
- stream << "Mismatching: simple run(" << inlineTextBox.start() << ", " << inlineTextBox.end() << ") (" << inlineTextBox.logicalLeft() << ", " << inlineTextBox.logicalRight() << ") layout run(" << layoutRun.start() << ", " << layoutRun.end() << ") (" << layoutRun.left() << ", " << layoutRun.right() << ")";
+ auto& inlineRun = inlineRunList[runIndex];
+ auto* inlineTextBox = is<InlineTextBox>(lineBox) ? downcast<InlineTextBox>(lineBox) : nullptr;
+
+ auto matchingRuns = areEssentiallyEqual(lineBox->logicalLeft(), inlineRun.logicalLeft()) && areEssentiallyEqual(lineBox->logicalRight(), inlineRun.logicalRight());
+ if (matchingRuns && inlineTextBox) {
+ ASSERT(inlineRun.textContext());
+ matchingRuns = inlineTextBox->start() == inlineRun.textContext()->position() && inlineTextBox->end() + 1 == (inlineRun.textContext()->position() + inlineRun.textContext()->length());
+ }
+
+ if (!matchingRuns) {
+ stream << "Mismatching: run ";
+
+ if (inlineTextBox)
+ stream << "(" << inlineTextBox->start() << ", " << inlineTextBox->end() + 1 << ")";
+ stream << " (" << lineBox->logicalLeft() << ", " << lineBox->logicalRight() << ") ";
+
+ stream << "layout run ";
+ if (inlineRun.textContext())
+ stream << "(" << inlineRun.textContext()->position() << ", " << inlineRun.textContext()->position() + inlineRun.textContext()->length() << ") ";
+ stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
stream.nextLine();
mismatched = true;
}
- ++layoutRunIndex;
+ ++runIndex;
}
}
return mismatched;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (237288 => 237289)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-19 16:41:58 UTC (rev 237288)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-19 16:51:44 UTC (rev 237289)
@@ -30,7 +30,6 @@
#include "FormattingState.h"
#include "InlineItem.h"
#include "InlineRun.h"
-#include "Runs.h"
#include <wtf/IsoMalloc.h>
namespace WebCore {
@@ -44,10 +43,6 @@
virtual ~InlineFormattingState();
InlineContent& inlineContent() { return m_inlineContent; }
- // This is temporary. We need to construct a display tree context for inlines.
- void addLayoutRuns(Vector<LayoutRun>&& layoutRuns) { m_layoutRuns = WTFMove(layoutRuns); }
- const Vector<LayoutRun>& layoutRuns() const { return m_layoutRuns; }
-
// Temp
InlineRuns& inlineRuns() { return m_inlineRuns; }
void appendInlineRun(InlineRun inlineRun) { m_inlineRuns.append(inlineRun); }
@@ -54,7 +49,6 @@
private:
InlineContent m_inlineContent;
- Vector<LayoutRun> m_layoutRuns;
InlineRuns m_inlineRuns;
};
Copied: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (from rev 237288, trunk/Source/WebCore/layout/inlineformatting/textlayout/TextUtil.cpp) (0 => 237289)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (rev 0)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2018-10-19 16:51:44 UTC (rev 237289)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2018 Apple Inc. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "TextUtil.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FontCascade.h"
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(TextUtil);
+
+TextUtil::TextUtil(const InlineContent& inlineContent)
+ : m_inlineContent(inlineContent)
+{
+}
+
+LayoutUnit TextUtil::width(const InlineItem& inlineItem, ItemPosition from, unsigned length, LayoutUnit contentLogicalLeft) const
+{
+ LayoutUnit width;
+ auto startPosition = from;
+ auto iterator = m_inlineContent.find<const InlineItem&, InlineItemHashTranslator>(inlineItem);
+ auto inlineItemEnd = m_inlineContent.end();
+ while (length) {
+ ASSERT(iterator != inlineItemEnd);
+ auto& currentInlineItem = **iterator;
+ auto endPosition = std::min<ItemPosition>(startPosition + length, currentInlineItem.textContent().length());
+ auto textWidth = this->textWidth(currentInlineItem, startPosition, endPosition, contentLogicalLeft);
+
+ contentLogicalLeft += textWidth;
+ width += textWidth;
+ length -= (endPosition - startPosition);
+
+ startPosition = 0;
+ ++iterator;
+ }
+
+ return width;
+}
+
+std::optional<ItemPosition> TextUtil::hyphenPositionBefore(const InlineItem&, ItemPosition, unsigned) const
+{
+ return std::nullopt;
+}
+
+LayoutUnit TextUtil::textWidth(const InlineItem& inlineTextItem, ItemPosition from, ItemPosition to, LayoutUnit contentLogicalLeft) const
+{
+ auto& style = inlineTextItem.style();
+ auto& font = style.fontCascade();
+ if (!font.size() || from == to)
+ return 0;
+
+ auto text = inlineTextItem.textContent();
+ if (font.isFixedPitch())
+ return fixedPitchWidth(text, style, from, to, contentLogicalLeft);
+
+ auto hasKerningOrLigatures = font.enableKerning() || font.requiresShaping();
+ auto measureWithEndSpace = hasKerningOrLigatures && to < text.length() && text[to] == ' ';
+ if (measureWithEndSpace)
+ ++to;
+ LayoutUnit width;
+ auto tabWidth = style.collapseWhiteSpace() ? 0 : style.tabSize();
+
+ WebCore::TextRun run(StringView(text).substring(from, to - from), contentLogicalLeft);
+ if (tabWidth)
+ run.setTabSize(true, tabWidth);
+ width = font.width(run);
+
+ if (measureWithEndSpace)
+ width -= (font.spaceWidth() + font.wordSpacing());
+
+ return std::max<LayoutUnit>(0, width);
+}
+
+LayoutUnit TextUtil::fixedPitchWidth(String text, const RenderStyle& style, ItemPosition from, ItemPosition to, LayoutUnit contentLogicalLeft) const
+{
+ auto& font = style.fontCascade();
+ auto monospaceCharacterWidth = font.spaceWidth();
+ LayoutUnit width;
+ for (auto i = from; i < to; ++i) {
+ auto character = text[i];
+ if (character >= ' ' || character == '\n')
+ width += monospaceCharacterWidth;
+ else if (character == '\t')
+ width += style.collapseWhiteSpace() ? monospaceCharacterWidth : font.tabWidth(style.tabSize(), contentLogicalLeft + width);
+
+ if (i > from && (character == ' ' || character == '\t' || character == '\n'))
+ width += font.wordSpacing();
+ }
+
+ return width;
+}
+
+}
+}
+#endif
Copied: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (from rev 237288, trunk/Source/WebCore/layout/inlineformatting/textlayout/TextUtil.h) (0 => 237289)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (rev 0)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2018-10-19 16:51:44 UTC (rev 237289)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 Apple Inc. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineItem.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+
+namespace Layout {
+
+class TextUtil {
+ WTF_MAKE_ISO_ALLOCATED(TextUtil);
+public:
+ TextUtil(const InlineContent&);
+
+ LayoutUnit width(const InlineItem&, ItemPosition from, unsigned length, LayoutUnit contentLogicalLeft) const;
+ std::optional<ItemPosition> hyphenPositionBefore(const InlineItem&, ItemPosition from, unsigned length) const;
+
+private:
+ LayoutUnit textWidth(const InlineItem&, ItemPosition from, ItemPosition to, LayoutUnit contentLogicalLeft) const;
+ LayoutUnit fixedPitchWidth(String, const RenderStyle&, ItemPosition from, ItemPosition to, LayoutUnit contentLogicalLeft) const;
+
+ const InlineContent& m_inlineContent;
+};
+
+}
+}
+#endif