Ben Murdoch | 02772c6 | 2013-07-26 10:21:05 +0100 | [diff] [blame] | 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 | |
| 33 | namespace WebCore { |
| 34 | |
| 35 | void StyleSheetScopingNodeList::add(ContainerNode* node) |
| 36 | { |
| 37 | ASSERT(node && node->inDocument()); |
| 38 | if (isTreeScopeRoot(node)) |
| 39 | return; |
| 40 | |
| 41 | if (!m_scopingNodes) |
| 42 | m_scopingNodes = adoptPtr(new DocumentOrderedList()); |
| 43 | m_scopingNodes->add(node); |
| 44 | |
| 45 | if (m_scopingNodesRemoved) |
| 46 | m_scopingNodesRemoved->remove(node); |
| 47 | } |
| 48 | |
| 49 | void StyleSheetScopingNodeList::remove(ContainerNode* node) |
| 50 | { |
| 51 | if (isTreeScopeRoot(node) || !m_scopingNodes) |
| 52 | return; |
| 53 | |
| 54 | m_scopingNodes->remove(node); |
| 55 | if (node->inDocument() && node->numberOfScopedHTMLStyleChildren()) |
| 56 | return; |
| 57 | |
| 58 | if (!m_scopingNodesRemoved) |
| 59 | m_scopingNodesRemoved = adoptPtr(new ListHashSet<Node*, 4>()); |
| 60 | m_scopingNodesRemoved->add(node); |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | |