Generate toHTMLMarquee|OListElement() to cleanup static_cast<>
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Nov 2013 15:24:33 +0000 (15:24 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Nov 2013 15:24:33 +0000 (15:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124707

Reviewed by Darin Adler.

As a step to use toFoo(), we need to generate toHTMLMarquee|OListElement().
Besides this patch cleans up remaining static_cast<> usage.

No new tests, no behavior changes.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::State::initElement):
(WebCore::StyleResolver::locateCousinList):
(WebCore::StyleResolver::findSiblingForStyleSharing):
* dom/Attr.cpp:
(WebCore::Attr::style):
* dom/Element.cpp:
(WebCore::Element::removeAttribute):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::wrappingStyleForSerialization):
* editing/Editor.cpp:
(WebCore::Editor::applyEditingStyleToElement):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
* html/HTMLMarqueeElement.h:
* html/HTMLOListElement.h:
* html/HTMLTagNames.in:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::buildObjectForAttributesStyle):
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForElementInfo):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::serializeFrame):
* rendering/RenderCounter.cpp:
(WebCore::planCounter):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::resize):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::calcValue):
(WebCore::RenderListItem::updateListMarkerNumbers):
* rendering/RenderMarquee.cpp:
(WebCore::RenderMarquee::marqueeSpeed):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159733 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/Attr.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/html/HTMLMarqueeElement.h
Source/WebCore/html/HTMLOListElement.h
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/rendering/RenderCounter.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderListItem.cpp
Source/WebCore/rendering/RenderMarquee.cpp

index 3d6732a..4daf36b 100644 (file)
@@ -1,3 +1,51 @@
+2013-11-24  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Generate toHTMLMarquee|OListElement() to cleanup static_cast<>
+        https://bugs.webkit.org/show_bug.cgi?id=124707
+
+        Reviewed by Darin Adler.
+
+        As a step to use toFoo(), we need to generate toHTMLMarquee|OListElement().
+        Besides this patch cleans up remaining static_cast<> usage.
+
+        No new tests, no behavior changes.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::State::initElement):
+        (WebCore::StyleResolver::locateCousinList):
+        (WebCore::StyleResolver::findSiblingForStyleSharing):
+        * dom/Attr.cpp:
+        (WebCore::Attr::style):
+        * dom/Element.cpp:
+        (WebCore::Element::removeAttribute):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
+        (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::wrappingStyleForSerialization):
+        * editing/Editor.cpp:
+        (WebCore::Editor::applyEditingStyleToElement):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+        * html/HTMLMarqueeElement.h:
+        * html/HTMLOListElement.h:
+        * html/HTMLTagNames.in:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::buildObjectForAttributesStyle):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForElementInfo):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::serializeFrame):
+        * rendering/RenderCounter.cpp:
+        (WebCore::planCounter):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::resize):
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::calcValue):
+        (WebCore::RenderListItem::updateListMarkerNumbers):
+        * rendering/RenderMarquee.cpp:
+        (WebCore::RenderMarquee::marqueeSpeed):
+
 2013-11-24  Tim Horton  <timothy_horton@apple.com>
 
         REGRESSION (r156291): TileController tiles don't always repaint when they resize
index 6ca4303..8582f4e 100644 (file)
@@ -410,7 +410,7 @@ bool StyleResolver::classNamesAffectedByRules(const SpaceSplitString& classNames
 inline void StyleResolver::State::initElement(Element* e)
 {
     m_element = e;
-    m_styledElement = e && e->isStyledElement() ? static_cast<StyledElement*>(e) : 0;
+    m_styledElement = e && e->isStyledElement() ? toStyledElement(e) : nullptr;
     m_elementLinkState = e ? e->document().visitedLinkState().determineLinkState(e) : NotInsideLink;
 }
 
@@ -465,7 +465,7 @@ Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCoun
         return 0;
     if (!parent || !parent->isStyledElement())
         return 0;
-    StyledElement* p = static_cast<StyledElement*>(parent);
+    StyledElement* p = toStyledElement(parent);
     if (p->inlineStyle())
         return 0;
 #if ENABLE(SVG)
@@ -713,12 +713,12 @@ inline StyledElement* StyleResolver::findSiblingForStyleSharing(Node* node, unsi
     for (; node; node = node->previousSibling()) {
         if (!node->isStyledElement())
             continue;
-        if (canShareStyleWithElement(static_cast<StyledElement*>(node)))
+        if (canShareStyleWithElement(toStyledElement(node)))
             break;
         if (count++ == cStyleSearchThreshold)
             return 0;
     }
-    return static_cast<StyledElement*>(node);
+    return toStyledElement(node);
 }
 
 RenderStyle* StyleResolver::locateSharedStyle()
index 3a229f4..dbf4763 100644 (file)
@@ -189,7 +189,7 @@ CSSStyleDeclaration* Attr::style()
     if (!m_element || !m_element->isStyledElement())
         return nullptr;
     m_style = MutableStylePropertySet::create();
-    static_cast<StyledElement*>(m_element)->collectStyleForPresentationAttribute(qualifiedName(), value(), *m_style);
+    toStyledElement(m_element)->collectStyleForPresentationAttribute(qualifiedName(), value(), *m_style);
     return m_style->ensureCSSStyleDeclaration();
 }
 
index 39c9327..176668f 100644 (file)
@@ -1899,7 +1899,7 @@ void Element::removeAttribute(const AtomicString& name)
     unsigned index = elementData()->findAttributeIndexByName(localName, false);
     if (index == ElementData::attributeNotFound) {
         if (UNLIKELY(localName == styleAttr) && elementData()->m_styleAttributeIsDirty && isStyledElement())
-            static_cast<StyledElement*>(this)->removeAllInlineStyleProperties();
+            toStyledElement(this)->removeAllInlineStyleProperties();
         return;
     }
 
index 6550943..f9bb6bc 100644 (file)
@@ -511,7 +511,7 @@ void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsp
         if (!n->isStyledElement())
             continue;
 
-        StyledElement* element = static_cast<StyledElement*>(n);
+        StyledElement* element = toStyledElement(n);
         int unicodeBidi = toIdentifier(ComputedStyleExtractor(element).propertyValue(CSSPropertyUnicodeBidi));
         if (!unicodeBidi || unicodeBidi == CSSValueNormal)
             continue;
@@ -1042,7 +1042,7 @@ void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
 
         RefPtr<StyledElement> styledElement;
         if (current->isStyledElement() && isStyledInlineElementToRemove(toElement(current.get()))) {
-            styledElement = static_cast<StyledElement*>(current.get());
+            styledElement = toStyledElement(current.get());
             elementsToPushDown.append(*styledElement);
         }
 
index 8c54a5b..b842696 100644 (file)
@@ -1053,7 +1053,7 @@ PassRefPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(Node* conte
     // When not annotating for interchange, we only preserve inline style declarations.
     for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
         if (node->isStyledElement() && !isMailBlockquote(node)) {
-            wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues,
+            wrappingStyle->mergeInlineAndImplicitStyleOfElement(toStyledElement(node), EditingStyle::DoNotOverrideValues,
                 EditingStyle::EditingPropertiesInEffect);
         }
     }
index 4cca3c5..2d7208d 100644 (file)
@@ -2812,7 +2812,7 @@ void Editor::applyEditingStyleToElement(Element* element) const
         return;
 
     // Mutate using the CSSOM wrapper so we get the same event behavior as a script.
-    CSSStyleDeclaration* style = static_cast<StyledElement*>(element)->style();
+    CSSStyleDeclaration* style = toStyledElement(element)->style();
     style->setPropertyInternal(CSSPropertyWordWrap, "break-word", false, IGNORE_EXCEPTION);
     style->setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false, IGNORE_EXCEPTION);
     style->setPropertyInternal(CSSPropertyWebkitLineBreak, "after-white-space", false, IGNORE_EXCEPTION);
index 723b8c9..ea5621b 100644 (file)
@@ -481,7 +481,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
         if (!node->isStyledElement())
             continue;
 
-        StyledElement* element = static_cast<StyledElement*>(node.get());
+        StyledElement* element = toStyledElement(node.get());
 
         const StylePropertySet* inlineStyle = element->inlineStyle();
         RefPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
@@ -493,7 +493,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
                 if (newInlineStyle->conflictsWithImplicitStyleOfElement(htmlElement)) {
                     // e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
                     node = replaceElementWithSpanPreservingChildrenAndAttributes(htmlElement);
-                    element = static_cast<StyledElement*>(node.get());
+                    element = toStyledElement(node.get());
                     insertedNodes.didReplaceNode(htmlElement, node.get());
                 } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
                     EditingStyle::DoNotExtractMatchingStyle)) {
index cbe2156..4ebd92f 100644 (file)
@@ -64,6 +64,8 @@ private:
     RenderMarquee* renderMarquee() const;
 };
 
+NODE_TYPE_CASTS(HTMLMarqueeElement)
+
 } // namespace WebCore
 
 #endif // HTMLMarqueeElement_h
index 670ed00..7e5c65f 100644 (file)
@@ -65,6 +65,7 @@ private:
     bool m_shouldRecalculateItemCount : 1;
 };
 
+NODE_TYPE_CASTS(HTMLOListElement)
 
 } //namespace
 
index b8f2e53..09f6827 100644 (file)
@@ -80,7 +80,7 @@ listing interfaceName=HTMLPreElement
 main interfaceName=HTMLElement
 map generateTypeHelpers
 mark interfaceName=HTMLElement
-marquee
+marquee generateTypeHelpers
 menu
 meta generateTypeHelpers
 meter interfaceName=HTMLMeterElement, conditional=METER_ELEMENT, generateTypeHelpers
@@ -90,7 +90,7 @@ noembed interfaceName=HTMLElement
 noframes interfaceName=HTMLElement
 nolayer interfaceName=HTMLElement
 object constructorNeedsFormElement, constructorNeedsCreatedByParser, generateTypeHelpers
-ol interfaceName=HTMLOListElement
+ol interfaceName=HTMLOListElement, generateTypeHelpers
 optgroup interfaceName=HTMLOptGroupElement, generateTypeHelpers
 option generateTypeHelpers
 output constructorNeedsFormElement
index 51e4902..b9d1a17 100644 (file)
@@ -1348,7 +1348,7 @@ PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttribut
         return 0;
 
     // FIXME: Ugliness below.
-    StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(static_cast<StyledElement*>(element)->presentationAttributeStyle());
+    StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(toStyledElement(element)->presentationAttributeStyle());
     if (!attributeStyle)
         return 0;
 
index 81eba0b..a36b45a 100644 (file)
@@ -638,7 +638,7 @@ static PassRefPtr<InspectorObject> buildObjectForElementInfo(Node* node)
     HashSet<AtomicString> usedClassNames;
     if (element->hasClass() && element->isStyledElement()) {
         StringBuilder classNames;
-        const SpaceSplitString& classNamesString = static_cast<StyledElement*>(element)->classNames();
+        const SpaceSplitString& classNamesString = toStyledElement(element)->classNames();
         size_t classNameCount = classNamesString.size();
         for (size_t i = 0; i < classNameCount; ++i) {
             const AtomicString& className = classNamesString[i];
index 0e2d928..59ed64b 100644 (file)
@@ -229,7 +229,7 @@ void PageSerializer::serializeFrame(Frame* frame)
         Element* element = toElement(node);
         // We have to process in-line style as it might contain some resources (typically background images).
         if (element->isStyledElement())
-            retrieveResourcesForProperties(static_cast<StyledElement*>(element)->inlineStyle(), document);
+            retrieveResourcesForProperties(toStyledElement(element)->inlineStyle(), document);
 
         if (isHTMLImageElement(element)) {
             HTMLImageElement* imageElement = toHTMLImageElement(element);
@@ -237,7 +237,7 @@ void PageSerializer::serializeFrame(Frame* frame)
             CachedImage* cachedImage = imageElement->cachedImage();
             addImageToResources(cachedImage, imageElement->renderer(), url);
         } else if (element->hasTagName(HTMLNames::linkTag)) {
-            HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(element);
+            HTMLLinkElement* linkElement = toHTMLLinkElement(element);
             if (CSSStyleSheet* sheet = linkElement->sheet()) {
                 URL url = document->completeURL(linkElement->getAttribute(HTMLNames::hrefAttr));
                 serializeCSSStyleSheet(sheet, url);
index c04431d..de99359 100644 (file)
@@ -147,7 +147,7 @@ static bool planCounter(RenderElement* object, const AtomicString& identifier, b
         }
         if (Element* e = object->element()) {
             if (e->hasTagName(olTag)) {
-                value = static_cast<HTMLOListElement*>(e)->start();
+                value = toHTMLOListElement(e)->start();
                 isReset = true;
                 return true;
             }
index 00ce546..47b27b5 100644 (file)
@@ -2550,8 +2550,7 @@ void RenderLayer::resize(const PlatformMouseEvent& evt, const LayoutSize& oldOff
     
     LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
 
-    ASSERT_WITH_SECURITY_IMPLICATION(element->isStyledElement());
-    StyledElement* styledElement = static_cast<StyledElement*>(element);
+    StyledElement* styledElement = toStyledElement(element);
     bool isBoxSizingBorder = renderer->style().boxSizing() == BORDER_BOX;
 
     EResize resize = renderer->style().resize();
index 332b5fc..aafed2f 100644 (file)
@@ -193,7 +193,7 @@ inline int RenderListItem::calcValue() const
         return m_explicitValue;
 
     Element* list = enclosingList(this);
-    HTMLOListElement* oListElement = (list && list->hasTagName(olTag)) ? static_cast<HTMLOListElement*>(list) : 0;
+    HTMLOListElement* oListElement = (list && list->hasTagName(olTag)) ? toHTMLOListElement(list) : nullptr;
     int valueStep = 1;
     if (oListElement && oListElement->isReversed())
         valueStep = -1;
@@ -503,7 +503,7 @@ void RenderListItem::updateListMarkerNumbers()
         return;
 
     bool isListReversed = false;
-    HTMLOListElement* oListElement = (listNode && listNode->hasTagName(olTag)) ? static_cast<HTMLOListElement*>(listNode) : 0;
+    HTMLOListElement* oListElement = (listNode && listNode->hasTagName(olTag)) ? toHTMLOListElement(listNode) : nullptr;
     if (oListElement) {
         oListElement->itemCountChanged();
         isListReversed = oListElement->isReversed();
index 9b8dc67..28e4e74 100644 (file)
@@ -73,10 +73,8 @@ int RenderMarquee::marqueeSpeed() const
 {
     int result = m_layer->renderer().style().marqueeSpeed();
     Element* element = m_layer->renderer().element();
-    if (element && element->hasTagName(marqueeTag)) {
-        HTMLMarqueeElement* marqueeElement = static_cast<HTMLMarqueeElement*>(element);
-        result = std::max(result, marqueeElement->minimumDelay());
-    }
+    if (element && element->hasTagName(marqueeTag))
+        result = std::max(result, toHTMLMarqueeElement(element)->minimumDelay());
     return result;
 }