| 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 28 matching lines...) Expand all Loading... |
| 39 enum ShouldIncludeTypingStyle { IncludeTypingStyle, IgnoreTypingStyle }; | 39 enum ShouldIncludeTypingStyle { IncludeTypingStyle, IgnoreTypingStyle }; |
| 40 | 40 |
| 41 class ApplyStyleCommand final : public CompositeEditCommand { | 41 class ApplyStyleCommand final : public CompositeEditCommand { |
| 42 public: | 42 public: |
| 43 enum EPropertyLevel { PropertyDefault, ForceBlockProperties }; | 43 enum EPropertyLevel { PropertyDefault, ForceBlockProperties }; |
| 44 enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone }; | 44 enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone }; |
| 45 enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement }; | 45 enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement }; |
| 46 typedef bool (*IsInlineElementToRemoveFunction)(const Element*); | 46 typedef bool (*IsInlineElementToRemoveFunction)(const Element*); |
| 47 | 47 |
| 48 static ApplyStyleCommand* create(Document& document, | 48 static ApplyStyleCommand* create(Document& document, |
| 49 CommandSource source, |
| 49 const EditingStyle* style, | 50 const EditingStyle* style, |
| 50 InputEvent::InputType inputType, | 51 InputEvent::InputType inputType, |
| 51 EPropertyLevel level = PropertyDefault) { | 52 EPropertyLevel level = PropertyDefault) { |
| 52 return new ApplyStyleCommand(document, style, inputType, level); | 53 return new ApplyStyleCommand(document, source, style, inputType, level); |
| 53 } | 54 } |
| 54 static ApplyStyleCommand* create(Document& document, | 55 static ApplyStyleCommand* create(Document& document, |
| 56 CommandSource source, |
| 55 const EditingStyle* style, | 57 const EditingStyle* style, |
| 56 const Position& start, | 58 const Position& start, |
| 57 const Position& end) { | 59 const Position& end) { |
| 58 return new ApplyStyleCommand(document, style, start, end); | 60 return new ApplyStyleCommand(document, source, style, start, end); |
| 59 } | 61 } |
| 60 static ApplyStyleCommand* create(Element* element, bool removeOnly) { | 62 static ApplyStyleCommand* create(CommandSource source, |
| 61 return new ApplyStyleCommand(element, removeOnly); | 63 Element* element, |
| 64 bool removeOnly) { |
| 65 return new ApplyStyleCommand(source, element, removeOnly); |
| 62 } | 66 } |
| 63 static ApplyStyleCommand* create( | 67 static ApplyStyleCommand* create( |
| 64 Document& document, | 68 Document& document, |
| 69 CommandSource source, |
| 65 const EditingStyle* style, | 70 const EditingStyle* style, |
| 66 IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, | 71 IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, |
| 67 InputEvent::InputType inputType) { | 72 InputEvent::InputType inputType) { |
| 68 return new ApplyStyleCommand(document, style, | 73 return new ApplyStyleCommand(document, source, style, |
| 69 isInlineElementToRemoveFunction, inputType); | 74 isInlineElementToRemoveFunction, inputType); |
| 70 } | 75 } |
| 71 | 76 |
| 72 DECLARE_VIRTUAL_TRACE(); | 77 DECLARE_VIRTUAL_TRACE(); |
| 73 | 78 |
| 74 private: | 79 private: |
| 75 ApplyStyleCommand(Document&, | 80 ApplyStyleCommand(Document&, |
| 81 CommandSource, |
| 76 const EditingStyle*, | 82 const EditingStyle*, |
| 77 InputEvent::InputType, | 83 InputEvent::InputType, |
| 78 EPropertyLevel); | 84 EPropertyLevel); |
| 79 ApplyStyleCommand(Document&, | 85 ApplyStyleCommand(Document&, |
| 86 CommandSource, |
| 80 const EditingStyle*, | 87 const EditingStyle*, |
| 81 const Position& start, | 88 const Position& start, |
| 82 const Position& end); | 89 const Position& end); |
| 83 ApplyStyleCommand(Element*, bool removeOnly); | 90 ApplyStyleCommand(CommandSource, Element*, bool removeOnly); |
| 84 ApplyStyleCommand(Document&, | 91 ApplyStyleCommand(Document&, |
| 92 CommandSource, |
| 85 const EditingStyle*, | 93 const EditingStyle*, |
| 86 bool (*isInlineElementToRemove)(const Element*), | 94 bool (*isInlineElementToRemove)(const Element*), |
| 87 InputEvent::InputType); | 95 InputEvent::InputType); |
| 88 | 96 |
| 89 void doApply(EditingState*) override; | 97 void doApply(EditingState*) override; |
| 90 InputEvent::InputType inputType() const override; | 98 InputEvent::InputType inputType() const override; |
| 91 | 99 |
| 92 // style-removal helpers | 100 // style-removal helpers |
| 93 bool isStyledInlineElementToRemove(Element*) const; | 101 bool isStyledInlineElementToRemove(Element*) const; |
| 94 bool shouldApplyInlineStyleToRun(EditingStyle*, | 102 bool shouldApplyInlineStyleToRun(EditingStyle*, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 StyleAttributeShouldBeEmpty | 216 StyleAttributeShouldBeEmpty |
| 209 }; | 217 }; |
| 210 bool isEmptyFontTag(const Element*, | 218 bool isEmptyFontTag(const Element*, |
| 211 ShouldStyleAttributeBeEmpty = StyleAttributeShouldBeEmpty); | 219 ShouldStyleAttributeBeEmpty = StyleAttributeShouldBeEmpty); |
| 212 bool isLegacyAppleHTMLSpanElement(const Node*); | 220 bool isLegacyAppleHTMLSpanElement(const Node*); |
| 213 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*); | 221 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*); |
| 214 | 222 |
| 215 } // namespace blink | 223 } // namespace blink |
| 216 | 224 |
| 217 #endif | 225 #endif |
| OLD | NEW |