Use is<>() / downcast<>() for all remaining RenderObject subclasses
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 03:42:03 +0000 (03:42 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 03:42:03 +0000 (03:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137845

Reviewed by Darin Adler.

Source/WebCore:

Use is<>() / downcast<>() for all remaining RenderObject subclasses and
clean up the surrounding code.

No new tests, no behavior change.

* accessibility/AccessibilityProgressIndicator.cpp:
(WebCore::AccessibilityProgressIndicator::progressElement):
(WebCore::AccessibilityProgressIndicator::meterElement):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::layoutCount):
(WebCore::AccessibilityRenderObject::widgetForAttachmentView):
(WebCore::AccessibilityRenderObject::visiblePositionForPoint):
* dom/Document.cpp:
(WebCore::widgetForElement):
* dom/Position.cpp:
(WebCore::Position::getInlineBoxAndOffset):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::overset):
(WebCore::WebKitNamedFlow::firstEmptyRegionIndex):
(WebCore::WebKitNamedFlow::getRegionsByContent):
(WebCore::WebKitNamedFlow::getRegions):
* editing/FrameSelection.cpp:
(WebCore::isFrameElement):
* html/HTMLEmbedElement.cpp:
(WebCore::findWidgetRenderer):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::HTMLFrameOwnerElement):
(WebCore::HTMLFrameOwnerElement::renderWidget):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::renderMeter):
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::supportsFocus):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::renderEmbeddedObject):
(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn):
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::renderProgress):
* html/PluginDocument.cpp:
(WebCore::PluginDocument::pluginWidget):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTimelineElement::defaultEventHandler):
(WebCore::MediaControlTextTrackContainerElement::updateSizes):
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::gatherLayersUsingRenderObjectHierarchy):
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForElementInfo):
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::loadSubframe):
* page/Frame.cpp:
(WebCore::Frame::ownerRenderer):
* page/FrameView.cpp:
(WebCore::FrameView::layout):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
(WebCore::EventHandler::passSubframeEventToSubframe):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
(WebCore::EventHandler::passSubframeEventToSubframe):
(WebCore::widgetForEventTarget):
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::applyEdjeRTLState):
* rendering/InlineTextBox.cpp:
(WebCore::fontToUse):
(WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove):
(WebCore::InlineTextBox::paint):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::collapseAnonymousBoxChild):
(WebCore::RenderBlock::simplifiedLayout):
(WebCore::RenderBlock::paintObject):
(WebCore::RenderBlock::selectionGaps):
(WebCore::RenderBlock::nodeAtPoint):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlock):
(WebCore::RenderBlockFlow::hitTestFloats):
(WebCore::RenderBlockFlow::checkForPaginationLogicalHeightChange):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::scroll):
(WebCore::RenderBox::nodeAtPoint):
(WebCore::RenderBox::repaintLayerRectsForImage):
(WebCore::RenderBox::mapLocalToContainer):
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
* rendering/RenderCombineText.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::adjustStyleDifference):
(WebCore::addLayers):
(WebCore::RenderElement::removeLayers):
(WebCore::RenderElement::moveLayers):
(WebCore::RenderElement::setNeedsPositionedMovementLayout):
(WebCore::RenderElement::renderNamedFlowThreadWrapper):
* rendering/RenderEmbeddedObject.h:
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::validateRegions):
(WebCore::RenderFlowThread::hasCompositingRegionDescendant):
(WebCore::RenderFlowThread::regionForCompositedLayer):
(WebCore::RenderFlowThread::clearRenderBoxRegionInfoAndCustomStyle):
(WebCore::RenderFlowThread::initializeRegionsComputedAutoHeight):
(WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
(WebCore::RenderFlowThread::addForcedRegionBreak):
(WebCore::RenderFlowThread::addRegionsOverflowFromChild):
* rendering/RenderFlowThread.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::setFilterBackendNeedsRepaintingInRect):
(WebCore::transparencyClipBox):
(WebCore::accumulateOffsetTowardsAncestor):
(WebCore::RenderLayer::collectFragments):
(WebCore::RenderLayer::hitTest):
(WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateAfterWidgetResize):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::isRestartedPlugin):
(WebCore::isCompositedPlugin):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
(WebCore::RenderLayerBacking::containsPaintedContent):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateBacking):
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
(WebCore::RenderLayerCompositor::requiresCompositingLayer):
(WebCore::RenderLayerCompositor::reasonsForCompositing):
(WebCore::RenderLayerCompositor::requiresCompositingForVideo):
(WebCore::RenderLayerCompositor::requiresCompositingForPlugin):
(WebCore::RenderLayerCompositor::requiresCompositingForFrame):
* rendering/RenderLayerModelObject.h:
* rendering/RenderLineBreak.h:
* rendering/RenderMeter.h:
* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::firstMultiColumnSet):
(WebCore::RenderMultiColumnFlowThread::lastMultiColumnSet):
(WebCore::RenderMultiColumnFlowThread::layout):
(WebCore::RenderMultiColumnFlowThread::addRegionToThread):
(WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted):
(WebCore::RenderMultiColumnFlowThread::flowThreadRelativeWillBeRemoved):
(WebCore::RenderMultiColumnFlowThread::flowThreadDescendantBoxLaidOut):
(WebCore::RenderMultiColumnFlowThread::setPageBreak):
(WebCore::RenderMultiColumnFlowThread::updateMinimumPageHeight):
(WebCore::RenderMultiColumnFlowThread::setRegionRangeForBox):
(WebCore::RenderMultiColumnFlowThread::addForcedRegionBreak):
(WebCore::RenderMultiColumnFlowThread::physicalTranslationOffsetFromFlowToRegion):
* rendering/RenderMultiColumnFlowThread.h:
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::nextSiblingMultiColumnSet):
(WebCore::RenderMultiColumnSet::previousSiblingMultiColumnSet):
* rendering/RenderMultiColumnSet.h:
* rendering/RenderMultiColumnSpannerPlaceholder.h:
* rendering/RenderNamedFlowFragment.cpp:
(WebCore::RenderNamedFlowFragment::checkRegionStyle):
(WebCore::RenderNamedFlowFragment::namedFlowThread):
* rendering/RenderNamedFlowFragment.h:
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::updateWritingMode):
(WebCore::addFragmentToList):
(WebCore::RenderNamedFlowThread::addRegionToThread):
(WebCore::RenderNamedFlowThread::removeRegionFromThread):
(WebCore::RenderNamedFlowThread::fragmentFromRenderBoxAsRenderBlock):
(WebCore::RenderNamedFlowThread::fragmentFromAbsolutePointAndBox):
(WebCore::RenderNamedFlowThread::checkInvalidRegions):
(WebCore::RenderNamedFlowThread::checkRegionsWithStyling):
(WebCore::RenderNamedFlowThread::clearRenderObjectCustomStyle):
* rendering/RenderNamedFlowThread.h:
* rendering/RenderObject.cpp:
(WebCore::scheduleRelayoutForSubtree):
(WebCore::RenderObject::setLayerNeedsFullRepaint):
(WebCore::RenderObject::setLayerNeedsFullRepaintForPositionedMovementLayout):
(WebCore::RenderObject::repaintUsingContainer):
(WebCore::RenderObject::selectionRoot):
(WebCore::RenderObject::shouldUseTransformFromContainer):
(WebCore::RenderObject::getTransformFromContainer):
(WebCore::RenderObject::isRooted):
(WebCore::RenderObject::willBeDestroyed):
(WebCore::RenderObject::isComposited):
(WebCore::RenderObject::currentRenderNamedFlowFragment):
* rendering/RenderObject.h:
* rendering/RenderProgress.h:
* rendering/RenderRuby.cpp:
(WebCore::lastRubyRun):
* rendering/RenderRubyBase.cpp:
(WebCore::RenderRubyBase::rubyRun):
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::removeChild):
* rendering/RenderRubyRun.h:
* rendering/RenderSlider.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::widthFromCache):
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::calculateProgressRect):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintProgressBar):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMeter):
(WebCore::RenderThemeMac::paintProgressBar):
* rendering/RenderThemeSafari.cpp:
(WebCore::RenderThemeSafari::paintMeter):
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::paintMeter):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderRegionList):
(WebCore::writeLayers):
* rendering/RenderVideo.h:
* rendering/RenderView.cpp:
(WebCore::SelectionIterator::checkForSpanner):
(WebCore::isComposited):
* rendering/RenderView.h:
* rendering/RenderWidget.h:
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::BreakingContext::handleText):
* rendering/line/LineBreaker.cpp:
(WebCore::LineBreaker::skipLeadingWhitespace):
* testing/Internals.cpp:
(WebCore::Internals::isPluginUnavailabilityIndicatorObscured):

Source/WebKit/mac:

Use is<>() / downcast<>() for all remaining RenderObject subclasses and
clean up the surrounding code.

* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView pluginHostDied]):
* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView _windowClipRect]):
(-[WebBaseNetscapePluginView actualVisibleRectInWindow]):
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createPlugin):
(WebFrameLoaderClient::createJavaAppletWidget):

Source/WebKit2:

Use is<>() / downcast<>() for all remaining RenderObject subclasses and
clean up the surrounding code.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pluginProcessCrashed):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin):

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

80 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityProgressIndicator.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/WebKitNamedFlow.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/html/HTMLEmbedElement.cpp
Source/WebCore/html/HTMLFrameOwnerElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMeterElement.cpp
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/inspector/InspectorLayerTreeAgent.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/SubframeLoader.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/gtk/EventHandlerGtk.cpp
Source/WebCore/page/ios/EventHandlerIOS.mm
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/platform/efl/RenderThemeEfl.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderCombineText.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderEmbeddedObject.h
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerModelObject.h
Source/WebCore/rendering/RenderLineBreak.h
Source/WebCore/rendering/RenderMeter.h
Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp
Source/WebCore/rendering/RenderMultiColumnFlowThread.h
Source/WebCore/rendering/RenderMultiColumnSet.cpp
Source/WebCore/rendering/RenderMultiColumnSet.h
Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h
Source/WebCore/rendering/RenderNamedFlowFragment.cpp
Source/WebCore/rendering/RenderNamedFlowFragment.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderNamedFlowThread.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderProgress.h
Source/WebCore/rendering/RenderRuby.cpp
Source/WebCore/rendering/RenderRubyBase.cpp
Source/WebCore/rendering/RenderRubyRun.cpp
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/RenderSlider.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeSafari.cpp
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderVideo.h
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/RenderWidget.h
Source/WebCore/rendering/line/BreakingContextInlineHeaders.h
Source/WebCore/rendering/line/LineBreaker.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 56f6a0f..4d68156 100644 (file)
@@ -1,5 +1,233 @@
 2014-10-19  Chris Dumez  <cdumez@apple.com>
 
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137845
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses and
+        clean up the surrounding code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityProgressIndicator.cpp:
+        (WebCore::AccessibilityProgressIndicator::progressElement):
+        (WebCore::AccessibilityProgressIndicator::meterElement):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::layoutCount):
+        (WebCore::AccessibilityRenderObject::widgetForAttachmentView):
+        (WebCore::AccessibilityRenderObject::visiblePositionForPoint):
+        * dom/Document.cpp:
+        (WebCore::widgetForElement):
+        * dom/Position.cpp:
+        (WebCore::Position::getInlineBoxAndOffset):
+        * dom/WebKitNamedFlow.cpp:
+        (WebCore::WebKitNamedFlow::overset):
+        (WebCore::WebKitNamedFlow::firstEmptyRegionIndex):
+        (WebCore::WebKitNamedFlow::getRegionsByContent):
+        (WebCore::WebKitNamedFlow::getRegions):
+        * editing/FrameSelection.cpp:
+        (WebCore::isFrameElement):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::findWidgetRenderer):
+        * html/HTMLFrameOwnerElement.cpp:
+        (WebCore::HTMLFrameOwnerElement::HTMLFrameOwnerElement):
+        (WebCore::HTMLFrameOwnerElement::renderWidget):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::renderMeter):
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::supportsFocus):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::renderEmbeddedObject):
+        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn):
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::renderProgress):
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocument::pluginWidget):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTimelineElement::defaultEventHandler):
+        (WebCore::MediaControlTextTrackContainerElement::updateSizes):
+        (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
+        * inspector/InspectorLayerTreeAgent.cpp:
+        (WebCore::InspectorLayerTreeAgent::gatherLayersUsingRenderObjectHierarchy):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForElementInfo):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::loadSubframe):
+        * page/Frame.cpp:
+        (WebCore::Frame::ownerRenderer):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        * page/gtk/EventHandlerGtk.cpp:
+        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
+        (WebCore::EventHandler::passSubframeEventToSubframe):
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
+        (WebCore::EventHandler::passSubframeEventToSubframe):
+        (WebCore::widgetForEventTarget):
+        * platform/efl/RenderThemeEfl.cpp:
+        (WebCore::RenderThemeEfl::applyEdjeRTLState):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::fontToUse):
+        (WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove):
+        (WebCore::InlineTextBox::paint):
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::collapseAnonymousBoxChild):
+        (WebCore::RenderBlock::simplifiedLayout):
+        (WebCore::RenderBlock::paintObject):
+        (WebCore::RenderBlock::selectionGaps):
+        (WebCore::RenderBlock::nodeAtPoint):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutBlock):
+        (WebCore::RenderBlockFlow::hitTestFloats):
+        (WebCore::RenderBlockFlow::checkForPaginationLogicalHeightChange):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::scroll):
+        (WebCore::RenderBox::nodeAtPoint):
+        (WebCore::RenderBox::repaintLayerRectsForImage):
+        (WebCore::RenderBox::mapLocalToContainer):
+        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
+        * rendering/RenderCombineText.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::adjustStyleDifference):
+        (WebCore::addLayers):
+        (WebCore::RenderElement::removeLayers):
+        (WebCore::RenderElement::moveLayers):
+        (WebCore::RenderElement::setNeedsPositionedMovementLayout):
+        (WebCore::RenderElement::renderNamedFlowThreadWrapper):
+        * rendering/RenderEmbeddedObject.h:
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::validateRegions):
+        (WebCore::RenderFlowThread::hasCompositingRegionDescendant):
+        (WebCore::RenderFlowThread::regionForCompositedLayer):
+        (WebCore::RenderFlowThread::clearRenderBoxRegionInfoAndCustomStyle):
+        (WebCore::RenderFlowThread::initializeRegionsComputedAutoHeight):
+        (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
+        (WebCore::RenderFlowThread::addForcedRegionBreak):
+        (WebCore::RenderFlowThread::addRegionsOverflowFromChild):
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::setFilterBackendNeedsRepaintingInRect):
+        (WebCore::transparencyClipBox):
+        (WebCore::accumulateOffsetTowardsAncestor):
+        (WebCore::RenderLayer::collectFragments):
+        (WebCore::RenderLayer::hitTest):
+        (WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions):
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateAfterWidgetResize):
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        (WebCore::isRestartedPlugin):
+        (WebCore::isCompositedPlugin):
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
+        (WebCore::RenderLayerBacking::containsPaintedContent):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateBacking):
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        (WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
+        (WebCore::RenderLayerCompositor::requiresCompositingLayer):
+        (WebCore::RenderLayerCompositor::reasonsForCompositing):
+        (WebCore::RenderLayerCompositor::requiresCompositingForVideo):
+        (WebCore::RenderLayerCompositor::requiresCompositingForPlugin):
+        (WebCore::RenderLayerCompositor::requiresCompositingForFrame):
+        * rendering/RenderLayerModelObject.h:
+        * rendering/RenderLineBreak.h:
+        * rendering/RenderMeter.h:
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        (WebCore::RenderMultiColumnFlowThread::firstMultiColumnSet):
+        (WebCore::RenderMultiColumnFlowThread::lastMultiColumnSet):
+        (WebCore::RenderMultiColumnFlowThread::layout):
+        (WebCore::RenderMultiColumnFlowThread::addRegionToThread):
+        (WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted):
+        (WebCore::RenderMultiColumnFlowThread::flowThreadRelativeWillBeRemoved):
+        (WebCore::RenderMultiColumnFlowThread::flowThreadDescendantBoxLaidOut):
+        (WebCore::RenderMultiColumnFlowThread::setPageBreak):
+        (WebCore::RenderMultiColumnFlowThread::updateMinimumPageHeight):
+        (WebCore::RenderMultiColumnFlowThread::setRegionRangeForBox):
+        (WebCore::RenderMultiColumnFlowThread::addForcedRegionBreak):
+        (WebCore::RenderMultiColumnFlowThread::physicalTranslationOffsetFromFlowToRegion):
+        * rendering/RenderMultiColumnFlowThread.h:
+        * rendering/RenderMultiColumnSet.cpp:
+        (WebCore::RenderMultiColumnSet::nextSiblingMultiColumnSet):
+        (WebCore::RenderMultiColumnSet::previousSiblingMultiColumnSet):
+        * rendering/RenderMultiColumnSet.h:
+        * rendering/RenderMultiColumnSpannerPlaceholder.h:
+        * rendering/RenderNamedFlowFragment.cpp:
+        (WebCore::RenderNamedFlowFragment::checkRegionStyle):
+        (WebCore::RenderNamedFlowFragment::namedFlowThread):
+        * rendering/RenderNamedFlowFragment.h:
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::updateWritingMode):
+        (WebCore::addFragmentToList):
+        (WebCore::RenderNamedFlowThread::addRegionToThread):
+        (WebCore::RenderNamedFlowThread::removeRegionFromThread):
+        (WebCore::RenderNamedFlowThread::fragmentFromRenderBoxAsRenderBlock):
+        (WebCore::RenderNamedFlowThread::fragmentFromAbsolutePointAndBox):
+        (WebCore::RenderNamedFlowThread::checkInvalidRegions):
+        (WebCore::RenderNamedFlowThread::checkRegionsWithStyling):
+        (WebCore::RenderNamedFlowThread::clearRenderObjectCustomStyle):
+        * rendering/RenderNamedFlowThread.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::scheduleRelayoutForSubtree):
+        (WebCore::RenderObject::setLayerNeedsFullRepaint):
+        (WebCore::RenderObject::setLayerNeedsFullRepaintForPositionedMovementLayout):
+        (WebCore::RenderObject::repaintUsingContainer):
+        (WebCore::RenderObject::selectionRoot):
+        (WebCore::RenderObject::shouldUseTransformFromContainer):
+        (WebCore::RenderObject::getTransformFromContainer):
+        (WebCore::RenderObject::isRooted):
+        (WebCore::RenderObject::willBeDestroyed):
+        (WebCore::RenderObject::isComposited):
+        (WebCore::RenderObject::currentRenderNamedFlowFragment):
+        * rendering/RenderObject.h:
+        * rendering/RenderProgress.h:
+        * rendering/RenderRuby.cpp:
+        (WebCore::lastRubyRun):
+        * rendering/RenderRubyBase.cpp:
+        (WebCore::RenderRubyBase::rubyRun):
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::removeChild):
+        * rendering/RenderRubyRun.h:
+        * rendering/RenderSlider.h:
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::widthFromCache):
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::calculateProgressRect):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::paintProgressBar):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMeter):
+        (WebCore::RenderThemeMac::paintProgressBar):
+        * rendering/RenderThemeSafari.cpp:
+        (WebCore::RenderThemeSafari::paintMeter):
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::paintMeter):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::writeRenderRegionList):
+        (WebCore::writeLayers):
+        * rendering/RenderVideo.h:
+        * rendering/RenderView.cpp:
+        (WebCore::SelectionIterator::checkForSpanner):
+        (WebCore::isComposited):
+        * rendering/RenderView.h:
+        * rendering/RenderWidget.h:
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::BreakingContext::handleText):
+        * rendering/line/LineBreaker.cpp:
+        (WebCore::LineBreaker::skipLeadingWhitespace):
+        * testing/Internals.cpp:
+        (WebCore::Internals::isPluginUnavailabilityIndicatorObscured):
+
+2014-10-19  Chris Dumez  <cdumez@apple.com>
+
         Use SPECIALIZE_TYPE_TRAITS_*() macro for RenderScrollbar
         https://bugs.webkit.org/show_bug.cgi?id=137854
 
index b52bf78..aafa7f3 100644 (file)
@@ -122,19 +122,19 @@ float AccessibilityProgressIndicator::minValueForRange() const
 
 HTMLProgressElement* AccessibilityProgressIndicator::progressElement() const
 {
-    if (!m_renderer->isProgress())
+    if (!is<RenderProgress>(*m_renderer))
         return nullptr;
     
-    return toRenderProgress(m_renderer)->progressElement();
+    return downcast<RenderProgress>(*m_renderer).progressElement();
 }
 
 #if ENABLE(METER_ELEMENT)
 HTMLMeterElement* AccessibilityProgressIndicator::meterElement() const
 {
-    if (!m_renderer->isMeter())
+    if (!is<RenderMeter>(*m_renderer))
         return nullptr;
 
-    return toRenderMeter(m_renderer)->meterElement();
+    return downcast<RenderMeter>(*m_renderer).meterElement();
 }
 #endif
 
index 769a562..ca22ecc 100644 (file)
@@ -1387,9 +1387,9 @@ double AccessibilityRenderObject::estimatedLoadingProgress() const
     
 int AccessibilityRenderObject::layoutCount() const
 {
-    if (!m_renderer->isRenderView())
+    if (!is<RenderView>(*m_renderer))
         return 0;
-    return toRenderView(*m_renderer).frameView().layoutCount();
+    return downcast<RenderView>(*m_renderer).frameView().layoutCount();
 }
 
 String AccessibilityRenderObject::text() const
@@ -1763,7 +1763,7 @@ Widget* AccessibilityRenderObject::widgetForAttachmentView() const
 {
     if (!isAttachment())
         return nullptr;
-    return toRenderWidget(m_renderer)->widget();
+    return downcast<RenderWidget>(*m_renderer).widget();
 }
 
 // This function is like a cross-platform version of - (WebCoreTextMarkerRange*)textMarkerRange. It returns
@@ -1996,11 +1996,11 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
         pointResult = result.localPoint();
 
         // done if hit something other than a widget
-        if (!renderer->isWidget())
+        if (!is<RenderWidget>(*renderer))
             break;
 
         // descend into widget (FRAME, IFRAME, OBJECT...)
-        Widget* widget = toRenderWidget(renderer)->widget();
+        Widget* widget = downcast<RenderWidget>(*renderer).widget();
         if (!is<FrameView>(widget))
             break;
         Frame& frame = downcast<FrameView>(*widget).frame();
index 8f676f0..0ae4876 100644 (file)
@@ -327,10 +327,10 @@ static Widget* widgetForElement(Element* focusedElement)
 {
     if (!focusedElement)
         return nullptr;
-    auto renderer = focusedElement->renderer();
-    if (!renderer || !renderer->isWidget())
+    auto* renderer = focusedElement->renderer();
+    if (!is<RenderWidget>(renderer))
         return nullptr;
-    return toRenderWidget(renderer)->widget();
+    return downcast<RenderWidget>(*renderer).widget();
 }
 
 static bool acceptsEditingFocus(Node* node)
index 805612e..9cc9576 100644 (file)
@@ -1156,7 +1156,7 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi
     RenderObject* renderer = deprecatedNode()->renderer();
 
     if (renderer->isBR())
-        inlineBox = !caretOffset ? toRenderLineBreak(renderer)->inlineBoxWrapper() : nullptr;
+        inlineBox = !caretOffset ? downcast<RenderLineBreak>(*renderer).inlineBoxWrapper() : nullptr;
     else if (is<RenderText>(*renderer)) {
         auto& textRenderer = downcast<RenderText>(*renderer);
         textRenderer.ensureLineBoxes();
index 395c889..51dfc0b 100644 (file)
@@ -72,8 +72,8 @@ bool WebKitNamedFlow::overset() const
     if (!m_parentFlowThread || !m_parentFlowThread->hasRegions())
         return true;
 
-    const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(m_parentFlowThread->lastRegion());
-    return namedFlowFragment->regionOversetState() == RegionOverset;
+    const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*m_parentFlowThread->lastRegion());
+    return namedFlowFragment.regionOversetState() == RegionOverset;
 }
 
 static inline bool inFlowThread(RenderObject* renderer, RenderNamedFlowThread* flowThread)
@@ -104,14 +104,14 @@ int WebKitNamedFlow::firstEmptyRegionIndex() const
 
     int countNonPseudoRegions = -1;
     for (const auto& renderRegion : regionList) {
-        const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+        const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
         // FIXME: Pseudo-elements are not included in the list.
         // They will be included when we will properly support the Region interface
         // http://dev.w3.org/csswg/css-regions/#the-region-interface
-        if (namedFlowFragment->isPseudoElementRegion())
+        if (namedFlowFragment.isPseudoElementRegion())
             continue;
-        countNonPseudoRegions++;
-        if (namedFlowFragment->regionOversetState() == RegionEmpty)
+        ++countNonPseudoRegions;
+        if (namedFlowFragment.regionOversetState() == RegionEmpty)
             return countNonPseudoRegions;
     }
     return -1;
@@ -135,15 +135,15 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
     if (inFlowThread(contentNode->renderer(), m_parentFlowThread)) {
         const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
         for (const auto& renderRegion : regionList) {
-            const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+            const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
             // FIXME: Pseudo-elements are not included in the list.
             // They will be included when we will properly support the Region interface
             // http://dev.w3.org/csswg/css-regions/#the-region-interface
-            if (namedFlowFragment->isPseudoElementRegion())
+            if (namedFlowFragment.isPseudoElementRegion())
                 continue;
-            if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), namedFlowFragment)) {
-                ASSERT(namedFlowFragment->generatingElement());
-                regionElements.append(*namedFlowFragment->generatingElement());
+            if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), &namedFlowFragment)) {
+                ASSERT(namedFlowFragment.generatingElement());
+                regionElements.append(*namedFlowFragment.generatingElement());
             }
         }
     }
@@ -165,14 +165,14 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
 
     const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
     for (const auto& renderRegion : regionList) {
-        const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+        const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
         // FIXME: Pseudo-elements are not included in the list.
         // They will be included when we will properly support the Region interface
         // http://dev.w3.org/csswg/css-regions/#the-region-interface
-        if (namedFlowFragment->isPseudoElementRegion())
+        if (namedFlowFragment.isPseudoElementRegion())
             continue;
-        ASSERT(namedFlowFragment->generatingElement());
-        regionElements.append(*namedFlowFragment->generatingElement());
+        ASSERT(namedFlowFragment.generatingElement());
+        regionElements.append(*namedFlowFragment.generatingElement());
     }
 
     return StaticElementList::adopt(regionElements);
index 9f93a84..80a06f9 100644 (file)
@@ -1912,9 +1912,9 @@ static bool isFrameElement(const Node* n)
     if (!n)
         return false;
     RenderObject* renderer = n->renderer();
-    if (!renderer || !renderer->isWidget())
+    if (!is<RenderWidget>(renderer))
         return false;
-    Widget* widget = toRenderWidget(renderer)->widget();
+    Widget* widget = downcast<RenderWidget>(*renderer).widget();
     return widget && widget->isFrameView();
 }
 
index 34542ad..5938173 100644 (file)
@@ -55,17 +55,18 @@ PassRefPtr<HTMLEmbedElement> HTMLEmbedElement::create(const QualifiedName& tagNa
     return adoptRef(new HTMLEmbedElement(tagName, document, createdByParser));
 }
 
-static inline RenderWidget* findWidgetRenderer(const Node* n
+static inline RenderWidget* findWidgetRenderer(const Node* node)
 {
-    if (!n->renderer())
-        do
-            n = n->parentNode();
-        while (n && !n->hasTagName(objectTag));
+    if (!node->renderer()) {
+        do {
+            node = node->parentNode();
+        } while (node && !is<HTMLObjectElement>(*node));
+    }
 
-    if (n && n->renderer() && n->renderer()->isWidget())
-        return toRenderWidget(n->renderer());
+    if (node && is<RenderWidget>(node->renderer()))
+        return downcast<RenderWidget>(node->renderer());
 
-    return 0;
+    return nullptr;
 }
 
 RenderWidget* HTMLEmbedElement::renderWidgetLoadingPlugin() const
index 5204726..a85e79d 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
 
 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
-    , m_contentFrame(0)
+    , m_contentFrame(nullptr)
     , m_sandboxFlags(SandboxNone)
 {
 }
@@ -43,9 +43,9 @@ RenderWidget* HTMLFrameOwnerElement::renderWidget() const
 {
     // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
     // when using fallback content.
-    if (!renderer() || !renderer()->isWidget())
-        return 0;
-    return toRenderWidget(renderer());
+    if (!is<RenderWidget>(renderer()))
+        return nullptr;
+    return downcast<RenderWidget>(renderer());
 }
 
 void HTMLFrameOwnerElement::setContentFrame(Frame* frame)
index 1fa90eb..1daab18 100644 (file)
@@ -4245,8 +4245,8 @@ void HTMLMediaElement::mediaPlayerSizeChanged(MediaPlayer*)
 
 bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*)
 {
-    if (renderer() && renderer()->isVideo())
-        return renderer()->view().compositor().canAccelerateVideoRendering(toRenderVideo(*renderer()));
+    if (is<RenderVideo>(renderer()))
+        return renderer()->view().compositor().canAccelerateVideoRendering(downcast<RenderVideo>(*renderer()));
     return false;
 }
 
index f2aac1c..945210e 100644 (file)
@@ -220,9 +220,9 @@ void HTMLMeterElement::didElementStateChange()
 
 RenderMeter* HTMLMeterElement::renderMeter() const
 {
-    if (renderer() && renderer()->isMeter())
-        return toRenderMeter(renderer());
-    return toRenderMeter(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
+    if (is<RenderMeter>(renderer()))
+        return downcast<RenderMeter>(renderer());
+    return downcast<RenderMeter>(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
 }
 
 void HTMLMeterElement::didAddUserAgentShadowRoot(ShadowRoot* root)
index 3a819db..2d17e7b 100644 (file)
@@ -275,9 +275,9 @@ bool HTMLPlugInElement::supportsFocus() const
     if (HTMLFrameOwnerElement::supportsFocus())
         return true;
 
-    if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject())
+    if (useFallbackContent() || !is<RenderEmbeddedObject>(renderer()))
         return false;
-    return !toRenderEmbeddedObject(renderer())->isPluginUnavailable();
+    return !downcast<RenderEmbeddedObject>(*renderer()).isPluginUnavailable();
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
index c1ec257..b60085d 100644 (file)
@@ -145,9 +145,7 @@ RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const
 {
     // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
     // when using fallback content.
-    if (!renderer() || !renderer()->isEmbeddedObject())
-        return 0;
-    return toRenderEmbeddedObject(renderer());
+    return is<RenderEmbeddedObject>(renderer()) ? downcast<RenderEmbeddedObject>(renderer()) : nullptr;
 }
 
 bool HTMLPlugInImageElement::isImageType()
@@ -693,7 +691,7 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const URL& url)
         return;
     }
     
-    auto& renderer = toRenderEmbeddedObject(*this->renderer());
+    auto& renderer = downcast<RenderEmbeddedObject>(*this->renderer());
     LayoutRect contentRect = renderer.contentBoxRect();
     int contentWidth = contentRect.width();
     int contentHeight = contentRect.height();
index 9837124..f50ffc0 100644 (file)
@@ -72,9 +72,9 @@ bool HTMLProgressElement::childShouldCreateRenderer(const Node& child) const
 
 RenderProgress* HTMLProgressElement::renderProgress() const
 {
-    if (renderer() && renderer()->isProgress())
-        return toRenderProgress(renderer());
-    return toRenderProgress(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
+    if (is<RenderProgress>(renderer()))
+        return downcast<RenderProgress>(renderer());
+    return downcast<RenderProgress>(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
 }
 
 void HTMLProgressElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
index b22087b..ed0f622 100644 (file)
@@ -155,11 +155,9 @@ PassRefPtr<DocumentParser> PluginDocument::createParser()
 
 Widget* PluginDocument::pluginWidget()
 {
-    if (m_pluginElement && m_pluginElement->renderer()) {
-        ASSERT(m_pluginElement->renderer()->isEmbeddedObject());
-        return toRenderEmbeddedObject(m_pluginElement->renderer())->widget();
-    }
-    return 0;
+    if (m_pluginElement && m_pluginElement->renderer())
+        return downcast<RenderEmbeddedObject>(*m_pluginElement->renderer()).widget();
+    return nullptr;
 }
 
 void PluginDocument::setPluginElement(PassRefPtr<HTMLPlugInElement> element)
index 271f06a..4c7bd75 100644 (file)
@@ -872,8 +872,8 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event)
     if (event->type() == eventNames().inputEvent && time != mediaController()->currentTime())
         mediaController()->setCurrentTime(time);
 
-    RenderSlider* slider = toRenderSlider(renderer());
-    if (slider && slider->inDragMode())
+    RenderSlider& slider = downcast<RenderSlider>(*renderer());
+    if (slider.inDragMode())
         m_controls->updateCurrentTimeDisplay();
 }
 
@@ -1337,9 +1337,9 @@ void MediaControlTextTrackContainerElement::updateSizes(bool forceUpdate)
     if (m_textTrackRepresentation)
         videoBox = m_textTrackRepresentation->bounds();
     else {
-        if (!mediaElement->renderer() || !mediaElement->renderer()->isVideo())
+        if (!is<RenderVideo>(mediaElement->renderer()))
             return;
-        videoBox = toRenderVideo(*mediaElement->renderer()).videoBox();
+        videoBox = downcast<RenderVideo>(*mediaElement->renderer()).videoBox();
     }
 
     if (!forceUpdate && m_videoDisplaySize == videoBox)
@@ -1363,14 +1363,14 @@ PassRefPtr<Image> MediaControlTextTrackContainerElement::createTextTrackRepresen
 
     document().updateLayout();
 
-    auto renderer = this->renderer();
+    auto* renderer = this->renderer();
     if (!renderer)
         return nullptr;
 
     if (!renderer->hasLayer())
         return nullptr;
 
-    RenderLayer* layer = toRenderLayerModelObject(renderer)->layer();
+    RenderLayer* layer = downcast<RenderLayerModelObject>(*renderer).layer();
 
     float deviceScaleFactor = 1;
     if (Page* page = document().page())
index e983f07..f0cef40 100644 (file)
@@ -129,7 +129,7 @@ void InspectorLayerTreeAgent::layersForNode(ErrorString& errorString, int nodeId
 void InspectorLayerTreeAgent::gatherLayersUsingRenderObjectHierarchy(ErrorString& errorString, RenderObject* renderer, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::LayerTree::Layer>>& layers)
 {
     if (renderer->hasLayer()) {
-        gatherLayersUsingRenderLayerHierarchy(errorString, toRenderLayerModelObject(renderer)->layer(), layers);
+        gatherLayersUsingRenderLayerHierarchy(errorString, downcast<RenderLayerModelObject>(*renderer).layer(), layers);
         return;
     }
 
index 84d4922..e14d1fa 100644 (file)
@@ -722,9 +722,9 @@ static PassRefPtr<InspectorObject> buildObjectForElementInfo(Node* node)
     }
 
     RenderFlowThread* containingFlowThread = renderer->flowThreadContainingBlock();
-    if (containingFlowThread && containingFlowThread->isRenderNamedFlowThread()) {
+    if (is<RenderNamedFlowThread>(containingFlowThread)) {
         RefPtr<InspectorObject> contentFlowInfo = InspectorObject::create();
-        contentFlowInfo->setString("name", toRenderNamedFlowThread(containingFlowThread)->flowThreadName());
+        contentFlowInfo->setString("name", downcast<RenderNamedFlowThread>(*containingFlowThread).flowThreadName());
         elementInfo->setObject("contentFlowInfo", contentFlowInfo.release());
     }
 
index 8a16142..5c37789 100644 (file)
@@ -328,10 +328,10 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement& ownerElement, const U
     // FIXME: Can we remove this entirely? m_isComplete normally gets set to false when a load is committed.
     frame->loader().started();
    
-    RenderObject* renderer = ownerElement.renderer();
+    auto* renderer = ownerElement.renderer();
     FrameView* view = frame->view();
-    if (renderer && renderer->isWidget() && view)
-        toRenderWidget(renderer)->setWidget(view);
+    if (is<RenderWidget>(renderer) && view)
+        downcast<RenderWidget>(*renderer).setWidget(view);
     
     m_frame.loader().checkCallImplicitClose();
     
index 8b8f63c..5ddca42 100644 (file)
@@ -735,17 +735,17 @@ RenderWidget* Frame::ownerRenderer() const
 {
     HTMLFrameOwnerElement* ownerElement = m_ownerElement;
     if (!ownerElement)
-        return 0;
-    auto object = ownerElement->renderer();
+        return nullptr;
+    auto* object = ownerElement->renderer();
     if (!object)
-        return 0;
+        return nullptr;
     // FIXME: If <object> is ever fixed to disassociate itself from frames
     // that it has started but canceled, then this can turn into an ASSERT
     // since m_ownerElement would be 0 when the load is canceled.
     // https://bugs.webkit.org/show_bug.cgi?id=18585
-    if (!object->isWidget())
-        return 0;
-    return toRenderWidget(object);
+    if (!is<RenderWidget>(*object))
+        return nullptr;
+    return downcast<RenderWidget>(object);
 }
 
 Frame* Frame::frameForWidget(const Widget* widget)
index f7890d4..33025a0 100644 (file)
@@ -1237,7 +1237,7 @@ void FrameView::layout(bool allowSubtree)
 
         autoSizeIfEnabled();
 
-        m_needsFullRepaint = !subtree && (m_firstLayout || toRenderView(*root).printing());
+        m_needsFullRepaint = !subtree && (m_firstLayout || downcast<RenderView>(*root).printing());
 
         if (!subtree) {
             ScrollbarMode hMode;
@@ -1325,7 +1325,7 @@ void FrameView::layout(bool allowSubtree)
         if (subtree)
             root->view().popLayoutState(*root);
 
-        m_layoutRoot = 0;
+        m_layoutRoot = nullptr;
 
         // Close block here to end the scope of changeSchedulingEnabled and layoutStateDisabler.
     }
@@ -1334,7 +1334,7 @@ void FrameView::layout(bool allowSubtree)
 
     bool neededFullRepaint = m_needsFullRepaint;
 
-    if (!subtree && !toRenderView(*root).printing())
+    if (!subtree && !downcast<RenderView>(*root).printing())
         adjustViewSize();
 
     m_layoutPhase = InPostLayout;
index 9483f93..750b88a 100644 (file)
@@ -61,10 +61,10 @@ void EventHandler::focusDocumentView()
 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
 {
     // Figure out which view to send the event to.
-    RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
-    if (!target || !target->isWidget())
+    RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : nullptr;
+    if (!is<RenderWidget>(target))
         return false;
-    return passMouseDownEventToWidget(toRenderWidget(target)->widget());
+    return passMouseDownEventToWidget(downcast<RenderWidget>(*target).widget());
 }
 
 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
index 837a7a9..02f095b 100644 (file)
@@ -169,15 +169,15 @@ void EventHandler::focusDocumentView()
 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
 {
     // Figure out which view to send the event to.
-    auto target = event.targetNode() ? event.targetNode()->renderer() : nullptr;
-    if (!target || !target->isWidget())
+    auto* target = event.targetNode() ? event.targetNode()->renderer() : nullptr;
+    if (!is<RenderWidget>(target))
         return false;
 
     // Double-click events don't exist in Cocoa. Since passWidgetMouseDownEventToWidget() will
     // just pass currentEvent down to the widget, we don't want to call it for events that
     // don't correspond to Cocoa events. The mousedown/ups will have already been passed on as
     // part of the pressed/released handling.
-    return passMouseDownEventToWidget(toRenderWidget(target)->widget());
+    return passMouseDownEventToWidget(downcast<RenderWidget>(*target).widget());
 }
 
 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
@@ -363,13 +363,13 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
             Node* node = event.targetNode();
             if (!node)
                 return false;
-            auto renderer = node->renderer();
-            if (!renderer || !renderer->isWidget())
+            auto* renderer = node->renderer();
+            if (!is<RenderWidget>(renderer))
                 return false;
-            Widget* widget = toRenderWidget(renderer)->widget();
+            Widget* widget = downcast<RenderWidget>(*renderer).widget();
             if (!widget || !widget->isFrameView())
                 return false;
-            if (!passWidgetMouseDownEventToWidget(toRenderWidget(renderer)))
+            if (!passWidgetMouseDownEventToWidget(downcast<RenderWidget>(renderer)))
                 return false;
             m_mouseDownWasInSubframe = true;
             return true;
index 42abc38..8be9f22 100644 (file)
@@ -143,15 +143,15 @@ void EventHandler::focusDocumentView()
 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
 {
     // Figure out which view to send the event to.
-    auto target = event.targetNode() ? event.targetNode()->renderer() : nullptr;
-    if (!target || !target->isWidget())
+    auto* target = event.targetNode() ? event.targetNode()->renderer() : nullptr;
+    if (!is<RenderWidget>(target))
         return false;
 
     // Double-click events don't exist in Cocoa. Since passWidgetMouseDownEventToWidget() will
     // just pass currentEvent down to the widget, we don't want to call it for events that
     // don't correspond to Cocoa events. The mousedown/ups will have already been passed on as
     // part of the pressed/released handling.
-    return passMouseDownEventToWidget(toRenderWidget(target)->widget());
+    return passMouseDownEventToWidget(downcast<RenderWidget>(*target).widget());
 }
 
 bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
@@ -361,13 +361,13 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
             Node* node = event.targetNode();
             if (!node)
                 return false;
-            auto renderer = node->renderer();
-            if (!renderer || !renderer->isWidget())
+            auto* renderer = node->renderer();
+            if (!is<RenderWidget>(renderer))
                 return false;
-            Widget* widget = toRenderWidget(renderer)->widget();
+            Widget* widget = downcast<RenderWidget>(*renderer).widget();
             if (!widget || !widget->isFrameView())
                 return false;
-            if (!passWidgetMouseDownEventToWidget(toRenderWidget(renderer)))
+            if (!passWidgetMouseDownEventToWidget(downcast<RenderWidget>(renderer)))
                 return false;
             m_mouseDownWasInSubframe = true;
             return true;
@@ -785,11 +785,11 @@ static Widget* widgetForEventTarget(Element* eventTarget)
     if (!eventTarget)
         return nullptr;
     
-    RenderElement* target = eventTarget->renderer();
-    if (!target || !target->isWidget())
+    auto* target = eventTarget->renderer();
+    if (!is<RenderWidget>(target))
         return nullptr;
     
-    return toRenderWidget(target)->widget();
+    return downcast<RenderWidget>(*target).widget();
 }
 
 static ScrollView* scrollViewForEventTarget(Element* eventTarget)
index dbe4d01..9fe67d2 100755 (executable)
@@ -301,11 +301,10 @@ void RenderThemeEfl::applyEdjeStateFromForm(Evas_Object* object, const ControlSt
 void RenderThemeEfl::applyEdjeRTLState(Evas_Object* edje, const RenderObject& object, FormType type, const IntRect& rect)
 {
     if (type == SliderVertical || type == SliderHorizontal) {
-        if (!object.isSlider())
+        if (!is<RenderSlider>(object))
             return; // probably have -webkit-appearance: slider..
 
-        const RenderSlider* renderSlider = toRenderSlider(&object);
-        HTMLInputElement& input = renderSlider->element();
+        HTMLInputElement& input = downcast<RenderSlider>(object).element();
         double valueRange = input.maximum() - input.minimum();
 
         OwnPtr<Edje_Message_Float_Set> msg = adoptPtr(static_cast<Edje_Message_Float_Set*>(::operator new (sizeof(Edje_Message_Float_Set) + sizeof(double))));
@@ -323,7 +322,7 @@ void RenderThemeEfl::applyEdjeRTLState(Evas_Object* edje, const RenderObject& ob
         msg->val[1] = (input.valueAsNumber() - input.minimum()) / valueRange;
         edje_object_message_send(edje, EDJE_MESSAGE_FLOAT_SET, 0, msg.get());
     } else if (type == ProgressBar) {
-        const RenderProgress& renderProgress = toRenderProgress(object);
+        const auto& renderProgress = downcast<RenderProgress>(object);
 
         int max = rect.width();
         double value = renderProgress.position();
index 354790c..5c59378 100644 (file)
@@ -248,8 +248,8 @@ RenderObject::SelectionState InlineTextBox::selectionState()
 
 static const Font& fontToUse(const RenderStyle& style, const RenderText& renderer)
 {
-    if (style.hasTextCombine() && renderer.isCombineText()) {
-        const RenderCombineText& textCombineRenderer = toRenderCombineText(renderer);
+    if (style.hasTextCombine() && is<RenderCombineText>(renderer)) {
+        const auto& textCombineRenderer = downcast<RenderCombineText>(renderer);
         if (textCombineRenderer.isCombined())
             return textCombineRenderer.textCombineFont();
     }
@@ -454,10 +454,10 @@ bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, bool&
     if (!containingBlock->isRubyBase())
         return true; // This text is not inside a ruby base, so it does not have ruby text over it.
 
-    if (!containingBlock->parent()->isRubyRun())
+    if (!is<RenderRubyRun>(*containingBlock->parent()))
         return true; // Cannot get the ruby text.
 
-    RenderRubyText* rubyText = toRenderRubyRun(containingBlock->parent())->rubyText();
+    RenderRubyText* rubyText = downcast<RenderRubyRun>(*containingBlock->parent()).rubyText();
 
     // The emphasis marks over are suppressed only if there is a ruby text box and it not empty.
     return !rubyText || !rubyText->hasLines();
@@ -519,7 +519,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     boxOrigin.moveBy(localPaintOffset);
     FloatRect boxRect(boxOrigin, FloatSize(logicalWidth(), logicalHeight()));
 
-    RenderCombineText* combinedText = lineStyle.hasTextCombine() && renderer().isCombineText() && toRenderCombineText(renderer()).isCombined() ? &toRenderCombineText(renderer()) : 0;
+    RenderCombineText* combinedText = lineStyle.hasTextCombine() && is<RenderCombineText>(renderer()) && downcast<RenderCombineText>(renderer()).isCombined() ? &downcast<RenderCombineText>(renderer()) : nullptr;
 
     bool shouldRotate = !isHorizontal() && !combinedText;
     if (shouldRotate)
index 18f51e0..17d0601 100644 (file)
@@ -112,8 +112,8 @@ LayoutState::LayoutState(std::unique_ptr<LayoutState> next, RenderBox* renderer,
     m_layoutDeltaYSaturated = m_next->m_layoutDeltaYSaturated;
 #endif
 
-    if (lineGrid() && (lineGrid()->style().writingMode() == renderer->style().writingMode()) && renderer->isRenderMultiColumnFlowThread())
-        toRenderMultiColumnFlowThread(renderer)->computeLineGridPaginationOrigin(*this);
+    if (lineGrid() && (lineGrid()->style().writingMode() == renderer->style().writingMode()) && is<RenderMultiColumnFlowThread>(*renderer))
+        downcast<RenderMultiColumnFlowThread>(*renderer).computeLineGridPaginationOrigin(*this);
 
     // If we have a new grid to track, then add it to our set.
     if (renderer->style().lineGrid() != RenderStyle::initialLineGrid() && is<RenderBlockFlow>(*renderer))
index 2d8cdcb..7de181c 100644 (file)
@@ -705,8 +705,8 @@ void RenderBlock::collapseAnonymousBoxChild(RenderBlock& parent, RenderBlock* ch
     RenderObject* nextSibling = child->nextSibling();
 
     RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
-    if (childFlowThread && childFlowThread->isRenderNamedFlowThread())
-        toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(child);
+    if (is<RenderNamedFlowThread>(childFlowThread))
+        downcast<RenderNamedFlowThread>(*childFlowThread).removeFlowChildInfo(child);
 
     parent.removeChildInternal(*child, child->hasLayer() ? NotifyChildren : DontNotifyChildren);
     child->moveAllChildrenTo(&parent, nextSibling, child->hasLayer());
@@ -1268,8 +1268,8 @@ bool RenderBlock::simplifiedLayout()
 
     // Make sure a forced break is applied after the content if we are a flow thread in a simplified layout.
     // This ensures the size information is correctly computed for the last auto-height region receiving content.
-    if (isRenderFlowThread())
-        toRenderFlowThread(this)->applyBreakAfterContent(clientLogicalBottom());
+    if (is<RenderFlowThread>(*this))
+        downcast<RenderFlowThread>(*this).applyBreakAfterContent(clientLogicalBottom());
 
     // Lay out our positioned objects if our positioned child bit is set.
     // Also, if an absolute position element inside a relative positioned container moves, and the absolute element has a fixed position
@@ -1580,7 +1580,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
             bool didClipToRegion = false;
             
             RenderNamedFlowFragment* namedFlowFragment = currentRenderNamedFlowFragment();
-            if (paintInfo.paintContainer && namedFlowFragment && paintInfo.paintContainer->isRenderNamedFlowThread()) {
+            if (namedFlowFragment && is<RenderNamedFlowThread>(paintInfo.paintContainer)) {
                 // If this box goes beyond the current region, then make sure not to overflow the region.
                 // This (overflowing region X altough also fragmented to region X+1) could happen when one of this box's children
                 // overflows region X and is an unsplittable element (like an image).
@@ -1589,7 +1589,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
                 paintInfo.context->save();
                 didClipToRegion = true;
 
-                paintInfo.context->clip(toRenderNamedFlowThread(paintInfo.paintContainer)->decorationsClipRectForBoxInNamedFlowFragment(*this, *namedFlowFragment));
+                paintInfo.context->clip(downcast<RenderNamedFlowThread>(*paintInfo.paintContainer).decorationsClipRectForBoxInNamedFlowFragment(*this, *namedFlowFragment));
             }
 
             paintBoxDecorations(paintInfo, paintOffset);
@@ -1898,9 +1898,9 @@ GapRects RenderBlock::selectionGaps(RenderBlock& rootBlock, const LayoutPoint& r
     }
     
     RenderNamedFlowFragment* namedFlowFragment = currentRenderNamedFlowFragment();
-    if (paintInfo && namedFlowFragment && paintInfo->paintContainer->isRenderFlowThread()) {
+    if (paintInfo && namedFlowFragment && is<RenderFlowThread>(*paintInfo->paintContainer)) {
         // Make sure the current object is actually flowed into the region being painted.
-        if (!toRenderFlowThread(paintInfo->paintContainer)->objectShouldFragmentInFlowRegion(this, namedFlowFragment))
+        if (!downcast<RenderFlowThread>(*paintInfo->paintContainer).objectShouldFragmentInFlowRegion(this, namedFlowFragment))
             return result;
     }
 
@@ -2442,7 +2442,7 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
     LayoutSize localOffset = toLayoutSize(adjustedLocation);
 
     RenderFlowThread* flowThread = flowThreadContainingBlock();
-    RenderNamedFlowFragment* namedFlowFragment = flowThread ? toRenderNamedFlowFragment(flowThread->currentRegion()) : nullptr;
+    RenderNamedFlowFragment* namedFlowFragment = flowThread ? downcast<RenderNamedFlowFragment>(flowThread->currentRegion()) : nullptr;
     // If we are now searching inside a region, make sure this element
     // is being fragmented into this region.
     if (namedFlowFragment && !flowThread->objectShouldFragmentInFlowRegion(this, namedFlowFragment))
index 9197a9b..cf05900 100644 (file)
@@ -501,8 +501,8 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
 
     // Before updating the final size of the flow thread make sure a forced break is applied after the content.
     // This ensures the size information is correctly computed for the last auto-height region receiving content.
-    if (isRenderFlowThread())
-        toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge);
+    if (is<RenderFlowThread>(*this))
+        downcast<RenderFlowThread>(*this).applyBreakAfterContent(oldClientAfterEdge);
 
     updateLogicalHeight();
     LayoutUnit newHeight = logicalHeight();
@@ -2826,8 +2826,8 @@ bool RenderBlockFlow::hitTestFloats(const HitTestRequest& request, HitTestResult
         return false;
 
     LayoutPoint adjustedLocation = accumulatedOffset;
-    if (isRenderView())
-        adjustedLocation += toLayoutSize(toRenderView(*this).frameView().scrollPosition());
+    if (is<RenderView>(*this))
+        adjustedLocation += toLayoutSize(downcast<RenderView>(*this).frameView().scrollPosition());
 
     const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     auto begin = floatingObjectSet.begin();
@@ -3724,8 +3724,8 @@ void RenderBlockFlow::checkForPaginationLogicalHeightChange(bool& relayoutChildr
         flowThread->setColumnHeightAvailable(std::max<LayoutUnit>(columnHeight, 0));
         if (oldHeightAvailable != flowThread->columnHeightAvailable())
             relayoutChildren = true;
-    } else if (isRenderFlowThread()) {
-        RenderFlowThread* flowThread = toRenderFlowThread(this);
+    } else if (is<RenderFlowThread>(*this)) {
+        RenderFlowThread& flowThread = downcast<RenderFlowThread>(*this);
 
         // FIXME: This is a hack to always make sure we have a page logical height, if said height
         // is known. The page logical height thing in LayoutState is meaningless for flow
@@ -3736,9 +3736,9 @@ void RenderBlockFlow::checkForPaginationLogicalHeightChange(bool& relayoutChildr
         // it's unknown, we need to prevent the pagination code from assuming page breaks everywhere
         // and thereby eating every top margin. It should be trivial to clean up and get rid of this
         // hack once the old multicol implementation is gone.
-        pageLogicalHeight = flowThread->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(0);
+        pageLogicalHeight = flowThread.isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(0);
 
-        pageLogicalHeightChanged = flowThread->pageLogicalSizeChanged();
+        pageLogicalHeightChanged = flowThread.pageLogicalSizeChanged();
     }
 }
 
index 4f4a9f5..03afc15 100644 (file)
@@ -734,7 +734,7 @@ BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo
             setLogicalWidthForTextRun(lineBox, run, &renderText, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
         } else {
             bool encounteredJustifiedRuby = false;
-            if (is<RenderRubyRun>(run->renderer()) && textAlign == JUSTIFY && run != trailingSpaceRun && toRenderRubyRun(run->renderer()).rubyBase()) {
+            if (is<RenderRubyRun>(run->renderer()) && textAlign == JUSTIFY && run != trailingSpaceRun && downcast<RenderRubyRun>(run->renderer()).rubyBase()) {
                 auto* rubyBase = downcast<RenderRubyRun>(run->renderer()).rubyBase();
                 if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && run->renderer().style().collapseWhiteSpace()) {
                     for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
index 51fd7d5..e9b71c2 100644 (file)
@@ -804,9 +804,9 @@ bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
         return true;
 
     RenderBlock* nextScrollBlock = containingBlock();
-    if (nextScrollBlock && nextScrollBlock->isRenderNamedFlowThread()) {
+    if (is<RenderNamedFlowThread>(nextScrollBlock)) {
         ASSERT(startBox);
-        nextScrollBlock = toRenderNamedFlowThread(nextScrollBlock)->fragmentFromAbsolutePointAndBox(wheelEventAbsolutePoint, *startBox);
+        nextScrollBlock = downcast<RenderNamedFlowThread>(*nextScrollBlock).fragmentFromAbsolutePointAndBox(wheelEventAbsolutePoint, *startBox);
     }
 
     if (nextScrollBlock && !nextScrollBlock->isRenderView())
@@ -1166,7 +1166,7 @@ bool RenderBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
     }
 
     RenderFlowThread* flowThread = flowThreadContainingBlock();
-    RenderRegion* regionToUse = flowThread ? toRenderNamedFlowFragment(flowThread->currentRegion()) : nullptr;
+    RenderRegion* regionToUse = flowThread ? downcast<RenderNamedFlowFragment>(flowThread->currentRegion()) : nullptr;
 
     // If the box is not contained by this region there's no point in going further.
     if (regionToUse && !flowThread->objectShouldFragmentInFlowRegion(this, regionToUse))
@@ -1640,7 +1640,7 @@ void RenderBox::imageChanged(WrappedImagePtr image, const IntRect*)
 bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground)
 {
     LayoutRect rendererRect;
-    RenderBox* layerRenderer = 0;
+    RenderBox* layerRenderer = nullptr;
 
     for (const FillLayer* curLayer = layers; curLayer; curLayer = curLayer->next()) {
         if (curLayer->image() && image == curLayer->image()->data() && curLayer->image()->canRender(this, style().effectiveZoom())) {
@@ -1650,8 +1650,8 @@ bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer
                 if (drawingRootBackground) {
                     layerRenderer = &view();
 
-                    LayoutUnit rw = toRenderView(*layerRenderer).frameView().contentsWidth();
-                    LayoutUnit rh = toRenderView(*layerRenderer).frameView().contentsHeight();
+                    LayoutUnit rw = downcast<RenderView>(*layerRenderer).frameView().contentsWidth();
+                    LayoutUnit rh = downcast<RenderView>(*layerRenderer).frameView().contentsHeight();
 
                     rendererRect = LayoutRect(-layerRenderer->marginLeft(),
                         -layerRenderer->marginTop(),
@@ -1664,7 +1664,7 @@ bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer
             }
 
             BackgroundImageGeometry geometry;
-            layerRenderer->calculateBackgroundImageGeometry(0, curLayer, rendererRect, geometry);
+            layerRenderer->calculateBackgroundImageGeometry(nullptr, curLayer, rendererRect, geometry);
             if (geometry.hasNonLocalGeometry()) {
                 // Rather than incur the costs of computing the paintContainer for renderers with fixed backgrounds
                 // in order to get the right destRect, just repaint the entire renderer.
@@ -1958,7 +1958,7 @@ void RenderBox::mapLocalToContainer(const RenderLayerModelObject* repaintContain
     if (!container->isOutOfFlowRenderFlowThread() || !fixedPositionedWithNamedFlowContainingBlock())
         container->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed);
     else
-        container->mapLocalToContainer(toRenderLayerModelObject(container), transformState, mode, wasFixed);
+        container->mapLocalToContainer(downcast<RenderLayerModelObject>(container), transformState, mode, wasFixed);
 }
 
 const RenderObject* RenderBox::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
@@ -3097,15 +3097,15 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
         const RenderBlock& cb = downcast<RenderBlock>(*containingBlock);
         RenderBoxRegionInfo* boxInfo = nullptr;
         if (!region) {
-            if (containingBlock->isRenderFlowThread() && !checkForPerpendicularWritingMode)
-                return toRenderFlowThread(containingBlock)->contentLogicalWidthOfFirstRegion();
+            if (is<RenderFlowThread>(*containingBlock) && !checkForPerpendicularWritingMode)
+                return downcast<RenderFlowThread>(*containingBlock).contentLogicalWidthOfFirstRegion();
             if (isWritingModeRoot()) {
                 LayoutUnit cbPageOffset = cb.offsetFromLogicalTopOfFirstPage();
                 RenderRegion* cbRegion = cb.regionAtBlockOffset(cbPageOffset);
                 if (cbRegion)
                     boxInfo = cb.renderBoxRegionInfo(cbRegion);
             }
-        } else if (region && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
+        } else if (flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
             RenderRegion* containingBlockRegion = cb.clampToStartAndEndRegions(region);
             boxInfo = cb.renderBoxRegionInfo(containingBlockRegion);
         }
index d429329..a5958d4 100644 (file)
@@ -57,8 +57,6 @@ private:
     bool m_needsFontUpdate : 1;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderCombineText, isCombineText())
index 4ca0e0b..d995266 100644 (file)
@@ -256,7 +256,7 @@ StyleDifference RenderElement::adjustStyleDifference(StyleDifference diff, unsig
         // Text nodes share style with their parents but transforms don't apply to them,
         // hence the !isText() check.
         // FIXME: when transforms are taken into account for overflow, we will need to do a layout.
-        if (!hasLayer() || !toRenderLayerModelObject(this)->layer()->isComposited()) {
+        if (!hasLayer() || !downcast<RenderLayerModelObject>(*this).layer()->isComposited()) {
             // We need to set at least SimplifiedLayout, but if PositionedMovementOnly is already set
             // then we actually need SimplifiedLayoutAndPositionedMovement.
             if (!hasLayer())
@@ -272,14 +272,14 @@ StyleDifference RenderElement::adjustStyleDifference(StyleDifference diff, unsig
     // If opacity changed, and we are not composited, need to repaint (also
     // ignoring text nodes)
     if (contextSensitiveProperties & ContextSensitivePropertyOpacity) {
-        if (!hasLayer() || !toRenderLayerModelObject(this)->layer()->isComposited())
+        if (!hasLayer() || !downcast<RenderLayerModelObject>(*this).layer()->isComposited())
             diff = StyleDifferenceRepaintLayer;
         else if (diff < StyleDifferenceRecompositeLayer)
             diff = StyleDifferenceRecompositeLayer;
     }
 
     if ((contextSensitiveProperties & ContextSensitivePropertyFilter) && hasLayer()) {
-        RenderLayer* layer = toRenderLayerModelObject(this)->layer();
+        RenderLayer* layer = downcast<RenderLayerModelObject>(*this).layer();
         if (!layer->isComposited() || layer->paintsWithFilters())
             diff = StyleDifferenceRepaintLayer;
         else if (diff < StyleDifferenceRecompositeLayer)
@@ -290,7 +290,7 @@ StyleDifference RenderElement::adjustStyleDifference(StyleDifference diff, unsig
     // style changing, since it depends on whether we decide to composite these elements. When the
     // layer status of one of these elements changes, we need to force a layout.
     if (diff == StyleDifferenceEqual && isRenderLayerModelObject()) {
-        if (hasLayer() != toRenderLayerModelObject(this)->requiresLayer())
+        if (hasLayer() != downcast<RenderLayerModelObject>(*this).requiresLayer())
             diff = StyleDifferenceLayout;
     }
 
@@ -658,7 +658,7 @@ static void addLayers(RenderElement& renderer, RenderLayer* parentLayer, RenderE
             beforeChild = newObject->parent()->findNextLayer(parentLayer, newObject);
             newObject = nullptr;
         }
-        parentLayer->addChild(toRenderLayerModelObject(renderer).layer(), beforeChild);
+        parentLayer->addChild(downcast<RenderLayerModelObject>(renderer).layer(), beforeChild);
         return;
     }
 
@@ -682,7 +682,7 @@ void RenderElement::removeLayers(RenderLayer* parentLayer)
         return;
 
     if (hasLayer()) {
-        parentLayer->removeChild(toRenderLayerModelObject(this)->layer());
+        parentLayer->removeChild(downcast<RenderLayerModelObject>(*this).layer());
         return;
     }
 
@@ -696,7 +696,7 @@ void RenderElement::moveLayers(RenderLayer* oldParent, RenderLayer* newParent)
         return;
 
     if (hasLayer()) {
-        RenderLayer* layer = toRenderLayerModelObject(this)->layer();
+        RenderLayer* layer = downcast<RenderLayerModelObject>(*this).layer();
         ASSERT(oldParent == layer->parent());
         if (oldParent)
             oldParent->removeChild(layer);
@@ -1034,7 +1034,7 @@ void RenderElement::setNeedsPositionedMovementLayout(const RenderStyle* oldStyle
     setNeedsPositionedMovementLayoutBit(true);
     markContainingBlocksForLayout();
     if (hasLayer()) {
-        if (oldStyle && style().diffRequiresLayerRepaint(*oldStyle, toRenderLayerModelObject(this)->layer()->isComposited()))
+        if (oldStyle && style().diffRequiresLayerRepaint(*oldStyle, downcast<RenderLayerModelObject>(*this).layer()->isComposited()))
             setLayerNeedsFullRepaint();
         else
             setLayerNeedsFullRepaintForPositionedMovementLayout();
@@ -1331,10 +1331,10 @@ bool RenderElement::repaintForPausedImageAnimationsIfNeeded(const IntRect& visib
 
 RenderNamedFlowThread* RenderElement::renderNamedFlowThreadWrapper()
 {
-    auto renderer = this;
-    while (renderer && renderer->isAnonymousBlock() && !renderer->isRenderNamedFlowThread())
+    auto* renderer = this;
+    while (renderer && renderer->isAnonymousBlock() && !is<RenderNamedFlowThread>(*renderer))
         renderer = renderer->parent();
-    return renderer && renderer->isRenderNamedFlowThread() ? toRenderNamedFlowThread(renderer) : nullptr;
+    return is<RenderNamedFlowThread>(renderer) ? downcast<RenderNamedFlowThread>(renderer) : nullptr;
 }
 
 bool RenderElement::hasControlStatesForRenderer(const RenderObject* o)
index 83c7c37..14f0a38 100644 (file)
@@ -101,8 +101,6 @@ private:
     String m_unavailabilityDescription;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderEmbeddedObject, isEmbeddedObject())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderEmbeddedObject, isEmbeddedObject())
index d2b0080..4be2869 100644 (file)
@@ -42,6 +42,7 @@
 #include "RenderLayer.h"
 #include "RenderLayerCompositor.h"
 #include "RenderNamedFlowFragment.h"
+#include "RenderNamedFlowThread.h"
 #include "RenderRegion.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
@@ -150,8 +151,8 @@ void RenderFlowThread::validateRegions()
                 // Also, if we have auto-height regions we can't assume m_regionsHaveUniformLogicalHeight to be true in the first phase
                 // because the auto-height regions don't have their height computed yet.
                 if (inMeasureContentLayoutPhase() && region->hasAutoLogicalHeight()) {
-                    RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
-                    namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
+                    auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*region);
+                    namedFlowFragment.setComputedAutoHeight(namedFlowFragment.maxPageLogicalHeight());
                     m_regionsHaveUniformLogicalHeight = false;
                 }
 
@@ -217,7 +218,7 @@ void RenderFlowThread::layout()
 bool RenderFlowThread::hasCompositingRegionDescendant() const
 {
     for (auto& region : m_regionList) {
-        if (toRenderNamedFlowFragment(region)->layerOwner().layer()->hasCompositingDescendant())
+        if (downcast<RenderNamedFlowFragment>(*region).layerOwner().layer()->hasCompositingDescendant())
             return true;
     }
 
@@ -240,12 +241,12 @@ RenderNamedFlowFragment* RenderFlowThread::regionForCompositedLayer(RenderLayer&
         RenderRegion* startRegion = nullptr;
         RenderRegion* endRegion = nullptr;
         if (getRegionRangeForBox(childLayer.renderBox(), startRegion, endRegion))
-            return toRenderNamedFlowFragment(startRegion);
+            return downcast<RenderNamedFlowFragment>(startRegion);
     }
 
     // FIXME: remove this when we'll have region ranges for inlines as well.
     LayoutPoint flowThreadOffset = flooredLayoutPoint(childLayer.renderer().localToContainerPoint(LayoutPoint(), this, ApplyContainerFlip));
-    return toRenderNamedFlowFragment(regionAtBlockOffset(0, flipForWritingMode(isHorizontalWritingMode() ? flowThreadOffset.y() : flowThreadOffset.x()), true));
+    return downcast<RenderNamedFlowFragment>(regionAtBlockOffset(0, flipForWritingMode(isHorizontalWritingMode() ? flowThreadOffset.y() : flowThreadOffset.x()), true));
 }
 
 RenderNamedFlowFragment* RenderFlowThread::cachedRegionForCompositedLayer(RenderLayer& childLayer) const
@@ -713,8 +714,8 @@ void RenderFlowThread::clearRenderBoxRegionInfoAndCustomStyle(const RenderBox* b
             insideNewRegionRange = true;
 
         if (!(insideOldRegionRange && insideNewRegionRange)) {
-            if (region->isRenderNamedFlowFragment())
-                toRenderNamedFlowFragment(region)->clearObjectStyleInRegion(box);
+            if (is<RenderNamedFlowFragment>(*region))
+                downcast<RenderNamedFlowFragment>(*region).clearObjectStyleInRegion(box);
             if (region->renderBoxRegionInfo(box))
                 region->removeRenderBoxRegionInfo(box);
         }
@@ -978,10 +979,10 @@ void RenderFlowThread::initializeRegionsComputedAutoHeight(RenderRegion* startRe
         return;
 
     for (auto regionIter = startRegion ? m_regionList.find(startRegion) : m_regionList.begin(), end = m_regionList.end(); regionIter != end; ++regionIter) {
-        RenderRegion* region = *regionIter;
-        if (region->hasAutoLogicalHeight()) {
-            RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
-            namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
+        RenderRegion& region = **regionIter;
+        if (region.hasAutoLogicalHeight()) {
+            auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(region);
+            namedFlowFragment.setComputedAutoHeight(namedFlowFragment.maxPageLogicalHeight());
         }
     }
 }
@@ -1020,7 +1021,7 @@ void RenderFlowThread::updateRegionsFlowThreadPortionRect(const RenderRegion* la
     for (auto& region : m_regionList) {
         // If we find an empty auto-height region, clear the computedAutoHeight value.
         if (emptyRegionsSegment && region->hasAutoLogicalHeight())
-            toRenderNamedFlowFragment(region)->clearComputedAutoHeight();
+            downcast<RenderNamedFlowFragment>(*region).clearComputedAutoHeight();
 
         LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
         LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(RenderFlowThread::maxLogicalHeight() - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
@@ -1082,24 +1083,24 @@ bool RenderFlowThread::addForcedRegionBreak(const RenderBlock* block, LayoutUnit
     LayoutUnit offsetBreakInCurrentRegion = offsetBreakInFlowThread - currentRegionOffsetInFlowThread;
 
     if (region->hasAutoLogicalHeight()) {
-        RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
+        auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*region);
 
         // A forced break can appear only in an auto-height region that didn't have a forced break before.
         // This ASSERT is a good-enough heuristic to verify the above condition.
-        ASSERT(namedFlowFragment->maxPageLogicalHeight() == namedFlowFragment->computedAutoHeight());
+        ASSERT(namedFlowFragment.maxPageLogicalHeight() == namedFlowFragment.computedAutoHeight());
 
-        mapToUse.set(breakChild, namedFlowFragment);
+        mapToUse.set(breakChild, &namedFlowFragment);
 
         hasComputedAutoHeight = true;
 
         // Compute the region height pretending that the offsetBreakInCurrentRegion is the logicalHeight for the auto-height region.
-        LayoutUnit regionComputedAutoHeight = namedFlowFragment->constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
+        LayoutUnit regionComputedAutoHeight = namedFlowFragment.constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
 
         // The new height of this region needs to be smaller than the initial value, the max height. A forced break is the only way to change the initial
         // height of an auto-height region besides content ending.
-        ASSERT(regionComputedAutoHeight <= namedFlowFragment->maxPageLogicalHeight());
+        ASSERT(regionComputedAutoHeight <= namedFlowFragment.maxPageLogicalHeight());
 
-        namedFlowFragment->setComputedAutoHeight(regionComputedAutoHeight);
+        namedFlowFragment.setComputedAutoHeight(regionComputedAutoHeight);
 
         currentRegionOffsetInFlowThread += regionComputedAutoHeight;
     } else
@@ -1409,9 +1410,9 @@ void RenderFlowThread::addRegionsOverflowFromChild(const RenderBox* box, const R
         // In order to behave in a similar manner to the non-regions case, content overflowing the box
         // flowed into the region must be painted on top of the region's padding and the box's margin.
         // See http://lists.w3.org/Archives/Public/www-style/2014Jan/0089.html
-        if (box->isRenderNamedFlowThread()) {
+        if (is<RenderNamedFlowThread>(*box)) {
             ASSERT(box == this);
-            RenderBlockFlow& fragmentContainer = toRenderNamedFlowFragment(region)->fragmentContainer();
+            RenderBlockFlow& fragmentContainer = downcast<RenderNamedFlowFragment>(*region).fragmentContainer();
             LayoutUnit spacingAfterLayout = fragmentContainer.paddingAfter() + child->marginAfter();
             if (isHorizontalWritingMode()) {
                 if (fragmentContainer.scrollsOverflowY()) {
index 84d0356..623ebfa 100644 (file)
@@ -376,8 +376,6 @@ protected:
     bool m_layersToRegionMappingsDirty : 1;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderFlowThread, isRenderFlowThread())
-
 // This structure is used by PODIntervalTree for debugging.
 #ifndef NDEBUG
 template <> struct ValueToString<RenderRegion*> {
index 08f7b54..2a06a51 100644 (file)
@@ -1497,7 +1497,7 @@ void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect)
     }
     
     if (parentLayer->isRootLayer()) {
-        toRenderView(parentLayer->renderer()).repaintViewRectangle(parentLayerRect);
+        downcast<RenderView>(parentLayer->renderer()).repaintViewRectangle(parentLayerRect);
         return;
     }
     
@@ -1652,7 +1652,7 @@ static LayoutRect transparencyClipBox(const RenderLayer& layer, const RenderLaye
         // We have to break up the transformed extent across our columns.
         // Split our box up into the actual fragment boxes that render in the columns/pages and unite those together to
         // get our true bounding box.
-        RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
+        auto& enclosingFlowThread = downcast<RenderFlowThread>(paginationLayer->renderer());
         result = enclosingFlowThread.fragmentsBoundingBox(result);
         result.move(paginationLayer->offsetFromAncestor(rootLayer));
         return result;
@@ -1990,8 +1990,8 @@ static inline const RenderLayer* accumulateOffsetTowardsAncestor(const RenderLay
 
     if (adjustForColumns == RenderLayer::AdjustForColumns) {
         if (RenderLayer* parentLayer = layer->parent()) {
-            if (parentLayer->renderer().isRenderMultiColumnFlowThread()) {
-                RenderRegion* region = toRenderMultiColumnFlowThread(parentLayer->renderer()).physicalTranslationFromFlowToRegion(location);
+            if (is<RenderMultiColumnFlowThread>(parentLayer->renderer())) {
+                RenderRegion* region = downcast<RenderMultiColumnFlowThread>(parentLayer->renderer()).physicalTranslationFromFlowToRegion(location);
                 if (region)
                     location.moveBy(region->topLeftLocation() + -parentLayer->renderBox()->topLeftLocation());
             }
@@ -4304,7 +4304,7 @@ void RenderLayer::collectFragments(LayerFragments& fragments, const RenderLayer*
     LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingBox : boundingBox(paginationLayer, offsetWithinPaginatedLayer);
     layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect());
     
-    RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
+    auto& enclosingFlowThread = downcast<RenderFlowThread>(paginationLayer->renderer());
     RenderLayer* parentPaginationLayer = paginationLayer->parent()->enclosingPaginationLayerInSubtree(rootLayer, inclusionMode);
     LayerFragments ancestorFragments;
     if (parentPaginationLayer) {
@@ -4627,7 +4627,7 @@ bool RenderLayer::hitTest(const HitTestRequest& request, const HitTestLocation&
     ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
     ASSERT(!renderer().view().needsLayout());
 
-    LayoutRect hitTestArea = isOutOfFlowRenderFlowThread() ? toRenderFlowThread(&renderer())->visualOverflowRect() : renderer().view().documentRect();
+    LayoutRect hitTestArea = isOutOfFlowRenderFlowThread() ? downcast<RenderFlowThread>(renderer()).visualOverflowRect() : renderer().view().documentRect();
     if (!request.ignoreClipping())
         hitTestArea.intersect(renderer().view().frameView().visibleContentRect(LegacyIOSDocumentVisibleRect));
 
@@ -4637,7 +4637,7 @@ bool RenderLayer::hitTest(const HitTestRequest& request, const HitTestLocation&
         // return ourselves. We do this so mouse events continue getting delivered after a drag has 
         // exited the WebView, and so hit testing over a scrollbar hits the content document.
         if (!request.isChildFrameHitTest() && (request.active() || request.release()) && isRootLayer()) {
-            renderer().updateHitTestResult(result, toRenderView(renderer()).flipForWritingMode(hitTestLocation.point()));
+            renderer().updateHitTestResult(result, downcast<RenderView>(renderer()).flipForWritingMode(hitTestLocation.point()));
             insideLayer = this;
         }
     }
@@ -4675,7 +4675,7 @@ RenderLayer* RenderLayer::enclosingFlowThreadAncestor() const
 
 bool RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions() const
 {
-    return renderer().isRenderFlowThread() && toRenderFlowThread(renderer()).collectsGraphicsLayersUnderRegions();
+    return is<RenderFlowThread>(renderer()) && downcast<RenderFlowThread>(renderer()).collectsGraphicsLayersUnderRegions();
 }
 
 // Compute the z-offset of the point in the transformState.
@@ -5662,7 +5662,7 @@ LayoutRect RenderLayer::boundingBox(const RenderLayer* ancestorLayer, const Layo
         // get our true bounding box.
         result.move(childLayer->offsetFromAncestor(paginationLayer));
 
-        RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
+        auto& enclosingFlowThread = downcast<RenderFlowThread>(paginationLayer->renderer());
         result = enclosingFlowThread.fragmentsBoundingBox(result);
         
         childLayer = paginationLayer;
@@ -5970,7 +5970,7 @@ void RenderLayer::dirtyZOrderLists()
 
     if (!renderer().documentBeingDestroyed()) {
         if (isFlowThreadCollectingGraphicsLayersUnderRegions())
-            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
+            downcast<RenderFlowThread>(renderer()).setNeedsLayerToRegionMappingsUpdate();
         compositor().setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor().setShouldReevaluateCompositingAfterLayout();
@@ -5994,7 +5994,7 @@ void RenderLayer::dirtyNormalFlowList()
 
     if (!renderer().documentBeingDestroyed()) {
         if (isFlowThreadCollectingGraphicsLayersUnderRegions())
-            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
+            downcast<RenderFlowThread>(renderer()).setNeedsLayerToRegionMappingsUpdate();
         compositor().setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor().setShouldReevaluateCompositingAfterLayout();
index 034dbce..2e8befd 100644 (file)
@@ -48,6 +48,7 @@
 #include "PluginViewBase.h"
 #include "ProgressTracker.h"
 #include "RenderFlowThread.h"
+#include "RenderHTMLCanvas.h"
 #include "RenderIFrame.h"
 #include "RenderImage.h"
 #include "RenderLayerCompositor.h"
@@ -469,9 +470,9 @@ void RenderLayerBacking::updateCompositedBounds()
 
 void RenderLayerBacking::updateAfterWidgetResize()
 {
-    if (!renderer().isWidget())
+    if (!is<RenderWidget>(renderer()))
         return;
-    if (RenderLayerCompositor* innerCompositor = RenderLayerCompositor::frameContentsCompositor(toRenderWidget(&renderer()))) {
+    if (RenderLayerCompositor* innerCompositor = RenderLayerCompositor::frameContentsCompositor(&downcast<RenderWidget>(renderer()))) {
         innerCompositor->frameViewDidChangeSize();
         innerCompositor->frameViewDidChangeLocation(flooredIntPoint(contentsBox().location()));
     }
@@ -598,8 +599,8 @@ bool RenderLayerBacking::updateConfiguration()
         layerConfigChanged = true;
     }
 #endif
-    if (renderer().isWidget())
-        layerConfigChanged = RenderLayerCompositor::parentFrameContentLayers(toRenderWidget(&renderer()));
+    if (is<RenderWidget>(renderer()))
+        layerConfigChanged = RenderLayerCompositor::parentFrameContentLayers(&downcast<RenderWidget>(renderer()));
 
     return layerConfigChanged;
 }
@@ -1675,21 +1676,21 @@ bool RenderLayerBacking::paintsChildren() const
     return false;
 }
 
-static bool isRestartedPlugin(RenderObject* renderer)
+static bool isRestartedPlugin(RenderObject& renderer)
 {
-    if (!renderer->isEmbeddedObject())
+    if (!is<RenderEmbeddedObject>(renderer))
         return false;
 
-    Element* element = downcast<Element>(renderer->node());
+    HTMLFrameOwnerElement& element = downcast<RenderEmbeddedObject>(renderer).frameOwnerElement();
     if (!is<HTMLPlugInElement>(element))
         return false;
 
-    return downcast<HTMLPlugInElement>(*element).isRestartedPlugin();
+    return downcast<HTMLPlugInElement>(element).isRestartedPlugin();
 }
 
-static bool isCompositedPlugin(RenderObject* renderer)
+static bool isCompositedPlugin(RenderObject& renderer)
 {
-    return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allowsAcceleratedCompositing();
+    return is<RenderEmbeddedObject>(renderer) && downcast<RenderEmbeddedObject>(renderer).allowsAcceleratedCompositing();
 }
 
 // A "simple container layer" is a RenderLayer which has no visible content to render.
@@ -1697,7 +1698,7 @@ static bool isCompositedPlugin(RenderObject* renderer)
 // This is a useful optimization, because it allows us to avoid allocating backing store.
 bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
 {
-    if (renderer().isRenderReplaced() && (!isCompositedPlugin(&renderer()) || isRestartedPlugin(&renderer())))
+    if (renderer().isRenderReplaced() && (!isCompositedPlugin(renderer()) || isRestartedPlugin(renderer())))
         return false;
 
     if (paintsBoxDecorations() || paintsChildren())
@@ -1803,12 +1804,12 @@ bool RenderLayerBacking::containsPaintedContent(bool isSimpleContainer) const
     // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
     // and set background color on the layer in that case, instead of allocating backing store and painting.
 #if ENABLE(VIDEO)
-    if (renderer().isVideo() && toRenderVideo(renderer()).shouldDisplayVideo())
+    if (is<RenderVideo>(renderer()) && downcast<RenderVideo>(renderer()).shouldDisplayVideo())
         return m_owningLayer.hasBoxDecorationsOrBackground();
 #endif
 
 #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS)
-    if (renderer().isCanvas() && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents)
+    if (is<RenderHTMLCanvas>(renderer()) && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents)
         return m_owningLayer.hasBoxDecorationsOrBackground();
 #endif
 
index 9d5012f..40904be 100644 (file)
@@ -943,10 +943,10 @@ bool RenderLayerCompositor::updateBacking(RenderLayer& layer, CompositingChangeR
             // its replica GraphicsLayer. In practice this should never happen because reflectee and reflection 
             // are both either composited, or not composited.
             if (layer.isReflection()) {
-                RenderLayer* sourceLayer = toRenderLayerModelObject(layer.renderer().parent())->layer();
+                RenderLayer* sourceLayer = downcast<RenderLayerModelObject>(*layer.renderer().parent()).layer();
                 if (RenderLayerBacking* backing = sourceLayer->backing()) {
                     ASSERT(backing->graphicsLayer()->replicaLayer() == layer.backing()->graphicsLayer());
-                    backing->graphicsLayer()->setReplicatedByLayer(0);
+                    backing->graphicsLayer()->setReplicatedByLayer(nullptr);
                 }
             }
 
@@ -966,14 +966,14 @@ bool RenderLayerCompositor::updateBacking(RenderLayer& layer, CompositingChangeR
     }
     
 #if ENABLE(VIDEO)
-    if (layerChanged && layer.renderer().isVideo()) {
+    if (layerChanged && is<RenderVideo>(layer.renderer())) {
         // If it's a video, give the media player a chance to hook up to the layer.
-        toRenderVideo(layer.renderer()).acceleratedRenderingStateChanged();
+        downcast<RenderVideo>(layer.renderer()).acceleratedRenderingStateChanged();
     }
 #endif
 
-    if (layerChanged && layer.renderer().isWidget()) {
-        RenderLayerCompositor* innerCompositor = frameContentsCompositor(toRenderWidget(&layer.renderer()));
+    if (layerChanged && is<RenderWidget>(layer.renderer())) {
+        RenderLayerCompositor* innerCompositor = frameContentsCompositor(&downcast<RenderWidget>(layer.renderer()));
         if (innerCompositor && innerCompositor->inCompositingMode())
             innerCompositor->updateRootLayerAttachment();
     }
@@ -1175,7 +1175,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
     layer.updateLayerListsIfNeeded();
 
     if (layer.isFlowThreadCollectingGraphicsLayersUnderRegions()) {
-        RenderFlowThread& flowThread = toRenderFlowThread(layer.renderer());
+        auto& flowThread = downcast<RenderFlowThread>(layer.renderer());
         layer.setHasCompositingDescendant(flowThread.hasCompositingRegionDescendant());
 
         // Before returning, we need to update the lists of all child layers. This is required because,
@@ -1548,8 +1548,8 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vect
 
     if (layerBacking) {
         bool parented = false;
-        if (layer.renderer().isWidget())
-            parented = parentFrameContentLayers(toRenderWidget(&layer.renderer()));
+        if (is<RenderWidget>(layer.renderer()))
+            parented = parentFrameContentLayers(&downcast<RenderWidget>(layer.renderer()));
 
         if (!parented)
             layerBacking->parentForSublayers()->setChildren(layerChildren);
@@ -2090,11 +2090,11 @@ bool RenderLayerCompositor::needsToBeComposited(const RenderLayer& layer, Render
 // static
 bool RenderLayerCompositor::requiresCompositingLayer(const RenderLayer& layer, RenderLayer::ViewportConstrainedNotCompositedReason* viewportConstrainedNotCompositedReason) const
 {
-    auto renderer = &layer.renderer();
+    auto* renderer = &layer.renderer();
 
     // The compositing state of a reflection should match that of its reflected layer.
     if (layer.isReflection())
-        renderer = toRenderLayerModelObject(renderer->parent()); // The RenderReplica's parent is the object being reflected.
+        renderer = downcast<RenderLayerModelObject>(renderer->parent()); // The RenderReplica's parent is the object being reflected.
 
     // The root layer always has a compositing layer, but it may not have backing.
     return requiresCompositingForTransform(*renderer)
@@ -2183,9 +2183,9 @@ CompositingReasons RenderLayerCompositor::reasonsForCompositing(const RenderLaye
     if (!layer.isComposited())
         return reasons;
 
-    auto renderer = &layer.renderer();
+    auto* renderer = &layer.renderer();
     if (layer.isReflection())
-        renderer = toRenderLayerModelObject(renderer->parent());
+        renderer = downcast<RenderLayerModelObject>(renderer->parent());
 
     if (requiresCompositingForTransform(*renderer))
         reasons |= CompositingReason3DTransform;
@@ -2450,8 +2450,8 @@ bool RenderLayerCompositor::requiresCompositingForVideo(RenderLayerModelObject&
     if (!(m_compositingTriggers & ChromeClient::VideoTrigger))
         return false;
 #if ENABLE(VIDEO)
-    if (renderer.isVideo()) {
-        RenderVideo& video = toRenderVideo(renderer);
+    if (is<RenderVideo>(renderer)) {
+        auto& video = downcast<RenderVideo>(renderer);
         return (video.requiresImmediateCompositing() || video.shouldDisplayVideo()) && canAccelerateVideoRendering(video);
     }
 #else
@@ -2484,13 +2484,13 @@ bool RenderLayerCompositor::requiresCompositingForPlugin(RenderLayerModelObject&
     if (!(m_compositingTriggers & ChromeClient::PluginTrigger))
         return false;
 
-    bool composite = renderer.isEmbeddedObject() && toRenderEmbeddedObject(&renderer)->allowsAcceleratedCompositing();
+    bool composite = is<RenderEmbeddedObject>(renderer) && downcast<RenderEmbeddedObject>(renderer).allowsAcceleratedCompositing();
     if (!composite)
         return false;
 
     m_reevaluateCompositingAfterLayout = true;
     
-    RenderWidget& pluginRenderer = *toRenderWidget(&renderer);
+    RenderWidget& pluginRenderer = downcast<RenderWidget>(renderer);
     // If we can't reliably know the size of the plugin yet, don't change compositing state.
     if (pluginRenderer.needsLayout())
         return pluginRenderer.hasLayer() && pluginRenderer.layer()->isComposited();
@@ -2502,10 +2502,10 @@ bool RenderLayerCompositor::requiresCompositingForPlugin(RenderLayerModelObject&
 
 bool RenderLayerCompositor::requiresCompositingForFrame(RenderLayerModelObject& renderer) const
 {
-    if (!renderer.isWidget())
+    if (!is<RenderWidget>(renderer))
         return false;
 
-    RenderWidget& frameRenderer = *toRenderWidget(&renderer);
+    auto& frameRenderer = downcast<RenderWidget>(renderer);
 
     if (!frameRenderer.requiresAcceleratedCompositing())
         return false;
index 2099042..6cf0fdc 100644 (file)
@@ -69,8 +69,6 @@ private:
     static bool s_layerWasSelfPainting;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderLayerModelObject, isRenderLayerModelObject())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderLayerModelObject, isRenderLayerModelObject())
index e8ec5ef..d0e3fe5 100644 (file)
@@ -93,8 +93,6 @@ private:
     bool m_isWBR;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderLineBreak, isLineBreak())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderLineBreak, isLineBreak())
index a63250e..c6e260a 100644 (file)
@@ -47,8 +47,6 @@ private:
     virtual bool requiresForcedStyleRecalcPropagation() const override { return true; }
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMeter, isMeter())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMeter, isMeter())
index d20cb03..65bc02c 100644 (file)
@@ -72,8 +72,8 @@ const char* RenderMultiColumnFlowThread::renderName() const
 RenderMultiColumnSet* RenderMultiColumnFlowThread::firstMultiColumnSet() const
 {
     for (RenderObject* sibling = nextSibling(); sibling; sibling = sibling->nextSibling()) {
-        if (sibling->isRenderMultiColumnSet())
-            return toRenderMultiColumnSet(sibling);
+        if (is<RenderMultiColumnSet>(*sibling))
+            return downcast<RenderMultiColumnSet>(sibling);
     }
     return nullptr;
 }
@@ -81,8 +81,8 @@ RenderMultiColumnSet* RenderMultiColumnFlowThread::firstMultiColumnSet() const
 RenderMultiColumnSet* RenderMultiColumnFlowThread::lastMultiColumnSet() const
 {
     for (RenderObject* sibling = multiColumnBlockFlow()->lastChild(); sibling; sibling = sibling->previousSibling()) {
-        if (sibling->isRenderMultiColumnSet())
-            return toRenderMultiColumnSet(sibling);
+        if (is<RenderMultiColumnSet>(*sibling))
+            return downcast<RenderMultiColumnSet>(sibling);
     }
     return nullptr;
 }
@@ -124,8 +124,8 @@ void RenderMultiColumnFlowThread::layout()
     m_inLayout = true;
     m_lastSetWorkedOn = nullptr;
     if (RenderBox* first = firstColumnSetOrSpanner()) {
-        if (first->isRenderMultiColumnSet()) {
-            m_lastSetWorkedOn = toRenderMultiColumnSet(first);
+        if (is<RenderMultiColumnSet>(*first)) {
+            m_lastSetWorkedOn = downcast<RenderMultiColumnSet>(first);
             m_lastSetWorkedOn->beginFlow(this);
         }
     }
@@ -196,7 +196,7 @@ void RenderMultiColumnFlowThread::evacuateAndDestroy()
 
 void RenderMultiColumnFlowThread::addRegionToThread(RenderRegion* renderRegion)
 {
-    RenderMultiColumnSet* columnSet = toRenderMultiColumnSet(renderRegion);
+    auto* columnSet = downcast<RenderMultiColumnSet>(renderRegion);
     if (RenderMultiColumnSet* nextSet = columnSet->nextSiblingMultiColumnSet()) {
         RenderRegionList::iterator it = m_regionList.find(nextSet);
         ASSERT(it != m_regionList.end());
@@ -367,36 +367,36 @@ void RenderMultiColumnFlowThread::flowThreadDescendantInserted(RenderObject* des
         return;
     RenderObject* subtreeRoot = descendant;
     for (; descendant; descendant = (descendant ? descendant->nextInPreOrder(subtreeRoot) : nullptr)) {
-        if (descendant->isRenderMultiColumnSpannerPlaceholder()) {
+        if (is<RenderMultiColumnSpannerPlaceholder>(*descendant)) {
             // A spanner's placeholder has been inserted. The actual spanner renderer is moved from
             // where it would otherwise occur (if it weren't a spanner) to becoming a sibling of the
             // column sets.
-            RenderMultiColumnSpannerPlaceholder* placeholder = toRenderMultiColumnSpannerPlaceholder(descendant);
-            if (placeholder->flowThread() != this) {
+            RenderMultiColumnSpannerPlaceholder& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*descendant);
+            if (placeholder.flowThread() != this) {
                 // This isn't our spanner! It shifted here from an ancestor multicolumn block. It's going to end up
                 // becoming our spanner instead, but for it to do that we first have to nuke the original spanner,
                 // and get the spanner content back into this flow thread.
-                RenderBox* spanner = placeholder->spanner();
+                RenderBox* spanner = placeholder.spanner();
                 
                 // Insert after the placeholder, but don't let a notification happen.
                 gShiftingSpanner = true;
                 RenderBlockFlow& ancestorBlock = downcast<RenderBlockFlow>(*spanner->parent());
-                ancestorBlock.moveChildTo(placeholder->parentBox(), spanner, placeholder->nextSibling(), true);
+                ancestorBlock.moveChildTo(placeholder.parentBox(), spanner, placeholder.nextSibling(), true);
                 gShiftingSpanner = false;
                 
                 // We have to nuke the placeholder, since the ancestor already lost the mapping to it when
                 // we shifted the placeholder down into this flow thread.
                 ancestorBlock.multiColumnFlowThread()->handleSpannerRemoval(spanner);
-                placeholder->destroy();
+                placeholder.destroy();
                 
                 // Now we process the spanner.
                 descendant = processPossibleSpannerDescendant(subtreeRoot, spanner);
                 continue;
             }
             
-            ASSERT(!m_spannerMap.get(placeholder->spanner()));
-            m_spannerMap.add(placeholder->spanner(), placeholder);
-            ASSERT(!placeholder->firstChild()); // There should be no children here, but if there are, we ought to skip them.
+            ASSERT(!m_spannerMap.get(placeholder.spanner()));
+            m_spannerMap.add(placeholder.spanner(), &placeholder);
+            ASSERT(!placeholder.firstChild()); // There should be no children here, but if there are, we ought to skip them.
             continue;
         }
         
@@ -428,12 +428,12 @@ void RenderMultiColumnFlowThread::flowThreadRelativeWillBeRemoved(RenderObject*
     if (m_beingEvacuated)
         return;
     invalidateRegions();
-    if (relative->isRenderMultiColumnSpannerPlaceholder()) {
+    if (is<RenderMultiColumnSpannerPlaceholder>(*relative)) {
         // Remove the map entry for this spanner, but leave the actual spanner renderer alone. Also
         // keep the reference to the spanner, since the placeholder may be about to be re-inserted
         // in the tree.
         ASSERT(relative->isDescendantOf(this));
-        m_spannerMap.remove(toRenderMultiColumnSpannerPlaceholder(relative)->spanner());
+        m_spannerMap.remove(downcast<RenderMultiColumnSpannerPlaceholder>(*relative).spanner());
         return;
     }
     if (relative->style().columnSpan() == ColumnSpanAll) {
@@ -449,21 +449,21 @@ void RenderMultiColumnFlowThread::flowThreadRelativeWillBeRemoved(RenderObject*
 
 void RenderMultiColumnFlowThread::flowThreadDescendantBoxLaidOut(RenderBox* descendant)
 {
-    if (!descendant->isRenderMultiColumnSpannerPlaceholder())
+    if (!is<RenderMultiColumnSpannerPlaceholder>(*descendant))
         return;
-    RenderMultiColumnSpannerPlaceholder* placeholder = toRenderMultiColumnSpannerPlaceholder(descendant);
-    RenderBlock* container = placeholder->containingBlock();
+    auto& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*descendant);
+    RenderBlock* container = placeholder.containingBlock();
 
-    for (RenderBox* prev = previousColumnSetOrSpannerSiblingOf(placeholder->spanner()); prev; prev = previousColumnSetOrSpannerSiblingOf(prev)) {
-        if (prev->isRenderMultiColumnSet()) {
-            toRenderMultiColumnSet(prev)->endFlow(container, placeholder->logicalTop());
+    for (RenderBox* prev = previousColumnSetOrSpannerSiblingOf(placeholder.spanner()); prev; prev = previousColumnSetOrSpannerSiblingOf(prev)) {
+        if (is<RenderMultiColumnSet>(*prev)) {
+            downcast<RenderMultiColumnSet>(*prev).endFlow(container, placeholder.logicalTop());
             break;
         }
     }
 
-    for (RenderBox* next = nextColumnSetOrSpannerSiblingOf(placeholder->spanner()); next; next = nextColumnSetOrSpannerSiblingOf(next)) {
-        if (next->isRenderMultiColumnSet()) {
-            m_lastSetWorkedOn = toRenderMultiColumnSet(next);
+    for (RenderBox* next = nextColumnSetOrSpannerSiblingOf(placeholder.spanner()); next; next = nextColumnSetOrSpannerSiblingOf(next)) {
+        if (is<RenderMultiColumnSet>(*next)) {
+            m_lastSetWorkedOn = downcast<RenderMultiColumnSet>(next);
             m_lastSetWorkedOn->beginFlow(container);
             break;
         }
@@ -484,13 +484,13 @@ LayoutUnit RenderMultiColumnFlowThread::initialLogicalWidth() const
 
 void RenderMultiColumnFlowThread::setPageBreak(const RenderBlock* block, LayoutUnit offset, LayoutUnit spaceShortage)
 {
-    if (RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(regionAtBlockOffset(block, offset)))
+    if (auto* multicolSet = downcast<RenderMultiColumnSet>(regionAtBlockOffset(block, offset)))
         multicolSet->recordSpaceShortage(spaceShortage);
 }
 
 void RenderMultiColumnFlowThread::updateMinimumPageHeight(const RenderBlock* block, LayoutUnit offset, LayoutUnit minHeight)
 {
-    if (RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(regionAtBlockOffset(block, offset)))
+    if (auto* multicolSet = downcast<RenderMultiColumnSet>(regionAtBlockOffset(block, offset)))
         multicolSet->updateMinimumColumnHeight(minHeight);
 }
 
@@ -534,12 +534,12 @@ void RenderMultiColumnFlowThread::setRegionRangeForBox(const RenderBox* box, Ren
     // exact same flow thread position, which means that some parts of the code may believe that a
     // given box lives in sets that it doesn't really live in. Make some adjustments here and
     // include such sets if they are adjacent to the start and/or end regions.
-    for (RenderMultiColumnSet* columnSet = toRenderMultiColumnSet(startRegion)->previousSiblingMultiColumnSet(); columnSet; columnSet = columnSet->previousSiblingMultiColumnSet()) {
+    for (RenderMultiColumnSet* columnSet = downcast<RenderMultiColumnSet>(*startRegion).previousSiblingMultiColumnSet(); columnSet; columnSet = columnSet->previousSiblingMultiColumnSet()) {
         if (columnSet->logicalHeightInFlowThread())
             break;
         startRegion = columnSet;
     }
-    for (RenderMultiColumnSet* columnSet = toRenderMultiColumnSet(startRegion)->nextSiblingMultiColumnSet(); columnSet; columnSet = columnSet->nextSiblingMultiColumnSet()) {
+    for (RenderMultiColumnSet* columnSet = downcast<RenderMultiColumnSet>(*startRegion).nextSiblingMultiColumnSet(); columnSet; columnSet = columnSet->nextSiblingMultiColumnSet()) {
         if (columnSet->logicalHeightInFlowThread())
             break;
         endRegion = columnSet;
@@ -550,7 +550,7 @@ void RenderMultiColumnFlowThread::setRegionRangeForBox(const RenderBox* box, Ren
 
 bool RenderMultiColumnFlowThread::addForcedRegionBreak(const RenderBlock* block, LayoutUnit offset, RenderBox* /*breakChild*/, bool /*isBefore*/, LayoutUnit* offsetBreakAdjustment)
 {
-    if (RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(regionAtBlockOffset(block, offset))) {
+    if (auto* multicolSet = downcast<RenderMultiColumnSet>(regionAtBlockOffset(block, offset))) {
         multicolSet->addForcedBreak(offset);
         if (offsetBreakAdjustment)
             *offsetBreakAdjustment = pageLogicalHeightForOffset(offset) ? pageRemainingLogicalHeightForOffset(offset, IncludePageBoundary) : LayoutUnit::fromPixel(0);
@@ -689,7 +689,7 @@ RenderRegion* RenderMultiColumnFlowThread::mapFromFlowToRegion(TransformState& t
 LayoutSize RenderMultiColumnFlowThread::physicalTranslationOffsetFromFlowToRegion(const RenderRegion* renderRegion, const LayoutUnit logicalOffset) const
 {
     // Now that we know which multicolumn set we hit, we need to get the appropriate translation offset for the column.
-    const RenderMultiColumnSet* columnSet = toRenderMultiColumnSet(renderRegion);
+    const auto* columnSet = downcast<RenderMultiColumnSet>(renderRegion);
     LayoutPoint translationOffset = columnSet->columnTranslationForOffset(logicalOffset);
     
     // Now we know how we want the rect to be translated into the region. At this point we're converting
index 513d31d..0223c98 100644 (file)
@@ -158,8 +158,6 @@ private:
     static bool gShiftingSpanner;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnFlowThread, isRenderMultiColumnFlowThread())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnFlowThread, isRenderMultiColumnFlowThread())
index a3cc6e7..248b948 100644 (file)
@@ -51,8 +51,8 @@ RenderMultiColumnSet::RenderMultiColumnSet(RenderFlowThread& flowThread, PassRef
 RenderMultiColumnSet* RenderMultiColumnSet::nextSiblingMultiColumnSet() const
 {
     for (RenderObject* sibling = nextSibling(); sibling; sibling = sibling->nextSibling()) {
-        if (sibling->isRenderMultiColumnSet())
-            return toRenderMultiColumnSet(sibling);
+        if (is<RenderMultiColumnSet>(*sibling))
+            return downcast<RenderMultiColumnSet>(sibling);
     }
     return nullptr;
 }
@@ -60,8 +60,8 @@ RenderMultiColumnSet* RenderMultiColumnSet::nextSiblingMultiColumnSet() const
 RenderMultiColumnSet* RenderMultiColumnSet::previousSiblingMultiColumnSet() const
 {
     for (RenderObject* sibling = previousSibling(); sibling; sibling = sibling->previousSibling()) {
-        if (sibling->isRenderMultiColumnSet())
-            return toRenderMultiColumnSet(sibling);
+        if (is<RenderMultiColumnSet>(*sibling))
+            return downcast<RenderMultiColumnSet>(sibling);
     }
     return nullptr;
 }
index f930b77..27ca737 100644 (file)
@@ -225,8 +225,6 @@ private:
     Vector<ContentRun, 1> m_contentRuns;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSet, isRenderMultiColumnSet())
index caac2e7..f1a5b88 100644 (file)
@@ -55,8 +55,6 @@ private:
     RenderMultiColumnFlowThread* m_flowThread;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSpannerPlaceholder, isRenderMultiColumnSpannerPlaceholder())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSpannerPlaceholder, isRenderMultiColumnSpannerPlaceholder())
index d2ff885..b508435 100644 (file)
@@ -344,7 +344,7 @@ void RenderNamedFlowFragment::checkRegionStyle()
     if (!isPseudoElement())
         customRegionStyle = view().document().ensureStyleResolver().checkRegionStyle(generatingElement());
     setHasCustomRegionStyle(customRegionStyle);
-    toRenderNamedFlowThread(m_flowThread)->checkRegionsWithStyling();
+    downcast<RenderNamedFlowThread>(*m_flowThread).checkRegionsWithStyling();
 }
 
 PassRefPtr<RenderStyle> RenderNamedFlowFragment::computeStyleInRegion(RenderElement& renderer, RenderStyle& parentStyle) const
@@ -489,7 +489,7 @@ void RenderNamedFlowFragment::restoreRegionObjectsOriginalStyle()
 
 RenderNamedFlowThread* RenderNamedFlowFragment::namedFlowThread() const
 {
-    return toRenderNamedFlowThread(flowThread());
+    return downcast<RenderNamedFlowThread>(flowThread());
 }
 
 LayoutRect RenderNamedFlowFragment::visualOverflowRect() const
index 330f30c..c5efb32 100644 (file)
@@ -77,7 +77,7 @@ public:
     // parent renderer instead.
     // This method returns that renderer holding the layer.
     // The return value cannot be null because CSS Regions create Stacking Contexts (which means they create layers).
-    RenderLayerModelObject& layerOwner() const { return *toRenderLayerModelObject(parent()); }
+    RenderLayerModelObject& layerOwner() const { return downcast<RenderLayerModelObject>(*parent()); }
 
     bool hasCustomRegionStyle() const { return m_hasCustomRegionStyle; }
     void clearObjectStyleInRegion(const RenderObject*);
@@ -163,8 +163,6 @@ private:
     LayoutUnit m_computedAutoHeight;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowFragment, isRenderNamedFlowFragment())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderNamedFlowFragment, isRenderNamedFlowFragment())
index 5cbcffd..174c8ce 100644 (file)
@@ -85,7 +85,7 @@ void RenderNamedFlowThread::clearContentElements()
 
 void RenderNamedFlowThread::updateWritingMode()
 {
-    RenderNamedFlowFragment* firstFragment = toRenderNamedFlowFragment(m_regionList.first());
+    auto* firstFragment = downcast<RenderNamedFlowFragment>(m_regionList.first());
     if (!firstFragment)
         return;
     if (style().writingMode() == firstFragment->style().writingMode())
@@ -203,7 +203,7 @@ static void addFragmentToList(RenderRegionList& regionList, RenderNamedFlowFragm
     else {
         // Find the first region "greater" than renderNamedFlowFragment.
         auto it = regionList.begin();
-        while (it != regionList.end() && !compareRenderNamedFlowFragments(renderNamedFlowFragment, toRenderNamedFlowFragment(*it)))
+        while (it != regionList.end() && !compareRenderNamedFlowFragments(renderNamedFlowFragment, downcast<RenderNamedFlowFragment>(*it)))
             ++it;
         regionList.insertBefore(it, renderNamedFlowFragment);
     }
@@ -230,18 +230,18 @@ void RenderNamedFlowThread::addRegionToThread(RenderRegion* renderRegion)
     ASSERT(renderRegion);
     ASSERT(!renderRegion->isValid());
 
-    RenderNamedFlowFragment* renderNamedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+    RenderNamedFlowFragment& renderNamedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
     resetMarkForDestruction();
 
-    if (renderNamedFlowFragment->parentNamedFlowThread() && renderNamedFlowFragment->parentNamedFlowThread()->dependsOn(this)) {
+    if (renderNamedFlowFragment.parentNamedFlowThread() && renderNamedFlowFragment.parentNamedFlowThread()->dependsOn(this)) {
         // The order of invalid regions is irrelevant.
-        m_invalidRegionList.add(renderNamedFlowFragment);
+        m_invalidRegionList.add(&renderNamedFlowFragment);
         // Register ourself to get a notification when the state changes.
-        renderNamedFlowFragment->parentNamedFlowThread()->m_observerThreadsSet.add(this);
+        renderNamedFlowFragment.parentNamedFlowThread()->m_observerThreadsSet.add(this);
         return;
     }
 
-    addFragmentToNamedFlowThread(renderNamedFlowFragment);
+    addFragmentToNamedFlowThread(&renderNamedFlowFragment);
 
     invalidateRegions();
 }
@@ -250,22 +250,22 @@ void RenderNamedFlowThread::removeRegionFromThread(RenderRegion* renderRegion)
 {
     ASSERT(renderRegion);
 
-    RenderNamedFlowFragment* renderNamedFlowFragment = toRenderNamedFlowFragment(renderRegion);
-    if (renderNamedFlowFragment->parentNamedFlowThread()) {
-        if (!renderNamedFlowFragment->isValid()) {
-            ASSERT(m_invalidRegionList.contains(renderNamedFlowFragment));
-            m_invalidRegionList.remove(renderNamedFlowFragment);
-            renderNamedFlowFragment->parentNamedFlowThread()->m_observerThreadsSet.remove(this);
+    RenderNamedFlowFragment& renderNamedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
+    if (renderNamedFlowFragment.parentNamedFlowThread()) {
+        if (!renderNamedFlowFragment.isValid()) {
+            ASSERT(m_invalidRegionList.contains(&renderNamedFlowFragment));
+            m_invalidRegionList.remove(&renderNamedFlowFragment);
+            renderNamedFlowFragment.parentNamedFlowThread()->m_observerThreadsSet.remove(this);
             // No need to invalidate the regions rectangles. The removed region
             // was not taken into account. Just return here.
             return;
         }
-        removeDependencyOnFlowThread(renderNamedFlowFragment->parentNamedFlowThread());
+        removeDependencyOnFlowThread(renderNamedFlowFragment.parentNamedFlowThread());
     }
 
-    ASSERT(m_regionList.contains(renderNamedFlowFragment));
-    bool wasFirst = m_regionList.first() == renderNamedFlowFragment;
-    m_regionList.remove(renderNamedFlowFragment);
+    ASSERT(m_regionList.contains(&renderNamedFlowFragment));
+    bool wasFirst = m_regionList.first() == &renderNamedFlowFragment;
+    m_regionList.remove(&renderNamedFlowFragment);
 
     if (canBeDestroyed())
         setMarkForDestruction();
@@ -377,7 +377,7 @@ LayoutRect RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment(c
 
 RenderBlock* RenderNamedFlowThread::fragmentFromRenderBoxAsRenderBlock(RenderBox* renderBox, const IntPoint& absolutePoint, const RenderBox& flowedBox)
 {
-    return toRenderNamedFlowThread(renderBox)->fragmentFromAbsolutePointAndBox(absolutePoint, flowedBox);
+    return downcast<RenderNamedFlowThread>(*renderBox).fragmentFromAbsolutePointAndBox(absolutePoint, flowedBox);
 }
 
 RenderNamedFlowFragment* RenderNamedFlowThread::fragmentFromAbsolutePointAndBox(const IntPoint& absolutePoint, const RenderBox& flowedBox)
@@ -388,13 +388,13 @@ RenderNamedFlowFragment* RenderNamedFlowThread::fragmentFromAbsolutePointAndBox(
         return nullptr;
     
     for (auto iter = m_regionList.find(startRegion), end = m_regionList.end(); iter != end; ++iter) {
-        RenderNamedFlowFragment* fragment = toRenderNamedFlowFragment(*iter);
-        RenderBlockFlow& fragmentContainer = fragment->fragmentContainer();
+        auto& fragment = downcast<RenderNamedFlowFragment>(**iter);
+        RenderBlockFlow& fragmentContainer = fragment.fragmentContainer();
         IntRect fragmentAbsoluteRect(roundedIntPoint(fragmentContainer.localToAbsolute()), roundedIntSize(fragmentContainer.paddingBoxRect().size()));
         if (fragmentAbsoluteRect.contains(absolutePoint))
-            return fragment;
+            return &fragment;
         
-        if (fragment == endRegion)
+        if (&fragment == endRegion)
             break;
     }
     
@@ -430,13 +430,13 @@ void RenderNamedFlowThread::checkInvalidRegions()
 {
     Vector<RenderNamedFlowFragment*> newValidFragments;
     for (auto& region : m_invalidRegionList) {
-        RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
+        auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*region);
         // The only reason a region would be invalid is because it has a parent flow thread.
-        ASSERT(!namedFlowFragment->isValid() && namedFlowFragment->parentNamedFlowThread());
-        if (namedFlowFragment->parentNamedFlowThread()->dependsOn(this))
+        ASSERT(!namedFlowFragment.isValid() && namedFlowFragment.parentNamedFlowThread());
+        if (namedFlowFragment.parentNamedFlowThread()->dependsOn(this))
             continue;
 
-        newValidFragments.append(namedFlowFragment);
+        newValidFragments.append(&namedFlowFragment);
     }
 
     for (auto& namedFlowFragment : newValidFragments) {
@@ -803,7 +803,7 @@ void RenderNamedFlowThread::checkRegionsWithStyling()
 {
     bool hasRegionsWithStyling = false;
     for (const auto& region : m_regionList) {
-        if (toRenderNamedFlowFragment(region)->hasCustomRegionStyle()) {
+        if (downcast<RenderNamedFlowFragment>(*region).hasCustomRegionStyle()) {
             hasRegionsWithStyling = true;
             break;
         }
@@ -816,7 +816,7 @@ void RenderNamedFlowThread::clearRenderObjectCustomStyle(const RenderObject* obj
     // Clear the styles for the object in the regions.
     // FIXME: Region styling is not computed only for the region range of the object so this is why we need to walk the whole chain.
     for (auto& region : m_regionList)
-        toRenderNamedFlowFragment(region)->clearObjectStyleInRegion(object);
+        downcast<RenderNamedFlowFragment>(*region).clearObjectStyleInRegion(object);
 }
 
 void RenderNamedFlowThread::removeFlowChildInfo(RenderObject* child)
index d82713a..1b0e794 100644 (file)
@@ -159,8 +159,6 @@ private:
     LayoutUnit m_flowContentBottom;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowThread, isRenderNamedFlowThread())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderNamedFlowThread, isRenderNamedFlowThread())
index 8880dde..abbc2b4 100644 (file)
@@ -569,13 +569,13 @@ void RenderObject::clearNeedsLayout()
 
 static void scheduleRelayoutForSubtree(RenderElement& renderer)
 {
-    if (!renderer.isRenderView()) {
+    if (!is<RenderView>(renderer)) {
         if (!renderer.isRooted())
             return;
         renderer.view().frameView().scheduleRelayoutOfSubtree(renderer);
         return;
     }
-    toRenderView(renderer).frameView().scheduleRelayout();
+    downcast<RenderView>(renderer).frameView().scheduleRelayout();
 }
 
 void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderElement* newRoot)
@@ -677,13 +677,13 @@ void RenderObject::invalidateContainerPreferredLogicalWidths()
 void RenderObject::setLayerNeedsFullRepaint()
 {
     ASSERT(hasLayer());
-    toRenderLayerModelObject(this)->layer()->setRepaintStatus(NeedsFullRepaint);
+    downcast<RenderLayerModelObject>(*this).layer()->setRepaintStatus(NeedsFullRepaint);
 }
 
 void RenderObject::setLayerNeedsFullRepaintForPositionedMovementLayout()
 {
     ASSERT(hasLayer());
-    toRenderLayerModelObject(this)->layer()->setRepaintStatus(NeedsFullRepaintForPositionedMovementLayout);
+    downcast<RenderLayerModelObject>(*this).layer()->setRepaintStatus(NeedsFullRepaintForPositionedMovementLayout);
 }
 
 RenderBlock* RenderObject::containingBlock() const
@@ -1237,8 +1237,8 @@ void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo
         return;
     }
 
-    if (repaintContainer->isRenderFlowThread()) {
-        toRenderFlowThread(repaintContainer)->repaintRectangleInRegions(r);
+    if (is<RenderFlowThread>(*repaintContainer)) {
+        downcast<RenderFlowThread>(*repaintContainer).repaintRectangleInRegions(r);
         return;
     }
 
@@ -1624,8 +1624,8 @@ Color RenderObject::selectionEmphasisMarkColor() const
 SelectionSubtreeRoot& RenderObject::selectionRoot() const
 {
     RenderFlowThread* flowThread = flowThreadContainingBlock();
-    if (flowThread && flowThread->isRenderNamedFlowThread())
-        return *toRenderNamedFlowThread(flowThread);
+    if (is<RenderNamedFlowThread>(flowThread))
+        return downcast<RenderNamedFlowThread>(*flowThread);
 
     return view();
 }
@@ -1761,7 +1761,7 @@ bool RenderObject::shouldUseTransformFromContainer(const RenderObject* container
 #if ENABLE(3D_RENDERING)
     // hasTransform() indicates whether the object has transform, transform-style or perspective. We just care about transform,
     // so check the layer's transform directly.
-    return (hasLayer() && toRenderLayerModelObject(this)->layer()->transform()) || (containerObject && containerObject->style().hasPerspective());
+    return (hasLayer() && downcast<RenderLayerModelObject>(*this).layer()->transform()) || (containerObject && containerObject->style().hasPerspective());
 #else
     UNUSED_PARAM(containerObject);
     return hasTransform();
@@ -1773,14 +1773,14 @@ void RenderObject::getTransformFromContainer(const RenderObject* containerObject
     transform.makeIdentity();
     transform.translate(offsetInContainer.width(), offsetInContainer.height());
     RenderLayer* layer;
-    if (hasLayer() && (layer = toRenderLayerModelObject(this)->layer()) && layer->transform())
+    if (hasLayer() && (layer = downcast<RenderLayerModelObject>(*this).layer()) && layer->transform())
         transform.multiply(layer->currentTransform());
     
 #if ENABLE(3D_RENDERING)
     if (containerObject && containerObject->hasLayer() && containerObject->style().hasPerspective()) {
         // Perpsective on the container affects us, so we have to factor it in here.
         ASSERT(containerObject->hasLayer());
-        FloatPoint perspectiveOrigin = toRenderLayerModelObject(containerObject)->layer()->perspectiveOrigin();
+        FloatPoint perspectiveOrigin = downcast<RenderLayerModelObject>(*containerObject).layer()->perspectiveOrigin();
 
         TransformationMatrix perspectiveMatrix;
         perspectiveMatrix.applyPerspective(containerObject->style().perspective());
@@ -1858,15 +1858,15 @@ LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
 
 bool RenderObject::isRooted(RenderView** view) const
 {
-    const RenderObject* o = this;
-    while (o->parent())
-        o = o->parent();
+    const RenderObject* renderer = this;
+    while (renderer->parent())
+        renderer = renderer->parent();
 
-    if (!o->isRenderView())
+    if (!is<RenderView>(*renderer))
         return false;
 
     if (view)
-        *view = &const_cast<RenderView&>(toRenderView(*o));
+        *view = const_cast<RenderView*>(downcast<RenderView>(renderer));
 
     return true;
 }
@@ -1999,7 +1999,7 @@ void RenderObject::willBeDestroyed()
     // be moved into RenderBoxModelObject::destroy.
     if (hasLayer()) {
         setHasLayer(false);
-        toRenderLayerModelObject(this)->destroyLayer();
+        downcast<RenderLayerModelObject>(*this).destroyLayer();
     }
 
     clearLayoutRootIfNeeded();
@@ -2132,7 +2132,7 @@ void RenderObject::updateDragState(bool dragOn)
 
 bool RenderObject::isComposited() const
 {
-    return hasLayer() && toRenderLayerModelObject(this)->layer()->isComposited();
+    return hasLayer() && downcast<RenderLayerModelObject>(*this).layer()->isComposited();
 }
 
 bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter hitTestFilter)
@@ -2579,7 +2579,7 @@ bool RenderObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const
 RenderNamedFlowFragment* RenderObject::currentRenderNamedFlowFragment() const
 {
     RenderFlowThread* flowThread = flowThreadContainingBlock();
-    if (!flowThread || !flowThread->isRenderNamedFlowThread())
+    if (!is<RenderNamedFlowThread>(flowThread))
         return nullptr;
 
     // FIXME: Once regions are fully integrated with the compositing system we should uncomment this assert.
@@ -2587,7 +2587,7 @@ RenderNamedFlowFragment* RenderObject::currentRenderNamedFlowFragment() const
     // a layer without knowing the containing region in advance.
     // ASSERT(flowThread->currentRegion() && flowThread->currentRegion()->isRenderNamedFlowFragment());
 
-    return toRenderNamedFlowFragment(flowThread->currentRegion());
+    return downcast<RenderNamedFlowFragment>(flowThread->currentRegion());
 }
 
 RenderFlowThread* RenderObject::locateFlowThreadContainingBlock() const
index e29e492..d7d3198 100644 (file)
@@ -1122,10 +1122,6 @@ inline bool RenderObject::backgroundIsKnownToBeObscured()
     return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
 }
 
-// FIXME: Remove this macro and use SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT() instead.
-#define RENDER_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, RenderObject, renderer, is<ToValueTypeName>(*renderer), is<ToValueTypeName>(renderer))
-
 } // namespace WebCore
 
 #define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
index 86e8765..e824f1a 100644 (file)
@@ -58,8 +58,6 @@ private:
     Timer<RenderProgress> m_animationTimer;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderProgress, isProgress())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderProgress, isProgress())
index f02abc0..d2e08d4 100644 (file)
@@ -94,10 +94,10 @@ static RenderBlock* createAnonymousRubyInlineBlock(RenderObject& ruby)
 static RenderRubyRun* lastRubyRun(const RenderElement* ruby)
 {
     RenderObject* child = ruby->lastChild();
-    if (child && !child->isRubyRun())
+    if (child && !is<RenderRubyRun>(*child))
         child = child->previousSibling();
-    ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child == rubyBeforeBlock(ruby));
-    return child && child->isRubyRun() ? toRenderRubyRun(child) : 0;
+    ASSERT(!child || is<RenderRubyRun>(*child) || child->isBeforeContent() || child == rubyBeforeBlock(ruby));
+    return downcast<RenderRubyRun>(child);
 }
 
 static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
index 3e53929..3132998 100644 (file)
@@ -131,9 +131,7 @@ void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* bef
 RenderRubyRun* RenderRubyBase::rubyRun() const
 {
     ASSERT(parent());
-    ASSERT(parent()->isRubyRun());
-
-    return &toRenderRubyRun(*parent());
+    return downcast<RenderRubyRun>(parent());
 }
 
 ETextAlign RenderRubyBase::textAlignmentForLine(bool /* endsWithSoftBreak */) const
index 1524ad3..c5aa403 100644 (file)
@@ -163,15 +163,15 @@ RenderObject* RenderRubyRun::removeChild(RenderObject& child)
     if (!beingDestroyed() && !documentBeingDestroyed() && child.isRubyText()) {
         RenderRubyBase* base = rubyBase();
         RenderObject* rightNeighbour = nextSibling();
-        if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
+        if (base && is<RenderRubyRun>(rightNeighbour)) {
             // Ruby run without a base can happen only at the first run.
-            RenderRubyRun* rightRun = toRenderRubyRun(rightNeighbour);
-            if (rightRun->hasRubyBase()) {
-                RenderRubyBase* rightBase = rightRun->rubyBaseSafe();
+            RenderRubyRun& rightRun = downcast<RenderRubyRun>(*rightNeighbour);
+            if (rightRun.hasRubyBase()) {
+                RenderRubyBase* rightBase = rightRun.rubyBaseSafe();
                 // Collect all children in a single base, then swap the bases.
                 rightBase->mergeChildrenWithBase(base);
-                moveChildTo(rightRun, base);
-                rightRun->moveChildTo(this, rightBase);
+                moveChildTo(&rightRun, base);
+                rightRun.moveChildTo(this, rightBase);
                 // The now empty ruby base will be removed below.
                 ASSERT(!rubyBase()->firstChild());
             }
index fdf381f..d9dce4f 100644 (file)
@@ -77,8 +77,6 @@ private:
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderRubyRun, isRubyRun())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderRubyRun, isRubyRun())
index da8ac7a..86da225 100644 (file)
@@ -51,8 +51,6 @@ private:
     virtual void layout() override;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderSlider, isSlider())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSlider, isSlider())
index ab42d54..857de67 100644 (file)
@@ -438,8 +438,8 @@ LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
 
 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len, float xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
 {
-    if (style.hasTextCombine() && isCombineText()) {
-        const RenderCombineText& combineText = toRenderCombineText(*this);
+    if (style.hasTextCombine() && is<RenderCombineText>(*this)) {
+        const RenderCombineText& combineText = downcast<RenderCombineText>(*this);
         if (combineText.isCombined())
             return combineText.combinedTextWidth(f);
     }
index c59875a..cd63295 100644 (file)
@@ -1620,7 +1620,7 @@ double RenderThemeGtk::animationDurationForProgressBar(RenderProgress&) const
 IntRect RenderThemeGtk::calculateProgressRect(const RenderObject& renderObject, const IntRect& fullBarRect)
 {
     IntRect progressRect(fullBarRect);
-    const RenderProgress& renderProgress = toRenderProgress(renderObject);
+    const auto& renderProgress = downcast<RenderProgress>(renderObject);
     if (renderProgress.isDeterminate()) {
         int progressWidth = progressRect.width() * renderProgress.position();
         if (renderObject.style().direction() == RTL)
index a7dbe85..ed5165e 100644 (file)
@@ -849,7 +849,7 @@ double RenderThemeIOS::animationDurationForProgressBar(RenderProgress&) const
 
 bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!renderer.isProgress())
+    if (!is<RenderProgress>(renderer))
         return true;
 
     const int progressBarHeight = 9;
@@ -897,7 +897,7 @@ bool RenderThemeIOS::paintProgressBar(const RenderObject& renderer, const PaintI
 
     context->fillRect(FloatRect(rect.x(), verticalRenderingPosition, rect.width(), upperGradientHeight));
 
-    const RenderProgress& renderProgress = *toRenderProgress(&renderer);
+    const auto& renderProgress = downcast<RenderProgress>(renderer);
     if (renderProgress.isDeterminate()) {
         // 2) Draw the progress bar.
         double position = clampTo(renderProgress.position(), 0.0, 1.0);
index 67731b4..e785bed 100644 (file)
@@ -967,12 +967,12 @@ IntSize RenderThemeMac::meterSizeForBounds(const RenderMeter& renderMeter, const
 
 bool RenderThemeMac::paintMeter(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!renderObject.isMeter())
+    if (!is<RenderMeter>(renderObject))
         return true;
 
     LocalCurrentGraphicsContext localContext(paintInfo.context);
 
-    NSLevelIndicatorCell* cell = levelIndicatorFor(toRenderMeter(renderObject));
+    NSLevelIndicatorCell* cell = levelIndicatorFor(downcast<RenderMeter>(renderObject));
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
 
     [cell drawWithFrame:rect inView:documentViewFor(renderObject)];
@@ -1115,13 +1115,13 @@ void RenderThemeMac::adjustProgressBarStyle(StyleResolver&, RenderStyle&, Elemen
 
 bool RenderThemeMac::paintProgressBar(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!renderObject.isProgress())
+    if (!is<RenderProgress>(renderObject))
         return true;
 
     IntRect inflatedRect = progressBarRectForBounds(renderObject, rect);
     NSControlSize controlSize = controlSizeForFont(renderObject.style());
 
-    const RenderProgress& renderProgress = *toRenderProgress(&renderObject);
+    const auto& renderProgress = downcast<RenderProgress>(renderObject);
     HIThemeTrackDrawInfo trackInfo;
     trackInfo.version = 0;
     if (controlSize == NSRegularControlSize)
index f3dc5a5..8652213 100644 (file)
@@ -1216,10 +1216,10 @@ bool RenderThemeSafari::paintMeter(const RenderObject& renderObject, const Paint
 {
     // NOTE: This routine is for testing only. It should be fleshed out with a real CG-based implementation.
     // Right now it uses a slider, with the thumb positioned at the meter point.
-    if (!renderObject.isMeter())
+    if (!is<RenderMeter>(renderObject))
         return true;
 
-    HTMLMeterElement* element = toRenderMeter(renderObject).meterElement();
+    HTMLMeterElement* element = downcast<RenderMeter>(renderObject).meterElement();
 
     int remaining = static_cast<int>((1.0 - element->valueRatio()) * static_cast<double>(rect.size().width()));
 
index 40ce529..adb4632 100644 (file)
@@ -1175,10 +1175,10 @@ IntSize RenderThemeWin::meterSizeForBounds(const RenderMeter&, const IntRect& bo
 
 bool RenderThemeWin::paintMeter(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
-    if (!renderObject.isMeter())
+    if (!is<RenderMeter>(renderObject))
         return true;
 
-    HTMLMeterElement* element = toRenderMeter(renderObject).meterElement();
+    HTMLMeterElement* element = downcast<RenderMeter>(renderObject).meterElement();
 
     ThemeData theme = getThemeData(renderObject);
 
index 24f07a4..6898790 100644 (file)
@@ -652,8 +652,8 @@ static void writeRenderRegionList(const RenderRegionList& flowThreadRegionList,
 
         Element* generatingElement = renderRegion->generatingElement();
         if (generatingElement) {
-            bool isRenderNamedFlowFragment = renderRegion->isRenderNamedFlowFragment();
-            if (isRenderNamedFlowFragment && toRenderNamedFlowFragment(renderRegion)->hasCustomRegionStyle())
+            bool isRenderNamedFlowFragment = is<RenderNamedFlowFragment>(*renderRegion);
+            if (isRenderNamedFlowFragment && downcast<RenderNamedFlowFragment>(*renderRegion).hasCustomRegionStyle())
                 ts << " region style: 1";
             if (renderRegion->hasAutoLogicalHeight())
                 ts << " hasAutoLogicalHeight";
@@ -802,8 +802,8 @@ static void writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLaye
     
     // Altough the RenderFlowThread requires a layer, it is not collected by its parent,
     // so we have to treat it as a special case.
-    if (l->renderer().isRenderView())
-        writeRenderNamedFlowThreads(ts, toRenderView(l->renderer()), rootLayer, paintDirtyRect, indent, behavior);
+    if (is<RenderView>(l->renderer()))
+        writeRenderNamedFlowThreads(ts, downcast<RenderView>(l->renderer()), rootLayer, paintDirtyRect, indent, behavior);
 }
 
 static String nodePosition(Node* node)
index 54ae3f0..ea608ec 100644 (file)
@@ -90,8 +90,6 @@ private:
     LayoutSize m_cachedImageSize;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderVideo, isVideo())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderVideo, isVideo())
index 7642291..5160926 100644 (file)
@@ -66,11 +66,11 @@ struct SelectionIterator {
     
     void checkForSpanner()
     {
-        if (!m_current || !m_current->isRenderMultiColumnSpannerPlaceholder())
+        if (!is<RenderMultiColumnSpannerPlaceholder>(m_current))
             return;
-        RenderMultiColumnSpannerPlaceholder* placeholder = toRenderMultiColumnSpannerPlaceholder(m_current);
-        m_spannerStack.append(placeholder);
-        m_current = placeholder->spanner();
+        auto& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*m_current);
+        m_spannerStack.append(&placeholder);
+        m_current = placeholder.spanner();
     }
     
     RenderObject* current()
@@ -503,7 +503,7 @@ void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 
 static inline bool isComposited(RenderElement* object)
 {
-    return object->hasLayer() && toRenderLayerModelObject(object)->layer()->isComposited();
+    return object->hasLayer() && downcast<RenderLayerModelObject>(*object).layer()->isComposited();
 }
 
 static inline bool rendererObscuresBackground(RenderElement* rootObject)
index 83abe72..296ff56 100644 (file)
@@ -369,8 +369,6 @@ private:
 #endif
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView())
-
 // Stack-based class to assist with LayoutState push/pop
 class LayoutStateMaintainer {
     WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
index b27ae9a..a55578a 100644 (file)
@@ -104,8 +104,6 @@ private:
     IntRect m_clipRect; // The rectangle needs to remain correct after scrolling, so it is stored in content view coordinates, and not clipped to window.
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderWidget, isWidget())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderWidget, isWidget())
index b64c764..53f01c1 100644 (file)
@@ -594,8 +594,8 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
     if (m_autoWrap && !RenderStyle::autoWrap(m_lastWS) && m_ignoringSpaces)
         commitLineBreakAtCurrentWidth(renderText);
 
-    if (renderText.style().hasTextCombine() && m_current.renderer()->isCombineText() && !toRenderCombineText(*m_current.renderer()).isCombined()) {
-        RenderCombineText& combineRenderer = toRenderCombineText(*m_current.renderer());
+    if (renderText.style().hasTextCombine() && is<RenderCombineText>(*m_current.renderer()) && !downcast<RenderCombineText>(*m_current.renderer()).isCombined()) {
+        auto& combineRenderer = downcast<RenderCombineText>(*m_current.renderer());
         combineRenderer.combineText();
         // The length of the renderer's text may have changed. Increment stale iterator positions
         if (iteratorIsBeyondEndOfRenderCombineText(m_lineBreak, combineRenderer)) {
index c774a58..b6857b6 100644 (file)
@@ -67,9 +67,9 @@ void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo&
             }
         } else if (object.isFloating())
             m_block.positionNewFloatOnLine(m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
-        else if (object.isText() && object.style().hasTextCombine() && object.isCombineText() && !toRenderCombineText(object).isCombined()) {
-            toRenderCombineText(object).combineText();
-            if (toRenderCombineText(object).isCombined())
+        else if (is<RenderCombineText>(object) && object.style().hasTextCombine() && !downcast<RenderCombineText>(object).isCombined()) {
+            downcast<RenderCombineText>(object).combineText();
+            if (downcast<RenderCombineText>(object).isCombined())
                 continue;
         }
         resolver.increment();
index 148d3c2..a85217b 100644 (file)
@@ -2220,14 +2220,13 @@ bool Internals::isPluginUnavailabilityIndicatorObscured(Element* element, Except
         return false;
     }
 
-    auto renderer = element->renderer();
-    if (!renderer || !renderer->isEmbeddedObject()) {
+    auto* renderer = element->renderer();
+    if (!is<RenderEmbeddedObject>(renderer)) {
         ec = INVALID_ACCESS_ERR;
         return false;
     }
 
-    RenderEmbeddedObject* embed = toRenderEmbeddedObject(renderer);
-    return embed->isReplacementObscured();
+    return downcast<RenderEmbeddedObject>(*renderer).isReplacementObscured();
 }
     
 bool Internals::isPluginSnapshotted(Element* element, ExceptionCode& ec)
index e7fa116..eecc68e 100644 (file)
@@ -1,3 +1,22 @@
+2014-10-19  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137845
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses and 
+        clean up the surrounding code.
+
+        * Plugins/Hosted/WebHostedNetscapePluginView.mm:
+        (-[WebHostedNetscapePluginView pluginHostDied]):
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView _windowClipRect]):
+        (-[WebBaseNetscapePluginView actualVisibleRectInWindow]):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::createPlugin):
+        (WebFrameLoaderClient::createJavaAppletWidget):
+
 2014-10-17  Tim Horton  <timothy_horton@apple.com>
 
         Build fix for 32-bit Yosemite
index f24dfd2..396e61e 100644 (file)
@@ -430,10 +430,8 @@ extern "C" {
 
 - (void)pluginHostDied
 {
-    if (_element->renderer() && _element->renderer()->isEmbeddedObject()) {
-        RenderEmbeddedObject* renderer = toRenderEmbeddedObject(_element->renderer());
-        renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginCrashed);
-    }
+    if (is<RenderEmbeddedObject>(_element->renderer()))
+        downcast<RenderEmbeddedObject>(*_element->renderer()).setPluginUnavailabilityReason(RenderEmbeddedObject::PluginCrashed);
 
     _pluginLayer = nil;
     _proxy = 0;
index 998594f..b9144fb 100644 (file)
@@ -290,11 +290,11 @@ using namespace WebCore;
 
 - (NSRect)_windowClipRect
 {
-    RenderObject* renderer = _element->renderer();
+    auto* renderer = _element->renderer();
     if (!renderer)
         return NSZeroRect;
 
-    return toRenderWidget(renderer)->windowClipRect();
+    return downcast<RenderWidget>(*renderer).windowClipRect();
 }
 
 - (NSRect)visibleRect
@@ -874,13 +874,13 @@ using namespace WebCore;
 
 - (NSRect)actualVisibleRectInWindow
 {
-    RenderObject* renderer = _element->renderer();
+    auto* renderer = _element->renderer();
     if (!renderer)
         return NSZeroRect;
 
     IntRect widgetRect = renderer->pixelSnappedAbsoluteClippedOverflowRect();
     widgetRect = renderer->view().frameView().contentsToWindow(widgetRect);
-    return intersection(toRenderWidget(renderer)->windowClipRect(), widgetRect);
+    return intersection(downcast<RenderWidget>(*renderer).windowClipRect(), widgetRect);
 }
 
 - (CALayer *)pluginLayer
index c5f9e3a..2e43ef8 100644 (file)
@@ -1962,8 +1962,8 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
     if (pluginPackage) {
         if (WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
             errorCode = WebKitErrorBlockedPlugInVersion;
-            if (element->renderer()->isEmbeddedObject())
-                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
+            if (is<RenderEmbeddedObject>(*element->renderer()))
+                downcast<RenderEmbeddedObject>(*element->renderer()).setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
         } else {
             if ([pluginPackage isKindOfClass:[WebPluginPackage class]])
                 view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, attributeKeys, kit(paramValues), baseURL, kit(element), loadManually);
@@ -2067,8 +2067,8 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s
     if (pluginPackage) {
         if (WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
             errorCode = WebKitErrorBlockedPlugInVersion;
-            if (element->renderer()->isEmbeddedObject())
-                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
+            if (is<RenderEmbeddedObject>(*element->renderer()))
+                downcast<RenderEmbeddedObject>(*element->renderer()).setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
         } else {
 #if ENABLE(NETSCAPE_PLUGIN_API)
             if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
index 3fa09ef..2d10e27 100644 (file)
@@ -1,3 +1,18 @@
+2014-10-19  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137845
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for all remaining RenderObject subclasses and 
+        clean up the surrounding code.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::pluginProcessCrashed):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::createPlugin):
+
 2014-10-19  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Move GtkDragAndDropHelper from Platform to WebKit2
index 0208071..f3359b8 100644 (file)
@@ -1466,16 +1466,12 @@ void PluginView::pluginProcessCrashed()
 {
     m_pluginProcessHasCrashed = true;
 
-    if (!m_pluginElement->renderer())
-        return;
-
-    if (!m_pluginElement->renderer()->isEmbeddedObject())
+    if (!is<RenderEmbeddedObject>(m_pluginElement->renderer()))
         return;
 
     m_pluginElement->setNeedsStyleRecalc(SyntheticStyleChange);
 
-    RenderEmbeddedObject* renderer = toRenderEmbeddedObject(m_pluginElement->renderer());
-    renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginCrashed);
+    downcast<RenderEmbeddedObject>(*m_pluginElement->renderer()).setPluginUnavailabilityReason(RenderEmbeddedObject::PluginCrashed);
     
     Widget::invalidate();
 }
index 9659f0d..eff7d05 100644 (file)
@@ -654,11 +654,11 @@ PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* plu
 
     if (isBlockedPlugin) {
         bool replacementObscured = false;
-        if (pluginElement->renderer()->isEmbeddedObject()) {
-            RenderEmbeddedObject* renderObject = toRenderEmbeddedObject(pluginElement->renderer());
-            renderObject->setPluginUnavailabilityReasonWithDescription(RenderEmbeddedObject::InsecurePluginVersion, unavailabilityDescription);
-            replacementObscured = renderObject->isReplacementObscured();
-            renderObject->setUnavailablePluginIndicatorIsHidden(replacementObscured);
+        if (is<RenderEmbeddedObject>(*pluginElement->renderer())) {
+            auto& renderObject = downcast<RenderEmbeddedObject>(*pluginElement->renderer());
+            renderObject.setPluginUnavailabilityReasonWithDescription(RenderEmbeddedObject::InsecurePluginVersion, unavailabilityDescription);
+            replacementObscured = renderObject.isReplacementObscured();
+            renderObject.setUnavailablePluginIndicatorIsHidden(replacementObscured);
         }
 
         send(Messages::WebPageProxy::DidBlockInsecurePluginVersion(parameters.mimeType, parameters.url.string(), frameURLString, pageURLString, replacementObscured));