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

Side by Side Diff: Source/core/editing/ApplyStyleCommand.h

Issue 1294543005: Move execCommand related files in core/editing/ related files into core/editing/commands/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-18T14:20:58 Rebase for merging code style fixes Created 5 years, 4 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
(Empty)
1 /*
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef ApplyStyleCommand_h
27 #define ApplyStyleCommand_h
28
29 #include "core/editing/CompositeEditCommand.h"
30 #include "core/editing/WritingDirection.h"
31 #include "core/html/HTMLElement.h"
32
33 namespace blink {
34
35 class EditingStyle;
36 class HTMLSpanElement;
37 class StyleChange;
38
39 enum ShouldIncludeTypingStyle {
40 IncludeTypingStyle,
41 IgnoreTypingStyle
42 };
43
44 class ApplyStyleCommand final : public CompositeEditCommand {
45 public:
46 enum EPropertyLevel { PropertyDefault, ForceBlockProperties };
47 enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone };
48 enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement };
49 typedef bool (*IsInlineElementToRemoveFunction)(const Element*);
50
51 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document, const EditingStyle* style, EditAction action = EditActionChangeAttributes, EProp ertyLevel level = PropertyDefault)
52 {
53 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, action, level));
54 }
55 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document, const EditingStyle* style, const Position& start, const Position& end, EditActio n action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault)
56 {
57 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, start, end, action, level));
58 }
59 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(PassRefPtrWillBeRawP tr<Element> element, bool removeOnly = false, EditAction action = EditActionChan geAttributes)
60 {
61 return adoptRefWillBeNoop(new ApplyStyleCommand(element, removeOnly, act ion));
62 }
63 static PassRefPtrWillBeRawPtr<ApplyStyleCommand> create(Document& document, const EditingStyle* style, IsInlineElementToRemoveFunction isInlineElementToRemo veFunction, EditAction action = EditActionChangeAttributes)
64 {
65 return adoptRefWillBeNoop(new ApplyStyleCommand(document, style, isInlin eElementToRemoveFunction, action));
66 }
67
68 DECLARE_VIRTUAL_TRACE();
69
70 private:
71 ApplyStyleCommand(Document&, const EditingStyle*, EditAction, EPropertyLevel );
72 ApplyStyleCommand(Document&, const EditingStyle*, const Position& start, con st Position& end, EditAction, EPropertyLevel);
73 ApplyStyleCommand(PassRefPtrWillBeRawPtr<Element>, bool removeOnly, EditActi on);
74 ApplyStyleCommand(Document&, const EditingStyle*, bool (*isInlineElementToRe move)(const Element*), EditAction);
75
76 void doApply() override;
77 EditAction editingAction() const override;
78
79 // style-removal helpers
80 bool isStyledInlineElementToRemove(Element*) const;
81 bool shouldApplyInlineStyleToRun(EditingStyle*, Node* runStart, Node* pastEn dNode);
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 = nullptr);
84 inline bool shouldRemoveInlineStyleFromElement(EditingStyle* style, HTMLElem ent* element) {return removeInlineStyleFromElement(style, element, RemoveNone);}
85 void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*);
86 bool removeImplicitlyStyledElement(EditingStyle*, HTMLElement*, InlineStyleR emovalMode, EditingStyle* extractedStyle);
87 bool removeCSSStyle(EditingStyle*, HTMLElement*, InlineStyleRemovalMode = Re moveIfNeeded, EditingStyle* extractedStyle = nullptr);
88 HTMLElement* highestAncestorWithConflictingInlineStyle(EditingStyle*, Node*) ;
89 void applyInlineStyleToPushDown(Node*, EditingStyle*);
90 void pushDownInlineStyleAroundNode(EditingStyle*, Node*);
91 void removeInlineStyle(EditingStyle* , const Position& start, const Position & end);
92 bool elementFullySelected(HTMLElement&, const Position& start, const Positio n& end) const;
93
94 // style-application helpers
95 void applyBlockStyle(EditingStyle*);
96 void applyRelativeFontStyleChange(EditingStyle*);
97 void applyInlineStyle(EditingStyle*);
98 void fixRangeAndApplyInlineStyle(EditingStyle*, const Position& start, const Position& end);
99 void applyInlineStyleToNodeRange(EditingStyle*, PassRefPtrWillBeRawPtr<Node> startNode, PassRefPtrWillBeRawPtr<Node> pastEndNode);
100 void addBlockStyle(const StyleChange&, HTMLElement*);
101 void addInlineStyleIfNeeded(EditingStyle*, PassRefPtrWillBeRawPtr<Node> star t, PassRefPtrWillBeRawPtr<Node> end, EAddStyledElement = AddStyledElement);
102 Position positionToComputeInlineStyleChange(PassRefPtrWillBeRawPtr<Node>, Re fPtrWillBeMember<HTMLSpanElement>& dummyElement);
103 void applyInlineStyleChange(PassRefPtrWillBeRawPtr<Node> startNode, PassRefP trWillBeRawPtr<Node> endNode, StyleChange&, EAddStyledElement);
104 void splitTextAtStart(const Position& start, const Position& end);
105 void splitTextAtEnd(const Position& start, const Position& end);
106 void splitTextElementAtStart(const Position& start, const Position& end);
107 void splitTextElementAtEnd(const Position& start, const Position& end);
108 bool shouldSplitTextElement(Element*, EditingStyle*);
109 bool isValidCaretPositionInTextNode(const Position&);
110 bool mergeStartWithPreviousIfIdentical(const Position& start, const Position & end);
111 bool mergeEndWithNextIfIdentical(const Position& start, const Position& end) ;
112 void cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanAncestor);
113
114 void surroundNodeRangeWithElement(PassRefPtrWillBeRawPtr<Node> start, PassRe fPtrWillBeRawPtr<Node> end, PassRefPtrWillBeRawPtr<Element>);
115 float computedFontSize(Node*);
116 void joinChildTextNodes(ContainerNode*, const Position& start, const Positio n& end);
117
118 HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, WritingDirect ion allowedDirection);
119 void removeEmbeddingUpToEnclosingBlock(Node*, HTMLElement* unsplitAncestor);
120
121 void updateStartEnd(const Position& newStart, const Position& newEnd);
122 Position startPosition();
123 Position endPosition();
124
125 RefPtrWillBeMember<EditingStyle> m_style;
126 EditAction m_editingAction;
127 EPropertyLevel m_propertyLevel;
128 Position m_start;
129 Position m_end;
130 bool m_useEndingSelection;
131 RefPtrWillBeMember<Element> m_styledInlineElement;
132 bool m_removeOnly;
133 IsInlineElementToRemoveFunction m_isInlineElementToRemoveFunction;
134 };
135
136 enum ShouldStyleAttributeBeEmpty { AllowNonEmptyStyleAttribute, StyleAttributeSh ouldBeEmpty };
137 bool isEmptyFontTag(const Element*, ShouldStyleAttributeBeEmpty = StyleAttribute ShouldBeEmpty);
138 bool isLegacyAppleHTMLSpanElement(const Node*);
139 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*);
140 PassRefPtrWillBeRawPtr<HTMLSpanElement> createStyleSpanElement(Document&);
141
142 } // namespace blink
143
144 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698