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

Side by Side Diff: Source/core/dom/DocumentMarker.h

Issue 23703016: [blink] Use functions for AllMarkers and MisspellingMarkers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 | Source/core/dom/DocumentMarkerController.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 * This file is part of the DOM implementation for WebCore. 2 * This file is part of the DOM implementation for WebCore.
3 * 3 *
4 * Copyright (C) 2006 Apple Computer, Inc. 4 * Copyright (C) 2006 Apple Computer, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 enum MarkerType { 41 enum MarkerType {
42 Spelling = 1 << 0, 42 Spelling = 1 << 0,
43 Grammar = 1 << 1, 43 Grammar = 1 << 1,
44 TextMatch = 1 << 2 44 TextMatch = 1 << 2
45 }; 45 };
46 46
47 class MarkerTypes { 47 class MarkerTypes {
48 public: 48 public:
49 // The constructor is intentionally implicit to allow conversion from th e bit-wise sum of above types 49 // The constructor is intentionally implicit to allow conversion from th e bit-wise sum of above types
50 MarkerTypes(unsigned mask) : m_mask(mask) { } 50 MarkerTypes(unsigned mask) : m_mask(mask) { }
tony 2013/09/20 18:10:28 Nit: explicit
please use gerrit instead 2013/09/20 18:20:29 The comment says that "the constructor is intentio
51 51
52 bool contains(MarkerType type) const { return m_mask & type; } 52 bool contains(MarkerType type) const { return m_mask & type; }
53 bool intersects(const MarkerTypes& types) const { return (m_mask & types .m_mask); } 53 bool intersects(const MarkerTypes& types) const { return (m_mask & types .m_mask); }
54 bool operator==(const MarkerTypes& other) const { return m_mask == other .m_mask; } 54 bool operator==(const MarkerTypes& other) const { return m_mask == other .m_mask; }
55 55
56 void add(const MarkerTypes& types) { m_mask |= types.m_mask; } 56 void add(const MarkerTypes& types) { m_mask |= types.m_mask; }
57 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; } 57 void remove(const MarkerTypes& types) { m_mask &= ~types.m_mask; }
58 58
59 private: 59 private:
60 unsigned m_mask; 60 unsigned m_mask;
61 }; 61 };
62 62
63 class AllMarkers : public MarkerTypes { 63 static MarkerTypes allMarkers() { return MarkerTypes(Spelling | Grammar | Te xtMatch); }
64 public: 64 static MarkerTypes misspellingMarkers() { return MarkerTypes(Spelling | Gram mar); }
65 AllMarkers()
66 : MarkerTypes(Spelling | Grammar | TextMatch)
67 {
68 }
69 };
70
71 class MisspellingMarkers : public MarkerTypes {
72 public:
73 MisspellingMarkers()
74 : MarkerTypes(Spelling | Grammar)
75 {
76 }
77 };
78 65
79 DocumentMarker(); 66 DocumentMarker();
80 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset); 67 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset);
81 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S tring& description); 68 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S tring& description);
82 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S tring& description, uint32_t hash); 69 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const S tring& description, uint32_t hash);
83 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch); 70 DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);
84 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, PassRef Ptr<DocumentMarkerDetails>); 71 DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, PassRef Ptr<DocumentMarkerDetails>);
85 72
86 MarkerType type() const { return m_type; } 73 MarkerType type() const { return m_type; }
87 unsigned startOffset() const { return m_startOffset; } 74 unsigned startOffset() const { return m_startOffset; }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 public: 116 public:
130 DocumentMarkerDetails() { } 117 DocumentMarkerDetails() { }
131 virtual ~DocumentMarkerDetails(); 118 virtual ~DocumentMarkerDetails();
132 virtual bool isDescription() const { return false; } 119 virtual bool isDescription() const { return false; }
133 virtual bool isTextMatch() const { return false; } 120 virtual bool isTextMatch() const { return false; }
134 }; 121 };
135 122
136 } // namespace WebCore 123 } // namespace WebCore
137 124
138 #endif // DocumentMarker_h 125 #endif // DocumentMarker_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/DocumentMarkerController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698