Title: [162804] trunk/Source/WebKit/mac
Revision
162804
Author
[email protected]
Date
2014-01-26 10:54:11 -0800 (Sun, 26 Jan 2014)

Log Message

Turn WebHistoryItemPrivate back into a real Objective-C class
https://bugs.webkit.org/show_bug.cgi?id=127653

Reviewed by Sam Weinig.

This is a first step towards moving some history specific code from WebCore::HistoryItem back into WebKit.

* History/WebHistoryItem.mm:
(-[WebHistoryItem dealloc]):
(-[WebHistoryItem finalize]):
(-[WebHistoryItem initWithWebCoreHistoryItem:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (162803 => 162804)


--- trunk/Source/WebKit/mac/ChangeLog	2014-01-26 18:28:26 UTC (rev 162803)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-01-26 18:54:11 UTC (rev 162804)
@@ -1,3 +1,17 @@
+2014-01-26  Anders Carlsson  <[email protected]>
+
+        Turn WebHistoryItemPrivate back into a real Objective-C class
+        https://bugs.webkit.org/show_bug.cgi?id=127653
+
+        Reviewed by Sam Weinig.
+
+        This is a first step towards moving some history specific code from WebCore::HistoryItem back into WebKit.
+
+        * History/WebHistoryItem.mm:
+        (-[WebHistoryItem dealloc]):
+        (-[WebHistoryItem finalize]):
+        (-[WebHistoryItem initWithWebCoreHistoryItem:]):
+
 2014-01-25  Sam Weinig  <[email protected]>
 
         Remove unused support for DRAGGABLE_REGION

Modified: trunk/Source/WebKit/mac/History/WebHistoryItem.mm (162803 => 162804)


--- trunk/Source/WebKit/mac/History/WebHistoryItem.mm	2014-01-26 18:28:26 UTC (rev 162803)
+++ trunk/Source/WebKit/mac/History/WebHistoryItem.mm	2014-01-26 18:54:11 UTC (rev 162804)
@@ -94,10 +94,22 @@
 
 using namespace WebCore;
 
+@interface WebHistoryItemPrivate : NSObject {
+@package
+    RefPtr<HistoryItem> _historyItem;
+}
+@end
+
+@implementation WebHistoryItemPrivate
+
+@end
+
 typedef HashMap<HistoryItem*, WebHistoryItem*> HistoryItemMap;
 
-static inline WebHistoryItemPrivate* kitPrivate(WebCoreHistoryItem* list) { return (WebHistoryItemPrivate*)list; }
-static inline WebCoreHistoryItem* core(WebHistoryItemPrivate* list) { return (WebCoreHistoryItem*)list; }
+static inline WebCoreHistoryItem* core(WebHistoryItemPrivate* itemPrivate)
+{
+    return itemPrivate->_historyItem.get();
+}
 
 static HistoryItemMap& historyItemWrappers()
 {
@@ -143,25 +155,21 @@
     if (WebCoreObjCScheduleDeallocateOnMainThread([WebHistoryItem class], self))
         return;
 
-    if (_private) {
-        HistoryItem* coreItem = core(_private);
-        coreItem->deref();
-        historyItemWrappers().remove(coreItem);
-    }
+    historyItemWrappers().remove(_private->_historyItem.get());
+    [_private release];
+
     [super dealloc];
 }
 
 - (void)finalize
 {
     WebCoreThreadViolationCheckRoundOne();
+
     // FIXME: ~HistoryItem is what releases the history item's icon from the icon database
     // It's probably not good to release icons from the database only when the object is garbage-collected. 
     // Need to change design so this happens at a predictable time.
-    if (_private) {
-        HistoryItem* coreItem = core(_private);
-        coreItem->deref();
-        historyItemWrappers().remove(coreItem);
-    }
+    historyItemWrappers().remove(_private->_historyItem.get());
+
     [super finalize];
 }
 
@@ -317,9 +325,12 @@
     // other "init before WebKit is used" type things
     WebCore::notifyHistoryItemChanged = WKNotifyHistoryItemChanged;
     
-    self = [super init];
-    
-    _private = kitPrivate(item.leakRef());
+    if (!(self = [super init]))
+        return nil;
+
+    _private = [[WebHistoryItemPrivate alloc] init];
+    _private->_historyItem = item;
+
     ASSERT(!historyItemWrappers().get(core(_private)));
     historyItemWrappers().set(core(_private), self);
     return self;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to