Commit 617c7791 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Use tighter typing in editing: ReplaceSelectionCommand

Use tighter typing in editing/ to increase code readability and to avoid
unnecessary type checks. This CL focuses on ReplaceSelectionCommand.

R=leviw@chromium.org, yosin@chromium.org

Review URL: https://codereview.chromium.org/423413005

git-svn-id: svn://svn.chromium.org/blink/trunk@180076 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 95238c4b
...@@ -62,7 +62,7 @@ static String& styleSpanClassString() ...@@ -62,7 +62,7 @@ static String& styleSpanClassString()
return styleSpanClassString; return styleSpanClassString;
} }
bool isLegacyAppleStyleSpan(const Node* node) bool isLegacyAppleHTMLSpanElement(const Node* node)
{ {
if (!isHTMLSpanElement(node)) if (!isHTMLSpanElement(node))
return false; return false;
...@@ -420,7 +420,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style) ...@@ -420,7 +420,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle->asText())); setNodeAttribute(element.get(), styleAttr, AtomicString(inlineStyle->asText()));
} }
if (inlineStyle->isEmpty()) { if (inlineStyle->isEmpty()) {
removeNodeAttribute(element.get(), styleAttr); removeElementAttribute(element.get(), styleAttr);
if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get())) if (isSpanWithoutAttributesOrUnstyledStyleSpan(element.get()))
unstyledSpans.append(element.release()); unstyledSpans.append(element.release());
} }
...@@ -529,7 +529,7 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, HTMLElemen ...@@ -529,7 +529,7 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, HTMLElemen
if (element->hasAttribute(dirAttr)) { if (element->hasAttribute(dirAttr)) {
// FIXME: If this is a BDO element, we should probably just remove it if it has no // FIXME: If this is a BDO element, we should probably just remove it if it has no
// other attributes, like we (should) do with B and I elements. // other attributes, like we (should) do with B and I elements.
removeNodeAttribute(element, dirAttr); removeElementAttribute(element, dirAttr);
} else { } else {
RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle()); RefPtrWillBeRawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
...@@ -966,7 +966,7 @@ bool ApplyStyleCommand::removeImplicitlyStyledElement(EditingStyle* style, HTMLE ...@@ -966,7 +966,7 @@ bool ApplyStyleCommand::removeImplicitlyStyledElement(EditingStyle* style, HTMLE
return false; return false;
for (size_t i = 0; i < attributes.size(); i++) for (size_t i = 0; i < attributes.size(); i++)
removeNodeAttribute(element, attributes[i]); removeElementAttribute(element, attributes[i]);
if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(element)) if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(element))
removeNodePreservingChildren(element); removeNodePreservingChildren(element);
......
...@@ -136,7 +136,7 @@ private: ...@@ -136,7 +136,7 @@ private:
enum ShouldStyleAttributeBeEmpty { AllowNonEmptyStyleAttribute, StyleAttributeShouldBeEmpty }; enum ShouldStyleAttributeBeEmpty { AllowNonEmptyStyleAttribute, StyleAttributeShouldBeEmpty };
bool isEmptyFontTag(const Element*, ShouldStyleAttributeBeEmpty = StyleAttributeShouldBeEmpty); bool isEmptyFontTag(const Element*, ShouldStyleAttributeBeEmpty = StyleAttributeShouldBeEmpty);
bool isLegacyAppleStyleSpan(const Node*); bool isLegacyAppleHTMLSpanElement(const Node*);
bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*); bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element*);
PassRefPtrWillBeRawPtr<HTMLSpanElement> createStyleSpanElement(Document&); PassRefPtrWillBeRawPtr<HTMLSpanElement> createStyleSpanElement(Document&);
......
...@@ -582,7 +582,7 @@ void CompositeEditCommand::removeCSSProperty(PassRefPtrWillBeRawPtr<Element> ele ...@@ -582,7 +582,7 @@ void CompositeEditCommand::removeCSSProperty(PassRefPtrWillBeRawPtr<Element> ele
applyCommandToComposite(RemoveCSSPropertyCommand::create(document(), element, property)); applyCommandToComposite(RemoveCSSPropertyCommand::create(document(), element, property));
} }
void CompositeEditCommand::removeNodeAttribute(PassRefPtrWillBeRawPtr<Element> element, const QualifiedName& attribute) void CompositeEditCommand::removeElementAttribute(PassRefPtrWillBeRawPtr<Element> element, const QualifiedName& attribute)
{ {
setNodeAttribute(element, attribute, AtomicString()); setNodeAttribute(element, attribute, AtomicString());
} }
......
...@@ -120,7 +120,7 @@ protected: ...@@ -120,7 +120,7 @@ protected:
bool canRebalance(const Position&) const; bool canRebalance(const Position&) const;
bool shouldRebalanceLeadingWhitespaceFor(const String&) const; bool shouldRebalanceLeadingWhitespaceFor(const String&) const;
void removeCSSProperty(PassRefPtrWillBeRawPtr<Element>, CSSPropertyID); void removeCSSProperty(PassRefPtrWillBeRawPtr<Element>, CSSPropertyID);
void removeNodeAttribute(PassRefPtrWillBeRawPtr<Element>, const QualifiedName& attribute); void removeElementAttribute(PassRefPtrWillBeRawPtr<Element>, const QualifiedName& attribute);
void removeChildrenInRange(PassRefPtrWillBeRawPtr<Node>, unsigned from, unsigned to); void removeChildrenInRange(PassRefPtrWillBeRawPtr<Node>, unsigned from, unsigned to);
virtual void removeNode(PassRefPtrWillBeRawPtr<Node>, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable); virtual void removeNode(PassRefPtrWillBeRawPtr<Node>, ShouldAssumeContentIsAlwaysEditable = DoNotAssumeContentIsAlwaysEditable);
HTMLSpanElement* replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtrWillBeRawPtr<HTMLElement>); HTMLSpanElement* replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtrWillBeRawPtr<HTMLElement>);
......
...@@ -77,10 +77,10 @@ private: ...@@ -77,10 +77,10 @@ private:
RefPtrWillBeMember<Node> m_lastNodeInserted; RefPtrWillBeMember<Node> m_lastNodeInserted;
}; };
Node* insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElement> listElement, Node* insertionNode, const Position&, InsertedNodes&); Node* insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElement> listElement, Element* insertionBlock, const Position&, InsertedNodes&);
void updateNodesInserted(Node*); void updateNodesInserted(Node*);
bool shouldRemoveEndBR(Node*, const VisiblePosition&); bool shouldRemoveEndBR(HTMLBRElement*, const VisiblePosition&);
bool shouldMergeStart(bool, bool, bool); bool shouldMergeStart(bool, bool, bool);
bool shouldMergeEnd(bool selectionEndWasEndOfParagraph); bool shouldMergeEnd(bool selectionEndWasEndOfParagraph);
...@@ -92,7 +92,7 @@ private: ...@@ -92,7 +92,7 @@ private:
void removeRedundantStylesAndKeepStyleSpanInline(InsertedNodes&); void removeRedundantStylesAndKeepStyleSpanInline(InsertedNodes&);
void makeInsertedContentRoundTrippableWithHTMLTreeBuilder(const InsertedNodes&); void makeInsertedContentRoundTrippableWithHTMLTreeBuilder(const InsertedNodes&);
void moveNodeOutOfAncestor(PassRefPtrWillBeRawPtr<Node>, PassRefPtrWillBeRawPtr<ContainerNode> ancestor); void moveElementOutOfAncestor(PassRefPtrWillBeRawPtr<Element>, PassRefPtrWillBeRawPtr<ContainerNode> ancestor);
void handleStyleSpans(InsertedNodes&); void handleStyleSpans(InsertedNodes&);
VisiblePosition positionAtStartOfInsertedContent() const; VisiblePosition positionAtStartOfInsertedContent() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment