File indexing completed on 2024-04-28 11:39:26
0001 /* 0002 * Copyright (C) 2007 David Smith (catfish.man@gmail.com) 0003 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 0018 * Boston, MA 02111-1307, USA. 0019 */ 0020 0021 #include "ClassNames.h" 0022 0023 namespace DOM 0024 { 0025 0026 void ClassNames::parseClassAttribute(const DOMString &classStr, bool inCompatMode) 0027 { 0028 if (!m_nameVector) { 0029 m_nameVector.set(new ClassNameVector); 0030 } else { 0031 m_nameVector->clear(); 0032 } 0033 0034 if (classStr.isEmpty()) { 0035 return; 0036 } 0037 0038 DOMString classAttr = inCompatMode ? classStr.lower() : classStr; 0039 0040 const QChar *str = classAttr.unicode(); 0041 const int length = classAttr.length(); 0042 int start = 0; 0043 while (true) { 0044 while (start < length && isClassWhitespace(str[start])) { 0045 ++start; 0046 } 0047 if (start >= length) { 0048 break; 0049 } 0050 int end = start + 1; 0051 while (end < length && !isClassWhitespace(str[end])) { 0052 ++end; 0053 } 0054 0055 m_nameVector->append(AtomicString(str + start, end - start)); 0056 0057 start = end + 1; 0058 } 0059 } 0060 0061 } // namespace DOM 0062