KHtml

ClassNames.cpp
1 /*
2  * Copyright (C) 2007 David Smith ([email protected])
3  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #include "ClassNames.h"
22 
23 namespace DOM
24 {
25 
26 void ClassNames::parseClassAttribute(const DOMString &classStr, bool inCompatMode)
27 {
28  if (!m_nameVector) {
29  m_nameVector.set(new ClassNameVector);
30  } else {
31  m_nameVector->clear();
32  }
33 
34  if (classStr.isEmpty()) {
35  return;
36  }
37 
38  DOMString classAttr = inCompatMode ? classStr.lower() : classStr;
39 
40  const QChar *str = classAttr.unicode();
41  const int length = classAttr.length();
42  int start = 0;
43  while (true) {
44  while (start < length && isClassWhitespace(str[start])) {
45  ++start;
46  }
47  if (start >= length) {
48  break;
49  }
50  int end = start + 1;
51  while (end < length && !isClassWhitespace(str[end])) {
52  ++end;
53  }
54 
55  m_nameVector->append(AtomicString(str + start, end - start));
56 
57  start = end + 1;
58  }
59 }
60 
61 } // namespace DOM
62 
DOMString lower() const
Returns a lowercase version of the string.
Definition: dom_string.cpp:232
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
const QList< QKeySequence > & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:47:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.