Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | |
| 5 * | 6 * |
| 6 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 10 * | 11 * |
| 11 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 44 | 45 |
| 45 typedef HashMap<MutableStylePropertySet*, OwnPtr<PropertySetCSSStyleDeclaration> > PropertySetCSSOMWrapperMap; | 46 typedef HashMap<MutableStylePropertySet*, OwnPtr<PropertySetCSSStyleDeclaration> > PropertySetCSSOMWrapperMap; |
| 46 static PropertySetCSSOMWrapperMap& propertySetCSSOMWrapperMap() | 47 static PropertySetCSSOMWrapperMap& propertySetCSSOMWrapperMap() |
| 47 { | 48 { |
| 48 DEFINE_STATIC_LOCAL(PropertySetCSSOMWrapperMap, propertySetCSSOMWrapperMapIn stance, ()); | 49 DEFINE_STATIC_LOCAL(PropertySetCSSOMWrapperMap, propertySetCSSOMWrapperMapIn stance, ()); |
| 49 return propertySetCSSOMWrapperMapInstance; | 50 return propertySetCSSOMWrapperMapInstance; |
| 50 } | 51 } |
| 51 | 52 |
| 52 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) | 53 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) |
| 53 { | 54 { |
| 54 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count; | 55 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(uint16_t) * count; |
| 55 } | 56 } |
| 56 | 57 |
| 57 PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CS SProperty* properties, unsigned count, CSSParserMode cssParserMode) | 58 PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CS SProperty* properties, unsigned count, CSSParserMode cssParserMode) |
| 58 { | 59 { |
| 59 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou nt(count)); | 60 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou nt(count)); |
| 60 return adoptRef(new (slot) ImmutableStylePropertySet(properties, count, cssP arserMode)); | 61 return adoptRef(new (slot) ImmutableStylePropertySet(properties, count, cssP arserMode)); |
| 61 } | 62 } |
| 62 | 63 |
| 63 PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() const | 64 PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() const |
| 64 { | 65 { |
| 65 if (!isMutable()) | 66 if (!isMutable()) |
| 66 return static_cast<ImmutableStylePropertySet*>(const_cast<StylePropertyS et*>(this)); | 67 return static_cast<ImmutableStylePropertySet*>(const_cast<StylePropertyS et*>(this)); |
| 67 const MutableStylePropertySet* mutableThis = static_cast<const MutableStyleP ropertySet*>(this); | 68 const MutableStylePropertySet* mutableThis = static_cast<const MutableStyleP ropertySet*>(this); |
| 68 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data( ), mutableThis->m_propertyVector.size(), cssParserMode()); | 69 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data( ), mutableThis->m_propertyVector.size(), cssParserMode()); |
| 69 } | 70 } |
| 70 | 71 |
| 71 MutableStylePropertySet::MutableStylePropertySet(const CSSProperty* properties, unsigned length) | 72 MutableStylePropertySet::MutableStylePropertySet(const CSSProperty* properties, unsigned length) |
| 72 : StylePropertySet(CSSStrictMode) | 73 : StylePropertySet(CSSStrictMode) |
| 73 { | 74 { |
| 74 m_propertyVector.reserveInitialCapacity(length); | 75 m_propertyVector.reserveInitialCapacity(length); |
| 75 for (unsigned i = 0; i < length; ++i) | 76 for (unsigned i = 0; i < length; ++i) |
| 76 m_propertyVector.uncheckedAppend(properties[i]); | 77 m_propertyVector.uncheckedAppend(properties[i]); |
| 77 } | 78 } |
| 78 | 79 |
| 79 ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti es, unsigned length, CSSParserMode cssParserMode) | 80 ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti es, unsigned length, CSSParserMode cssParserMode) |
| 80 : StylePropertySet(cssParserMode, length) | 81 : StylePropertySet(cssParserMode, length) |
| 81 { | 82 { |
| 82 StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(th is->metadataArray()); | 83 uint16_t* metadataArray = const_cast<uint16_t*>(this->metadataArray()); |
| 83 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); | 84 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); |
| 84 for (unsigned i = 0; i < length; ++i) { | 85 for (unsigned i = 0; i < length; ++i) { |
| 85 metadataArray[i] = properties[i].metadata(); | 86 StylePropertyMetadata metadata = properties[i].metadata(); |
| 87 metadataArray[i] = *(reinterpret_cast<uint16_t*>(&metadata)); | |
|
Jeffrey Yasskin
2013/06/21 19:56:27
That reinterpret_cast is undefined behavior; use m
| |
| 86 valueArray[i] = properties[i].value(); | 88 valueArray[i] = properties[i].value(); |
| 87 valueArray[i]->ref(); | 89 valueArray[i]->ref(); |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 | 92 |
| 91 ImmutableStylePropertySet::~ImmutableStylePropertySet() | 93 ImmutableStylePropertySet::~ImmutableStylePropertySet() |
| 92 { | 94 { |
| 93 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); | 95 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray()); |
| 94 for (unsigned i = 0; i < m_arraySize; ++i) | 96 for (unsigned i = 0; i < m_arraySize; ++i) |
| 95 valueArray[i]->deref(); | 97 valueArray[i]->deref(); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 result.appendLiteral(": "); | 606 result.appendLiteral(": "); |
| 605 result.append(propertyValue()->cssText()); | 607 result.append(propertyValue()->cssText()); |
| 606 if (isImportant()) | 608 if (isImportant()) |
| 607 result.appendLiteral(" !important"); | 609 result.appendLiteral(" !important"); |
| 608 result.append(';'); | 610 result.append(';'); |
| 609 return result.toString(); | 611 return result.toString(); |
| 610 } | 612 } |
| 611 | 613 |
| 612 | 614 |
| 613 } // namespace WebCore | 615 } // namespace WebCore |
| OLD | NEW |