Changeset 183996 in webkit
- Timestamp:
- May 8, 2015, 10:18:00 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/text/StringView.h (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSPrimitiveValue.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/StringTruncator.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/TextRun.h (modified) (2 diffs)
-
Source/WebCore/platform/mac/DragImageMac.mm (modified) (2 diffs)
-
Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (modified) (2 diffs)
-
Source/WebCore/rendering/TextPainter.cpp (modified) (2 diffs)
-
Source/WebKit/mac/ChangeLog (modified) (1 diff)
-
Source/WebKit/mac/Misc/WebKitNSStringExtras.mm (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r183988 r183996 1 2015-05-08 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Remove convenience constructors for TextRun 4 https://bugs.webkit.org/show_bug.cgi?id=144752 5 6 Reviewed by Anders Carlsson. 7 8 No reason why StringView shouldn't have a StringImpl* constructor. 9 10 Test: StringView8Bit in TestWebKitAPI 11 12 * wtf/text/StringView.h: Add the constructor. 13 1 14 2015-05-08 Andreas Kling <akling@apple.com> 2 15 -
trunk/Source/WTF/wtf/text/StringView.h
r181845 r183996 59 59 StringView(const String&); 60 60 StringView(const StringImpl&); 61 StringView(const StringImpl*); 61 62 StringView(const LChar*, unsigned length); 62 63 StringView(const UChar*, unsigned length); … … 270 271 else 271 272 initialize(string.characters16(), string.length()); 273 } 274 275 inline StringView::StringView(const StringImpl* string) 276 { 277 if (!string) 278 return; 279 280 setUnderlyingString(string); 281 if (string->is8Bit()) 282 initialize(string->characters8(), string->length()); 283 else 284 initialize(string->characters16(), string->length()); 272 285 } 273 286 -
trunk/Source/WebCore/ChangeLog
r183991 r183996 1 2015-05-08 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Remove convenience constructors for TextRun 4 https://bugs.webkit.org/show_bug.cgi?id=144752 5 6 These convenience constructors are unnecessary. Moving the code that makes the StringView 7 back to the call site will also help us make things more elegant in future refactoring. 8 9 Reviewed by Darin Adler. 10 11 No new tests because there is no behavior change. 12 13 * css/CSSPrimitiveValue.cpp: 14 (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): Remove ambiguous call. 15 * platform/graphics/StringTruncator.cpp: 16 (WebCore::stringWidth): 17 * platform/graphics/TextRun.h: 18 (WebCore::TextRun::TextRun): 19 * platform/mac/DragImageMac.mm: 20 (WebCore::widthWithFont): 21 (WebCore::drawAtPoint): 22 * rendering/SimpleLineLayout.cpp: 23 (WebCore::SimpleLineLayout::canUseFor): 24 * rendering/SimpleLineLayoutTextFragmentIterator.cpp: 25 (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style): 26 (WebCore::SimpleLineLayout::TextFragmentIterator::runWidth): 27 * rendering/TextPainter.cpp: 28 (WebCore::TextPainter::paintText): 29 1 30 2015-05-08 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr> 2 31 -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r182354 r183996 1052 1052 result.reserveCapacity(6 + m_value.string->length()); 1053 1053 result.appendLiteral("attr("); 1054 result.append( m_value.string);1054 result.append(String(m_value.string)); 1055 1055 result.append(')'); 1056 1056 -
trunk/Source/WebCore/platform/graphics/StringTruncator.cpp
r178510 r183996 195 195 static float stringWidth(const FontCascade& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks) 196 196 { 197 TextRun run( characters, length);197 TextRun run(StringView(characters, length)); 198 198 if (disableRoundingHacks) 199 199 run.disableRoundingHacks(); -
trunk/Source/WebCore/platform/graphics/TextRun.h
r183904 r183996 53 53 typedef unsigned RoundingHacks; 54 54 55 explicit TextRun(StringView s, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)56 : m_text( s)57 , m_charactersLength( s.length())55 explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding) 56 : m_text(text) 57 , m_charactersLength(text.length()) 58 58 , m_tabSize(0) 59 59 , m_xpos(xpos) … … 68 68 , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks) 69 69 , m_disableSpacing(false) 70 {71 }72 73 explicit TextRun(const String& s)74 : TextRun(StringView(s))75 {76 }77 78 TextRun(const LChar* c, unsigned len)79 : TextRun(StringView(c, len))80 {81 }82 83 TextRun(const UChar* c, unsigned len)84 : TextRun(StringView(c, len))85 70 { 86 71 } -
trunk/Source/WebCore/platform/mac/DragImageMac.mm
r183269 r183996 193 193 if (canUseFastRenderer(buffer.data(), length)) { 194 194 FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize])); 195 TextRun run( buffer.data(), length);195 TextRun run(StringView(buffer.data(), length)); 196 196 run.disableRoundingHacks(); 197 197 return webCoreFont.width(run); … … 225 225 226 226 FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]), Antialiased); 227 TextRun run( buffer.data(), length);227 TextRun run(StringView(buffer.data(), length)); 228 228 run.disableRoundingHacks(); 229 229 -
trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp
r183576 r183996 41 41 , wrapLines(style.autoWrap()) 42 42 , breakWordOnOverflow(style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline)) 43 , spaceWidth(font.width(TextRun( &space, 1)))43 , spaceWidth(font.width(TextRun(StringView(&space, 1)))) 44 44 , tabWidth(collapseWhitespace ? 0 : style.tabSize()) 45 45 , locale(style.locale()) … … 198 198 if (measureWithEndSpace) 199 199 ++segmentTo; 200 TextRun run( segment.text.characters<CharacterType>() + segmentFrom, segmentTo - segmentFrom);200 TextRun run(StringView(segment.text.substring(segmentFrom, segmentTo - segmentFrom))); 201 201 run.setXPos(xPosition); 202 202 run.setTabSize(!!m_style.tabWidth, m_style.tabWidth); -
trunk/Source/WebCore/rendering/TextPainter.cpp
r178510 r183996 171 171 updateGraphicsContext(m_context, m_textPaintStyle, UseEmphasisMarkColor); 172 172 173 static NeverDestroyed<TextRun> objectReplacementCharacterTextRun( &objectReplacementCharacter, 1);173 static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(StringView(&objectReplacementCharacter, 1)); 174 174 TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : m_textRun; 175 175 FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin; … … 197 197 updateGraphicsContext(m_context, m_selectionPaintStyle, UseEmphasisMarkColor); 198 198 199 DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, ( &objectReplacementCharacter, 1));199 DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (StringView(&objectReplacementCharacter, 1))); 200 200 TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun : m_textRun; 201 201 FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin; -
trunk/Source/WebKit/mac/ChangeLog
r183976 r183996 1 2015-05-08 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Remove convenience constructors for TextRun 4 https://bugs.webkit.org/show_bug.cgi?id=144752 5 6 These convenience constructors are unnecessary. Moving the code that makes the StringView 7 back to the call site will also help us make things more elegant in future refactoring. 8 9 Reviewed by Darin Adler. 10 11 No new tests because there is no behavior change. 12 13 * Misc/WebKitNSStringExtras.mm: 14 (-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]): 15 (-[NSString _web_widthWithFont:]): 16 1 17 2015-05-07 Anders Carlsson <andersca@apple.com> 2 18 -
trunk/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm
r183269 r183996 94 94 95 95 FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]), fontSmoothingIsAllowed ? AutoSmoothing : Antialiased); 96 TextRun run( buffer.data(), length);96 TextRun run(StringView(buffer.data(), length)); 97 97 run.disableRoundingHacks(); 98 98 … … 140 140 if (canUseFastRenderer(buffer.data(), length)) { 141 141 FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize])); 142 TextRun run( buffer.data(), length);142 TextRun run(StringView(buffer.data(), length)); 143 143 run.disableRoundingHacks(); 144 144 return webCoreFont.width(run); -
trunk/Tools/ChangeLog
r183995 r183996 1 2015-05-08 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Remove convenience constructors for TextRun 4 https://bugs.webkit.org/show_bug.cgi?id=144752 5 6 Reviewed by Anders Carlsson. 7 8 Test the StringView which takes a StringImpl*. 9 10 * TestWebKitAPI/Tests/WTF/StringView.cpp: 11 (StringView8Bit): Testing is8Bit() on StringView 12 1 13 2015-05-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
r181845 r183996 698 698 } 699 699 700 TEST(WTF, StringView8Bit) 701 { 702 StringView nullView; 703 StringView emptyView = StringView::empty(); 704 EXPECT_TRUE(StringView().is8Bit()); 705 EXPECT_TRUE(StringView::empty().is8Bit()); 706 707 LChar* lcharPtr = nullptr; 708 UChar* ucharPtr = nullptr; 709 EXPECT_TRUE(StringView(lcharPtr, 0).is8Bit()); 710 EXPECT_FALSE(StringView(ucharPtr, 0).is8Bit()); 711 712 EXPECT_TRUE(StringView(String(lcharPtr, 0)).is8Bit()); 713 EXPECT_TRUE(StringView(String(ucharPtr, 0)).is8Bit()); 714 715 EXPECT_TRUE(StringView(String().impl()).is8Bit()); 716 EXPECT_TRUE(StringView(emptyString().impl()).is8Bit()); 717 } 718 700 719 } // namespace TestWebKitAPI
Note:
See TracChangeset
for help on using the changeset viewer.