| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 class EditingStyle; | 35 class EditingStyle; |
| 36 class HTMLSpanElement; | 36 class HTMLSpanElement; |
| 37 class StyleChange; | 37 class StyleChange; |
| 38 | 38 |
| 39 enum ShouldIncludeTypingStyle { | 39 enum ShouldIncludeTypingStyle { |
| 40 IncludeTypingStyle, | 40 IncludeTypingStyle, |
| 41 IgnoreTypingStyle | 41 IgnoreTypingStyle |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class ApplyStyleCommand FINAL : public CompositeEditCommand { | 44 class ApplyStyleCommand final : public CompositeEditCommand { |
| 45 public: | 45 public: |
| 46 enum EPropertyLevel { PropertyDefault, ForceBlockProperties }; | 46 enum EPropertyLevel { PropertyDefault, ForceBlockProperties }; |
| 47 enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone }; | 47 enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone }; |
| 48 enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement }; | 48 enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement }; |
| 49 typedef bool (*IsInlineElementToRemoveFunction)(const Element*); | 49 typedef bool (*IsInlineElementToRemoveFunction)(const Element*); |
| 50 | 50 |
| 51 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, EditAction action = EditActionChangeAttributes, EProp
ertyLevel level = PropertyDefault) | 51 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, EditAction action = EditActionChangeAttributes, EProp
ertyLevel level = PropertyDefault) |
| 52 { | 52 { |
| 53 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, action,
level)); | 53 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, action,
level)); |
| 54 } | 54 } |
| 55 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, const Position& start, const Position& end, EditActio
n action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault) | 55 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, const Position& start, const Position& end, EditActio
n action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault) |
| 56 { | 56 { |
| 57 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, start,
end, action, level)); | 57 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, start,
end, action, level)); |
| 58 } | 58 } |
| 59 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(PassRefPtrWillBeRawP
tr<Element> element, bool removeOnly = false, EditAction action = EditActionChan
geAttributes) | 59 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(PassRefPtrWillBeRawP
tr<Element> element, bool removeOnly = false, EditAction action = EditActionChan
geAttributes) |
| 60 { | 60 { |
| 61 return adoptRefWillBeNoop(new ApplyStyleCommand(element, removeOnly, act
ion)); | 61 return adoptRefWillBeNoop(new ApplyStyleCommand(element, removeOnly, act
ion)); |
| 62 } | 62 } |
| 63 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, IsInlineElementToRemoveFunction isInlineElementToRemo
veFunction, EditAction action = EditActionChangeAttributes) | 63 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document,
const EditingStyle* style, IsInlineElementToRemoveFunction isInlineElementToRemo
veFunction, EditAction action = EditActionChangeAttributes) |
| 64 { | 64 { |
| 65 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, isInlin
eElementToRemoveFunction, action)); | 65 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, isInlin
eElementToRemoveFunction, action)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void trace(Visitor*) OVERRIDE; | 68 virtual void trace(Visitor*) override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 ApplyStyleCommand(Document&, const EditingStyle*, EditAction, EPropertyLevel
); | 71 ApplyStyleCommand(Document&, const EditingStyle*, EditAction, EPropertyLevel
); |
| 72 ApplyStyleCommand(Document&, const EditingStyle*, const Position& start, con
st Position& end, EditAction, EPropertyLevel); | 72 ApplyStyleCommand(Document&, const EditingStyle*, const Position& start, con
st Position& end, EditAction, EPropertyLevel); |
| 73 ApplyStyleCommand(PassRefPtrWillBeRawPtr<Element>, bool removeOnly, EditActi
on); | 73 ApplyStyleCommand(PassRefPtrWillBeRawPtr<Element>, bool removeOnly, EditActi
on); |
| 74 ApplyStyleCommand(Document&, const EditingStyle*, bool (*isInlineElementToRe
move)(const Element*), EditAction); | 74 ApplyStyleCommand(Document&, const EditingStyle*, bool (*isInlineElementToRe
move)(const Element*), EditAction); |
| 75 | 75 |
| 76 virtual void doApply() OVERRIDE; | 76 virtual void doApply() override; |
| 77 virtual EditAction editingAction() const OVERRIDE; | 77 virtual EditAction editingAction() const override; |
| 78 | 78 |
| 79 // style-removal helpers | 79 // style-removal helpers |
| 80 bool isStyledInlineElementToRemove(Element*) const; | 80 bool isStyledInlineElementToRemove(Element*) const; |
| 81 bool shouldApplyInlineStyleToRun(EditingStyle*, Node* runStart, Node* pastEn
dNode); | 81 bool shouldApplyInlineStyleToRun(EditingStyle*, Node* runStart, Node* pastEn
dNode); |
| 82 void removeConflictingInlineStyleFromRun(EditingStyle*, RefPtrWillBeMember<N
ode>& runStart, RefPtrWillBeMember<Node>& runEnd, PassRefPtrWillBeRawPtr<Node> p
astEndNode); | 82 void removeConflictingInlineStyleFromRun(EditingStyle*, RefPtrWillBeMember<N
ode>& runStart, RefPtrWillBeMember<Node>& runEnd, PassRefPtrWillBeRawPtr<Node> p
astEndNode); |
| 83 bool removeInlineStyleFromElement(EditingStyle*, PassRefPtrWillBeRawPtr<HTML
Element>, InlineStyleRemovalMode = RemoveIfNeeded, EditingStyle* extractedStyle
= 0); | 83 bool removeInlineStyleFromElement(EditingStyle*, PassRefPtrWillBeRawPtr<HTML
Element>, InlineStyleRemovalMode = RemoveIfNeeded, EditingStyle* extractedStyle
= 0); |
| 84 inline bool shouldRemoveInlineStyleFromElement(EditingStyle* style, HTMLElem
ent* element) {return removeInlineStyleFromElement(style, element, RemoveNone);} | 84 inline bool shouldRemoveInlineStyleFromElement(EditingStyle* style, HTMLElem
ent* element) {return removeInlineStyleFromElement(style, element, RemoveNone);} |
| 85 void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*); | 85 void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*); |
| 86 bool removeImplicitlyStyledElement(EditingStyle*, HTMLElement*, InlineStyleR
emovalMode, EditingStyle* extractedStyle); | 86 bool removeImplicitlyStyledElement(EditingStyle*, HTMLElement*, InlineStyleR
emovalMode, EditingStyle* extractedStyle); |
| 87 bool removeCSSStyle(EditingStyle*, HTMLElement*, InlineStyleRemovalMode = Re
moveIfNeeded, EditingStyle* extractedStyle = 0); | 87 bool removeCSSStyle(EditingStyle*, HTMLElement*, InlineStyleRemovalMode = Re
moveIfNeeded, EditingStyle* extractedStyle = 0); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 enum ShouldStyleAttributeBeEmpty { AllowNonEmptyStyleAttribute, StyleAttributeSh
ouldBeEmpty }; | 136 enum ShouldStyleAttributeBeEmpty { AllowNonEmptyStyleAttribute, StyleAttributeSh
ouldBeEmpty }; |
| 137 bool isEmptyFontTag(const Element*, ShouldStyleAttributeBeEmpty = StyleAttribute
ShouldBeEmpty); | 137 bool isEmptyFontTag(const Element*, ShouldStyleAttributeBeEmpty = StyleAttribute
ShouldBeEmpty); |
| 138 bool isLegacyAppleHTMLSpanElement(const Node*); | 138 bool isLegacyAppleHTMLSpanElement(const Node*); |
| 139 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*); | 139 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*); |
| 140 PassRefPtrWillBeRawPtr<HTMLSpanElement> createStyleSpanElement(Document&); | 140 PassRefPtrWillBeRawPtr<HTMLSpanElement> createStyleSpanElement(Document&); |
| 141 | 141 |
| 142 } // namespace blink | 142 } // namespace blink |
| 143 | 143 |
| 144 #endif | 144 #endif |
| OLD | NEW |