Bug 128839

Summary: Add WKBackForwardListDidChangeNotification
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: mitz
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mitz: review+

Description Anders Carlsson 2014-02-14 13:19:20 PST
Add WKBackForwardListDidChangeNotification
Comment 1 Anders Carlsson 2014-02-14 13:20:32 PST
Created attachment 224248 [details]
Patch
Comment 2 mitz 2014-02-14 13:29:15 PST
Comment on attachment 224248 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224248&action=review

> Source/WebKit2/UIProcess/API/Cocoa/WKBackForwardList.mm:36
> +WK_EXPORT NSString * const WKBackForwardListDidChangeNotification = @"WKBackForwardListDidChangeNotification";
> +WK_EXPORT NSString * const WKBackForwardListAddedItemKey = @"WKBackForwardListAddedItemKey";
> +WK_EXPORT NSString * const WKBackForwardListRemovedItemsKey = @"WKBackForwardListRemovedItemsKey";

There’s no need to use WK_EXPORT here.

> Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:398
> +    if (addedItem) {
> +        keys.append(WKBackForwardListAddedItemKey);
> +        values.append(wrapper(*addedItem));
> +    }
> +
> +    if (!removedItems.isEmpty()) {
> +        Vector<id> removed;
> +        removed.reserveInitialCapacity(removedItems.size());
> +
> +        for (const auto& removedItem : removedItems)
> +            removed.uncheckedAppend(wrapper(*removedItem));
> +
> +        keys.append(WKBackForwardListRemovedItemsKey);
> +        values.append([NSArray arrayWithObjects:removed.data() count:removed.size()]);
> +    }
> +
> +    auto userInfo = adoptNS([[NSDictionary alloc] initWithObjects:values.data() forKeys:keys.data() count:keys.size()]);

Why take the risk that someone might append to one vector and not the other? Just create an NSMutableDictionary and use setObject:forKey: or the equivalent subscript syntax.
Comment 3 Anders Carlsson 2014-02-14 14:04:48 PST
Committed r164132: <http://trac.webkit.org/changeset/164132>