Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp

Issue 399062: For the 249 branch:... (Closed) Base URL: svn://chrome-svn/chrome/branches/249/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Computer, Inc. 2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 24 matching lines...) Expand all
35 #if PLATFORM(WIN_OS) 35 #if PLATFORM(WIN_OS)
36 #include "Base64.h" 36 #include "Base64.h"
37 #include "ChromiumBridge.h" 37 #include "ChromiumBridge.h"
38 #include "OpenTypeUtilities.h" 38 #include "OpenTypeUtilities.h"
39 #elif PLATFORM(LINUX) 39 #elif PLATFORM(LINUX)
40 #include "SkStream.h" 40 #include "SkStream.h"
41 #endif 41 #endif
42 42
43 #include "FontPlatformData.h" 43 #include "FontPlatformData.h"
44 #include "NotImplemented.h" 44 #include "NotImplemented.h"
45 #include "OpenTypeSanitizer.h"
45 #include "SharedBuffer.h" 46 #include "SharedBuffer.h"
46 47
47 #if PLATFORM(WIN_OS) 48 #if PLATFORM(WIN_OS)
48 #include <objbase.h> 49 #include <objbase.h>
49 #elif PLATFORM(LINUX) 50 #elif PLATFORM(LINUX)
50 #include <cstring> 51 #include <cstring>
51 #endif 52 #endif
52 53
53 namespace WebCore { 54 namespace WebCore {
54 55
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 private: 165 private:
165 RefPtr<SharedBuffer> m_buffer; 166 RefPtr<SharedBuffer> m_buffer;
166 size_t m_offset; 167 size_t m_offset;
167 }; 168 };
168 #endif 169 #endif
169 170
170 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) 171 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
171 { 172 {
172 ASSERT_ARG(buffer, buffer); 173 ASSERT_ARG(buffer, buffer);
173 174
175 #if ENABLE(OPENTYPE_SANITIZER)
176 OpenTypeSanitizer sanitizer(buffer);
177 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
178 if (!transcodeBuffer)
179 return 0; // validation failed.
180 buffer = transcodeBuffer.get();
181 #endif
182
174 #if PLATFORM(WIN_OS) 183 #if PLATFORM(WIN_OS)
175 // Introduce the font to GDI. AddFontMemResourceEx should be used with care, because it will pollute the process's 184 // Introduce the font to GDI. AddFontMemResourceEx should be used with care, because it will pollute the process's
176 // font namespace (Windows has no API for creating an HFONT from data withou t exposing the font to the 185 // font namespace (Windows has no API for creating an HFONT from data withou t exposing the font to the
177 // entire process first). 186 // entire process first).
178 String fontName = createUniqueFontName(); 187 String fontName = createUniqueFontName();
179 HANDLE fontReference = renameAndActivateFont(buffer, fontName); 188 HANDLE fontReference = renameAndActivateFont(buffer, fontName);
180 if (!fontReference) 189 if (!fontReference)
181 return 0; 190 return 0;
182 return new FontCustomPlatformData(fontReference, fontName); 191 return new FontCustomPlatformData(fontReference, fontName);
183 #elif PLATFORM(LINUX) 192 #elif PLATFORM(LINUX)
184 RemoteFontStream stream(buffer); 193 RemoteFontStream stream(buffer);
185 SkTypeface* typeface = SkTypeface::CreateFromStream(&stream); 194 SkTypeface* typeface = SkTypeface::CreateFromStream(&stream);
186 if (!typeface) 195 if (!typeface)
187 return 0; 196 return 0;
188 return new FontCustomPlatformData(typeface); 197 return new FontCustomPlatformData(typeface);
189 #else 198 #else
190 notImplemented(); 199 notImplemented();
191 return 0; 200 return 0;
192 #endif 201 #endif
193 } 202 }
194 203
195 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698