Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "core/css/CSSParserValues.h" | 22 #include "core/css/CSSParserValues.h" |
| 23 | 23 |
| 24 #include "core/css/CSSFunctionValue.h" | 24 #include "core/css/CSSFunctionValue.h" |
| 25 #include "core/css/CSSSelectorList.h" | 25 #include "core/css/CSSSelectorList.h" |
| 26 #include "core/html/parser/HTMLParserIdioms.h" | 26 #include "core/html/parser/HTMLParserIdioms.h" |
| 27 | 27 |
| 28 namespace WebCore { | 28 namespace WebCore { |
| 29 | 29 |
| 30 using namespace WTF; | 30 using namespace WTF; |
| 31 | 31 |
| 32 static void destroy(Vector<CSSParserValue, 4>& values) | |
| 33 { | |
| 34 size_t numValues = values.size(); | |
| 35 for (size_t i = 0; i < numValues; i++) { | |
| 36 if (values[i].unit == CSSParserValue::Function) | |
| 37 delete values[i].function; | |
| 38 else if (values[i].unit == CSSParserValue::ValueList) | |
| 39 delete values[i].valueList; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void CSSParserValueList::destroyAndClear() | |
| 44 { | |
| 45 destroy(m_values); | |
| 46 clear(); | |
| 47 } | |
| 48 | |
| 32 CSSParserValueList::~CSSParserValueList() | 49 CSSParserValueList::~CSSParserValueList() |
| 33 { | 50 { |
| 34 size_t numValues = m_values.size(); | 51 destroy(m_values); |
|
eseidel
2014/05/07 15:26:10
Seems like this could end up destroying twice. I
Yoav Weiss
2014/05/07 15:34:43
Yeah, and calling destroyAndClear immediately foll
| |
| 35 for (size_t i = 0; i < numValues; i++) { | |
| 36 if (m_values[i].unit == CSSParserValue::Function) | |
| 37 delete m_values[i].function; | |
| 38 else if (m_values[i].unit == CSSParserValue::ValueList) | |
| 39 delete m_values[i].valueList; | |
| 40 } | |
| 41 } | 52 } |
| 42 | 53 |
| 43 void CSSParserValueList::addValue(const CSSParserValue& v) | 54 void CSSParserValueList::addValue(const CSSParserValue& v) |
| 44 { | 55 { |
| 45 m_values.append(v); | 56 m_values.append(v); |
| 46 } | 57 } |
| 47 | 58 |
| 48 void CSSParserValueList::insertValueAt(unsigned i, const CSSParserValue& v) | 59 void CSSParserValueList::insertValueAt(unsigned i, const CSSParserValue& v) |
| 49 { | 60 { |
| 50 m_values.insert(i, v); | 61 m_values.insert(i, v); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 { | 231 { |
| 221 CSSParserSelector* selector = const_cast<CSSParserSelector*>(this); | 232 CSSParserSelector* selector = const_cast<CSSParserSelector*>(this); |
| 222 do { | 233 do { |
| 223 if (selector->pseudoType() == CSSSelector::PseudoHost || selector->pseud oType() == CSSSelector::PseudoHostContext) | 234 if (selector->pseudoType() == CSSSelector::PseudoHost || selector->pseud oType() == CSSSelector::PseudoHostContext) |
| 224 return true; | 235 return true; |
| 225 } while ((selector = selector->tagHistory())); | 236 } while ((selector = selector->tagHistory())); |
| 226 return false; | 237 return false; |
| 227 } | 238 } |
| 228 | 239 |
| 229 } // namespace WebCore | 240 } // namespace WebCore |
| OLD | NEW |