| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 class WebDragData; | 48 class WebDragData; |
| 49 | 49 |
| 50 // A data object for holding data that would be in a clipboard or moved | 50 // A data object for holding data that would be in a clipboard or moved |
| 51 // during a drag-n-drop operation. This is the data that WebCore is aware | 51 // during a drag-n-drop operation. This is the data that WebCore is aware |
| 52 // of and is not specific to a platform. | 52 // of and is not specific to a platform. |
| 53 class CORE_EXPORT DataObject : public GarbageCollectedFinalized<DataObject>, | 53 class CORE_EXPORT DataObject : public GarbageCollectedFinalized<DataObject>, |
| 54 public Supplementable<DataObject> { | 54 public Supplementable<DataObject> { |
| 55 USING_GARBAGE_COLLECTED_MIXIN(DataObject); | 55 USING_GARBAGE_COLLECTED_MIXIN(DataObject); |
| 56 | 56 |
| 57 public: | 57 public: |
| 58 struct CORE_EXPORT Observer : public GarbageCollectedMixin { |
| 59 // Called whenever |item_list_| is modified. Note it can be called multiple |
| 60 // times for a single mutation. For example, DataObject::SetData() calls |
| 61 // both ClearData() and Add(), each of which can call this method. |
| 62 virtual void OnItemListChanged() = 0; |
| 63 }; |
| 64 |
| 58 static DataObject* CreateFromPasteboard(PasteMode); | 65 static DataObject* CreateFromPasteboard(PasteMode); |
| 59 static DataObject* CreateFromString(const String&); | 66 static DataObject* CreateFromString(const String&); |
| 60 static DataObject* Create(); | 67 static DataObject* Create(); |
| 61 static DataObject* Create(WebDragData); | 68 static DataObject* Create(WebDragData); |
| 62 | 69 |
| 63 virtual ~DataObject(); | 70 virtual ~DataObject(); |
| 64 | 71 |
| 65 // DataTransferItemList support. | 72 // DataTransferItemList support. |
| 66 size_t length() const; | 73 size_t length() const; |
| 67 DataObjectItem* Item(unsigned long index); | 74 DataObjectItem* Item(unsigned long index); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 111 |
| 105 // Used to handle files (images) being dragged out. | 112 // Used to handle files (images) being dragged out. |
| 106 void AddSharedBuffer(PassRefPtr<SharedBuffer>, | 113 void AddSharedBuffer(PassRefPtr<SharedBuffer>, |
| 107 const KURL&, | 114 const KURL&, |
| 108 const String& filename_extension, | 115 const String& filename_extension, |
| 109 const AtomicString& content_disposition); | 116 const AtomicString& content_disposition); |
| 110 | 117 |
| 111 int GetModifiers() const { return modifiers_; } | 118 int GetModifiers() const { return modifiers_; } |
| 112 void SetModifiers(int modifiers) { modifiers_ = modifiers; } | 119 void SetModifiers(int modifiers) { modifiers_ = modifiers; } |
| 113 | 120 |
| 121 // Adds an observer (and retains a reference to it) that is notified |
| 122 // whenever the underlying item_list_ changes. |
| 123 void AddObserver(Observer*); |
| 124 |
| 114 DECLARE_TRACE(); | 125 DECLARE_TRACE(); |
| 115 | 126 |
| 116 WebDragData ToWebDragData(); | 127 WebDragData ToWebDragData(); |
| 117 | 128 |
| 118 private: | 129 private: |
| 119 DataObject(); | 130 DataObject(); |
| 120 | 131 |
| 121 DataObjectItem* FindStringItem(const String& type) const; | 132 DataObjectItem* FindStringItem(const String& type) const; |
| 122 bool InternalAddStringItem(DataObjectItem*); | 133 bool InternalAddStringItem(DataObjectItem*); |
| 123 void InternalAddFileItem(DataObjectItem*); | 134 void InternalAddFileItem(DataObjectItem*); |
| 124 | 135 |
| 136 void NotifyItemListChanged() const; |
| 137 |
| 125 HeapVector<Member<DataObjectItem>> item_list_; | 138 HeapVector<Member<DataObjectItem>> item_list_; |
| 139 HeapHashSet<Member<Observer>> observers_; |
| 126 | 140 |
| 127 // State of Shift/Ctrl/Alt/Meta keys and Left/Right/Middle mouse buttons | 141 // State of Shift/Ctrl/Alt/Meta keys and Left/Right/Middle mouse buttons |
| 128 int modifiers_; | 142 int modifiers_; |
| 129 String filesystem_id_; | 143 String filesystem_id_; |
| 130 }; | 144 }; |
| 131 | 145 |
| 132 } // namespace blink | 146 } // namespace blink |
| 133 | 147 |
| 134 #endif | 148 #endif |
| OLD | NEW |