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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/UnicodeRangeSet.h

Issue 1806653002: Shape unicode-range: font faces in only one iteration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update UnicodeRangeSetTests to RefPtrtr, rm copy constructor and test Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef UnicodeRangeSet_h 26 #ifndef UnicodeRangeSet_h
27 #define UnicodeRangeSet_h 27 #define UnicodeRangeSet_h
28 28
29 #include "platform/PlatformExport.h" 29 #include "platform/PlatformExport.h"
30 #include "platform/fonts/FontDataRange.h"
31 #include "wtf/Allocator.h" 30 #include "wtf/Allocator.h"
31 #include "wtf/RefCounted.h"
32 #include "wtf/Vector.h"
33 #include "wtf/text/CharacterNames.h"
32 #include "wtf/text/Unicode.h" 34 #include "wtf/text/Unicode.h"
35 #include "wtf/text/WTFString.h"
33 36
34 namespace blink { 37 namespace blink {
35 38
36 struct PLATFORM_EXPORT UnicodeRange { 39 struct PLATFORM_EXPORT UnicodeRange final {
37 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 40 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
38 UnicodeRange(UChar32 from, UChar32 to) 41 UnicodeRange(UChar32 from, UChar32 to)
39 : m_from(from) 42 : m_from(from)
40 , m_to(to) 43 , m_to(to)
41 { 44 {
42 } 45 }
43 46
44 UChar32 from() const { return m_from; } 47 UChar32 from() const { return m_from; }
45 UChar32 to() const { return m_to; } 48 UChar32 to() const { return m_to; }
46 bool contains(UChar32 c) const { return m_from <= c && c <= m_to; } 49 bool contains(UChar32 c) const { return m_from <= c && c <= m_to; }
47 bool operator<(const UnicodeRange& other) const 50 bool operator<(const UnicodeRange& other) const
48 { 51 {
49 return m_from < other.m_from; 52 return m_from < other.m_from;
50 } 53 }
51 bool operator<(UChar32 c) const { return m_to < c; } 54 bool operator<(UChar32 c) const { return m_to < c; }
52 bool operator==(const FontDataRange& fontDataRange) const 55 bool operator==(const UnicodeRange& other) const
53 { 56 {
54 return fontDataRange.from() == m_from 57 return other.m_from == m_from && other.m_to == m_to;
55 && fontDataRange.to() == m_to;
56 }; 58 };
57 59
58 private: 60 private:
59 UChar32 m_from; 61 UChar32 m_from;
60 UChar32 m_to; 62 UChar32 m_to;
61 }; 63 };
62 64
63 class PLATFORM_EXPORT UnicodeRangeSet { 65 class PLATFORM_EXPORT UnicodeRangeSet : public RefCounted<UnicodeRangeSet> {
64 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
65
66 public: 66 public:
67 explicit UnicodeRangeSet(const Vector<UnicodeRange>&); 67 explicit UnicodeRangeSet(const Vector<UnicodeRange>&);
68 UnicodeRangeSet() { };
68 bool contains(UChar32) const; 69 bool contains(UChar32) const;
69 bool contains(const FontDataRange&) const;
70 bool intersectsWith(const String&) const; 70 bool intersectsWith(const String&) const;
71 bool isEntireRange() const { return m_ranges.isEmpty(); } 71 bool isEntireRange() const { return m_ranges.isEmpty(); }
72 size_t size() const { return m_ranges.size(); } 72 size_t size() const { return m_ranges.size(); }
73 const UnicodeRange& rangeAt(size_t i) const { return m_ranges[i]; } 73 const UnicodeRange& rangeAt(size_t i) const { return m_ranges[i]; }
74 bool operator==(const UnicodeRangeSet& other) const;
75
74 private: 76 private:
75 Vector<UnicodeRange> m_ranges; // If empty, represents the whole code space. 77 Vector<UnicodeRange> m_ranges; // If empty, represents the whole code space.
76 }; 78 };
77 79
78 } // namespace blink 80 } // namespace blink
79 81
80 #endif 82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698