Changeset 94936 in webkit
- Timestamp:
- Sep 11, 2011 8:14:42 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r94929 r94936 1 2011-09-11 Jeremy Moskovich <jeremy@chromium.org> 2 3 [Chromium] Change OOP Font loading code to use CGFont*() APIs. 4 https://bugs.webkit.org/show_bug.cgi?id=66935 5 6 This change is necessary due a bug in ATSFontDeactivate() on 10.7. 7 See crbug.com/93191 for details. 8 9 Reviewed by Eric Seidel. 10 11 No new tests - covered by existing tests. 12 13 * platform/chromium/PlatformBridge.h: 14 * platform/graphics/chromium/CrossProcessFontLoading.h: 15 * platform/graphics/chromium/CrossProcessFontLoading.mm: 16 (WebCore::MemoryActivatedFont::create): 17 (WebCore::MemoryActivatedFont::MemoryActivatedFont): 18 (WebCore::MemoryActivatedFont::~MemoryActivatedFont): 19 1 20 2011-09-09 Oliver Hunt <oliver@apple.com> 2 21 -
trunk/Source/WebCore/platform/chromium/PlatformSupport.h
r94504 r94936 153 153 #endif 154 154 #if OS(DARWIN) 155 static bool loadFont(NSFont* srcFont, ATSFontContainerRef*, uint32_t* fontID);155 static bool loadFont(NSFont* srcFont, CGFontRef*, uint32_t* fontID); 156 156 #elif OS(UNIX) 157 157 static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result); -
trunk/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.h
r92269 r94936 37 37 38 38 typedef struct CGFont* CGFontRef; 39 typedef UInt32 ATSFontContainerRef;40 typedef UInt32 ATSFontRef;41 39 42 40 namespace WebCore { … … 75 73 public: 76 74 // Use to create a new object, see docs on constructor below. 77 static PassRefPtr<MemoryActivatedFont> create(uint32_t fontID, NSFont*, ATSFontContainerRef);75 static PassRefPtr<MemoryActivatedFont> create(uint32_t fontID, NSFont*, CGFontRef); 78 76 ~MemoryActivatedFont(); 79 77 80 78 // Get cached CGFontRef corresponding to the in-memory font. 81 79 CGFontRef cgFont() { return m_cgFont.get(); } 82 83 // Get cached ATSFontRef corresponding to the in-memory font.84 ATSFontRef atsFontRef() { return m_atsFontRef; }85 80 86 81 private: … … 89 84 // container - a font container corresponding to an identical font that 90 85 // we loaded cross-process. 91 MemoryActivatedFont(uint32_t fontID, NSFont*, ATSFontContainerRef);86 MemoryActivatedFont(uint32_t fontID, NSFont*, CGFontRef); 92 87 93 ATSFontContainerRef m_fontContainer;94 88 WTF::RetainPtr<CGFontRef> m_cgFont; 95 ATSFontRef m_atsFontRef;96 89 uint32_t m_fontID; 97 90 WTF::String m_inSandboxHashKey; -
trunk/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm
r94275 r94936 133 133 return font; 134 134 135 ATSFontContainerRef container;135 CGFontRef tmpCGFont; 136 136 uint32_t fontID; 137 137 // Send cross-process request to load font. 138 if (!PlatformSupport::loadFont(nsFont, & container, &fontID))138 if (!PlatformSupport::loadFont(nsFont, &tmpCGFont, &fontID)) 139 139 return 0; 140 140 141 RetainPtr<CGFontRef> cgFont(tmpCGFont); 141 142 // Now that we have the fontID from the browser process, we can consult 142 143 // the ID cache. 143 144 font = fontCacheByFontID().get(fontID); 144 if (font) { 145 // We can safely discard the new container since we already have the 146 // font in our cache. 145 if (font) 147 146 // FIXME: PlatformSupport::loadFont() should consult the id cache 148 // before activating the font. Then we can save this activate/deactive 149 // dance altogether. 150 ATSFontDeactivate(container, 0, kATSOptionFlagsDefault); 147 // before activating the font. 151 148 return font; 152 } 153 154 return MemoryActivatedFont::create(fontID, nsFont, container); 149 150 return MemoryActivatedFont::create(fontID, nsFont, cgFont.get()); 155 151 } 156 152 157 153 } // namespace 158 154 159 PassRefPtr<MemoryActivatedFont> MemoryActivatedFont::create(uint32_t fontID, NSFont* nsFont, ATSFontContainerRef container) 160 { 161 MemoryActivatedFont* font = new MemoryActivatedFont(fontID, nsFont, container); 162 if (!font->cgFont()) // Object construction failed. 163 { 164 delete font; 165 return 0; 166 } 167 return adoptRef(font); 168 } 169 170 MemoryActivatedFont::MemoryActivatedFont(uint32_t fontID, NSFont* nsFont, ATSFontContainerRef container) 171 : m_fontContainer(container) 172 , m_atsFontRef(kATSFontRefUnspecified) 155 PassRefPtr<MemoryActivatedFont> MemoryActivatedFont::create(uint32_t fontID, NSFont* nsFont, CGFontRef cgFont) 156 { 157 return adoptRef(new MemoryActivatedFont(fontID, nsFont, cgFont)); 158 } 159 160 MemoryActivatedFont::MemoryActivatedFont(uint32_t fontID, NSFont* nsFont, CGFontRef cgFont) 161 : m_cgFont(cgFont) 173 162 , m_fontID(fontID) 174 163 , m_inSandboxHashKey(hashKeyFromNSFont(nsFont)) 175 164 { 176 if (!container)177 return;178 179 // Count the number of fonts in the container.180 ItemCount fontCount = 0;181 OSStatus err = ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 0, 0, &fontCount);182 if (err != noErr || fontCount < 1)183 return;184 185 // For now always assume that we want the first font in the container.186 ATSFontFindFromContainer(container, kATSOptionFlagsDefault, 1, &m_atsFontRef, 0);187 188 if (!m_atsFontRef)189 return;190 191 // Cache CGFont representation of the font.192 m_cgFont.adoptCF(CGFontCreateWithPlatformFont(&m_atsFontRef));193 194 if (!m_cgFont)195 return;196 197 165 // Add ourselves to caches. 198 166 fontCacheByFontID().add(fontID, this); … … 204 172 MemoryActivatedFont::~MemoryActivatedFont() 205 173 { 206 if (m_cgFont) { 207 // First remove ourselves from the caches. 208 ASSERT(fontCacheByFontID().contains(m_fontID)); 209 ASSERT(fontCacheByFontName().contains(m_inSandboxHashKey)); 210 211 fontCacheByFontID().remove(m_fontID); 212 fontCacheByFontName().remove(m_inSandboxHashKey); 213 214 // Make sure the CGFont is destroyed before its font container. 215 m_cgFont.releaseRef(); 216 } 217 218 if (m_fontContainer != kATSFontContainerRefUnspecified) 219 ATSFontDeactivate(m_fontContainer, 0, kATSOptionFlagsDefault); 174 // First remove ourselves from the caches. 175 ASSERT(fontCacheByFontID().contains(m_fontID)); 176 ASSERT(fontCacheByFontName().contains(m_inSandboxHashKey)); 177 178 fontCacheByFontID().remove(m_fontID); 179 fontCacheByFontName().remove(m_inSandboxHashKey); 220 180 } 221 181 -
trunk/Source/WebKit/chromium/ChangeLog
r94935 r94936 1 2011-09-11 Jeremy Moskovich <jeremy@chromium.org> 2 3 [Chromium] Change OOP Font loading code to use CGFont*() APIs. 4 https://bugs.webkit.org/show_bug.cgi?id=66935 5 6 This change is necessary due a bug in ATSFontDeactivate() on 10.7. 7 See crbug.com/93191 for details. 8 9 Reviewed by Eric Seidel. 10 11 * public/mac/WebSandboxSupport.h: 12 * src/PlatformBridge.cpp: 13 (WebCore::PlatformBridge::loadFont): 14 1 15 2011-09-11 Adam Barth <abarth@webkit.org> 2 16 -
trunk/Source/WebKit/chromium/public/mac/WebSandboxSupport.h
r92269 r94936 32 32 #define WebSandboxSupport_h 33 33 34 typedef uintptr_t ATSFontContainerRef;34 typedef struct CGFont* CGFontRef; 35 35 36 36 #ifdef __OBJC__ … … 46 46 public: 47 47 // Given an input font - |srcFont| [which can't be loaded due to sandbox 48 // restrictions]. Return a font container belonging to an equivalent 49 // font file that can be used to access the font and a unique identifier 50 // corresponding to the on-disk font file. 51 // 52 // Note that a font container may contain multiple fonts, the caller is 53 // responsible for retreiving the appropriate font from the container. 48 // restrictions]. Return a font belonging to an equivalent font file 49 // that can be used to access the font and a unique identifier corresponding 50 // to the on-disk font file. 54 51 // 55 52 // If this function succeeds, the caller assumes ownership of the |out| 56 // parameter and must call ATSFontDeactivate() to unload it when done.53 // parameter and must call CGFontRelease() to unload it when done. 57 54 // 58 55 // Returns: true on success, false on error. 59 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef*, uint32_t* fontID) = 0;56 virtual bool loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID) = 0; 60 57 }; 61 58 -
trunk/Source/WebKit/chromium/src/PlatformSupport.cpp
r94859 r94936 447 447 448 448 #if OS(DARWIN) 449 bool PlatformSupport::loadFont(NSFont* srcFont, ATSFontContainerRef* container, uint32_t* fontID)449 bool PlatformSupport::loadFont(NSFont* srcFont, CGFontRef* out, uint32_t* fontID) 450 450 { 451 451 WebSandboxSupport* ss = webKitPlatformSupport()->sandboxSupport(); 452 452 if (ss) 453 return ss->loadFont(srcFont, container, fontID);453 return ss->loadFont(srcFont, out, fontID); 454 454 455 455 // This function should only be called in response to an error loading a … … 457 457 // This by definition shouldn't happen if there is no sandbox support. 458 458 ASSERT_NOT_REACHED(); 459 * container= 0;459 *out = 0; 460 460 *fontID = 0; 461 461 return false;
Note: See TracChangeset
for help on using the changeset viewer.