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

Side by Side Diff: third_party/WebKit/Source/core/dom/UserActionElementSet.cpp

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 years, 8 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 23 matching lines...) Expand all
34 UserActionElementSet::UserActionElementSet() 34 UserActionElementSet::UserActionElementSet()
35 { 35 {
36 } 36 }
37 37
38 UserActionElementSet::~UserActionElementSet() 38 UserActionElementSet::~UserActionElementSet()
39 { 39 {
40 } 40 }
41 41
42 void UserActionElementSet::didDetach(Element& element) 42 void UserActionElementSet::didDetach(Element& element)
43 { 43 {
44 ASSERT(element.isUserActionElement()); 44 DCHECK(element.isUserActionElement());
45 clearFlags(&element, IsActiveFlag | InActiveChainFlag | IsHoveredFlag); 45 clearFlags(&element, IsActiveFlag | InActiveChainFlag | IsHoveredFlag);
46 } 46 }
47 47
48 #if !ENABLE(OILPAN) 48 #if !ENABLE(OILPAN)
49 void UserActionElementSet::documentDidRemoveLastRef() 49 void UserActionElementSet::documentDidRemoveLastRef()
50 { 50 {
51 m_elements.clear(); 51 m_elements.clear();
52 } 52 }
53 #endif 53 #endif
54 54
55 bool UserActionElementSet::hasFlags(const Node* node, unsigned flags) const 55 bool UserActionElementSet::hasFlags(const Node* node, unsigned flags) const
56 { 56 {
57 ASSERT(node->isUserActionElement() && node->isElementNode()); 57 DCHECK(node->isUserActionElement() && node->isElementNode());
58 return hasFlags(toElement(node), flags); 58 return hasFlags(toElement(node), flags);
59 } 59 }
60 60
61 void UserActionElementSet::setFlags(Node* node, unsigned flags) 61 void UserActionElementSet::setFlags(Node* node, unsigned flags)
62 { 62 {
63 if (!node->isElementNode()) 63 if (!node->isElementNode())
64 return; 64 return;
65 return setFlags(toElement(node), flags); 65 return setFlags(toElement(node), flags);
66 } 66 }
67 67
68 void UserActionElementSet::clearFlags(Node* node, unsigned flags) 68 void UserActionElementSet::clearFlags(Node* node, unsigned flags)
69 { 69 {
70 if (!node->isElementNode()) 70 if (!node->isElementNode())
71 return; 71 return;
72 return clearFlags(toElement(node), flags); 72 return clearFlags(toElement(node), flags);
73 } 73 }
74 74
75 inline bool UserActionElementSet::hasFlags(const Element* element, unsigned flag s) const 75 inline bool UserActionElementSet::hasFlags(const Element* element, unsigned flag s) const
76 { 76 {
77 ASSERT(element->isUserActionElement()); 77 DCHECK(element->isUserActionElement());
78 ElementFlagMap::const_iterator found = m_elements.find(const_cast<Element*>( element)); 78 ElementFlagMap::const_iterator found = m_elements.find(const_cast<Element*>( element));
79 if (found == m_elements.end()) 79 if (found == m_elements.end())
80 return false; 80 return false;
81 return found->value & flags; 81 return found->value & flags;
82 } 82 }
83 83
84 inline void UserActionElementSet::clearFlags(Element* element, unsigned flags) 84 inline void UserActionElementSet::clearFlags(Element* element, unsigned flags)
85 { 85 {
86 if (!element->isUserActionElement()) { 86 if (!element->isUserActionElement()) {
87 ASSERT(m_elements.end() == m_elements.find(element)); 87 DCHECK(m_elements.end() == m_elements.find(element));
88 return; 88 return;
89 } 89 }
90 90
91 ElementFlagMap::iterator found = m_elements.find(element); 91 ElementFlagMap::iterator found = m_elements.find(element);
92 if (found == m_elements.end()) { 92 if (found == m_elements.end()) {
93 element->setUserActionElement(false); 93 element->setUserActionElement(false);
94 return; 94 return;
95 } 95 }
96 96
97 unsigned updated = found->value & ~flags; 97 unsigned updated = found->value & ~flags;
98 if (!updated) { 98 if (!updated) {
99 element->setUserActionElement(false); 99 element->setUserActionElement(false);
100 m_elements.remove(found); 100 m_elements.remove(found);
101 return; 101 return;
102 } 102 }
103 103
104 found->value = updated; 104 found->value = updated;
105 } 105 }
106 106
107 inline void UserActionElementSet::setFlags(Element* element, unsigned flags) 107 inline void UserActionElementSet::setFlags(Element* element, unsigned flags)
108 { 108 {
109 ElementFlagMap::iterator result = m_elements.find(element); 109 ElementFlagMap::iterator result = m_elements.find(element);
110 if (result != m_elements.end()) { 110 if (result != m_elements.end()) {
111 ASSERT(element->isUserActionElement()); 111 DCHECK(element->isUserActionElement());
112 result->value |= flags; 112 result->value |= flags;
113 return; 113 return;
114 } 114 }
115 115
116 element->setUserActionElement(true); 116 element->setUserActionElement(true);
117 m_elements.add(element, flags); 117 m_elements.add(element, flags);
118 } 118 }
119 119
120 DEFINE_TRACE(UserActionElementSet) 120 DEFINE_TRACE(UserActionElementSet)
121 { 121 {
122 visitor->trace(m_elements); 122 visitor->trace(m_elements);
123 } 123 }
124 124
125 } // namespace blink 125 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/URLSearchParams.cpp ('k') | third_party/WebKit/Source/core/dom/VisitedLinkState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698