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

Unified Diff: Source/core/dom/Element.cpp

Issue 174293005: Fix crash in which elementData() might be null. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 18d1114960311ee8d36d1d9f9980865c25693a32..dc0f28ff831fc3b992b1f6571bc71af4b2fc6b0b 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1087,18 +1087,20 @@ void Element::classAttributeChanged(const AtomicString& newClassString)
StyleResolver* styleResolver = document().styleResolver();
bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styleChangeType() < SubtreeStyleChange;
- if (classStringHasClassName(newClassString)) {
- const bool shouldFoldCase = document().inQuirksMode();
- const SpaceSplitString oldClasses = elementData()->classNames();
- elementData()->setClass(newClassString, shouldFoldCase);
- const SpaceSplitString& newClasses = elementData()->classNames();
- if (testShouldInvalidateStyle)
- styleResolver->ensureRuleFeatureSet().scheduleStyleInvalidationForClassChange(oldClasses, newClasses, this);
- } else {
- const SpaceSplitString& oldClasses = elementData()->classNames();
- if (testShouldInvalidateStyle)
- styleResolver->ensureRuleFeatureSet().scheduleStyleInvalidationForClassChange(oldClasses, this);
- elementData()->clearClass();
+ if (elementData()) {
adamk 2014/02/21 03:33:50 This is crazy. No element should have classAttribu
+ if (classStringHasClassName(newClassString)) {
+ const bool shouldFoldCase = document().inQuirksMode();
+ const SpaceSplitString oldClasses = elementData()->classNames();
+ elementData()->setClass(newClassString, shouldFoldCase);
+ const SpaceSplitString& newClasses = elementData()->classNames();
+ if (testShouldInvalidateStyle)
+ styleResolver->ensureRuleFeatureSet().scheduleStyleInvalidationForClassChange(oldClasses, newClasses, this);
+ } else {
+ const SpaceSplitString& oldClasses = elementData()->classNames();
+ if (testShouldInvalidateStyle)
+ styleResolver->ensureRuleFeatureSet().scheduleStyleInvalidationForClassChange(oldClasses, this);
+ elementData()->clearClass();
+ }
}
if (hasRareData())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698