Index: Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp |
diff --git a/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp b/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6ad7aa8a9dcb23ee998a3826351d70194b23c408 |
--- /dev/null |
+++ b/Source/core/page/scrolling/ScrollCustomizationCallbacks.cpp |
@@ -0,0 +1,64 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/page/scrolling/ScrollCustomizationCallbacks.h" |
+ |
+#include "core/page/scrolling/ScrollStateCallback.h" |
+#include "wtf/Deque.h" |
+ |
+namespace blink { |
+ |
+void ScrollCustomizationCallbacks::setDistributeScroll(Element* element, ScrollStateCallback* scrollStateCallback) |
+{ |
+ m_distributeScrollCallbacks.set(element, scrollStateCallback); |
+} |
+ |
+ScrollStateCallback* ScrollCustomizationCallbacks::getDistributeScroll(Element* element) |
+{ |
+ auto it = m_distributeScrollCallbacks.find(element); |
+ if (it == m_distributeScrollCallbacks.end()) |
+ return nullptr; |
+ return it->value.get(); |
+} |
+ |
+void ScrollCustomizationCallbacks::setApplyScroll(Element* element, ScrollStateCallback* scrollStateCallback) |
+{ |
+ m_applyScrollCallbacks.set(element, scrollStateCallback); |
+} |
+ |
+ScrollStateCallback* ScrollCustomizationCallbacks::getApplyScroll(Element* element) |
+{ |
+ auto it = m_applyScrollCallbacks.find(element); |
+ if (it == m_applyScrollCallbacks.end()) |
+ return nullptr; |
+ return it->value.get(); |
+} |
+ |
+void ScrollCustomizationCallbacks::removeAllCallbacksForDocument(Document* document) |
haraken
2015/08/27 00:49:40
Can we remove this?
tdresser
2015/08/27 20:48:40
Done.
|
+{ |
+ Deque<Element*> applyScrollCallbacksToRemove; |
+ for (auto it : m_applyScrollCallbacks) { |
+ if (&it.key->document() == document) |
+ applyScrollCallbacksToRemove.append(it.key); |
+ } |
+ Deque<Element*> distributeScrollCallbacksToRemove; |
+ for (auto it : m_distributeScrollCallbacks) { |
+ if (&it.key->document() == document) |
+ distributeScrollCallbacksToRemove.append(it.key); |
+ } |
+ |
+ m_applyScrollCallbacks.removeAll(applyScrollCallbacksToRemove); |
+ m_distributeScrollCallbacks.removeAll(distributeScrollCallbacksToRemove); |
+} |
+ |
+#if !ENABLE(OILPAN) |
+void ScrollCustomizationCallbacks::removeCallbacksForElement(Element* element) |
+{ |
+ m_applyScrollCallbacks.remove(element); |
+ m_distributeScrollCallbacks.remove(element); |
+} |
+#endif |
+ |
+} // namespace blink |