| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class Element; | 53 class Element; |
| 54 class HTMLElement; | 54 class HTMLElement; |
| 55 class MutableStylePropertySet; | 55 class MutableStylePropertySet; |
| 56 class Node; | 56 class Node; |
| 57 class Position; | 57 class Position; |
| 58 class QualifiedName; | 58 class QualifiedName; |
| 59 class RenderStyle; | 59 class RenderStyle; |
| 60 class StylePropertySet; | 60 class StylePropertySet; |
| 61 class VisibleSelection; | 61 class VisibleSelection; |
| 62 | 62 |
| 63 class EditingStyle : public RefCounted<EditingStyle> { | 63 class EditingStyle FINAL : public RefCountedWillBeGarbageCollectedFinalized<Edit
ingStyle> { |
| 64 public: | 64 public: |
| 65 | 65 |
| 66 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties,
EditingPropertiesInEffect }; | 66 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties,
EditingPropertiesInEffect }; |
| 67 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv
eWritingDirection }; | 67 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv
eWritingDirection }; |
| 68 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching
Style }; | 68 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching
Style }; |
| 69 static float NoFontDelta; | 69 static float NoFontDelta; |
| 70 | 70 |
| 71 static PassRefPtr<EditingStyle> create() | 71 static PassRefPtrWillBeRawPtr<EditingStyle> create() |
| 72 { | 72 { |
| 73 return adoptRef(new EditingStyle()); | 73 return adoptRefWillBeNoop(new EditingStyle()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 static PassRefPtr<EditingStyle> create(Node* node, PropertiesToInclude prope
rtiesToInclude = OnlyEditingInheritableProperties) | 76 static PassRefPtrWillBeRawPtr<EditingStyle> create(Node* node, PropertiesToI
nclude propertiesToInclude = OnlyEditingInheritableProperties) |
| 77 { | 77 { |
| 78 return adoptRef(new EditingStyle(node, propertiesToInclude)); | 78 return adoptRefWillBeNoop(new EditingStyle(node, propertiesToInclude)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 static PassRefPtr<EditingStyle> create(const Position& position, PropertiesT
oInclude propertiesToInclude = OnlyEditingInheritableProperties) | 81 static PassRefPtrWillBeRawPtr<EditingStyle> create(const Position& position,
PropertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) |
| 82 { | 82 { |
| 83 return adoptRef(new EditingStyle(position, propertiesToInclude)); | 83 return adoptRefWillBeNoop(new EditingStyle(position, propertiesToInclude
)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 static PassRefPtr<EditingStyle> create(const StylePropertySet* style) | 86 static PassRefPtrWillBeRawPtr<EditingStyle> create(const StylePropertySet* s
tyle) |
| 87 { | 87 { |
| 88 return adoptRef(new EditingStyle(style)); | 88 return adoptRefWillBeNoop(new EditingStyle(style)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static PassRefPtr<EditingStyle> create(CSSPropertyID propertyID, const Strin
g& value) | 91 static PassRefPtrWillBeRawPtr<EditingStyle> create(CSSPropertyID propertyID,
const String& value) |
| 92 { | 92 { |
| 93 return adoptRef(new EditingStyle(propertyID, value)); | 93 return adoptRefWillBeNoop(new EditingStyle(propertyID, value)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 ~EditingStyle(); | 96 ~EditingStyle(); |
| 97 | 97 |
| 98 MutableStylePropertySet* style() { return m_mutableStyle.get(); } | 98 MutableStylePropertySet* style() { return m_mutableStyle.get(); } |
| 99 bool textDirection(WritingDirection&) const; | 99 bool textDirection(WritingDirection&) const; |
| 100 bool isEmpty() const; | 100 bool isEmpty() const; |
| 101 void overrideWithStyle(const StylePropertySet*); | 101 void overrideWithStyle(const StylePropertySet*); |
| 102 void clear(); | 102 void clear(); |
| 103 PassRefPtr<EditingStyle> copy() const; | 103 PassRefPtrWillBeRawPtr<EditingStyle> copy() const; |
| 104 PassRefPtr<EditingStyle> extractAndRemoveBlockProperties(); | 104 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveBlockProperties(); |
| 105 PassRefPtr<EditingStyle> extractAndRemoveTextDirection(); | 105 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveTextDirection(); |
| 106 void removeBlockProperties(); | 106 void removeBlockProperties(); |
| 107 void removeStyleAddedByNode(Node*); | 107 void removeStyleAddedByNode(Node*); |
| 108 void removeStyleConflictingWithStyleOfNode(Node*); | 108 void removeStyleConflictingWithStyleOfNode(Node*); |
| 109 void collapseTextDecorationProperties(); | 109 void collapseTextDecorationProperties(); |
| 110 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT
extOnlyProperties }; | 110 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT
extOnlyProperties }; |
| 111 TriState triStateOfStyle(EditingStyle*) const; | 111 TriState triStateOfStyle(EditingStyle*) const; |
| 112 TriState triStateOfStyle(const VisibleSelection&) const; | 112 TriState triStateOfStyle(const VisibleSelection&) const; |
| 113 bool conflictsWithInlineStyleOfElement(Element* element) const { return conf
lictsWithInlineStyleOfElement(element, 0, 0); } | 113 bool conflictsWithInlineStyleOfElement(Element* element) const { return conf
lictsWithInlineStyleOfElement(element, 0, 0); } |
| 114 bool conflictsWithInlineStyleOfElement(Element* element, EditingStyle* extra
ctedStyle, Vector<CSSPropertyID>& conflictingProperties) const | 114 bool conflictsWithInlineStyleOfElement(Element* element, EditingStyle* extra
ctedStyle, Vector<CSSPropertyID>& conflictingProperties) const |
| 115 { | 115 { |
| 116 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl
ictingProperties); | 116 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl
ictingProperties); |
| 117 } | 117 } |
| 118 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract
edStyle = 0, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const; | 118 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract
edStyle = 0, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const; |
| 119 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; | 119 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; |
| 120 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv
eWritingDirection, EditingStyle* extractedStyle, | 120 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv
eWritingDirection, EditingStyle* extractedStyle, |
| 121 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingS
tyle) const; | 121 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingS
tyle) const; |
| 122 bool styleIsPresentInComputedStyleOfNode(Node*) const; | 122 bool styleIsPresentInComputedStyleOfNode(Node*) const; |
| 123 | 123 |
| 124 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); | 124 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); |
| 125 | 125 |
| 126 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo
tPreserveWritingDirection); | 126 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo
tPreserveWritingDirection); |
| 127 void mergeTypingStyle(Document*); | 127 void mergeTypingStyle(Document*); |
| 128 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; | 128 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; |
| 129 void mergeInlineStyleOfElement(Element*, CSSPropertyOverrideMode, Properties
ToInclude = AllProperties); | 129 void mergeInlineStyleOfElement(Element*, CSSPropertyOverrideMode, Properties
ToInclude = AllProperties); |
| 130 static PassRefPtr<EditingStyle> wrappingStyleForSerialization(Node* context,
bool shouldAnnotate); | 130 static PassRefPtrWillBeRawPtr<EditingStyle> wrappingStyleForSerialization(No
de* context, bool shouldAnnotate); |
| 131 void mergeStyleFromRules(Element*); | 131 void mergeStyleFromRules(Element*); |
| 132 void mergeStyleFromRulesForSerialization(Element*); | 132 void mergeStyleFromRulesForSerialization(Element*); |
| 133 void removeStyleFromRulesAndContext(Element*, Node* context); | 133 void removeStyleFromRulesAndContext(Element*, Node* context); |
| 134 void removePropertiesInElementDefaultStyle(Element*); | 134 void removePropertiesInElementDefaultStyle(Element*); |
| 135 void forceInline(); | 135 void forceInline(); |
| 136 int legacyFontSize(Document*) const; | 136 int legacyFontSize(Document*) const; |
| 137 | 137 |
| 138 float fontSizeDelta() const { return m_fontSizeDelta; } | 138 float fontSizeDelta() const { return m_fontSizeDelta; } |
| 139 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } | 139 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } |
| 140 | 140 |
| 141 static PassRefPtr<EditingStyle> styleAtSelectionStart(const VisibleSelection
&, bool shouldUseBackgroundColorInEffect = false); | 141 static PassRefPtrWillBeRawPtr<EditingStyle> styleAtSelectionStart(const Visi
bleSelection&, bool shouldUseBackgroundColorInEffect = false); |
| 142 static WritingDirection textDirectionForSelection(const VisibleSelection&, E
ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); | 142 static WritingDirection textDirectionForSelection(const VisibleSelection&, E
ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); |
| 143 |
| 144 void trace(Visitor*); |
| 145 |
| 143 private: | 146 private: |
| 144 EditingStyle(); | 147 EditingStyle(); |
| 145 EditingStyle(Node*, PropertiesToInclude); | 148 EditingStyle(Node*, PropertiesToInclude); |
| 146 EditingStyle(const Position&, PropertiesToInclude); | 149 EditingStyle(const Position&, PropertiesToInclude); |
| 147 explicit EditingStyle(const StylePropertySet*); | 150 explicit EditingStyle(const StylePropertySet*); |
| 148 EditingStyle(CSSPropertyID, const String& value); | 151 EditingStyle(CSSPropertyID, const String& value); |
| 149 void init(Node*, PropertiesToInclude); | 152 void init(Node*, PropertiesToInclude); |
| 150 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*); | 153 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*); |
| 151 void setProperty(CSSPropertyID, const String& value, bool important = false)
; | 154 void setProperty(CSSPropertyID, const String& value, bool important = false)
; |
| 152 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar
ation*); | 155 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar
ation*); |
| 153 void extractFontSizeDelta(); | 156 void extractFontSizeDelta(); |
| 154 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe
xtOnlyProperties) const; | 157 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe
xtOnlyProperties) const; |
| 155 bool conflictsWithInlineStyleOfElement(Element*, EditingStyle* extractedStyl
e, Vector<CSSPropertyID>* conflictingProperties) const; | 158 bool conflictsWithInlineStyleOfElement(Element*, EditingStyle* extractedStyl
e, Vector<CSSPropertyID>* conflictingProperties) const; |
| 156 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode,
PropertiesToInclude); | 159 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode,
PropertiesToInclude); |
| 157 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); | 160 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); |
| 158 | 161 |
| 159 RefPtrWillBePersistent<MutableStylePropertySet> m_mutableStyle; | 162 RefPtrWillBeMember<MutableStylePropertySet> m_mutableStyle; |
| 160 bool m_shouldUseFixedDefaultFontSize; | 163 bool m_shouldUseFixedDefaultFontSize; |
| 161 float m_fontSizeDelta; | 164 float m_fontSizeDelta; |
| 162 | 165 |
| 163 friend class HTMLElementEquivalent; | 166 friend class HTMLElementEquivalent; |
| 164 friend class HTMLAttributeEquivalent; | 167 friend class HTMLAttributeEquivalent; |
| 165 }; | 168 }; |
| 166 | 169 |
| 167 class StyleChange { | 170 class StyleChange { |
| 168 public: | 171 public: |
| 169 StyleChange() | 172 StyleChange() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 String m_applyFontSize; | 227 String m_applyFontSize; |
| 225 }; | 228 }; |
| 226 | 229 |
| 227 // FIXME: Remove these functions or make them non-global to discourage using CSS
StyleDeclaration directly. | 230 // FIXME: Remove these functions or make them non-global to discourage using CSS
StyleDeclaration directly. |
| 228 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); | 231 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); |
| 229 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); | 232 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); |
| 230 | 233 |
| 231 } // namespace WebCore | 234 } // namespace WebCore |
| 232 | 235 |
| 233 #endif // EditingStyle_h | 236 #endif // EditingStyle_h |
| OLD | NEW |