Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 #include "wtf/TriState.h" | 43 #include "wtf/TriState.h" |
| 44 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
| 45 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 class CSSStyleDeclaration; | 49 class CSSStyleDeclaration; |
| 50 class CSSComputedStyleDeclaration; | 50 class CSSComputedStyleDeclaration; |
| 51 class CSSPrimitiveValue; | 51 class CSSPrimitiveValue; |
| 52 class CSSValue; | 52 class CSSValue; |
| 53 class ContainerNode; | |
| 53 class Document; | 54 class Document; |
| 54 class Element; | 55 class Element; |
| 55 class HTMLElement; | 56 class HTMLElement; |
| 56 class MutableStylePropertySet; | 57 class MutableStylePropertySet; |
| 57 class Node; | 58 class Node; |
| 58 class Position; | 59 class Position; |
| 59 class QualifiedName; | 60 class QualifiedName; |
| 60 class RenderStyle; | 61 class RenderStyle; |
| 61 class StylePropertySet; | 62 class StylePropertySet; |
| 62 class VisibleSelection; | 63 class VisibleSelection; |
| 63 | 64 |
| 64 class EditingStyle FINAL : public RefCountedWillBeGarbageCollectedFinalized<Edit ingStyle> { | 65 class EditingStyle FINAL : public RefCountedWillBeGarbageCollectedFinalized<Edit ingStyle> { |
| 65 public: | 66 public: |
| 66 | 67 |
| 67 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, EditingPropertiesInEffect }; | 68 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, EditingPropertiesInEffect }; |
| 68 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv eWritingDirection }; | 69 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv eWritingDirection }; |
| 69 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching Style }; | 70 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching Style }; |
| 70 static float NoFontDelta; | 71 static float NoFontDelta; |
| 71 | 72 |
| 72 static PassRefPtrWillBeRawPtr<EditingStyle> create() | 73 static PassRefPtrWillBeRawPtr<EditingStyle> create() |
| 73 { | 74 { |
| 74 return adoptRefWillBeNoop(new EditingStyle()); | 75 return adoptRefWillBeNoop(new EditingStyle()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 static PassRefPtrWillBeRawPtr<EditingStyle> create(Node* node, PropertiesToI nclude propertiesToInclude = OnlyEditingInheritableProperties) | 78 static PassRefPtrWillBeRawPtr<EditingStyle> create(ContainerNode* node, Prop ertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) |
| 78 { | 79 { |
| 79 return adoptRefWillBeNoop(new EditingStyle(node, propertiesToInclude)); | 80 return adoptRefWillBeNoop(new EditingStyle(node, propertiesToInclude)); |
| 80 } | 81 } |
| 81 | 82 |
| 82 static PassRefPtrWillBeRawPtr<EditingStyle> create(const Position& position, PropertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) | 83 static PassRefPtrWillBeRawPtr<EditingStyle> create(const Position& position, PropertiesToInclude propertiesToInclude = OnlyEditingInheritableProperties) |
| 83 { | 84 { |
| 84 return adoptRefWillBeNoop(new EditingStyle(position, propertiesToInclude )); | 85 return adoptRefWillBeNoop(new EditingStyle(position, propertiesToInclude )); |
| 85 } | 86 } |
| 86 | 87 |
| 87 static PassRefPtrWillBeRawPtr<EditingStyle> create(const StylePropertySet* s tyle) | 88 static PassRefPtrWillBeRawPtr<EditingStyle> create(const StylePropertySet* s tyle) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 98 | 99 |
| 99 MutableStylePropertySet* style() { return m_mutableStyle.get(); } | 100 MutableStylePropertySet* style() { return m_mutableStyle.get(); } |
| 100 bool textDirection(WritingDirection&) const; | 101 bool textDirection(WritingDirection&) const; |
| 101 bool isEmpty() const; | 102 bool isEmpty() const; |
| 102 void overrideWithStyle(const StylePropertySet*); | 103 void overrideWithStyle(const StylePropertySet*); |
| 103 void clear(); | 104 void clear(); |
| 104 PassRefPtrWillBeRawPtr<EditingStyle> copy() const; | 105 PassRefPtrWillBeRawPtr<EditingStyle> copy() const; |
| 105 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveBlockProperties(); | 106 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveBlockProperties(); |
| 106 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveTextDirection(); | 107 PassRefPtrWillBeRawPtr<EditingStyle> extractAndRemoveTextDirection(); |
| 107 void removeBlockProperties(); | 108 void removeBlockProperties(); |
| 108 void removeStyleAddedByNode(Node*); | 109 void removeStyleAddedByElement(Element*); |
| 109 void removeStyleConflictingWithStyleOfNode(Node*); | 110 void removeStyleConflictingWithStyleOfElement(Element*); |
| 110 void collapseTextDecorationProperties(); | 111 void collapseTextDecorationProperties(); |
| 111 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT extOnlyProperties }; | 112 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT extOnlyProperties }; |
| 112 TriState triStateOfStyle(EditingStyle*) const; | 113 TriState triStateOfStyle(EditingStyle*) const; |
| 113 TriState triStateOfStyle(const VisibleSelection&) const; | 114 TriState triStateOfStyle(const VisibleSelection&) const; |
| 114 bool conflictsWithInlineStyleOfElement(Element* element) const { return conf lictsWithInlineStyleOfElement(element, 0, 0); } | 115 bool conflictsWithInlineStyleOfElement(HTMLElement* element) const { return conflictsWithInlineStyleOfElement(element, 0, 0); } |
| 115 bool conflictsWithInlineStyleOfElement(Element* element, EditingStyle* extra ctedStyle, Vector<CSSPropertyID>& conflictingProperties) const | 116 bool conflictsWithInlineStyleOfElement(HTMLElement* element, EditingStyle* e xtractedStyle, Vector<CSSPropertyID>& conflictingProperties) const |
| 116 { | 117 { |
| 117 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl ictingProperties); | 118 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl ictingProperties); |
| 118 } | 119 } |
| 119 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract edStyle = 0, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const; | 120 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract edStyle = 0, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const; |
| 120 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; | 121 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const; |
| 121 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv eWritingDirection, EditingStyle* extractedStyle, | 122 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv eWritingDirection, EditingStyle* extractedStyle, |
| 122 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingS tyle) const; | 123 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingS tyle) const; |
| 123 bool styleIsPresentInComputedStyleOfNode(Node*) const; | 124 bool styleIsPresentInComputedStyleOfNode(Node*) const; |
| 124 | 125 |
| 125 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); | 126 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); |
| 126 | 127 |
| 127 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo tPreserveWritingDirection); | 128 void prepareToApplyAt(const Position&, ShouldPreserveWritingDirection = DoNo tPreserveWritingDirection); |
| 128 void mergeTypingStyle(Document*); | 129 void mergeTypingStyle(Document*); |
| 129 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; | 130 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues }; |
| 130 void mergeInlineStyleOfElement(Element*, CSSPropertyOverrideMode, Properties ToInclude = AllProperties); | 131 void mergeInlineStyleOfElement(HTMLElement*, CSSPropertyOverrideMode, Proper tiesToInclude = AllProperties); |
| 131 static PassRefPtrWillBeRawPtr<EditingStyle> wrappingStyleForSerialization(No de* context, bool shouldAnnotate); | 132 static PassRefPtrWillBeRawPtr<EditingStyle> wrappingStyleForSerialization(Co ntainerNode* context, bool shouldAnnotate); |
| 132 void mergeStyleFromRules(Element*); | 133 void mergeStyleFromRules(Element*); |
| 133 void mergeStyleFromRulesForSerialization(Element*); | 134 void mergeStyleFromRulesForSerialization(Element*); |
| 134 void removeStyleFromRulesAndContext(Element*, Node* context); | 135 void removeStyleFromRulesAndContext(Element*, ContainerNode* context); |
| 135 void removePropertiesInElementDefaultStyle(Element*); | 136 void removePropertiesInElementDefaultStyle(Element*); |
| 136 void addAbsolutePositioningFromElement(const Element&); | 137 void addAbsolutePositioningFromElement(const Element&); |
| 137 void forceInline(); | 138 void forceInline(); |
| 138 int legacyFontSize(Document*) const; | 139 int legacyFontSize(Document*) const; |
| 139 | 140 |
| 140 float fontSizeDelta() const { return m_fontSizeDelta; } | 141 float fontSizeDelta() const { return m_fontSizeDelta; } |
| 141 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } | 142 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; } |
| 142 | 143 |
| 143 static PassRefPtrWillBeRawPtr<EditingStyle> styleAtSelectionStart(const Visi bleSelection&, bool shouldUseBackgroundColorInEffect = false); | 144 static PassRefPtrWillBeRawPtr<EditingStyle> styleAtSelectionStart(const Visi bleSelection&, bool shouldUseBackgroundColorInEffect = false); |
| 144 static WritingDirection textDirectionForSelection(const VisibleSelection&, E ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); | 145 static WritingDirection textDirectionForSelection(const VisibleSelection&, E ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings); |
| 145 | 146 |
| 146 void trace(Visitor*); | 147 void trace(Visitor*); |
| 147 | 148 |
| 148 private: | 149 private: |
| 149 EditingStyle(); | 150 EditingStyle(); |
| 150 EditingStyle(Node*, PropertiesToInclude); | 151 EditingStyle(ContainerNode*, PropertiesToInclude); |
| 151 EditingStyle(const Position&, PropertiesToInclude); | 152 EditingStyle(const Position&, PropertiesToInclude); |
| 152 explicit EditingStyle(const StylePropertySet*); | 153 explicit EditingStyle(const StylePropertySet*); |
| 153 EditingStyle(CSSPropertyID, const String& value); | 154 EditingStyle(CSSPropertyID, const String& value); |
| 154 void init(Node*, PropertiesToInclude); | 155 void init(Node*, PropertiesToInclude); |
| 155 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*); | 156 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*); |
| 156 void setProperty(CSSPropertyID, const String& value, bool important = false) ; | 157 void setProperty(CSSPropertyID, const String& value, bool important = false) ; |
| 157 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar ation*); | 158 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar ation*); |
| 158 void extractFontSizeDelta(); | 159 void extractFontSizeDelta(); |
| 159 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe xtOnlyProperties) const; | 160 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe xtOnlyProperties) const; |
| 160 bool conflictsWithInlineStyleOfElement(Element*, EditingStyle* extractedStyl e, Vector<CSSPropertyID>* conflictingProperties) const; | 161 bool conflictsWithInlineStyleOfElement(HTMLElement*, EditingStyle* extracted Style, Vector<CSSPropertyID>* conflictingProperties) const; |
|
eseidel
2014/07/26 21:19:15
Again, this clearly assumes non-SVG content? It's
leviw_travelin_and_unemployed
2014/07/29 21:59:18
From what I can tell, the only tests covering edit
| |
| 161 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode, PropertiesToInclude); | 162 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode, PropertiesToInclude); |
| 162 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); | 163 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); |
| 163 | 164 |
| 164 RefPtrWillBeMember<MutableStylePropertySet> m_mutableStyle; | 165 RefPtrWillBeMember<MutableStylePropertySet> m_mutableStyle; |
| 165 FixedPitchFontType m_fixedPitchFontType; | 166 FixedPitchFontType m_fixedPitchFontType; |
| 166 float m_fontSizeDelta; | 167 float m_fontSizeDelta; |
| 167 | 168 |
| 168 friend class HTMLElementEquivalent; | 169 friend class HTMLElementEquivalent; |
| 169 friend class HTMLAttributeEquivalent; | 170 friend class HTMLAttributeEquivalent; |
| 170 }; | 171 }; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 String m_applyFontSize; | 230 String m_applyFontSize; |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 // FIXME: Remove these functions or make them non-global to discourage using CSS StyleDeclaration directly. | 233 // FIXME: Remove these functions or make them non-global to discourage using CSS StyleDeclaration directly. |
| 233 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); | 234 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); |
| 234 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); | 235 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID); |
| 235 | 236 |
| 236 } // namespace blink | 237 } // namespace blink |
| 237 | 238 |
| 238 #endif // EditingStyle_h | 239 #endif // EditingStyle_h |
| OLD | NEW |