Use explicit HTMLFrameElementBase cast and introduce toHTMLFrameElementBase
authorkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2013 09:10:33 +0000 (09:10 +0000)
committerkangil.han@samsung.com <kangil.han@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2013 09:10:33 +0000 (09:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118873

Reviewed by Ryosuke Niwa.

It should be HTMLFrameElementBase that embraces both HTMLFrameElement and HTMLIFrameElement.
This also makes correct toFooElement possible.
Next, to avoid direct use of static_cast, this patch introduces toHTMLFrameElementBase for code cleanup.

* editing/FrameSelection.cpp:
(WebCore::scanForForm):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::didNotifySubtreeInsertions):
* html/HTMLFrameElementBase.h:
(WebCore::toHTMLFrameElementBase):
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::loadSubframe):
* page/EventHandler.cpp:
(WebCore::targetIsFrame):
* page/FrameView.cpp:
(WebCore::FrameView::init):
* rendering/RenderFrameBase.cpp:
(WebCore::RenderFrameBase::layoutWithFlattening):
* rendering/RenderLayer.cpp:
(WebCore::frameElementAndViewPermitScroll):
(WebCore::RenderLayer::scrollRectToVisible):

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

Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLFrameElementBase.h
Source/WebCore/loader/SubframeLoader.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/RenderFrameBase.cpp
Source/WebCore/rendering/RenderLayer.cpp

index eb07081..0dd93c9 100644 (file)
@@ -1,3 +1,32 @@
+2013-07-19  Kangil Han  <kangil.han@samsung.com>
+
+        Use explicit HTMLFrameElementBase cast and introduce toHTMLFrameElementBase
+        https://bugs.webkit.org/show_bug.cgi?id=118873
+
+        Reviewed by Ryosuke Niwa.
+
+        It should be HTMLFrameElementBase that embraces both HTMLFrameElement and HTMLIFrameElement.
+        This also makes correct toFooElement possible.
+        Next, to avoid direct use of static_cast, this patch introduces toHTMLFrameElementBase for code cleanup.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::scanForForm):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::didNotifySubtreeInsertions):
+        * html/HTMLFrameElementBase.h:
+        (WebCore::toHTMLFrameElementBase):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::loadSubframe):
+        * page/EventHandler.cpp:
+        (WebCore::targetIsFrame):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::init):
+        * rendering/RenderFrameBase.cpp:
+        (WebCore::RenderFrameBase::layoutWithFlattening):
+        * rendering/RenderLayer.cpp:
+        (WebCore::frameElementAndViewPermitScroll):
+        (WebCore::RenderLayer::scrollRectToVisible):
+
 2013-07-18  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         Bindings generation tests are failing
index 73c2898..1cd93c0 100644 (file)
@@ -1974,11 +1974,9 @@ static HTMLFormElement* scanForForm(Node* start)
             return toHTMLFormElement(element);
         if (element->isHTMLElement() && toHTMLElement(element)->isFormControlElement())
             return static_cast<HTMLFormControlElement*>(element)->form();
-        if (element->hasTagName(frameTag) || element->hasTagName(iframeTag)) {
-            Node* childDocument = static_cast<HTMLFrameElementBase*>(element)->contentDocument();
-            if (HTMLFormElement* frameResult = scanForForm(childDocument))
+        if (element->hasTagName(frameTag) || element->hasTagName(iframeTag))
+            if (HTMLFormElement* frameResult = scanForForm(toHTMLFrameElementBase(element)->contentDocument()))
                 return frameResult;
-        }
     }
     return 0;
 }
index 47ed64d..fbe6484 100644 (file)
@@ -172,7 +172,7 @@ void HTMLBodyElement::didNotifySubtreeInsertions(ContainerNode* insertionPoint)
     // FIXME: Perhaps this code should be in attach() instead of here.
     Element* ownerElement = document()->ownerElement();
     if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))) {
-        HTMLFrameElementBase* ownerFrameElement = static_cast<HTMLFrameElementBase*>(ownerElement);
+        HTMLFrameElementBase* ownerFrameElement = toHTMLFrameElementBase(ownerElement);
         int marginWidth = ownerFrameElement->marginWidth();
         if (marginWidth != -1)
             setAttribute(marginwidthAttr, String::number(marginWidth));
index 1c5b03a..c094f12 100644 (file)
@@ -81,6 +81,12 @@ private:
     bool m_viewSource;
 };
 
+inline HTMLFrameElementBase* toHTMLFrameElementBase(Node* node)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(HTMLNames::frameTag) || node->hasTagName(HTMLNames::iframeTag));
+    return static_cast<HTMLFrameElementBase*>(node);
+}
+
 } // namespace WebCore
 
 #endif // HTMLFrameElementBase_h
index f682d37..b90ecca 100644 (file)
@@ -353,10 +353,10 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const K
     int marginWidth = -1;
     int marginHeight = -1;
     if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag)) {
-        HTMLFrameElementBase* o = static_cast<HTMLFrameElementBase*>(ownerElement);
-        allowsScrolling = o->scrollingMode() != ScrollbarAlwaysOff;
-        marginWidth = o->marginWidth();
-        marginHeight = o->marginHeight();
+        HTMLFrameElementBase* frameElementBase = toHTMLFrameElementBase(ownerElement);
+        allowsScrolling = frameElementBase->scrollingMode() != ScrollbarAlwaysOff;
+        marginWidth = frameElementBase->marginWidth();
+        marginHeight = frameElementBase->marginHeight();
     }
 
     if (!ownerElement->document()->securityOrigin()->canDisplay(url)) {
index 8de250e..ee4583e 100644 (file)
@@ -2003,7 +2003,7 @@ static bool targetIsFrame(Node* target, Frame*& frame)
     if (!target->hasTagName(frameTag) && !target->hasTagName(iframeTag))
         return false;
 
-    frame = static_cast<HTMLFrameElementBase*>(target)->contentFrame();
+    frame = toHTMLFrameElementBase(target)->contentFrame();
 
     return true;
 }
index 70b2930..b7e117a 100644 (file)
@@ -347,7 +347,7 @@ void FrameView::init()
     // Propagate the marginwidth/height and scrolling modes to the view.
     Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
     if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))) {
-        HTMLFrameElementBase* frameElt = static_cast<HTMLFrameElementBase*>(ownerElement);
+        HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement);
         if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
             setCanHaveScrollbars(false);
         LayoutUnit marginWidth = frameElt->marginWidth();
index f2be9f6..94c0900 100644 (file)
@@ -72,8 +72,7 @@ void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeig
     // we obey them and do not expand. With frame flattening
     // no subframe much ever become scrollable.
 
-    HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
-    bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
+    bool isScrollable = toHTMLFrameElementBase(node())->scrollingMode() != ScrollbarAlwaysOff;
 
     // consider iframe inset border
     int hBorder = borderLeft() + borderRight();
index 6c92d78..2aa2bdc 100644 (file)
@@ -2264,10 +2264,10 @@ void RenderLayer::scrollTo(int x, int y)
         frame->loader()->client()->didChangeScrollOffset(); 
 }
 
-static inline bool frameElementAndViewPermitScroll(HTMLFrameElement* frameElement, FrameView* frameView) 
+static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameElementBase, FrameView* frameView) 
 {
     // If scrollbars aren't explicitly forbidden, permit scrolling.
-    if (frameElement && frameElement->scrollingMode() != ScrollbarAlwaysOff)
+    if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlwaysOff)
         return true;
 
     // If scrollbars are forbidden, user initiated scrolls should obviously be ignored.
@@ -2320,12 +2320,12 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
                 ownerElement = renderer()->document()->ownerElement();
 
             if (ownerElement && ownerElement->renderer()) {
-                HTMLFrameElement* frameElement = 0;
+                HTMLFrameElementBase* frameElementBase = 0;
 
                 if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))
-                    frameElement = static_cast<HTMLFrameElement*>(ownerElement);
+                    frameElementBase = toHTMLFrameElementBase(ownerElement);
 
-                if (frameElementAndViewPermitScroll(frameElement, frameView)) {
+                if (frameElementAndViewPermitScroll(frameElementBase, frameView)) {
                     LayoutRect viewRect = frameView->visibleContentRect();
                     LayoutRect exposeRect = getRectToExpose(viewRect, viewRect, rect, alignX, alignY);