Diff
Modified: trunk/Source/WebCore/ChangeLog (158496 => 158497)
--- trunk/Source/WebCore/ChangeLog 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/ChangeLog 2013-11-02 21:18:19 UTC (rev 158497)
@@ -1,3 +1,14 @@
+2013-11-02 Andreas Kling <akl...@apple.com>
+
+ Use RenderChildIterator in a couple of places.
+ <https://webkit.org/b/123684>
+
+ Added isRendererOfType() for RenderBox and RenderBlock and switch
+ some loops over to using childrenOfType<>. Also sprinkled const
+ and references on touched code.
+
+ Reviewed by Antti Koivisto.
+
2013-11-02 Zan Dobersek <zdober...@igalia.com>
Manage FileReaderLoader through std::unique_ptr
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-11-02 21:18:19 UTC (rev 158497)
@@ -50,6 +50,7 @@
#include "RenderDeprecatedFlexibleBox.h"
#include "RenderFlexibleBox.h"
#include "RenderInline.h"
+#include "RenderIterator.h"
#include "RenderLayer.h"
#include "RenderMarquee.h"
#include "RenderNamedFlowThread.h"
@@ -1386,12 +1387,10 @@
setNeedsLayout();
return;
}
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->isRenderBlock())
- continue;
- RenderBlock* childBlock = toRenderBlock(child);
+
+ auto blockChildren = childrenOfType<RenderBlock>(*this);
+ for (auto childBlock = blockChildren.begin(), end = blockChildren.end(); childBlock != end; ++childBlock)
childBlock->markShapeInsideDescendantsForLayout();
- }
}
ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2013-11-02 21:18:19 UTC (rev 158497)
@@ -715,6 +715,7 @@
static bool s_canPropagateFloatIntoSibling;
};
+template<> inline bool isRendererOfType<const RenderBlock>(const RenderObject& renderer) { return renderer.isRenderBlock(); }
RENDER_OBJECT_TYPE_CASTS(RenderBlock, isRenderBlock())
LayoutUnit blockDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2013-11-02 21:18:19 UTC (rev 158497)
@@ -45,6 +45,7 @@
#include "RenderFlowThread.h"
#include "RenderGeometryMap.h"
#include "RenderInline.h"
+#include "RenderIterator.h"
#include "RenderLayer.h"
#include "RenderRegion.h"
#include "RenderTableCell.h"
@@ -1280,10 +1281,10 @@
return backgroundRect.contains(localRect);
}
-static bool isCandidateForOpaquenessTest(RenderBox* childBox)
+static bool isCandidateForOpaquenessTest(const RenderBox& childBox)
{
- const RenderStyle& childStyle = childBox->style();
- if (childStyle.position() != StaticPosition && childBox->containingBlock() != childBox->parent())
+ const RenderStyle& childStyle = childBox.style();
+ if (childStyle.position() != StaticPosition && childBox.containingBlock() != childBox.parent())
return false;
if (childStyle.visibility() != VISIBLE)
return false;
@@ -1291,9 +1292,9 @@
if (childStyle.shapeOutside())
return false;
#endif
- if (!childBox->width() || !childBox->height())
+ if (!childBox.width() || !childBox.height())
return false;
- if (RenderLayer* childLayer = childBox->layer()) {
+ if (RenderLayer* childLayer = childBox.layer()) {
#if USE(ACCELERATED_COMPOSITING)
if (childLayer->isComposited())
return false;
@@ -1311,28 +1312,27 @@
{
if (!maxDepthToTest)
return false;
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->isBox())
- continue;
- RenderBox* childBox = toRenderBox(child);
+ auto boxChildren = childrenOfType<RenderBox>(*this);
+ for (auto child = boxChildren.begin(), end = boxChildren.end(); child != end; ++child) {
+ const RenderBox& childBox = *child;
if (!isCandidateForOpaquenessTest(childBox))
continue;
- LayoutPoint childLocation = childBox->location();
- if (childBox->isRelPositioned())
- childLocation.move(childBox->relativePositionOffset());
+ LayoutPoint childLocation = childBox.location();
+ if (childBox.isRelPositioned())
+ childLocation.move(childBox.relativePositionOffset());
LayoutRect childLocalRect = localRect;
childLocalRect.moveBy(-childLocation);
if (childLocalRect.y() < 0 || childLocalRect.x() < 0) {
// If there is unobscured area above/left of a static positioned box then the rect is probably not covered.
- if (childBox->style().position() == StaticPosition)
+ if (childBox.style().position() == StaticPosition)
return false;
continue;
}
- if (childLocalRect.maxY() > childBox->height() || childLocalRect.maxX() > childBox->width())
+ if (childLocalRect.maxY() > childBox.height() || childLocalRect.maxX() > childBox.width())
continue;
- if (childBox->backgroundIsKnownToBeOpaqueInRect(childLocalRect))
+ if (childBox.backgroundIsKnownToBeOpaqueInRect(childLocalRect))
return true;
- if (childBox->foregroundIsKnownToBeOpaqueInRect(childLocalRect, maxDepthToTest - 1))
+ if (childBox.foregroundIsKnownToBeOpaqueInRect(childLocalRect, maxDepthToTest - 1))
return true;
}
return false;
Modified: trunk/Source/WebCore/rendering/RenderBox.h (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderBox.h 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2013-11-02 21:18:19 UTC (rev 158497)
@@ -712,6 +712,7 @@
static bool s_hadOverflowClip;
};
+template<> inline bool isRendererOfType<const RenderBox>(const RenderObject& renderer) { return renderer.isBox(); }
RENDER_OBJECT_TYPE_CASTS(RenderBox, isBox())
inline RenderBox* RenderBox::previousSiblingBox() const
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2013-11-02 21:18:19 UTC (rev 158497)
@@ -671,10 +671,9 @@
info.phase = paintPhase;
info.updateSubtreePaintRootForChildren(this);
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->isBox())
- continue;
- RenderBox& box = toRenderBox(*child);
+ auto boxChildren = childrenOfType<RenderBox>(*this);
+ for (auto child = boxChildren.begin(), end = boxChildren.end(); child != end; ++child) {
+ RenderBox& box = *child;
if (!box.hasSelfPaintingLayer() && (box.isTableSection() || box.isTableCaption())) {
LayoutPoint childPoint = flipForWritingModeForChild(&box, paintOffset);
box.paint(info, childPoint);
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (158496 => 158497)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2013-11-02 21:18:19 UTC (rev 158497)
@@ -37,6 +37,7 @@
#include "ImageQualityController.h"
#include "Page.h"
#include "RenderGeometryMap.h"
+#include "RenderIterator.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "RenderNamedFlowThread.h"
@@ -303,10 +304,10 @@
bool relayoutChildren = !shouldUsePrintingLayout() && (width() != viewWidth() || height() != viewHeight());
if (relayoutChildren) {
setChildNeedsLayout(MarkOnlyThis);
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->isBox())
- continue;
- RenderBox& box = toRenderBox(*child);
+
+ auto boxChildren = childrenOfType<RenderBox>(*this);
+ for (auto child = boxChildren.begin(), end = boxChildren.end(); child != end; ++child) {
+ RenderBox& box = *child;
if (box.hasRelativeLogicalHeight()
|| box.hasViewportPercentageLogicalHeight()
|| box.style().logicalHeight().isPercent()
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp (158496 => 158497)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2013-11-02 21:03:05 UTC (rev 158496)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp 2013-11-02 21:18:19 UTC (rev 158497)
@@ -32,6 +32,7 @@
#include "GraphicsContext.h"
#include "PaintInfo.h"
+#include "RenderIterator.h"
#include "RenderMathMLRow.h"
using namespace std;
@@ -185,11 +186,9 @@
void RenderMathMLRoot::layout()
{
- for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->isBox())
- continue;
- toRenderBox(child)->layoutIfNeeded();
- }
+ auto boxChildren = childrenOfType<RenderBox>(*this);
+ for (auto box = boxChildren.begin(), end = boxChildren.end(); box != end; ++box)
+ box->layoutIfNeeded();
int baseHeight = firstChild() && firstChild()->isBox() ? roundToInt(toRenderBox(firstChild())->logicalHeight()) : style().fontSize();
int frontWidth = lroundf(gFrontWidthEms * style().fontSize());