Diff
Modified: trunk/Source/WebCore/ChangeLog (205281 => 205282)
--- trunk/Source/WebCore/ChangeLog 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/ChangeLog 2016-09-01 07:37:19 UTC (rev 205282)
@@ -1,3 +1,60 @@
+2016-09-01 Myles C. Maxfield <[email protected]>
+
+ Clean up TextRun-related code
+ https://bugs.webkit.org/show_bug.cgi?id=161473
+
+ Reviewed by Simon Fraser.
+
+ Some assorted cleanup, including:
+ - Renaming "AllowTrailingExpansion | ForbidLeadingExpansion" to "DefaultExpansion"
+ - Migrating from pointers to references
+ - Migrating from ints to unsigneds
+ - Using proper character names from CharacterNames.h
+ - Simplifying CoreTextSPI.h
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/TextRun.h:
+ (WebCore::TextRun::TextRun):
+ * platform/graphics/mac/ComplexTextController.cpp:
+ (WebCore::TextLayout::isNeeded):
+ (WebCore::TextLayout::constructTextRun):
+ * platform/spi/cocoa/CoreTextSPI.h:
+ * platform/text/TextFlags.h:
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::constructTextRun):
+ * rendering/RenderBlock.h:
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::computePreferredLogicalWidths):
+ (WebCore::RenderListMarker::getRelativeMarkerRect):
+ * rendering/RenderMenuList.cpp:
+ (RenderMenuList::updateOptionsWidth):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::widthFromCache):
+ (WebCore::RenderText::trimmedPrefWidths):
+ (WebCore::hyphenWidth):
+ (WebCore::maxWordFragmentWidth):
+ (WebCore::RenderText::computePreferredLogicalWidths):
+ (WebCore::RenderText::width):
+ * rendering/RenderText.h:
+ * rendering/RenderThemeIOS.mm:
+ * rendering/line/BreakingContext.h:
+ (WebCore::textWidth):
+ (WebCore::tryHyphenating):
+ * rendering/svg/SVGInlineTextBox.cpp:
+ (WebCore::SVGInlineTextBox::offsetForPositionInFragment):
+ (WebCore::SVGInlineTextBox::selectionRectForTextFragment):
+ (WebCore::SVGInlineTextBox::localSelectionRect):
+ (WebCore::SVGInlineTextBox::paintSelectionBackground):
+ (WebCore::SVGInlineTextBox::paint):
+ (WebCore::SVGInlineTextBox::acquirePaintingResource):
+ (WebCore::SVGInlineTextBox::prepareGraphicsContextForTextPainting):
+ (WebCore::SVGInlineTextBox::constructTextRun):
+ (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
+ (WebCore::SVGInlineTextBox::paintTextWithShadows):
+ (WebCore::SVGInlineTextBox::paintText):
+ * rendering/svg/SVGInlineTextBox.h:
+
2016-08-31 Carlos Garcia Campos <[email protected]>
[GTK] Move GObject DOM bindings to WebKit2 layer and stop auto generating them
Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (205281 => 205282)
--- trunk/Source/WebCore/platform/graphics/TextRun.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -45,7 +45,7 @@
class TextRun {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
+ explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = DefaultExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_text(text)
, m_charactersLength(text.length())
, m_tabSize(0)
Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (205281 => 205282)
--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -51,7 +51,7 @@
public:
static bool isNeeded(RenderText& text, const FontCascade& font)
{
- TextRun run = RenderBlock::constructTextRun(&text, text.style());
+ TextRun run = RenderBlock::constructTextRun(text, text.style());
return font.codePath(run) == FontCascade::Complex;
}
@@ -76,7 +76,7 @@
private:
static TextRun constructTextRun(RenderText& text, float xPos)
{
- TextRun run = RenderBlock::constructTextRun(&text, text.style());
+ TextRun run = RenderBlock::constructTextRun(text, text.style());
run.setCharactersLength(text.textLength());
ASSERT(run.charactersLength() >= run.length());
run.setXPos(xPos);
Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (205281 => 205282)
--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -42,6 +42,18 @@
kCTFontUIFontSystemUltraLight = 104,
};
+typedef CF_OPTIONS(uint32_t, CTFontTransformOptions)
+{
+ kCTFontTransformApplyShaping = (1 << 0),
+ kCTFontTransformApplyPositioning = (1 << 1)
+};
+
+typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions)
+{
+ kCTFontDescriptorOptionSystemUIFont = 1 << 1,
+ kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont
+};
+
#endif
extern "C" {
@@ -52,16 +64,7 @@
extern const CFStringRef kCTFontReferenceURLAttribute;
extern const CFStringRef kCTFontOpticalSizeAttribute;
-#if PLATFORM(COCOA)
-#if !USE(APPLE_INTERNAL_SDK)
-typedef CF_OPTIONS(uint32_t, CTFontTransformOptions)
-{
- kCTFontTransformApplyShaping = (1 << 0),
- kCTFontTransformApplyPositioning = (1 << 1)
-};
-#endif
bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions);
-#endif
CGSize CTRunGetInitialAdvance(CTRunRef run);
CTLineRef CTLineCreateWithUniCharProvider(CTUniCharProviderCallback provide, CTUniCharDisposeCallback dispose, void* refCon);
@@ -73,26 +76,15 @@
CTFontDescriptorRef CTFontDescriptorCreateCopyWithSymbolicTraits(CTFontDescriptorRef original, CTFontSymbolicTraits symTraitValue, CTFontSymbolicTraits symTraitMask);
CFBitVectorRef CTFontCopyGlyphCoverageForFeature(CTFontRef, CFDictionaryRef feature);
-#if PLATFORM(COCOA)
-#if !USE(APPLE_INTERNAL_SDK)
-typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions)
-{
- kCTFontDescriptorOptionSystemUIFont = 1 << 1,
- kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont
-};
-
CTFontDescriptorRef CTFontDescriptorCreateWithAttributesAndOptions(CFDictionaryRef attributes, CTFontDescriptorOptions);
extern const CFStringRef kCTFontDescriptorTextStyleAttribute;
extern const CFStringRef kCTFontUIFontDesignTrait;
-#endif
-#endif
bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
CTFontRef CTFontCreateForCSS(CFStringRef name, uint16_t weight, CTFontSymbolicTraits, CGFloat size);
CTFontRef CTFontCreateForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CFIndex *coveredLength);
-#if PLATFORM(COCOA)
extern const CFStringRef kCTUIFontTextStyleShortHeadline;
extern const CFStringRef kCTUIFontTextStyleShortBody;
extern const CFStringRef kCTUIFontTextStyleShortSubhead;
@@ -118,14 +110,11 @@
extern const CGFloat kCTFontWeightBold;
extern const CGFloat kCTFontWeightHeavy;
extern const CGFloat kCTFontWeightBlack;
-#endif
-#if PLATFORM(IOS)
extern const CFStringRef kCTUIFontTextStyleTitle1;
extern const CFStringRef kCTUIFontTextStyleTitle2;
extern const CFStringRef kCTUIFontTextStyleTitle3;
CTFontDescriptorRef CTFontCreatePhysicalFontDescriptorForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength);
-#endif
CTFontRef CTFontCreatePhysicalFontForCharactersWithLanguage(CTFontRef, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength);
bool CTFontIsAppleColorEmoji(CTFontRef);
Modified: trunk/Source/WebCore/platform/text/TextFlags.h (205281 => 205282)
--- trunk/Source/WebCore/platform/text/TextFlags.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/platform/text/TextFlags.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -52,6 +52,8 @@
AllowLeadingExpansion = 1 << 2,
ForceLeadingExpansion = 2 << 2,
LeadingExpansionMask = 3 << 2,
+
+ DefaultExpansion = AllowTrailingExpansion | ForbidLeadingExpansion,
};
typedef unsigned ExpansionBehavior;
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -3801,24 +3801,24 @@
return constructTextRun(StringView(string), style, expansion, flags);
}
-TextRun RenderBlock::constructTextRun(const RenderText* text, const RenderStyle& style, ExpansionBehavior expansion)
+TextRun RenderBlock::constructTextRun(const RenderText& text, const RenderStyle& style, ExpansionBehavior expansion)
{
- return constructTextRun(text->stringView(), style, expansion);
+ return constructTextRun(text.stringView(), style, expansion);
}
-TextRun RenderBlock::constructTextRun(const RenderText* text, unsigned offset, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
+TextRun RenderBlock::constructTextRun(const RenderText& text, unsigned offset, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
{
unsigned stop = offset + length;
- ASSERT(stop <= text->textLength());
- return constructTextRun(text->stringView(offset, stop), style, expansion);
+ ASSERT(stop <= text.textLength());
+ return constructTextRun(text.stringView(offset, stop), style, expansion);
}
-TextRun RenderBlock::constructTextRun(const LChar* characters, int length, const RenderStyle& style, ExpansionBehavior expansion)
+TextRun RenderBlock::constructTextRun(const LChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
{
return constructTextRun(StringView(characters, length), style, expansion);
}
-TextRun RenderBlock::constructTextRun(const UChar* characters, int length, const RenderStyle& style, ExpansionBehavior expansion)
+TextRun RenderBlock::constructTextRun(const UChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
{
return constructTextRun(StringView(characters, length), style, expansion);
}
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -204,17 +204,17 @@
}
static TextRun constructTextRun(StringView, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
+ ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
static TextRun constructTextRun(const String&, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
- static TextRun constructTextRun(const RenderText*, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);
- static TextRun constructTextRun(const RenderText*, unsigned offset, unsigned length, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);
- static TextRun constructTextRun(const LChar* characters, int length, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);
- static TextRun constructTextRun(const UChar* characters, int length, const RenderStyle&,
- ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);
+ ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
+ static TextRun constructTextRun(const RenderText&, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const RenderText&, unsigned offset, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const LChar* characters, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
+ static TextRun constructTextRun(const UChar* characters, unsigned length, const RenderStyle&,
+ ExpansionBehavior = DefaultExpansion);
LayoutUnit paginationStrut() const;
void setPaginationStrut(LayoutUnit);
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -1543,7 +1543,7 @@
break;
case Asterisks:
case Footnotes: {
- TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(m_text, style());
logicalWidth = font.width(run); // no suffix for these types
}
break;
@@ -1630,7 +1630,7 @@
if (m_text.isEmpty())
logicalWidth = 0;
else {
- TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(m_text, style());
LayoutUnit itemWidth = font.width(run);
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
LayoutUnit suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
@@ -1763,7 +1763,7 @@
case Asterisks:
case Footnotes: {
const FontCascade& font = style().fontCascade();
- TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(m_text, style());
relativeRect = FloatRect(0, 0, font.width(run), font.fontMetrics().height());
break;
}
@@ -1857,7 +1857,7 @@
if (m_text.isEmpty())
return FloatRect();
const FontCascade& font = style().fontCascade();
- TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(m_text, style());
float itemWidth = font.width(run);
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
float suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderMenuList.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -219,13 +219,13 @@
optionWidth += minimumValueForLength(optionStyle->textIndent(), 0);
if (!text.isEmpty()) {
const FontCascade& font = style().fontCascade();
- TextRun run = RenderBlock::constructTextRun(text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(text, style());
optionWidth += font.width(run);
}
maxOptionWidth = std::max(maxOptionWidth, optionWidth);
} else if (!text.isEmpty()) {
const FontCascade& font = style().fontCascade();
- TextRun run = RenderBlock::constructTextRun(text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(text, style());
maxOptionWidth = std::max(maxOptionWidth, font.width(run));
}
}
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -452,7 +452,7 @@
return box.root().computeCaretRect(left, caretWidth, extraWidthToEndOfLine);
}
-ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, int start, int len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
+ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
{
if (style.hasTextCombine() && is<RenderCombineText>(*this)) {
const RenderCombineText& combineText = downcast<RenderCombineText>(*this);
@@ -466,7 +466,7 @@
bool isSpace;
ASSERT(m_text);
StringImpl& text = *m_text.impl();
- for (int i = start; i < start + len; i++) {
+ for (unsigned i = start; i < start + len; i++) {
char c = text[i];
if (c <= ' ') {
if (c == ' ' || c == '\n') {
@@ -492,7 +492,7 @@
return w;
}
- TextRun run = RenderBlock::constructTextRun(this, start, len, style);
+ TextRun run = RenderBlock::constructTextRun(*this, start, len, style);
run.setCharactersLength(textLength() - start);
ASSERT(run.charactersLength() >= run.length());
@@ -608,7 +608,7 @@
beginWS = !stripFrontSpaces && m_hasBeginWS;
endWS = m_hasEndWS;
- int len = textLength();
+ unsigned len = textLength();
if (!len || (stripFrontSpaces && text()->containsOnlyWhitespace())) {
beginMinW = 0;
@@ -632,10 +632,9 @@
ASSERT(m_text);
StringImpl& text = *m_text.impl();
- if (text[0] == ' ' || (text[0] == '\n' && !style.preserveNewline()) || text[0] == '\t') {
+ if (text[0] == space || (text[0] == newlineCharacter && !style.preserveNewline()) || text[0] == '\t') {
const FontCascade& font = style.fontCascade(); // FIXME: This ignores first-line.
if (stripFrontSpaces) {
- const UChar space = ' ';
float spaceWidth = font.width(RenderBlock::constructTextRun(&space, 1, style));
maxW -= spaceWidth;
} else
@@ -653,8 +652,8 @@
bool firstLine = true;
beginMaxW = maxW;
endMaxW = maxW;
- for (int i = 0; i < len; i++) {
- int linelen = 0;
+ for (unsigned i = 0; i < len; i++) {
+ unsigned linelen = 0;
while (i + linelen < len && text[i + linelen] != '\n')
linelen++;
@@ -726,13 +725,14 @@
m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
-static inline float hyphenWidth(RenderText* renderer, const FontCascade& font)
+static inline float hyphenWidth(RenderText& renderer, const FontCascade& font)
{
- const RenderStyle& style = renderer->style();
- return font.width(RenderBlock::constructTextRun(style.hyphenString().string(), style));
+ const RenderStyle& style = renderer.style();
+ auto textRun = RenderBlock::constructTextRun(style.hyphenString().string(), style);
+ return font.width(textRun);
}
-static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style, const FontCascade& font, StringView word, int minimumPrefixLength, unsigned minimumSuffixLength, int& suffixStart, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow)
+static float maxWordFragmentWidth(RenderText& renderer, const RenderStyle& style, const FontCascade& font, StringView word, unsigned minimumPrefixLength, unsigned minimumSuffixLength, unsigned& suffixStart, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow)
{
suffixStart = 0;
if (word.length() <= minimumSuffixLength)
@@ -739,7 +739,8 @@
return 0;
Vector<int, 8> hyphenLocations;
- int hyphenLocation = word.length() - minimumSuffixLength;
+ ASSERT(word.length() >= minimumSuffixLength);
+ unsigned hyphenLocation = word.length() - minimumSuffixLength;
while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength)
hyphenLocations.append(hyphenLocation);
@@ -758,7 +759,7 @@
TextRun run = RenderBlock::constructTextRun(fragmentWithHyphen.toString(), style);
run.setCharactersLength(fragmentWithHyphen.length());
- run.setCharacterScanForCodePath(!renderer->canUseSimpleFontCodePath());
+ run.setCharacterScanForCodePath(!renderer.canUseSimpleFontCodePath());
float fragmentWidth = font.width(run, &fallbackFonts, &glyphOverflow);
// Narrow prefixes are ignored. See tryHyphenating in RenderBlockLineLayout.cpp.
@@ -807,19 +808,17 @@
// If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
// fragment) encountered so far, and only try hyphenating words that are wider.
float maxWordWidth = std::numeric_limits<float>::max();
- int minimumPrefixLength = 0;
- int minimumSuffixLength = 0;
+ unsigned minimumPrefixLength = 0;
+ unsigned minimumSuffixLength = 0;
if (style.hyphens() == HyphensAuto && canHyphenate(style.locale())) {
maxWordWidth = 0;
// Map 'hyphenate-limit-{before,after}: auto;' to 2.
- minimumPrefixLength = style.hyphenationLimitBefore();
- if (minimumPrefixLength < 0)
- minimumPrefixLength = 2;
+ auto before = style.hyphenationLimitBefore();
+ minimumPrefixLength = before < 0 ? 2 : before;
- minimumSuffixLength = style.hyphenationLimitAfter();
- if (minimumSuffixLength < 0)
- minimumSuffixLength = 2;
+ auto after = style.hyphenationLimitAfter();
+ minimumSuffixLength = after < 0 ? 2 : after;
}
Optional<int> firstGlyphLeftOverflow;
@@ -906,12 +905,12 @@
else {
w = widthFromCache(font, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
if (c == softHyphen && style.hyphens() != HyphensNone)
- currMinWidth = hyphenWidth(this, font);
+ currMinWidth = hyphenWidth(*this, font);
}
if (w > maxWordWidth) {
- int suffixStart;
- float maxFragmentWidth = maxWordFragmentWidth(this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
+ unsigned suffixStart;
+ float maxFragmentWidth = maxWordFragmentWidth(*this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
if (suffixStart) {
float suffixWidth;
@@ -985,7 +984,7 @@
m_maxWidth = currMaxWidth;
currMaxWidth = 0;
} else {
- TextRun run = RenderBlock::constructTextRun(this, i, 1, style);
+ TextRun run = RenderBlock::constructTextRun(*this, i, 1, style);
run.setCharactersLength(len - i);
ASSERT(run.charactersLength() >= run.length());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
@@ -1325,7 +1324,7 @@
} else
w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow, style);
} else {
- TextRun run = RenderBlock::constructTextRun(this, from, len, style);
+ TextRun run = RenderBlock::constructTextRun(*this, from, len, style);
run.setCharactersLength(textLength() - from);
ASSERT(run.charactersLength() >= run.length());
Modified: trunk/Source/WebCore/rendering/RenderText.h (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderText.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderText.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -196,7 +196,7 @@
bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) final { ASSERT_NOT_REACHED(); return false; }
- float widthFromCache(const FontCascade&, int start, int len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow*, const RenderStyle&) const;
+ float widthFromCache(const FontCascade&, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow*, const RenderStyle&) const;
bool isAllASCII() const { return m_isAllASCII; }
bool computeUseBackslashAsYenSymbol() const;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (205281 => 205282)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-09-01 07:37:19 UTC (rev 205282)
@@ -575,7 +575,7 @@
}
float measureText(const String& string) const override
{
- TextRun run = RenderBlock::constructTextRun(string, m_style, AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
+ TextRun run = RenderBlock::constructTextRun(string, m_style);
return m_font.width(run);
}
private:
Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (205281 => 205282)
--- trunk/Source/WebCore/rendering/line/BreakingContext.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -644,7 +644,7 @@
if (layout)
return FontCascade::width(*layout, from, len, &fallbackFonts);
- TextRun run = RenderBlock::constructTextRun(&text, from, len, style);
+ TextRun run = RenderBlock::constructTextRun(text, from, len, style);
run.setCharactersLength(text.textLength() - from);
ASSERT(run.charactersLength() >= run.length());
@@ -693,7 +693,7 @@
return;
const RenderStyle& style = text.style();
- TextRun run = RenderBlock::constructTextRun(&text, lastSpace, pos - lastSpace, style);
+ TextRun run = RenderBlock::constructTextRun(text, lastSpace, pos - lastSpace, style);
run.setCharactersLength(text.textLength() - lastSpace);
ASSERT(run.charactersLength() >= run.length());
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (205281 => 205282)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp 2016-09-01 07:37:19 UTC (rev 205282)
@@ -88,7 +88,7 @@
float scalingFactor = renderer().scalingFactor();
ASSERT(scalingFactor);
- TextRun textRun = constructTextRun(&renderer().style(), fragment);
+ TextRun textRun = constructTextRun(renderer().style(), fragment);
// Eventually handle lengthAdjust="spacingAndGlyphs".
// FIXME: Handle vertical text.
@@ -107,10 +107,9 @@
return 0;
}
-FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle* style) const
+FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle& style) const
{
ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition);
- ASSERT(style);
float scalingFactor = renderer().scalingFactor();
ASSERT(scalingFactor);
@@ -157,7 +156,7 @@
if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition))
continue;
- FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);
+ FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style);
fragment.buildFragmentTransform(fragmentTransform);
if (!fragmentTransform.isIdentity())
fragmentRect = fragmentTransform.mapRect(fragmentRect);
@@ -225,7 +224,7 @@
paintInfo.context().concatCTM(fragmentTransform);
paintInfo.context().setFillColor(backgroundColor);
- paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style), backgroundColor);
+ paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style), backgroundColor);
m_paintingResourceMode = ApplyToDefaultMode;
}
@@ -306,13 +305,15 @@
if (!hasFill)
continue;
m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode;
- paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
+ ASSERT(selectionStyle);
+ paintText(paintInfo.context(), style, *selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
break;
case PaintTypeStroke:
if (!hasVisibleStroke)
continue;
m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
- paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
+ ASSERT(selectionStyle);
+ paintText(paintInfo.context(), style, *selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
break;
case PaintTypeMarkers:
continue;
@@ -333,17 +334,16 @@
ASSERT(!m_paintingResource);
}
-bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle* style)
+bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle& style)
{
ASSERT(scalingFactor);
- ASSERT(style);
ASSERT(m_paintingResourceMode != ApplyToDefaultMode);
Color fallbackColor;
if (m_paintingResourceMode & ApplyToFillMode)
- m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, *style, fallbackColor);
+ m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, style, fallbackColor);
else if (m_paintingResourceMode & ApplyToStrokeMode)
- m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, *style, fallbackColor);
+ m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, style, fallbackColor);
else {
// We're either called for stroking or filling.
ASSERT_NOT_REACHED();
@@ -352,13 +352,13 @@
if (!m_paintingResource)
return false;
- if (!m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode)) {
+ if (!m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode)) {
if (fallbackColor.isValid()) {
RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
fallbackResource->setColor(fallbackColor);
m_paintingResource = fallbackResource;
- m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode);
+ m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode);
}
}
@@ -376,7 +376,7 @@
m_paintingResource = nullptr;
}
-bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle* style)
+bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle& style)
{
return acquirePaintingResource(context, scalingFactor, parent()->renderer(), style);
}
@@ -386,16 +386,14 @@
releasePaintingResource(context, /* path */nullptr);
}
-TextRun SVGInlineTextBox::constructTextRun(const RenderStyle* style, const SVGTextFragment& fragment) const
+TextRun SVGInlineTextBox::constructTextRun(const RenderStyle& style, const SVGTextFragment& fragment) const
{
- ASSERT(style);
-
TextRun run(StringView(renderer().text()).substring(fragment.characterOffset, fragment.length)
, 0 /* xPos, only relevant with allowTabs=true */
, 0 /* padding, only relevant for justified text, not relevant for SVG */
, AllowTrailingExpansion
, direction()
- , dirOverride() || style->rtlOrdering() == VisualOrder /* directionalOverride */);
+ , dirOverride() || style.rtlOrdering() == VisualOrder /* directionalOverride */);
// We handle letter & word spacing ourselves.
run.disableSpacing();
@@ -538,17 +536,17 @@
path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness)));
GraphicsContext* contextPtr = &context;
- if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, &decorationStyle))
+ if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, decorationStyle))
releasePaintingResource(contextPtr, &path);
}
-void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition)
+void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle& style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition)
{
float scalingFactor = renderer().scalingFactor();
ASSERT(scalingFactor);
const FontCascade& scaledFont = renderer().scaledFont();
- const ShadowData* shadow = style->textShadow();
+ const ShadowData* shadow = style.textShadow();
FloatPoint textOrigin(fragment.x, fragment.y);
FloatSize textSize(fragment.width, fragment.height);
@@ -587,11 +585,8 @@
} while (shadow);
}
-void SVGInlineTextBox::paintText(GraphicsContext& context, const RenderStyle* style, const RenderStyle* selectionStyle, const SVGTextFragment& fragment, bool hasSelection, bool paintSelectedTextOnly)
+void SVGInlineTextBox::paintText(GraphicsContext& context, const RenderStyle& style, const RenderStyle& selectionStyle, const SVGTextFragment& fragment, bool hasSelection, bool paintSelectedTextOnly)
{
- ASSERT(style);
- ASSERT(selectionStyle);
-
unsigned startPosition = 0;
unsigned endPosition = 0;
if (hasSelection) {
@@ -612,12 +607,12 @@
// Draw text using selection style from the start to the end position of the selection
if (style != selectionStyle)
- SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *selectionStyle);
+ SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, selectionStyle);
paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition);
if (style != selectionStyle)
- SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *style);
+ SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, style);
// Eventually draw text using regular style from the end position of the selection to the end of the current chunk part
if (endPosition < fragment.length && !paintSelectedTextOnly)
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h (205281 => 205282)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2016-09-01 07:37:19 UTC (rev 205282)
@@ -64,23 +64,23 @@
void setStartsNewTextChunk(bool newTextChunk) { m_startsNewTextChunk = newTextChunk; }
int offsetForPositionInFragment(const SVGTextFragment&, float position, bool includePartialGlyphs) const;
- FloatRect selectionRectForTextFragment(const SVGTextFragment&, unsigned fragmentStartPosition, unsigned fragmentEndPosition, const RenderStyle*) const;
+ FloatRect selectionRectForTextFragment(const SVGTextFragment&, unsigned fragmentStartPosition, unsigned fragmentEndPosition, const RenderStyle&) const;
private:
bool isSVGInlineTextBox() const override { return true; }
- TextRun constructTextRun(const RenderStyle*, const SVGTextFragment&) const;
+ TextRun constructTextRun(const RenderStyle&, const SVGTextFragment&) const;
- bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle*);
+ bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle&);
void releasePaintingResource(GraphicsContext*&, const Path*);
- bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle*);
+ bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle&);
void restoreGraphicsContextAfterTextPainting(GraphicsContext*&);
void paintDecoration(GraphicsContext&, TextDecoration, const SVGTextFragment&);
void paintDecorationWithStyle(GraphicsContext&, TextDecoration, const SVGTextFragment&, RenderBoxModelObject& decorationRenderer);
- void paintTextWithShadows(GraphicsContext&, const RenderStyle*, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition);
- void paintText(GraphicsContext&, const RenderStyle*, const RenderStyle* selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly);
+ void paintTextWithShadows(GraphicsContext&, const RenderStyle&, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition);
+ void paintText(GraphicsContext&, const RenderStyle&, const RenderStyle& selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly);
bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
Modified: trunk/Source/WebKit/mac/ChangeLog (205281 => 205282)
--- trunk/Source/WebKit/mac/ChangeLog 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-09-01 07:37:19 UTC (rev 205282)
@@ -1,3 +1,15 @@
+2016-09-01 Myles C. Maxfield <[email protected]>
+
+ Clean up TextRun-related code
+ https://bugs.webkit.org/show_bug.cgi?id=161473
+
+ Reviewed by Simon Fraser.
+
+ Remove unused #includes.
+
+ * WebCoreSupport/WebDragClient.mm:
+ * WebView/WebView.mm:
+
2016-08-31 Keith Rollin <[email protected]>
WebKit should set a subsystem for os_log so it's easier to filter for WebKit log messages
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (205281 => 205282)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm 2016-09-01 07:37:19 UTC (rev 205282)
@@ -38,7 +38,6 @@
#import "WebKitNSStringExtras.h"
#import "WebNSPasteboardExtras.h"
#import "WebNSURLExtras.h"
-#import "WebStringTruncator.h"
#import "WebUIDelegate.h"
#import "WebUIDelegatePrivate.h"
#import "WebViewInternal.h"
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (205281 => 205282)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2016-09-01 07:31:42 UTC (rev 205281)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2016-09-01 07:37:19 UTC (rev 205282)
@@ -261,7 +261,6 @@
#import <WebCore/ResourceLoadStatisticsStore.h>
#import <WebCore/SQLiteDatabaseTracker.h>
#import <WebCore/SmartReplace.h>
-#import <WebCore/TextRun.h>
#import <WebCore/TileControllerMemoryHandlerIOS.h>
#import <WebCore/WAKWindow.h>
#import <WebCore/WKView.h>