⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185775 in webkit


Ignore:
Timestamp:
Jun 19, 2015, 4:33:36 PM (11 years ago)
Author:
mmaxfield@apple.com
Message:

REGRESSION(r185475): [Mac] ASSERT() when clicking on text using web fonts with force touch trackpad
https://bugs.webkit.org/show_bug.cgi?id=145890
<rdar://problem/21390877>

Reviewed by Darin Adler and Tim Horton.

The best place to stop the serialization of unserializable fonts is inside WebKit2's IPC code. We want
this logic to occur when encoding an NSAttributedString, rather than when encoding an NSDictionary,
because changing the shape of an NSAttributedString is less likely to result in problems rather than
changing the shape of an NSDictionary.

  • Shared/mac/ArgumentCodersMac.mm:

(IPC::fontIsSerializable):
(IPC::filterUnserializableValues):
(IPC::encode):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r185774 r185775  
     12015-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
    1192015-06-19  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm

    r185475 r185775  
    2727#import "ArgumentCodersMac.h"
    2828
     29#import <CoreText/CoreText.h>
     30#if PLATFORM(IOS)
     31#import <UIKit/UIKit.h>
     32#endif
     33
    2934#import "ArgumentCodersCF.h"
    3035#import "ArgumentDecoder.h"
     
    211216}
    212217
     218static inline bool isSerializableFont(CTFontRef font)
     219{
     220    return adoptCF(CTFontCopyAttribute(font, kCTFontURLAttribute));
     221}
     222
     223static 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
     233static 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
    213253void encode(ArgumentEncoder& encoder, NSAttributedString *string)
    214254{
     
    230270        ASSERT(NSMaxRange(effectiveRange) <= length);
    231271
    232         ranges.append(std::make_pair(effectiveRange, attributesAtIndex));
     272        ranges.append(std::make_pair(effectiveRange, filterUnserializableValues(attributesAtIndex.get())));
    233273
    234274        position = NSMaxRange(effectiveRange);
     
    314354        ASSERT([key isKindOfClass:[NSString class]]);
    315355        ASSERT(value);
     356        ASSERT(isSerializableValue(value));
    316357
    317358        // Ignore values we don't recognize.
     
    410451            continue;
    411452
     453        ASSERT(isSerializableValue(value));
     454
    412455        encode(encoder, value);
    413456    }
Note: See TracChangeset for help on using the changeset viewer.