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

Side by Side Diff: Source/core/dom/shadow/ContentDistribution.cpp

Issue 23133006: Merge ContentDistributor into ElementShadow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't find git copies Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its
11 * contributors may be used to endorse or promote products derived from
12 * this software without specific prior written permission.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "config.h"
28 #include "core/dom/shadow/ContentDistribution.h"
29
30 namespace WebCore {
31
32 void ContentDistribution::swap(ContentDistribution& other)
33 {
34 m_nodes.swap(other.m_nodes);
35 m_indices.swap(other.m_indices);
36 }
37
38 void ContentDistribution::append(PassRefPtr<Node> node)
39 {
40 size_t size = m_nodes.size();
41 m_indices.set(node.get(), size);
42 m_nodes.append(node);
43 }
44
45 size_t ContentDistribution::find(const Node* node) const
46 {
47 HashMap<const Node*, size_t>::const_iterator it = m_indices.find(node);
48 if (it == m_indices.end())
49 return notFound;
50
51 return it.get()->value;
52 }
53
54 Node* ContentDistribution::nextTo(const Node* node) const
55 {
56 size_t index = find(node);
57 if (index == notFound || index + 1 == size())
58 return 0;
59 return at(index + 1).get();
60 }
61
62 Node* ContentDistribution::previousTo(const Node* node) const
63 {
64 size_t index = find(node);
65 if (index == notFound || !index)
66 return 0;
67 return at(index - 1).get();
68 }
69
70 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698