| 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 |
| 503 int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const | 523 int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| 504 { | 524 { |
| 505 // Convert here propertyID into an uint16_t to compare it with the metadata'
s m_propertyID to avoid | 525 const CSSProperty* begin = m_propertyVector.data(); |
| 506 // the compiler converting it to an int multiple times in the loop. | 526 const CSSProperty* end = begin + m_propertyVector.size(); |
| 507 uint16_t id = static_cast<uint16_t>(propertyID); | 527 const CSSProperty* it = std::find_if(begin, end, CSSPropertyIDComparer(prope
rtyID)); |
| 508 const CSSProperty* properties = m_propertyVector.data(); | |
| 509 for (int n = m_propertyVector.size() - 1 ; n >= 0; --n) { | |
| 510 if (properties[n].metadata().m_propertyID == id) { | |
| 511 // Only enabled properties should be part of the style. | |
| 512 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); | |
| 513 return n; | |
| 514 } | |
| 515 } | |
| 516 | 528 |
| 517 return -1; | 529 return (it == end) ? -1 : it - begin; |
| 518 } | 530 } |
| 519 | 531 |
| 520 DEFINE_TRACE_AFTER_DISPATCH(MutableStylePropertySet) | 532 DEFINE_TRACE_AFTER_DISPATCH(MutableStylePropertySet) |
| 521 { | 533 { |
| 522 #if ENABLE(OILPAN) | 534 #if ENABLE(OILPAN) |
| 523 visitor->trace(m_cssomWrapper); | 535 visitor->trace(m_cssomWrapper); |
| 524 visitor->trace(m_propertyVector); | 536 visitor->trace(m_propertyVector); |
| 525 #endif | 537 #endif |
| 526 StylePropertySet::traceAfterDispatch(visitor); | 538 StylePropertySet::traceAfterDispatch(visitor); |
| 527 } | 539 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 549 { | 561 { |
| 550 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); | 562 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); |
| 551 } | 563 } |
| 552 | 564 |
| 553 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) | 565 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) |
| 554 { | 566 { |
| 555 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); | 567 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); |
| 556 } | 568 } |
| 557 | 569 |
| 558 } // namespace blink | 570 } // namespace blink |
| OLD | NEW |