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 * 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 171 } |
172 template CORE_EXPORT String StylePropertySet::getPropertyValue<CSSPropertyID>(CS
SPropertyID) const; | 172 template CORE_EXPORT String StylePropertySet::getPropertyValue<CSSPropertyID>(CS
SPropertyID) const; |
173 template CORE_EXPORT String StylePropertySet::getPropertyValue<AtomicString>(Ato
micString) const; | 173 template CORE_EXPORT String StylePropertySet::getPropertyValue<AtomicString>(Ato
micString) const; |
174 | 174 |
175 template<typename T> | 175 template<typename T> |
176 const CSSValue* StylePropertySet::getPropertyCSSValue(T property) const | 176 const CSSValue* StylePropertySet::getPropertyCSSValue(T property) const |
177 { | 177 { |
178 int foundPropertyIndex = findPropertyIndex(property); | 178 int foundPropertyIndex = findPropertyIndex(property); |
179 if (foundPropertyIndex == -1) | 179 if (foundPropertyIndex == -1) |
180 return nullptr; | 180 return nullptr; |
181 return propertyAt(foundPropertyIndex).value(); | 181 return &propertyAt(foundPropertyIndex).value(); |
182 } | 182 } |
183 template CORE_EXPORT const CSSValue* StylePropertySet::getPropertyCSSValue<CSSPr
opertyID>(CSSPropertyID) const; | 183 template CORE_EXPORT const CSSValue* StylePropertySet::getPropertyCSSValue<CSSPr
opertyID>(CSSPropertyID) const; |
184 template CORE_EXPORT const CSSValue* StylePropertySet::getPropertyCSSValue<Atomi
cString>(AtomicString) const; | 184 template CORE_EXPORT const CSSValue* StylePropertySet::getPropertyCSSValue<Atomi
cString>(AtomicString) const; |
185 | 185 |
186 DEFINE_TRACE(StylePropertySet) | 186 DEFINE_TRACE(StylePropertySet) |
187 { | 187 { |
188 if (m_isMutable) | 188 if (m_isMutable) |
189 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); | 189 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); |
190 else | 190 else |
191 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); | 191 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); |
(...skipping 18 matching lines...) Expand all Loading... |
210 | 210 |
211 bool MutableStylePropertySet::removePropertyAtIndex(int propertyIndex, String* r
eturnText) | 211 bool MutableStylePropertySet::removePropertyAtIndex(int propertyIndex, String* r
eturnText) |
212 { | 212 { |
213 if (propertyIndex == -1) { | 213 if (propertyIndex == -1) { |
214 if (returnText) | 214 if (returnText) |
215 *returnText = ""; | 215 *returnText = ""; |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 if (returnText) | 219 if (returnText) |
220 *returnText = propertyAt(propertyIndex).value()->cssText(); | 220 *returnText = propertyAt(propertyIndex).value().cssText(); |
221 | 221 |
222 // A more efficient removal strategy would involve marking entries as empty | 222 // A more efficient removal strategy would involve marking entries as empty |
223 // and sweeping them when the vector grows too big. | 223 // and sweeping them when the vector grows too big. |
224 m_propertyVector.remove(propertyIndex); | 224 m_propertyVector.remove(propertyIndex); |
225 | 225 |
226 return true; | 226 return true; |
227 } | 227 } |
228 | 228 |
229 template<typename T> | 229 template<typename T> |
230 bool MutableStylePropertySet::removeProperty(T property, String* returnText) | 230 bool MutableStylePropertySet::removeProperty(T property, String* returnText) |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 setProperty(toMerge.toCSSProperty(), old); | 390 setProperty(toMerge.toCSSProperty(), old); |
391 else | 391 else |
392 m_propertyVector.append(toMerge.toCSSProperty()); | 392 m_propertyVector.append(toMerge.toCSSProperty()); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 bool StylePropertySet::hasFailedOrCanceledSubresources() const | 396 bool StylePropertySet::hasFailedOrCanceledSubresources() const |
397 { | 397 { |
398 unsigned size = propertyCount(); | 398 unsigned size = propertyCount(); |
399 for (unsigned i = 0; i < size; ++i) { | 399 for (unsigned i = 0; i < size; ++i) { |
400 if (propertyAt(i).value()->hasFailedOrCanceledSubresources()) | 400 if (propertyAt(i).value().hasFailedOrCanceledSubresources()) |
401 return true; | 401 return true; |
402 } | 402 } |
403 return false; | 403 return false; |
404 } | 404 } |
405 | 405 |
406 void MutableStylePropertySet::clear() | 406 void MutableStylePropertySet::clear() |
407 { | 407 { |
408 m_propertyVector.clear(); | 408 m_propertyVector.clear(); |
409 } | 409 } |
410 | 410 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 foundPropertyIndex = findPropertyIndex(customPropertyName); | 448 foundPropertyIndex = findPropertyIndex(customPropertyName); |
449 } else { | 449 } else { |
450 ASSERT(customPropertyName.isNull()); | 450 ASSERT(customPropertyName.isNull()); |
451 foundPropertyIndex = findPropertyIndex(propertyID); | 451 foundPropertyIndex = findPropertyIndex(propertyID); |
452 } | 452 } |
453 if (foundPropertyIndex == -1) | 453 if (foundPropertyIndex == -1) |
454 return nullptr; | 454 return nullptr; |
455 return &m_propertyVector.at(foundPropertyIndex); | 455 return &m_propertyVector.at(foundPropertyIndex); |
456 } | 456 } |
457 | 457 |
458 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue*
propertyValue) const | 458 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue&
propertyValue) const |
459 { | 459 { |
460 int foundPropertyIndex = findPropertyIndex(propertyID); | 460 int foundPropertyIndex = findPropertyIndex(propertyID); |
461 if (foundPropertyIndex == -1) | 461 if (foundPropertyIndex == -1) |
462 return false; | 462 return false; |
463 return propertyAt(foundPropertyIndex).value()->equals(*propertyValue); | 463 return propertyAt(foundPropertyIndex).value().equals(propertyValue); |
464 } | 464 } |
465 | 465 |
466 void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet*
style) | 466 void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet*
style) |
467 { | 467 { |
468 Vector<CSSPropertyID> propertiesToRemove; | 468 Vector<CSSPropertyID> propertiesToRemove; |
469 unsigned size = m_propertyVector.size(); | 469 unsigned size = m_propertyVector.size(); |
470 for (unsigned i = 0; i < size; ++i) { | 470 for (unsigned i = 0; i < size; ++i) { |
471 PropertyReference property = propertyAt(i); | 471 PropertyReference property = propertyAt(i); |
472 if (style->propertyMatches(property.id(), property.value())) | 472 if (style->propertyMatches(property.id(), property.value())) |
473 propertiesToRemove.append(property.id()); | 473 propertiesToRemove.append(property.id()); |
474 } | 474 } |
475 // FIXME: This should use mass removal. | 475 // FIXME: This should use mass removal. |
476 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 476 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
477 removeProperty(propertiesToRemove[i]); | 477 removeProperty(propertiesToRemove[i]); |
478 } | 478 } |
479 | 479 |
480 void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclarati
on* style) | 480 void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclarati
on* style) |
481 { | 481 { |
482 Vector<CSSPropertyID> propertiesToRemove; | 482 Vector<CSSPropertyID> propertiesToRemove; |
483 unsigned size = m_propertyVector.size(); | 483 unsigned size = m_propertyVector.size(); |
484 for (unsigned i = 0; i < size; ++i) { | 484 for (unsigned i = 0; i < size; ++i) { |
485 PropertyReference property = propertyAt(i); | 485 PropertyReference property = propertyAt(i); |
486 if (style->cssPropertyMatches(property.id(), property.value())) | 486 if (style->cssPropertyMatches(property.id(), &property.value())) |
487 propertiesToRemove.append(property.id()); | 487 propertiesToRemove.append(property.id()); |
488 } | 488 } |
489 // FIXME: This should use mass removal. | 489 // FIXME: This should use mass removal. |
490 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 490 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
491 removeProperty(propertiesToRemove[i]); | 491 removeProperty(propertiesToRemove[i]); |
492 } | 492 } |
493 | 493 |
494 MutableStylePropertySet* StylePropertySet::mutableCopy() const | 494 MutableStylePropertySet* StylePropertySet::mutableCopy() const |
495 { | 495 { |
496 return new MutableStylePropertySet(*this); | 496 return new MutableStylePropertySet(*this); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 { | 568 { |
569 return new MutableStylePropertySet(cssParserMode); | 569 return new MutableStylePropertySet(cssParserMode); |
570 } | 570 } |
571 | 571 |
572 MutableStylePropertySet* MutableStylePropertySet::create(const CSSProperty* prop
erties, unsigned count) | 572 MutableStylePropertySet* MutableStylePropertySet::create(const CSSProperty* prop
erties, unsigned count) |
573 { | 573 { |
574 return new MutableStylePropertySet(properties, count); | 574 return new MutableStylePropertySet(properties, count); |
575 } | 575 } |
576 | 576 |
577 } // namespace blink | 577 } // namespace blink |
OLD | NEW |