Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1764)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.h

Issue 2151353002: [InputEvent] Replace |EditAction| with |InputType| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inputevent-text-styling
Patch Set: Replaced |EditAction| with |InputType| Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
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 ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, EditAction action, EPropertyLevel level = PropertyDefault) 51 static ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, InputEvent::InputType inputType, EPropertyLevel level = PropertyDefault)
52 { 52 {
53 return new ApplyStyleCommand(document, style, action, level); 53 return new ApplyStyleCommand(document, style, inputType, level);
54 } 54 }
55 static ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, const Position& start, const Position& end) 55 static ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, const Position& start, const Position& end)
56 { 56 {
57 return new ApplyStyleCommand(document, style, start, end); 57 return new ApplyStyleCommand(document, style, start, end);
58 } 58 }
59 static ApplyStyleCommand* create(Element* element, bool removeOnly) 59 static ApplyStyleCommand* create(Element* element, bool removeOnly)
60 { 60 {
61 return new ApplyStyleCommand(element, removeOnly); 61 return new ApplyStyleCommand(element, removeOnly);
62 } 62 }
63 static ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, EditAction action) 63 static ApplyStyleCommand* create(Document& document, const EditingStyle* sty le, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, InputEvent: :InputType inputType)
64 { 64 {
65 return new ApplyStyleCommand(document, style, isInlineElementToRemoveFun ction, action); 65 return new ApplyStyleCommand(document, style, isInlineElementToRemoveFun ction, inputType);
66 } 66 }
67 67
68 DECLARE_VIRTUAL_TRACE(); 68 DECLARE_VIRTUAL_TRACE();
69 69
70 private: 70 private:
71 ApplyStyleCommand(Document&, const EditingStyle*, EditAction, EPropertyLevel ); 71 ApplyStyleCommand(Document&, const EditingStyle*, InputEvent::InputType, EPr opertyLevel);
72 ApplyStyleCommand(Document&, const EditingStyle*, const Position& start, con st Position& end); 72 ApplyStyleCommand(Document&, const EditingStyle*, const Position& start, con st Position& end);
73 ApplyStyleCommand(Element*, bool removeOnly); 73 ApplyStyleCommand(Element*, bool removeOnly);
74 ApplyStyleCommand(Document&, const EditingStyle*, bool (*isInlineElementToRe move)(const Element*), EditAction); 74 ApplyStyleCommand(Document&, const EditingStyle*, bool (*isInlineElementToRe move)(const Element*), InputEvent::InputType);
75 75
76 void doApply(EditingState*) override; 76 void doApply(EditingState*) override;
77 EditAction editingAction() const override; 77 InputEvent::InputType inputType() 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*, Member<Node>& runSta rt, Member<Node>& runEnd, Node* pastEndNode, EditingState*); 82 void removeConflictingInlineStyleFromRun(EditingStyle*, Member<Node>& runSta rt, Member<Node>& runEnd, Node* pastEndNode, EditingState*);
83 bool removeInlineStyleFromElement(EditingStyle*, HTMLElement*, EditingState* , InlineStyleRemovalMode = RemoveIfNeeded, EditingStyle* extractedStyle = nullpt r); 83 bool removeInlineStyleFromElement(EditingStyle*, HTMLElement*, EditingState* , InlineStyleRemovalMode = RemoveIfNeeded, EditingStyle* extractedStyle = nullpt r);
84 inline bool shouldRemoveInlineStyleFromElement(EditingStyle* style, HTMLElem ent* element) { return removeInlineStyleFromElement(style, element, ASSERT_NO_ED ITING_ABORT, RemoveNone); } 84 inline bool shouldRemoveInlineStyleFromElement(EditingStyle* style, HTMLElem ent* element) { return removeInlineStyleFromElement(style, element, ASSERT_NO_ED ITING_ABORT, RemoveNone); }
85 void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*, EditingState*) ; 85 void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*, EditingState*) ;
86 bool removeImplicitlyStyledElement(EditingStyle*, HTMLElement*, InlineStyleR emovalMode, EditingStyle* extractedStyle, EditingState*); 86 bool removeImplicitlyStyledElement(EditingStyle*, HTMLElement*, InlineStyleR emovalMode, EditingStyle* extractedStyle, EditingState*);
87 bool removeCSSStyle(EditingStyle*, HTMLElement*, EditingState*, InlineStyleR emovalMode = RemoveIfNeeded, EditingStyle* extractedStyle = nullptr); 87 bool removeCSSStyle(EditingStyle*, HTMLElement*, EditingState*, InlineStyleR emovalMode = RemoveIfNeeded, EditingStyle* extractedStyle = nullptr);
(...skipping 28 matching lines...) Expand all
116 void joinChildTextNodes(ContainerNode*, const Position& start, const Positio n& end); 116 void joinChildTextNodes(ContainerNode*, const Position& start, const Positio n& end);
117 117
118 HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, WritingDirect ion allowedDirection); 118 HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, WritingDirect ion allowedDirection);
119 void removeEmbeddingUpToEnclosingBlock(Node*, HTMLElement* unsplitAncestor, EditingState*); 119 void removeEmbeddingUpToEnclosingBlock(Node*, HTMLElement* unsplitAncestor, EditingState*);
120 120
121 void updateStartEnd(const Position& newStart, const Position& newEnd); 121 void updateStartEnd(const Position& newStart, const Position& newEnd);
122 Position startPosition(); 122 Position startPosition();
123 Position endPosition(); 123 Position endPosition();
124 124
125 Member<EditingStyle> m_style; 125 Member<EditingStyle> m_style;
126 EditAction m_editingAction; 126 InputEvent::InputType m_inputType;
127 EPropertyLevel m_propertyLevel; 127 EPropertyLevel m_propertyLevel;
128 Position m_start; 128 Position m_start;
129 Position m_end; 129 Position m_end;
130 bool m_useEndingSelection; 130 bool m_useEndingSelection;
131 Member<Element> m_styledInlineElement; 131 Member<Element> m_styledInlineElement;
132 bool m_removeOnly; 132 bool m_removeOnly;
133 IsInlineElementToRemoveFunction m_isInlineElementToRemoveFunction; 133 IsInlineElementToRemoveFunction m_isInlineElementToRemoveFunction;
134 }; 134 };
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 140
141 } // namespace blink 141 } // namespace blink
142 142
143 #endif 143 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698