Diff
Modified: trunk/Source/WebCore/ChangeLog (166062 => 166063)
--- trunk/Source/WebCore/ChangeLog 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/ChangeLog 2014-03-21 15:22:45 UTC (rev 166063)
@@ -1,3 +1,37 @@
+2014-03-21 Darin Adler <[email protected]>
+
+ Stop using deprecatedCharacters in WebCore/platform/win
+ https://bugs.webkit.org/show_bug.cgi?id=130515
+
+ Reviewed by Brent Fulgham.
+
+ * platform/graphics/TextRun.h:
+ (WebCore::TextRun::TextRun): Add a constructor that takes a StringView.
+ Later, we might want to exclusively use the StringView version and remove
+ some of the others.
+ (WebCore::TextRun::setText): Add a version of this function that takes a StringView.
+
+ * platform/graphics/win/FontCacheWin.cpp:
+ (WebCore::FontCache::systemFallbackForCharacters): Use StringView::getCharactersWithUpconvert.
+ (WebCore::createGDIFont): Ditto.
+ (WebCore::FontCache::getTraitsInFamily): Ditto.
+ * platform/win/BString.cpp:
+ (WebCore::BString::BString): Use StringView::upconvertedCharacters.
+ * platform/win/ClipboardUtilitiesWin.cpp:
+ (WebCore::createGlobalData): Use StringView::getCharactersWithUpconvert.
+ * platform/win/FileSystemWin.cpp:
+ (WebCore::pathByAppendingComponent): Use StringBuilder and StringView::getCharactersWithUpconvert.
+ (WebCore::fileSystemRepresentation): Use StringView::upconvertedCharacters.
+ * platform/win/PasteboardWin.cpp:
+ (WebCore::filesystemPathFromUrlOrTitle): Use StringView::getCharactersWithUpconvert.
+ (WebCore::Pasteboard::writeURLToDataObject): Ditto.
+ (WebCore::createGlobalImageFileDescriptor): Ditto.
+
+ * platform/win/PopupMenuWin.cpp:
+ (WebCore::PopupMenuWin::calculatePositionAndSize): Use the new TextRun constructor.
+ * platform/win/WebCoreTextRenderer.cpp:
+ (WebCore::doDrawTextAtPoint): Ditto.
+
2014-03-21 Zalan Bujtas <[email protected]>
Subpixel rendering: RenderBox is positioned off by one when non-compositing transform is present.
Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (166062 => 166063)
--- trunk/Source/WebCore/platform/graphics/TextRun.h 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h 2014-03-21 15:22:45 UTC (rev 166063)
@@ -26,7 +26,7 @@
#include "TextDirection.h"
#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
namespace WebCore {
@@ -37,6 +37,7 @@
class GlyphBuffer;
class GlyphToPathTranslator;
class SimpleFontData;
+
struct GlyphData;
struct WidthIterator;
@@ -125,6 +126,29 @@
}
}
+ 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)
+ : m_charactersLength(s.length())
+ , m_len(s.length())
+ , m_xpos(xpos)
+ , m_horizontalGlyphStretch(1)
+ , m_expansion(expansion)
+ , m_expansionBehavior(expansionBehavior)
+ , m_is8Bit(s.is8Bit())
+ , m_allowTabs(false)
+ , m_direction(direction)
+ , m_directionalOverride(directionalOverride)
+ , m_characterScanForCodePath(characterScanForCodePath)
+ , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
+ , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
+ , m_disableSpacing(false)
+ , m_tabSize(0)
+ {
+ if (s.is8Bit())
+ m_data.characters8 = s.characters8();
+ else
+ m_data.characters16 = s.characters16();
+ }
+
TextRun subRun(unsigned startOffset, unsigned length) const
{
ASSERT_WITH_SECURITY_IMPLICATION(startOffset < m_len);
@@ -158,6 +182,7 @@
void setText(const LChar* c, unsigned len) { m_data.characters8 = c; m_len = len; m_is8Bit = true;}
void setText(const UChar* c, unsigned len) { m_data.characters16 = c; m_len = len; m_is8Bit = false;}
+ void setText(StringView);
void setCharactersLength(unsigned charactersLength) { m_charactersLength = charactersLength; }
float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; }
@@ -242,6 +267,16 @@
m_tabSize = size;
}
+inline void TextRun::setText(StringView string)
+{
+ m_len = string.length();
+ m_is8Bit = string.is8Bit();
+ if (string.is8Bit())
+ m_data.characters8 = string.characters8();
+ else
+ m_data.characters16 = string.characters16();
}
+}
+
#endif
Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -36,7 +36,9 @@
#include <windows.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringHash.h>
+#include <wtf/text/StringView.h>
#include <wtf/win/GDIObject.h>
+
#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
@@ -276,7 +278,7 @@
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
- memcpy(logFont.lfFaceName, linkedFonts->at(linkedFontIndex).deprecatedCharacters(), linkedFonts->at(linkedFontIndex).length() * sizeof(WCHAR));
+ StringView(linkedFonts->at(linkedFontIndex)).getCharactersWithUpconvert(logFont.lfFaceName);
logFont.lfFaceName[linkedFonts->at(linkedFontIndex).length()] = 0;
EnumFontFamiliesEx(hdc, &logFont, linkedFontEnumProc, reinterpret_cast<LPARAM>(&hfont), 0);
linkedFontIndex++;
@@ -446,9 +448,9 @@
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(family.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, family.string().deprecatedCharacters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
+ StringView truncatedFamily = StringView(family).substring(0, static_cast<unsigned>(LF_FACESIZE - 1));
+ truncatedFamily.getCharactersWithUpconvert(logFont.lfFaceName);
+ logFont.lfFaceName[truncatedFamily.length()] = 0;
logFont.lfPitchAndFamily = 0;
MatchImprovingProcData matchData(desiredWeight, desiredItalic);
@@ -528,9 +530,9 @@
LOGFONT logFont;
logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, familyName.string().deprecatedCharacters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
+ StringView truncatedFamily = StringView(familyName).substring(0, static_cast<unsigned>(LF_FACESIZE - 1));
+ truncatedFamily.getCharactersWithUpconvert(logFont.lfFaceName);
+ logFont.lfFaceName[truncatedFamily.length()] = 0;
logFont.lfPitchAndFamily = 0;
TraitsInFamilyProcData procData(familyName);
@@ -587,4 +589,3 @@
}
}
-
Modified: trunk/Source/WebCore/platform/win/BString.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/BString.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/BString.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -29,7 +29,7 @@
#include "URL.h"
#include <windows.h>
#include <wtf/text/AtomicString.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringView.h>
#if USE(CF)
#include <CoreFoundation/CoreFoundation.h>
@@ -65,7 +65,7 @@
if (s.isNull())
m_bstr = 0;
else
- m_bstr = SysAllocStringLen(s.deprecatedCharacters(), s.length());
+ m_bstr = SysAllocStringLen(StringView(s).upconvertedCharacters(), s.length());
}
BString::BString(const URL& url)
@@ -73,7 +73,7 @@
if (url.isNull())
m_bstr = 0;
else
- m_bstr = SysAllocStringLen(url.string().deprecatedCharacters(), url.string().length());
+ m_bstr = SysAllocStringLen(StringView(url.string()).upconvertedCharacters(), url.string().length());
}
BString::BString(const AtomicString& s)
@@ -81,7 +81,7 @@
if (s.isNull())
m_bstr = 0;
else
- m_bstr = SysAllocStringLen(s.string().deprecatedCharacters(), s.length());
+ m_bstr = SysAllocStringLen(StringView(s.string()).upconvertedCharacters(), s.length());
}
#if USE(CF)
Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -35,7 +35,6 @@
#include <wtf/StringExtras.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
#if !OS(WINCE)
#include <shlwapi.h>
@@ -194,7 +193,7 @@
if (!vm)
return 0;
UChar* buffer = static_cast<UChar*>(GlobalLock(vm));
- memcpy(buffer, str.deprecatedCharacters(), str.length() * sizeof(UChar));
+ StringView(str).getCharactersWithUpconvert(buffer);
buffer[str.length()] = 0;
GlobalUnlock(vm);
return vm;
Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -36,7 +36,7 @@
#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringBuilder.h>
#include <windows.h>
#include <shlobj.h>
@@ -156,39 +156,43 @@
String pathByAppendingComponent(const String& path, const String& component)
{
- Vector<UChar> buffer(MAX_PATH);
-
#if OS(WINCE)
- buffer.append(path.deprecatedCharacters(), path.length());
+ StringBuilder builder;
+ builder.append(path);
+
UChar lastPathCharacter = path[path.length() - 1];
if (lastPathCharacter != L'\\' && lastPathCharacter != L'/' && component[0] != L'\\' && component[0] != L'/')
- buffer.append(PlatformFilePathSeparator);
+ builder.append(PlatformFilePathSeparator);
- buffer.append(component.deprecatedCharacters(), component.length());
- buffer.shrinkToFit();
+ builder.append(component);
+
+ return builder.toString();
#else
+ Vector<UChar> buffer(MAX_PATH);
+
if (path.length() + 1 > buffer.size())
return String();
- memcpy(buffer.data(), path.deprecatedCharacters(), path.length() * sizeof(UChar));
+ StringView(path).getCharactersWithUpconvert(buffer.data());
buffer[path.length()] = '\0';
- String componentCopy = component;
- if (!PathAppendW(buffer.data(), componentCopy.charactersWithNullTermination().data()))
+ if (!PathAppendW(buffer.data(), component.charactersWithNullTermination().data()))
return String();
- buffer.resize(wcslen(buffer.data()));
-#endif
+ buffer.shrink(wcslen(buffer.data()));
return String::adopt(buffer);
+#endif
}
#if !USE(CF)
CString fileSystemRepresentation(const String& path)
{
- const UChar* characters = path.deprecatedCharacters();
+ auto upconvertedCharacters = path.upconvertedCharacters();
+
+ const UChar* characters = upconvertedCharacters;
int size = WideCharToMultiByte(CP_ACP, 0, characters, path.length(), 0, 0, 0, 0) - 1;
char* buffer;
Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -51,6 +51,7 @@
#include "markup.h"
#include <wtf/WindowsExtras.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
#include <wtf/win/GDIObject.h>
namespace WebCore {
@@ -558,7 +559,7 @@
if (!title.isEmpty()) {
size_t len = std::min<size_t>(title.length(), fsPathMaxLengthExcludingExtension);
- CopyMemory(fsPathBuffer, title.deprecatedCharacters(), len * sizeof(UChar));
+ StringView(title).substring(0, len).getCharactersWithUpconvert(fsPathBuffer);
fsPathBuffer[len] = 0;
pathRemoveBadFSCharacters(fsPathBuffer, len);
}
@@ -573,10 +574,10 @@
String lastComponent = kurl.lastPathComponent();
if (kurl.isLocalFile() || (!isLink && !lastComponent.isEmpty())) {
len = std::min<DWORD>(fsPathMaxLengthExcludingExtension, lastComponent.length());
- CopyMemory(fsPathBuffer, lastComponent.deprecatedCharacters(), len * sizeof(UChar));
+ StringView(lastComponent).substring(0, len).getCharactersWithUpconvert(fsPathBuffer);
} else {
len = std::min<DWORD>(fsPathMaxLengthExcludingExtension, url.length());
- CopyMemory(fsPathBuffer, url.deprecatedCharacters(), len * sizeof(UChar));
+ StringView(url).substring(0, len).getCharactersWithUpconvert(fsPathBuffer);
}
fsPathBuffer[len] = 0;
pathRemoveBadFSCharacters(fsPathBuffer, len);
@@ -672,7 +673,7 @@
fgd->fgd[0].nFileSizeLow = content.length();
unsigned maxSize = std::min<unsigned>(fsPath.length(), WTF_ARRAY_LENGTH(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, fsPath.deprecatedCharacters(), maxSize * sizeof(UChar));
+ StringView(fsPath).substring(0, maxSize).getCharactersWithUpconvert(fgd->fgd[0].cFileName);
GlobalUnlock(urlFileDescriptor);
char* fileContents = static_cast<char*>(GlobalLock(urlFileContent));
@@ -907,7 +908,7 @@
}
int maxSize = std::min<int>(fsPath.length(), WTF_ARRAY_LENGTH(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, (LPCWSTR)fsPath.deprecatedCharacters(), maxSize * sizeof(UChar));
+ StringView(fsPath).substring(0, maxSize).getCharactersWithUpconvert(fgd->fgd[0].cFileName);
GlobalUnlock(memObj);
return memObj;
Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -351,7 +351,7 @@
itemFont.update(m_popupClient->fontSelector());
}
- popupWidth = std::max(popupWidth, static_cast<int>(ceilf(itemFont.width(TextRun(text.deprecatedCharacters(), text.length())))));
+ popupWidth = std::max(popupWidth, static_cast<int>(ceilf(itemFont.width(TextRun(text)))));
}
if (naturalHeight > maxPopupHeight)
Modified: trunk/Source/WebCore/platform/win/WebCoreTextRenderer.cpp (166062 => 166063)
--- trunk/Source/WebCore/platform/win/WebCoreTextRenderer.cpp 2014-03-21 14:49:34 UTC (rev 166062)
+++ trunk/Source/WebCore/platform/win/WebCoreTextRenderer.cpp 2014-03-21 15:22:45 UTC (rev 166063)
@@ -50,7 +50,7 @@
{
FontCachePurgePreventer fontCachePurgePreventer;
- TextRun run(text.deprecatedCharacters(), text.length());
+ TextRun run(text);
context.setFillColor(color, ColorSpaceDeviceRGB);
if (isOneLeftToRightRun(run))
@@ -63,12 +63,12 @@
int beforeWidth;
if (underlinedIndex > 0) {
- TextRun beforeRun(text.deprecatedCharacters(), underlinedIndex);
+ TextRun beforeRun(StringView(text).substring(0, underlinedIndex));
beforeWidth = font.width(beforeRun);
} else
beforeWidth = 0;
- TextRun underlinedRun(text.deprecatedCharacters() + underlinedIndex, 1);
+ TextRun underlinedRun(StringView(text).substring(underlinedIndex, 1));
int underlinedWidth = font.width(underlinedRun);
IntPoint underlinePoint(point);