| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 // style property set. | 493 // style property set. |
| 494 if (m_cssomWrapper) { | 494 if (m_cssomWrapper) { |
| 495 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); | 495 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); |
| 496 ASSERT(!m_cssomWrapper->parentElement()); | 496 ASSERT(!m_cssomWrapper->parentElement()); |
| 497 return m_cssomWrapper.get(); | 497 return m_cssomWrapper.get(); |
| 498 } | 498 } |
| 499 m_cssomWrapper = adoptPtrWillBeNoop(new PropertySetCSSStyleDeclaration(*this
)); | 499 m_cssomWrapper = adoptPtrWillBeNoop(new PropertySetCSSStyleDeclaration(*this
)); |
| 500 return m_cssomWrapper.get(); | 500 return m_cssomWrapper.get(); |
| 501 } | 501 } |
| 502 | 502 |
| 503 | |
| 504 class CSSPropertyIDComparer { | |
| 505 public: | |
| 506 explicit CSSPropertyIDComparer(CSSPropertyID propertyID) | |
| 507 : m_propertyID(static_cast<uint16_t>(propertyID)) { } | |
| 508 bool operator()(const CSSProperty& property) const | |
| 509 { | |
| 510 if (property.metadata().m_propertyID == m_propertyID) { | |
| 511 // Only enabled properties should be part of the style. | |
| 512 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID())); | |
| 513 return true; | |
| 514 } | |
| 515 return false; | |
| 516 } | |
| 517 | |
| 518 private: | |
| 519 CSSPropertyID propertyID() const { return static_cast<CSSPropertyID>(m_prope
rtyID); } | |
| 520 uint16_t m_propertyID; // Store as uint16_t to avoid casts while comparing. | |
| 521 }; | |
| 522 | |
| 523 int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | 503 int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| 524 { | 504 { |
| 525 const CSSProperty* begin = m_propertyVector.data(); | 505 const CSSProperty* begin = m_propertyVector.data(); |
| 526 const CSSProperty* end = begin + m_propertyVector.size(); | 506 const CSSProperty* end = begin + m_propertyVector.size(); |
| 527 const CSSProperty* it = std::find_if(begin, end, CSSPropertyIDComparer(prope
rtyID)); | 507 // Convert here propertyID into an uint16_t to compare it with the metadata'
s m_propertyID to avoid |
| 508 // the compiler converting it to an int multiple times in the loop. |
| 509 uint16_t id = static_cast<uint16_t>(propertyID); |
| 510 |
| 511 auto compare = [propertyID, id](const CSSProperty& property) -> bool |
| 512 { |
| 513 if (property.metadata().m_propertyID == id) { |
| 514 // Only enabled properties should be part of the style. |
| 515 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); |
| 516 return true; |
| 517 } |
| 518 return false; |
| 519 }; |
| 520 |
| 521 const CSSProperty* it = std::find_if(begin, end, compare); |
| 528 | 522 |
| 529 return (it == end) ? -1 : it - begin; | 523 return (it == end) ? -1 : it - begin; |
| 530 } | 524 } |
| 531 | 525 |
| 532 DEFINE_TRACE_AFTER_DISPATCH(MutableStylePropertySet) | 526 DEFINE_TRACE_AFTER_DISPATCH(MutableStylePropertySet) |
| 533 { | 527 { |
| 534 #if ENABLE(OILPAN) | 528 #if ENABLE(OILPAN) |
| 535 visitor->trace(m_cssomWrapper); | 529 visitor->trace(m_cssomWrapper); |
| 536 visitor->trace(m_propertyVector); | 530 visitor->trace(m_propertyVector); |
| 537 #endif | 531 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 561 { | 555 { |
| 562 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); | 556 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); |
| 563 } | 557 } |
| 564 | 558 |
| 565 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) | 559 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) |
| 566 { | 560 { |
| 567 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); | 561 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); |
| 568 } | 562 } |
| 569 | 563 |
| 570 } // namespace blink | 564 } // namespace blink |
| OLD | NEW |