class ApplyStyleCommand : public CompositeEditCommand {
public:
enum EPropertyLevel { PropertyDefault, ForceBlockProperties };
+ enum InlineStyleRemovalMode { RemoveIfNeeded, RemoveAlways, RemoveNone };
+ enum EAddStyledElement { AddStyledElement, DoNotAddStyledElement };
+ typedef bool (*IsInlineElementToRemoveFunction)(const Element*);
static PassRefPtr<ApplyStyleCommand> create(Document* document, CSSStyleDeclaration* style, EditAction action = EditActionChangeAttributes, EPropertyLevel level = PropertyDefault)
{
{
return adoptRef(new ApplyStyleCommand(element, removeOnly, action));
}
-
+ static PassRefPtr<ApplyStyleCommand> create(Document* document, CSSStyleDeclaration* style, IsInlineElementToRemoveFunction isInlineElementToRemoveFunction, EditAction action = EditActionChangeAttributes)
+ {
+ return adoptRef(new ApplyStyleCommand(document, style, isInlineElementToRemoveFunction, action));
+ }
+
+ static RefPtr<CSSMutableStyleDeclaration> removeNonEditingProperties(CSSStyleDeclaration* style);
static PassRefPtr<CSSMutableStyleDeclaration> editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle = IgnoreTypingStyle);
private:
ApplyStyleCommand(Document*, CSSStyleDeclaration*, EditAction, EPropertyLevel);
ApplyStyleCommand(Document*, CSSStyleDeclaration*, const Position& start, const Position& end, EditAction, EPropertyLevel);
ApplyStyleCommand(PassRefPtr<Element>, bool removeOnly, EditAction);
+ ApplyStyleCommand(Document*, CSSStyleDeclaration*, bool (*isInlineElementToRemove)(const Element*), EditAction);
virtual void doApply();
virtual EditAction editingAction() const;
CSSMutableStyleDeclaration* style() const { return m_style.get(); }
// style-removal helpers
- bool shouldRemoveTextDecorationTag(CSSStyleDeclaration* styleToApply, int textDecorationAddedByTag) const;
- bool implicitlyStyledElementShouldBeRemovedWhenApplyingStyle(HTMLElement*, CSSMutableStyleDeclaration*);
+ bool isStyledInlineElementToRemove(Element*) const;
+ bool removeStyleFromRunBeforeApplyingStyle(CSSMutableStyleDeclaration* style, Node*& runStart, Node*& runEnd);
+ bool removeInlineStyleFromElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded, CSSMutableStyleDeclaration* extractedStyle = 0);
+ inline bool shouldRemoveInlineStyleFromElement(CSSMutableStyleDeclaration* style, HTMLElement* element) {return removeInlineStyleFromElement(style, element, RemoveNone);}
+ bool removeImplicitlyStyledElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode, CSSMutableStyleDeclaration* extractedStyle);
void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*&);
- void removeHTMLFontStyle(CSSMutableStyleDeclaration*, HTMLElement*);
- void removeHTMLBidiEmbeddingStyle(CSSMutableStyleDeclaration*, HTMLElement*);
- void removeCSSStyle(CSSMutableStyleDeclaration*, HTMLElement*);
+ bool removeCSSStyle(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded, CSSMutableStyleDeclaration* extractedStyle = 0);
+ HTMLElement* highestAncestorWithConflictingInlineStyle(CSSMutableStyleDeclaration*, Node*);
+ void applyInlineStyleToPushDown(Node*, CSSMutableStyleDeclaration *style);
+ void pushDownInlineStyleAroundNode(CSSMutableStyleDeclaration*, Node*);
void removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration>, const Position& start, const Position& end);
bool nodeFullySelected(Node*, const Position& start, const Position& end) const;
bool nodeFullyUnselected(Node*, const Position& start, const Position& end) const;
- PassRefPtr<CSSMutableStyleDeclaration> extractTextDecorationStyle(Node*);
- PassRefPtr<CSSMutableStyleDeclaration> extractAndNegateTextDecorationStyle(Node*);
- void applyTextDecorationStyle(Node*, CSSMutableStyleDeclaration *style);
- void pushDownTextDecorationStyleAroundNode(Node*, bool forceNegate);
- void pushDownTextDecorationStyleAtBoundaries(const Position& start, const Position& end);
-
+
// style-application helpers
void applyBlockStyle(CSSMutableStyleDeclaration*);
void applyRelativeFontStyleChange(CSSMutableStyleDeclaration*);
void applyInlineStyle(CSSMutableStyleDeclaration*);
- void applyInlineStyleToRange(CSSMutableStyleDeclaration*, const Position& start, const Position& end);
+ void fixRangeAndApplyInlineStyle(CSSMutableStyleDeclaration*, const Position& start, const Position& end);
+ void applyInlineStyleToNodeRange(CSSMutableStyleDeclaration*, Node* startNode, Node* pastEndNode);
void addBlockStyle(const StyleChange&, HTMLElement*);
- void addInlineStyleIfNeeded(CSSMutableStyleDeclaration*, Node* start, Node* end);
+ void addInlineStyleIfNeeded(CSSMutableStyleDeclaration*, Node* start, Node* end, EAddStyledElement addStyledElement = AddStyledElement);
void splitTextAtStart(const Position& start, const Position& end);
void splitTextAtEnd(const Position& start, const Position& end);
void splitTextElementAtStart(const Position& start, const Position& end);
void splitTextElementAtEnd(const Position& start, const Position& end);
+ bool shouldSplitTextElement(Element* elem, CSSMutableStyleDeclaration*);
bool isValidCaretPositionInTextNode(const Position& position);
bool mergeStartWithPreviousIfIdentical(const Position& start, const Position& end);
bool mergeEndWithNextIfIdentical(const Position& start, const Position& end);
float computedFontSize(const Node*);
void joinChildTextNodes(Node*, const Position& start, const Position& end);
- HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, RefPtr<CSSPrimitiveValue> allowedDirection);
+ HTMLElement* splitAncestorsWithUnicodeBidi(Node*, bool before, int allowedDirection);
void removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsplitAncestor);
void updateStartEnd(const Position& newStart, const Position& newEnd);
bool m_useEndingSelection;
RefPtr<Element> m_styledInlineElement;
bool m_removeOnly;
+ IsInlineElementToRemoveFunction m_isInlineElementToRemoveFunction;
};
bool isStyleSpan(const Node*);
PassRefPtr<HTMLElement> createStyleSpanElement(Document*);
-RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle);
+RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
void prepareEditingStyleToApplyAt(CSSMutableStyleDeclaration*, Position);
void removeStylesAddedByNode(CSSMutableStyleDeclaration*, Node*);