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

Side by Side Diff: third_party/WebKit/Source/core/css/StylePropertySet.cpp

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: All windows error are Resolved now. Created 3 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 5 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. 6 * Copyright (C) 2013 Intel Corporation. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 unsigned count) { 46 unsigned count) {
47 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + 47 return sizeof(ImmutableStylePropertySet) - sizeof(void*) +
48 sizeof(Member<CSSValue>) * count + 48 sizeof(Member<CSSValue>) * count +
49 sizeof(StylePropertyMetadata) * count; 49 sizeof(StylePropertyMetadata) * count;
50 } 50 }
51 51
52 ImmutableStylePropertySet* ImmutableStylePropertySet::create( 52 ImmutableStylePropertySet* ImmutableStylePropertySet::create(
53 const CSSProperty* properties, 53 const CSSProperty* properties,
54 unsigned count, 54 unsigned count,
55 CSSParserMode cssParserMode) { 55 CSSParserMode cssParserMode) {
56 ASSERT(count <= MaxArraySize); 56 DCHECK_LE(count, static_cast<unsigned>(MaxArraySize));
57 void* slot = ThreadHeap::allocate<StylePropertySet>( 57 void* slot = ThreadHeap::allocate<StylePropertySet>(
58 sizeForImmutableStylePropertySetWithPropertyCount(count)); 58 sizeForImmutableStylePropertySetWithPropertyCount(count));
59 return new (slot) ImmutableStylePropertySet(properties, count, cssParserMode); 59 return new (slot) ImmutableStylePropertySet(properties, count, cssParserMode);
60 } 60 }
61 61
62 ImmutableStylePropertySet* StylePropertySet::immutableCopyIfNeeded() const { 62 ImmutableStylePropertySet* StylePropertySet::immutableCopyIfNeeded() const {
63 if (!isMutable()) 63 if (!isMutable())
64 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this)); 64 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this));
65 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this); 65 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this);
66 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(), 66 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 static uint16_t getConvertedCSSPropertyID(const AtomicString&) { 105 static uint16_t getConvertedCSSPropertyID(const AtomicString&) {
106 return static_cast<uint16_t>(CSSPropertyVariable); 106 return static_cast<uint16_t>(CSSPropertyVariable);
107 } 107 }
108 108
109 static bool isPropertyMatch(const StylePropertyMetadata& metadata, 109 static bool isPropertyMatch(const StylePropertyMetadata& metadata,
110 const CSSValue&, 110 const CSSValue&,
111 uint16_t id, 111 uint16_t id,
112 CSSPropertyID propertyID) { 112 CSSPropertyID propertyID) {
113 ASSERT(id == propertyID); 113 DCHECK_EQ(id, propertyID);
114 bool result = metadata.m_propertyID == id; 114 bool result = metadata.m_propertyID == id;
115 // Only enabled properties should be part of the style. 115 // Only enabled properties should be part of the style.
116 ASSERT(!result || CSSPropertyMetadata::isEnabledProperty(propertyID)); 116 DCHECK(!result || CSSPropertyMetadata::isEnabledProperty(propertyID));
117 return result; 117 return result;
118 } 118 }
119 119
120 static bool isPropertyMatch(const StylePropertyMetadata& metadata, 120 static bool isPropertyMatch(const StylePropertyMetadata& metadata,
121 const CSSValue& value, 121 const CSSValue& value,
122 uint16_t id, 122 uint16_t id,
123 const AtomicString& customPropertyName) { 123 const AtomicString& customPropertyName) {
124 ASSERT(id == CSSPropertyVariable); 124 DCHECK_EQ(id, CSSPropertyVariable);
125 return metadata.m_propertyID == id && 125 return metadata.m_propertyID == id &&
126 toCSSCustomPropertyDeclaration(value).name() == customPropertyName; 126 toCSSCustomPropertyDeclaration(value).name() == customPropertyName;
127 } 127 }
128 128
129 template <typename T> 129 template <typename T>
130 int ImmutableStylePropertySet::findPropertyIndex(T property) const { 130 int ImmutableStylePropertySet::findPropertyIndex(T property) const {
131 uint16_t id = getConvertedCSSPropertyID(property); 131 uint16_t id = getConvertedCSSPropertyID(property);
132 for (int n = m_arraySize - 1; n >= 0; --n) { 132 for (int n = m_arraySize - 1; n >= 0; --n) {
133 if (isPropertyMatch(metadataArray()[n], *valueArray()[n], id, property)) 133 if (isPropertyMatch(metadataArray()[n], *valueArray()[n], id, property))
134 return n; 134 return n;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID( 480 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(
481 CSSPropertyID propertyID, 481 CSSPropertyID propertyID,
482 const AtomicString& customPropertyName) { 482 const AtomicString& customPropertyName) {
483 int foundPropertyIndex = -1; 483 int foundPropertyIndex = -1;
484 if (propertyID == CSSPropertyVariable && !customPropertyName.isNull()) { 484 if (propertyID == CSSPropertyVariable && !customPropertyName.isNull()) {
485 // TODO(shanestephens): fix call sites so we always have a 485 // TODO(shanestephens): fix call sites so we always have a
486 // customPropertyName here. 486 // customPropertyName here.
487 foundPropertyIndex = findPropertyIndex(customPropertyName); 487 foundPropertyIndex = findPropertyIndex(customPropertyName);
488 } else { 488 } else {
489 ASSERT(customPropertyName.isNull()); 489 DCHECK(customPropertyName.isNull());
490 foundPropertyIndex = findPropertyIndex(propertyID); 490 foundPropertyIndex = findPropertyIndex(propertyID);
491 } 491 }
492 if (foundPropertyIndex == -1) 492 if (foundPropertyIndex == -1)
493 return nullptr; 493 return nullptr;
494 return &m_propertyVector.at(foundPropertyIndex); 494 return &m_propertyVector.at(foundPropertyIndex);
495 } 495 }
496 496
497 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, 497 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID,
498 const CSSValue& propertyValue) const { 498 const CSSValue& propertyValue) const {
499 int foundPropertyIndex = findPropertyIndex(propertyID); 499 int foundPropertyIndex = findPropertyIndex(propertyID);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (value) 543 if (value)
544 list.push_back(CSSProperty(properties[i], *value, false)); 544 list.push_back(CSSProperty(properties[i], *value, false));
545 } 545 }
546 return MutableStylePropertySet::create(list.data(), list.size()); 546 return MutableStylePropertySet::create(list.data(), list.size());
547 } 547 }
548 548
549 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() { 549 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() {
550 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a 550 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a
551 // style property set. 551 // style property set.
552 if (m_cssomWrapper) { 552 if (m_cssomWrapper) {
553 ASSERT( 553 DCHECK(
554 !static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule()); 554 !static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule());
555 ASSERT(!m_cssomWrapper->parentElement()); 555 DCHECK(!m_cssomWrapper->parentElement());
556 return m_cssomWrapper.get(); 556 return m_cssomWrapper.get();
557 } 557 }
558 m_cssomWrapper = new PropertySetCSSStyleDeclaration(*this); 558 m_cssomWrapper = new PropertySetCSSStyleDeclaration(*this);
559 return m_cssomWrapper.get(); 559 return m_cssomWrapper.get();
560 } 560 }
561 561
562 template <typename T> 562 template <typename T>
563 int MutableStylePropertySet::findPropertyIndex(T property) const { 563 int MutableStylePropertySet::findPropertyIndex(T property) const {
564 const CSSProperty* begin = m_propertyVector.data(); 564 const CSSProperty* begin = m_propertyVector.data();
565 const CSSProperty* end = begin + m_propertyVector.size(); 565 const CSSProperty* end = begin + m_propertyVector.size();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 612
613 MutableStylePropertySet* MutableStylePropertySet::create( 613 MutableStylePropertySet* MutableStylePropertySet::create(
614 const CSSProperty* properties, 614 const CSSProperty* properties,
615 unsigned count) { 615 unsigned count) {
616 return new MutableStylePropertySet(properties, count); 616 return new MutableStylePropertySet(properties, count);
617 } 617 }
618 618
619 DEFINE_TRACE(CSSLazyPropertyParser) {} 619 DEFINE_TRACE(CSSLazyPropertyParser) {}
620 620
621 } // namespace blink 621 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleMedia.cpp ('k') | third_party/WebKit/Source/core/css/StylePropertyShorthandCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698