| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 class ContainerNode; | 52 class ContainerNode; |
| 53 class Document; | 53 class Document; |
| 54 class Element; | 54 class Element; |
| 55 class HTMLElement; | 55 class HTMLElement; |
| 56 class MutableStylePropertySet; | 56 class MutableStylePropertySet; |
| 57 class Node; | 57 class Node; |
| 58 class QualifiedName; | 58 class QualifiedName; |
| 59 class ComputedStyle; | 59 class ComputedStyle; |
| 60 class StylePropertySet; | 60 class StylePropertySet; |
| 61 | 61 |
| 62 class EditingStyle final : public RefCountedWillBeGarbageCollectedFinalized<Edit
ingStyle> { | 62 class EditingStyle final : public GarbageCollectedFinalized<EditingStyle> { |
| 63 public: | 63 public: |
| 64 | 64 |
| 65 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties,
EditingPropertiesInEffect }; | 65 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties,
EditingPropertiesInEffect }; |
| 66 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv
eWritingDirection }; | 66 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv
eWritingDirection }; |
| 67 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching
Style }; | 67 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching
Style }; |
| 68 static float NoFontDelta; | 68 static float NoFontDelta; |
| 69 | 69 |
| 70 static PassRefPtrWillBeRawPtr<EditingStyle> create() | 70 static RawPtr<EditingStyle> create() |
| 71 { | 71 { |
| 72 return adoptRefWillBeNoop(new EditingStyle()); | 72 return new EditingStyle(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 static PassRefPtrWillBeRawPtr<EditingStyle> create(ContainerNode* node, Prop
ertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) | 75 static RawPtr<EditingStyle> create(ContainerNode* node, PropertiesToInclude
propertiesToInclude = OnlyEditingInheritableProperties) |
| 76 { | 76 { |
| 77 return adoptRefWillBeNoop(new EditingStyle(node, propertiesToInclude)); | 77 return new EditingStyle(node, propertiesToInclude); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static PassRefPtrWillBeRawPtr<EditingStyle> create(const Position& position,
PropertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) | 80 static RawPtr<EditingStyle> create(const Position& position, PropertiesToInc
lude propertiesToInclude = OnlyEditingInheritableProperties) |
| 81 { | 81 { |
| 82 return adoptRefWillBeNoop(new EditingStyle(position, propertiesToInclude
)); | 82 return new EditingStyle(position, propertiesToInclude); |
| 83 } | 83 } |
| 84 | 84 |
| 85 static PassRefPtrWillBeRawPtr<EditingStyle> create(const StylePropertySet* s
tyle) | 85 static RawPtr<EditingStyle> create(const StylePropertySet* style) |
| 86 { | 86 { |
| 87 return adoptRefWillBeNoop(new EditingStyle(style)); | 87 return new EditingStyle(style); |
| 88 } | 88 } |
| 89 | 89 |
| 90 static PassRefPtrWillBeRawPtr<EditingStyle> create(CSSPropertyID propertyID,
const String& value) | 90 static RawPtr<EditingStyle> create(CSSPropertyID propertyID, const String& v
alue) |
| 91 { | 91 { |
| 92 return adoptRefWillBeNoop(new EditingStyle(propertyID, value)); | 92 return new EditingStyle(propertyID, value); |
| 93 } | 93 } |
| 94 | 94 |
| 95 ~EditingStyle(); | 95 ~EditingStyle(); |
| 96 | 96 |
| 97 MutableStylePropertySet* style() { return m_mutableStyle.get(); } | 97 MutableStylePropertySet* style() { return m_mutableStyle.get(); } |
| 98 bool textDirection(WritingDirection&) const; | 98 bool textDirection(WritingDirection&) const; |
| 99 bool isEmpty() const; | 99 bool isEmpty() const; |
| 100 void overrideWithStyle(const StylePropertySet*); | 100 void overrideWithStyle(const StylePropertySet*); |
| 101 void clear(); | 101 void clear(); |
| 102 PassRefPtrWillBeRawPtr<EditingStyle> copy() const; | 102 RawPtr<EditingStyle> copy() const; |
| 103 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveBlockProperties(); | 103 RawPtr<EditingStyle> extractAndRemoveBlockProperties(); |
| 104 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveTextDirection(); | 104 RawPtr<EditingStyle> extractAndRemoveTextDirection(); |
| 105 void removeBlockProperties(); | 105 void removeBlockProperties(); |
| 106 void removeStyleAddedByElement(Element*); | 106 void removeStyleAddedByElement(Element*); |
| 107 void removeStyleConflictingWithStyleOfElement(Element*); | 107 void removeStyleConflictingWithStyleOfElement(Element*); |
| 108 void collapseTextDecorationProperties(); | 108 void collapseTextDecorationProperties(); |
| 109 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT
extOnlyProperties }; | 109 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT
extOnlyProperties }; |
| 110 TriState triStateOfStyle(EditingStyle*) const; | 110 TriState triStateOfStyle(EditingStyle*) const; |
| 111 TriState triStateOfStyle(const VisibleSelection&) const; | 111 TriState triStateOfStyle(const VisibleSelection&) const; |
| 112 bool conflictsWithInlineStyleOfElement(HTMLElement* element) const { return
conflictsWithInlineStyleOfElement(element, 0, 0); } | 112 bool conflictsWithInlineStyleOfElement(HTMLElement* element) const { return
conflictsWithInlineStyleOfElement(element, 0, 0); } |
| 113 bool conflictsWithInlineStyleOfElement(HTMLElement* element, EditingStyle* e
xtractedStyle, Vector<CSSPropertyID>& conflictingProperties) const | 113 bool conflictsWithInlineStyleOfElement(HTMLElement* element, EditingStyle* e
xtractedStyle, Vector<CSSPropertyID>& conflictingProperties) const |
| 114 { | 114 { |
| 115 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl
ictingProperties); | 115 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl
ictingProperties); |
| 116 } | 116 } |
| 117 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract
edStyle = nullptr, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const
; | 117 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract
edStyle = nullptr, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const
; |
| 118 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; | 118 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; |
| 119 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv
eWritingDirection, EditingStyle* extractedStyle, | 119 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv
eWritingDirection, EditingStyle* extractedStyle, |
| 120 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle
) const; | 120 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle
) const; |
| 121 bool styleIsPresentInComputedStyleOfNode(Node*) const; | 121 bool styleIsPresentInComputedStyleOfNode(Node*) const; |
| 122 | 122 |
| 123 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); | 123 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); |
| 124 | 124 |
| 125 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo
tPreserveWritingDirection); | 125 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo
tPreserveWritingDirection); |
| 126 void mergeTypingStyle(Document*); | 126 void mergeTypingStyle(Document*); |
| 127 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; | 127 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; |
| 128 void mergeInlineStyleOfElement(HTMLElement*, CSSPropertyOverrideMode, Proper
tiesToInclude = AllProperties); | 128 void mergeInlineStyleOfElement(HTMLElement*, CSSPropertyOverrideMode, Proper
tiesToInclude = AllProperties); |
| 129 static PassRefPtrWillBeRawPtr<EditingStyle> wrappingStyleForAnnotatedSeriali
zation(ContainerNode* context); | 129 static RawPtr<EditingStyle> wrappingStyleForAnnotatedSerialization(Container
Node* context); |
| 130 static PassRefPtrWillBeRawPtr<EditingStyle> wrappingStyleForSerialization(Co
ntainerNode* context); | 130 static RawPtr<EditingStyle> wrappingStyleForSerialization(ContainerNode* con
text); |
| 131 void mergeStyleFromRules(Element*); | 131 void mergeStyleFromRules(Element*); |
| 132 void mergeStyleFromRulesForSerialization(Element*); | 132 void mergeStyleFromRulesForSerialization(Element*); |
| 133 void removeStyleFromRulesAndContext(Element*, ContainerNode* context); | 133 void removeStyleFromRulesAndContext(Element*, ContainerNode* context); |
| 134 void removePropertiesInElementDefaultStyle(Element*); | 134 void removePropertiesInElementDefaultStyle(Element*); |
| 135 void addAbsolutePositioningFromElement(const Element&); | 135 void addAbsolutePositioningFromElement(const Element&); |
| 136 void forceInline(); | 136 void forceInline(); |
| 137 int legacyFontSize(Document*) const; | 137 int legacyFontSize(Document*) const; |
| 138 | 138 |
| 139 float fontSizeDelta() const { return m_fontSizeDelta; } | 139 float fontSizeDelta() const { return m_fontSizeDelta; } |
| 140 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } | 140 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } |
| 141 | 141 |
| 142 static PassRefPtrWillBeRawPtr<EditingStyle> styleAtSelectionStart(const Visi
bleSelection&, bool shouldUseBackgroundColorInEffect = false); | 142 static RawPtr<EditingStyle> styleAtSelectionStart(const VisibleSelection&, b
ool shouldUseBackgroundColorInEffect = false); |
| 143 static WritingDirection textDirectionForSelection(const VisibleSelection&, E
ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); | 143 static WritingDirection textDirectionForSelection(const VisibleSelection&, E
ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); |
| 144 static bool isEmbedOrIsolate(CSSValueID unicodeBidi) | 144 static bool isEmbedOrIsolate(CSSValueID unicodeBidi) |
| 145 { | 145 { |
| 146 return unicodeBidi == CSSValueIsolate || unicodeBidi == CSSValueWebkitIs
olate || unicodeBidi == CSSValueEmbed; | 146 return unicodeBidi == CSSValueIsolate || unicodeBidi == CSSValueWebkitIs
olate || unicodeBidi == CSSValueEmbed; |
| 147 } | 147 } |
| 148 | 148 |
| 149 DECLARE_TRACE(); | 149 DECLARE_TRACE(); |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 EditingStyle(); | 152 EditingStyle(); |
| 153 EditingStyle(ContainerNode*, PropertiesToInclude); | 153 EditingStyle(ContainerNode*, PropertiesToInclude); |
| 154 EditingStyle(const Position&, PropertiesToInclude); | 154 EditingStyle(const Position&, PropertiesToInclude); |
| 155 explicit EditingStyle(const StylePropertySet*); | 155 explicit EditingStyle(const StylePropertySet*); |
| 156 EditingStyle(CSSPropertyID, const String& value); | 156 EditingStyle(CSSPropertyID, const String& value); |
| 157 void init(Node*, PropertiesToInclude); | 157 void init(Node*, PropertiesToInclude); |
| 158 void removeTextFillAndStrokeColorsIfNeeded(const ComputedStyle*); | 158 void removeTextFillAndStrokeColorsIfNeeded(const ComputedStyle*); |
| 159 void setProperty(CSSPropertyID, const String& value, bool important = false)
; | 159 void setProperty(CSSPropertyID, const String& value, bool important = false)
; |
| 160 void replaceFontSizeByKeywordIfPossible(const ComputedStyle*, CSSComputedSty
leDeclaration*); | 160 void replaceFontSizeByKeywordIfPossible(const ComputedStyle*, CSSComputedSty
leDeclaration*); |
| 161 void extractFontSizeDelta(); | 161 void extractFontSizeDelta(); |
| 162 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe
xtOnlyProperties) const; | 162 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe
xtOnlyProperties) const; |
| 163 bool conflictsWithInlineStyleOfElement(HTMLElement*, EditingStyle* extracted
Style, Vector<CSSPropertyID>* conflictingProperties) const; | 163 bool conflictsWithInlineStyleOfElement(HTMLElement*, EditingStyle* extracted
Style, Vector<CSSPropertyID>* conflictingProperties) const; |
| 164 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode,
PropertiesToInclude); | 164 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode,
PropertiesToInclude); |
| 165 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); | 165 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); |
| 166 | 166 |
| 167 RefPtrWillBeMember<MutableStylePropertySet> m_mutableStyle; | 167 Member<MutableStylePropertySet> m_mutableStyle; |
| 168 bool m_isMonospaceFont; | 168 bool m_isMonospaceFont; |
| 169 float m_fontSizeDelta; | 169 float m_fontSizeDelta; |
| 170 | 170 |
| 171 friend class HTMLElementEquivalent; | 171 friend class HTMLElementEquivalent; |
| 172 friend class HTMLAttributeEquivalent; | 172 friend class HTMLAttributeEquivalent; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 class StyleChange { | 175 class StyleChange { |
| 176 DISALLOW_NEW(); | 176 DISALLOW_NEW(); |
| 177 public: | 177 public: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 String m_applyFontSize; | 233 String m_applyFontSize; |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 // FIXME: Remove these functions or make them non-global to discourage using CSS
StyleDeclaration directly. | 236 // FIXME: Remove these functions or make them non-global to discourage using CSS
StyleDeclaration directly. |
| 237 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); | 237 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); |
| 238 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); | 238 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); |
| 239 | 239 |
| 240 } // namespace blink | 240 } // namespace blink |
| 241 | 241 |
| 242 #endif // EditingStyle_h | 242 #endif // EditingStyle_h |
| OLD | NEW |