Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp

Issue 2292133002: [compositor-worker] root scrolling layer is associated with document scrolling element
Patch Set: Use document instead of documentElement() Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/CompositorMutableStateProvider.h" 5 #include "platform/graphics/CompositorMutableStateProvider.h"
6 6
7 #include "cc/layers/layer_impl.h" 7 #include "cc/layers/layer_impl.h"
8 #include "cc/trees/layer_tree_impl.h" 8 #include "cc/trees/layer_tree_impl.h"
9 #include "platform/graphics/CompositorElementId.h" 9 #include "platform/graphics/CompositorElementId.h"
10 #include "platform/graphics/CompositorMutableProperties.h" 10 #include "platform/graphics/CompositorMutableProperties.h"
11 #include "platform/graphics/CompositorMutableState.h" 11 #include "platform/graphics/CompositorMutableState.h"
12 #include "platform/graphics/CompositorMutation.h" 12 #include "platform/graphics/CompositorMutation.h"
13 #include "wtf/PtrUtil.h" 13 #include "wtf/PtrUtil.h"
14 #include <memory> 14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 CompositorMutableStateProvider::CompositorMutableStateProvider( 18 CompositorMutableStateProvider::CompositorMutableStateProvider(
19 cc::LayerTreeImpl* treeImpl, 19 cc::LayerTreeImpl* treeImpl,
20 CompositorMutations* mutations) 20 CompositorMutations* mutations)
21 : m_tree(treeImpl), m_mutations(mutations) {} 21 : m_tree(treeImpl), m_mutations(mutations) {}
22 22
23 CompositorMutableStateProvider::~CompositorMutableStateProvider() {} 23 CompositorMutableStateProvider::~CompositorMutableStateProvider() {}
24 24
25 std::unique_ptr<CompositorMutableState> 25 std::unique_ptr<CompositorMutableState>
26 CompositorMutableStateProvider::getMutableStateFor(uint64_t elementId) { 26 CompositorMutableStateProvider::getMutableStateFor(
27 uint64_t elementId,
28 uint64_t scrollingElementId) {
27 cc::LayerImpl* mainLayer = m_tree->LayerByElementId( 29 cc::LayerImpl* mainLayer = m_tree->LayerByElementId(
28 createCompositorElementId(elementId, CompositorSubElementId::Primary)); 30 createCompositorElementId(elementId, CompositorSubElementId::Primary));
29 cc::LayerImpl* scrollLayer = m_tree->LayerByElementId( 31 cc::LayerImpl* scrollLayer =
30 createCompositorElementId(elementId, CompositorSubElementId::Scroll)); 32 m_tree->LayerByElementId(createCompositorElementId(
33 scrollingElementId, CompositorSubElementId::Scroll));
31 34
32 if (!mainLayer && !scrollLayer) 35 if (!mainLayer && !scrollLayer)
33 return nullptr; 36 return nullptr;
34 37
35 // Ensure that we have an entry in the map for |elementId| but do as few 38 // Ensure that we have an entry in the map for |elementId| but do as few
36 // allocations and queries as possible. This will update the map only if we 39 // allocations and queries as possible. This will update the map only if we
37 // have not added a value for |elementId|. 40 // have not added a value for |elementId|.
38 auto result = m_mutations->map.insert(elementId, nullptr); 41 auto result = m_mutations->map.insert(elementId, nullptr);
39 42
40 // Only if this is a new entry do we want to allocate a new mutation. 43 // Only if this is a new entry do we want to allocate a new mutation.
41 if (result.isNewEntry) 44 if (result.isNewEntry)
42 result.storedValue->value = WTF::wrapUnique(new CompositorMutation); 45 result.storedValue->value = WTF::wrapUnique(new CompositorMutation);
43 46
44 return WTF::wrapUnique(new CompositorMutableState( 47 return WTF::wrapUnique(new CompositorMutableState(
45 result.storedValue->value.get(), mainLayer, scrollLayer)); 48 result.storedValue->value.get(), mainLayer, scrollLayer));
46 } 49 }
47 50
48 } // namespace blink 51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698