| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2014 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "core/dom/SpaceSplitString.h" | 37 #include "core/dom/SpaceSplitString.h" |
| 38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 39 #include "wtf/text/AtomicString.h" | 39 #include "wtf/text/AtomicString.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class ShareableElementData; | 43 class ShareableElementData; |
| 44 class StylePropertySet; | 44 class StylePropertySet; |
| 45 class UniqueElementData; | 45 class UniqueElementData; |
| 46 | 46 |
| 47 enum class CachedTextDirection { |
| 48 NotAutoOrNotCached, |
| 49 AutoLTR, |
| 50 AutoRTL, |
| 51 // This should also have a state like AutoInherit as it is possible for |
| 52 // an element with dir=auto to end up inheriting its parent's directionality |
| 53 // but we currently don't handle that correctly. |
| 54 }; |
| 55 |
| 47 // ElementData represents very common, but not necessarily unique to an element, | 56 // ElementData represents very common, but not necessarily unique to an element, |
| 48 // data such as attributes, inline style, and parsed class names and ids. | 57 // data such as attributes, inline style, and parsed class names and ids. |
| 49 class ElementData : public GarbageCollectedFinalized<ElementData> { | 58 class ElementData : public GarbageCollectedFinalized<ElementData> { |
| 50 public: | 59 public: |
| 51 // Override GarbageCollectedFinalized's finalizeGarbageCollectedObject to | 60 // Override GarbageCollectedFinalized's finalizeGarbageCollectedObject to |
| 52 // dispatch to the correct subclass destructor. | 61 // dispatch to the correct subclass destructor. |
| 53 void finalizeGarbageCollectedObject(); | 62 void finalizeGarbageCollectedObject(); |
| 54 | 63 |
| 55 void clearClass() const { m_classNames.clear(); } | 64 void clearClass() const { m_classNames.clear(); } |
| 56 void setClass(const AtomicString& className, bool shouldFoldCase) const { m_
classNames.set(shouldFoldCase ? className.lowerASCII() : className , SpaceSplitS
tring::ShouldNotFoldCase); } | 65 void setClass(const AtomicString& className, bool shouldFoldCase) const { m_
classNames.set(shouldFoldCase ? className.lowerASCII() : className , SpaceSplitS
tring::ShouldNotFoldCase); } |
| 57 const SpaceSplitString& classNames() const { return m_classNames; } | 66 const SpaceSplitString& classNames() const { return m_classNames; } |
| 58 | 67 |
| 59 const AtomicString& idForStyleResolution() const { return m_idForStyleResolu
tion; } | 68 const AtomicString& idForStyleResolution() const { return m_idForStyleResolu
tion; } |
| 60 void setIdForStyleResolution(const AtomicString& newId) const { m_idForStyle
Resolution = newId; } | 69 void setIdForStyleResolution(const AtomicString& newId) const { m_idForStyle
Resolution = newId; } |
| 61 | 70 |
| 62 const StylePropertySet* inlineStyle() const { return m_inlineStyle.get(); } | 71 const StylePropertySet* inlineStyle() const { return m_inlineStyle.get(); } |
| 63 | 72 |
| 64 const StylePropertySet* presentationAttributeStyle() const; | 73 const StylePropertySet* presentationAttributeStyle() const; |
| 65 | 74 |
| 66 AttributeCollection attributes() const; | 75 AttributeCollection attributes() const; |
| 67 | 76 |
| 68 bool hasID() const { return !m_idForStyleResolution.isNull(); } | 77 bool hasID() const { return !m_idForStyleResolution.isNull(); } |
| 69 bool hasClass() const { return !m_classNames.isNull(); } | 78 bool hasClass() const { return !m_classNames.isNull(); } |
| 70 | 79 |
| 71 bool isEquivalent(const ElementData* other) const; | 80 bool isEquivalent(const ElementData* other) const; |
| 72 | 81 |
| 73 bool isUnique() const { return m_isUnique; } | 82 bool isUnique() const { return m_isUnique; } |
| 74 | 83 |
| 84 CachedTextDirection directionality() const { return static_cast<CachedTextDi
rection>(m_directionality); } |
| 85 void setDirectionality(CachedTextDirection directionality) const { m_directi
onality = static_cast<int>(directionality); } |
| 86 |
| 75 DECLARE_TRACE_AFTER_DISPATCH(); | 87 DECLARE_TRACE_AFTER_DISPATCH(); |
| 76 DECLARE_TRACE(); | 88 DECLARE_TRACE(); |
| 77 | 89 |
| 78 protected: | 90 protected: |
| 79 ElementData(); | 91 ElementData(); |
| 80 explicit ElementData(unsigned arraySize); | 92 explicit ElementData(unsigned arraySize); |
| 81 ElementData(const ElementData&, bool isUnique); | 93 ElementData(const ElementData&, bool isUnique); |
| 82 | 94 |
| 83 // Keep the type in a bitfield instead of using virtual destructors to avoid
adding a vtable. | 95 // Keep the type in a bitfield instead of using virtual destructors to avoid
adding a vtable. |
| 84 unsigned m_isUnique : 1; | 96 unsigned m_isUnique : 1; |
| 85 unsigned m_arraySize : 28; | 97 unsigned m_arraySize : 26; |
| 98 mutable unsigned m_directionality : 2; |
| 86 mutable unsigned m_presentationAttributeStyleIsDirty : 1; | 99 mutable unsigned m_presentationAttributeStyleIsDirty : 1; |
| 87 mutable unsigned m_styleAttributeIsDirty : 1; | 100 mutable unsigned m_styleAttributeIsDirty : 1; |
| 88 mutable unsigned m_animatedSVGAttributesAreDirty : 1; | 101 mutable unsigned m_animatedSVGAttributesAreDirty : 1; |
| 89 | 102 |
| 90 mutable Member<StylePropertySet> m_inlineStyle; | 103 mutable Member<StylePropertySet> m_inlineStyle; |
| 91 mutable SpaceSplitString m_classNames; | 104 mutable SpaceSplitString m_classNames; |
| 92 mutable AtomicString m_idForStyleResolution; | 105 mutable AtomicString m_idForStyleResolution; |
| 93 | 106 |
| 94 private: | 107 private: |
| 95 friend class Element; | 108 friend class Element; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 212 } |
| 200 | 213 |
| 201 inline MutableAttributeCollection UniqueElementData::attributes() | 214 inline MutableAttributeCollection UniqueElementData::attributes() |
| 202 { | 215 { |
| 203 return MutableAttributeCollection(m_attributeVector); | 216 return MutableAttributeCollection(m_attributeVector); |
| 204 } | 217 } |
| 205 | 218 |
| 206 } // namespace blink | 219 } // namespace blink |
| 207 | 220 |
| 208 #endif // ElementData_h | 221 #endif // ElementData_h |
| OLD | NEW |