Changeset 185775 in webkit
- Timestamp:
- Jun 19, 2015, 4:33:36 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Shared/mac/ArgumentCodersMac.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r185774 r185775 1 2015-06-18 Myles C. Maxfield <mmaxfield@apple.com> 2 3 REGRESSION(r185475): [Mac] ASSERT() when clicking on text using web fonts with force touch trackpad 4 https://bugs.webkit.org/show_bug.cgi?id=145890 5 <rdar://problem/21390877> 6 7 Reviewed by Darin Adler and Tim Horton. 8 9 The best place to stop the serialization of unserializable fonts is inside WebKit2's IPC code. We want 10 this logic to occur when encoding an NSAttributedString, rather than when encoding an NSDictionary, 11 because changing the shape of an NSAttributedString is less likely to result in problems rather than 12 changing the shape of an NSDictionary. 13 14 * Shared/mac/ArgumentCodersMac.mm: 15 (IPC::fontIsSerializable): 16 (IPC::filterUnserializableValues): 17 (IPC::encode): 18 1 19 2015-06-19 Michael Catanzaro <mcatanzaro@igalia.com> 2 20 -
trunk/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm
r185475 r185775 27 27 #import "ArgumentCodersMac.h" 28 28 29 #import <CoreText/CoreText.h> 30 #if PLATFORM(IOS) 31 #import <UIKit/UIKit.h> 32 #endif 33 29 34 #import "ArgumentCodersCF.h" 30 35 #import "ArgumentDecoder.h" … … 211 216 } 212 217 218 static inline bool isSerializableFont(CTFontRef font) 219 { 220 return adoptCF(CTFontCopyAttribute(font, kCTFontURLAttribute)); 221 } 222 223 static inline bool isSerializableValue(id value) 224 { 225 #if USE(APPKIT) 226 auto fontClass = [NSFont class]; 227 #else 228 auto fontClass = [UIFont class]; 229 #endif 230 return ![value isKindOfClass:fontClass] || isSerializableFont(reinterpret_cast<CTFontRef>(value)); 231 } 232 233 static inline RetainPtr<NSDictionary> filterUnserializableValues(NSDictionary *dictionary) 234 { 235 __block bool modificationNecessary = false; 236 [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) { 237 if (!isSerializableValue(object)) { 238 modificationNecessary = true; 239 *stop = YES; 240 } 241 }]; 242 if (!modificationNecessary) 243 return dictionary; 244 245 auto result = adoptNS([[NSMutableDictionary alloc] init]); 246 [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) { 247 if (isSerializableValue(object)) 248 [result setObject:object forKey:key]; 249 }]; 250 return result; 251 } 252 213 253 void encode(ArgumentEncoder& encoder, NSAttributedString *string) 214 254 { … … 230 270 ASSERT(NSMaxRange(effectiveRange) <= length); 231 271 232 ranges.append(std::make_pair(effectiveRange, attributesAtIndex));272 ranges.append(std::make_pair(effectiveRange, filterUnserializableValues(attributesAtIndex.get()))); 233 273 234 274 position = NSMaxRange(effectiveRange); … … 314 354 ASSERT([key isKindOfClass:[NSString class]]); 315 355 ASSERT(value); 356 ASSERT(isSerializableValue(value)); 316 357 317 358 // Ignore values we don't recognize. … … 410 451 continue; 411 452 453 ASSERT(isSerializableValue(value)); 454 412 455 encode(encoder, value); 413 456 }
Note:
See TracChangeset
for help on using the changeset viewer.