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

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

Issue 23708049: Cap allocation for ImmutableStylePropertySet. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use ASSERT instead. Created 7 years, 3 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 | « no previous file | no next file » | 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 * (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 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * 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.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) 46 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count)
47 { 47 {
48 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count; 48 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
49 } 49 }
50 50
51 PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CS SProperty* properties, unsigned count, CSSParserMode cssParserMode) 51 PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CS SProperty* properties, unsigned count, CSSParserMode cssParserMode)
52 { 52 {
53 ASSERT(count <= MaxArraySize);
53 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou nt(count)); 54 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCou nt(count));
54 return adoptRef(new (slot) ImmutableStylePropertySet(properties, count, cssP arserMode)); 55 return adoptRef(new (slot) ImmutableStylePropertySet(properties, count, cssP arserMode));
55 } 56 }
56 57
57 PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() const 58 PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() const
58 { 59 {
59 if (!isMutable()) 60 if (!isMutable())
60 return static_cast<ImmutableStylePropertySet*>(const_cast<StylePropertyS et*>(this)); 61 return static_cast<ImmutableStylePropertySet*>(const_cast<StylePropertyS et*>(this));
61 const MutableStylePropertySet* mutableThis = static_cast<const MutableStyleP ropertySet*>(this); 62 const MutableStylePropertySet* mutableThis = static_cast<const MutableStyleP ropertySet*>(this);
62 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data( ), mutableThis->m_propertyVector.size(), cssParserMode()); 63 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data( ), mutableThis->m_propertyVector.size(), cssParserMode());
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 result.appendLiteral(": "); 652 result.appendLiteral(": ");
652 result.append(propertyValue()->cssText()); 653 result.append(propertyValue()->cssText());
653 if (isImportant()) 654 if (isImportant())
654 result.appendLiteral(" !important"); 655 result.appendLiteral(" !important");
655 result.append(';'); 656 result.append(';');
656 return result.toString(); 657 return result.toString();
657 } 658 }
658 659
659 660
660 } // namespace WebCore 661 } // namespace WebCore
OLDNEW
« 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