Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(972)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserString.h

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bad assert. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2009, 2010 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 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 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef CSSParserString_h 21 #ifndef CSSParserString_h
22 #define CSSParserString_h 22 #define CSSParserString_h
23 23
24 #include "wtf/Allocator.h" 24 #include "wtf/Allocator.h"
25 #include "wtf/text/AtomicString.h" 25 #include "wtf/text/AtomicString.h"
26 #include "wtf/text/StringView.h"
26 #include "wtf/text/WTFString.h" 27 #include "wtf/text/WTFString.h"
27 28
28 namespace blink { 29 namespace blink {
29 30
30 struct CSSParserString { 31 struct CSSParserString {
31 STACK_ALLOCATED(); 32 STACK_ALLOCATED();
32 void init(const LChar* characters, unsigned length) 33 void init(const LChar* characters, unsigned length)
33 { 34 {
34 m_data.characters8 = characters; 35 m_data.characters8 = characters;
35 m_length = length; 36 m_length = length;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 83 }
83 84
84 template<unsigned matchLength> 85 template<unsigned matchLength>
85 bool equalIgnoringASCIICase(const char (&match)[matchLength]) const 86 bool equalIgnoringASCIICase(const char (&match)[matchLength]) const
86 { 87 {
87 if (matchLength - 1 != length()) 88 if (matchLength - 1 != length())
88 return false; 89 return false;
89 return is8Bit() ? WTF::equalIgnoringASCIICase(characters8(), match, leng th()) : WTF::equalIgnoringASCIICase(characters16(), match, length()); 90 return is8Bit() ? WTF::equalIgnoringASCIICase(characters8(), match, leng th()) : WTF::equalIgnoringASCIICase(characters16(), match, length());
90 } 91 }
91 92
93 // TODO(esprehn): Remove both of these implicit operators, they're very expe nsive.
92 operator String() const { return is8Bit() ? String(m_data.characters8, m_len gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); } 94 operator String() const { return is8Bit() ? String(m_data.characters8, m_len gth) : StringImpl::create8BitIfPossible(m_data.characters16, m_length); }
93 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac ters8, m_length) : AtomicString(m_data.characters16, m_length); } 95 operator AtomicString() const { return is8Bit() ? AtomicString(m_data.charac ters8, m_length) : AtomicString(m_data.characters16, m_length); }
94 96
97 operator StringView() const { return is8Bit() ? StringView(m_data.characters 8, m_length) : StringView(m_data.characters16, m_length); }
98
95 union { 99 union {
96 const LChar* characters8; 100 const LChar* characters8;
97 const UChar* characters16; 101 const UChar* characters16;
98 const void* charactersRaw; 102 const void* charactersRaw;
99 } m_data; 103 } m_data;
100 unsigned m_length; 104 unsigned m_length;
101 bool m_is8Bit; 105 bool m_is8Bit;
102 }; 106 };
103 107
104 } // namespace blink 108 } // namespace blink
105 109
106 #endif 110 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698