Bug 128839 - Add WKBackForwardListDidChangeNotification
Summary: Add WKBackForwardListDidChangeNotification
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-14 13:19 PST by Anders Carlsson
Modified: 2014-02-14 14:04 PST (History)
1 user (show)

See Also:


Attachments
Patch (13.65 KB, patch)
2014-02-14 13:20 PST, Anders Carlsson
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>