1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 * Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public License
23 * along with this library; see the file COPYING.LIB.  If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26 */
27
28#include "config.h"
29#include "core/dom/StyleSheetScopingNodeList.h"
30
31#include "core/dom/Document.h"
32#include "core/dom/Node.h"
33
34namespace WebCore {
35
36void StyleSheetScopingNodeList::add(ContainerNode* node)
37{
38    ASSERT(node && node->inDocument());
39    if (isTreeScopeRoot(node))
40        return;
41
42    if (!m_scopingNodes)
43        m_scopingNodes = adoptPtr(new DocumentOrderedList());
44    m_scopingNodes->add(node);
45
46    if (m_scopingNodesRemoved)
47        m_scopingNodesRemoved->remove(node);
48}
49
50void StyleSheetScopingNodeList::remove(ContainerNode* node)
51{
52    if (isTreeScopeRoot(node) || !m_scopingNodes)
53        return;
54
55    // If the node is still working as a scoping node, we cannot remove.
56    if (node->inDocument())
57        return;
58
59    m_scopingNodes->remove(node);
60    if (!m_scopingNodesRemoved)
61        m_scopingNodesRemoved = adoptPtr(new ListHashSet<Node*, 4>());
62    m_scopingNodesRemoved->add(node);
63}
64
65}
66