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

Side by Side Diff: sky/engine/core/dom/Element.cpp

Issue 871203005: Remove ElementFlags system. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « sky/engine/core/dom/Element.h ('k') | sky/engine/core/dom/ElementRareData.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 { 118 {
119 ASSERT(hasRareData()); 119 ASSERT(hasRareData());
120 return static_cast<ElementRareData*>(rareData()); 120 return static_cast<ElementRareData*>(rareData());
121 } 121 }
122 122
123 inline ElementRareData& Element::ensureElementRareData() 123 inline ElementRareData& Element::ensureElementRareData()
124 { 124 {
125 return static_cast<ElementRareData&>(ensureRareData()); 125 return static_cast<ElementRareData&>(ensureRareData());
126 } 126 }
127 127
128 bool Element::hasElementFlagInternal(ElementFlags mask) const
129 {
130 return elementRareData()->hasElementFlag(mask);
131 }
132
133 void Element::setElementFlag(ElementFlags mask, bool value)
134 {
135 if (!hasRareData() && !value)
136 return;
137 ensureElementRareData().setElementFlag(mask, value);
138 }
139
140 void Element::clearElementFlag(ElementFlags mask)
141 {
142 if (!hasRareData())
143 return;
144 elementRareData()->clearElementFlag(mask);
145 }
146
147 void Element::clearTabIndexExplicitlyIfNeeded()
148 {
149 if (hasRareData())
150 elementRareData()->clearTabIndexExplicitly();
151 }
152
153 void Element::setTabIndexExplicitly(short tabIndex)
154 {
155 ensureElementRareData().setTabIndexExplicitly(tabIndex);
156 }
157
158 void Element::setTabIndex(int value) 128 void Element::setTabIndex(int value)
159 { 129 {
160 setIntegralAttribute(HTMLNames::tabindexAttr, value); 130 setIntegralAttribute(HTMLNames::tabindexAttr, value);
161 } 131 }
162 132
163 short Element::tabIndex() const 133 short Element::tabIndex() const
164 { 134 {
165 if (supportsFocus()) 135 if (supportsFocus())
166 return hasRareData() ? elementRareData()->tabIndex() : 0; 136 return hasRareData() ? elementRareData()->tabIndex() : 0;
167 return -1; 137 return -1;
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1055
1086 strncpy(buffer, result.toString().utf8().data(), length - 1); 1056 strncpy(buffer, result.toString().utf8().data(), length - 1);
1087 } 1057 }
1088 #endif 1058 #endif
1089 1059
1090 void Element::parseAttribute(const QualifiedName& name, const AtomicString& valu e) 1060 void Element::parseAttribute(const QualifiedName& name, const AtomicString& valu e)
1091 { 1061 {
1092 if (name == HTMLNames::tabindexAttr) { 1062 if (name == HTMLNames::tabindexAttr) {
1093 int tabindex = 0; 1063 int tabindex = 0;
1094 if (value.isEmpty()) { 1064 if (value.isEmpty()) {
1095 clearTabIndexExplicitlyIfNeeded(); 1065 if (hasRareData())
1066 elementRareData()->clearTabIndex();
1096 if (treeScope().adjustedFocusedElement() == this) { 1067 if (treeScope().adjustedFocusedElement() == this) {
1097 // We might want to call blur(), but it's dangerous to dispatch 1068 // We might want to call blur(), but it's dangerous to dispatch
1098 // events here. 1069 // events here.
1099 document().setNeedsFocusedElementCheck(); 1070 document().setNeedsFocusedElementCheck();
1100 } 1071 }
1101 } else if (parseHTMLInteger(value, tabindex)) { 1072 } else if (parseHTMLInteger(value, tabindex)) {
1102 // Clamp tabindex to the range of 'short' to match Firefox's behavio r. 1073 // Clamp tabindex to the range of 'short' to match Firefox's behavio r.
1103 setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short >::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max() )))); 1074 tabindex = max(static_cast<int>(std::numeric_limits<short>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max())));
1075 ensureElementRareData().setTabIndex(tabindex);
1104 } 1076 }
1105 } 1077 }
1106 } 1078 }
1107 1079
1108 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu te inSynchronizationOfLazyAttribute) 1080 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu te inSynchronizationOfLazyAttribute)
1109 { 1081 {
1110 MutableAttributeCollection attributes = ensureUniqueElementData().attributes (); 1082 MutableAttributeCollection attributes = ensureUniqueElementData().attributes ();
1111 ASSERT_WITH_SECURITY_IMPLICATION(index < attributes.size()); 1083 ASSERT_WITH_SECURITY_IMPLICATION(index < attributes.size());
1112 1084
1113 QualifiedName name = attributes[index].name(); 1085 QualifiedName name = attributes[index].name();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 } 1192 }
1221 } 1193 }
1222 1194
1223 bool Element::supportsFocus() const 1195 bool Element::supportsFocus() const
1224 { 1196 {
1225 // FIXME: supportsFocus() can be called when layout is not up to date. 1197 // FIXME: supportsFocus() can be called when layout is not up to date.
1226 // Logic that deals with the renderer should be moved to rendererIsFocusable (). 1198 // Logic that deals with the renderer should be moved to rendererIsFocusable ().
1227 // But supportsFocus must return true when the element is editable, or else 1199 // But supportsFocus must return true when the element is editable, or else
1228 // it won't be focusable. Furthermore, supportsFocus cannot just return true 1200 // it won't be focusable. Furthermore, supportsFocus cannot just return true
1229 // always or else tabIndex() will change for all HTML elements. 1201 // always or else tabIndex() will change for all HTML elements.
1230 return hasElementFlag(TabIndexWasSetExplicitly) || (hasEditableStyle() && pa rentNode() && !parentNode()->hasEditableStyle()); 1202 if (hasRareData() && elementRareData()->hasTabIndex())
1203 return true;
1204 return hasEditableStyle() && parentNode() && !parentNode()->hasEditableStyle ();
1231 } 1205 }
1232 1206
1233 bool Element::isFocusable() const 1207 bool Element::isFocusable() const
1234 { 1208 {
1235 return inDocument() && supportsFocus() && rendererIsFocusable(); 1209 return inDocument() && supportsFocus() && rendererIsFocusable();
1236 } 1210 }
1237 1211
1238 bool Element::isKeyboardFocusable() const 1212 bool Element::isKeyboardFocusable() const
1239 { 1213 {
1240 return isFocusable() && tabIndex() >= 0; 1214 return isFocusable() && tabIndex() >= 0;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 return false; 1711 return false;
1738 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue)) 1712 if (treeScope().scopedStyleResolver().hasSelectorForId(idValue))
1739 return true; 1713 return true;
1740 // Host rules could also have effects. 1714 // Host rules could also have effects.
1741 if (ShadowRoot* shadowRoot = this->shadowRoot()) 1715 if (ShadowRoot* shadowRoot = this->shadowRoot())
1742 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue); 1716 return shadowRoot->scopedStyleResolver().hasSelectorForId(idValue);
1743 return false; 1717 return false;
1744 } 1718 }
1745 1719
1746 } // namespace blink 1720 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Element.h ('k') | sky/engine/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698