Diff
Modified: trunk/Source/WebCore/ChangeLog (158610 => 158611)
--- trunk/Source/WebCore/ChangeLog 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/ChangeLog 2013-11-05 00:12:56 UTC (rev 158611)
@@ -1,3 +1,26 @@
+2013-11-04 Andreas Kling <[email protected]>
+
+ Use RenderAncestorIterator in a couple of places.
+ <https://webkit.org/b/123725>
+
+ Take the ancestorsOfType<RenderMoo>() thingy out for a spin.
+
+ Found a bunch of parent chain walking loops that were really just
+ looking for the first ancestor renderer of a certain type.
+ They were a perfect fit for this pattern:
+
+ if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(renderer).first())
+ svgRoot->shakeMoneyMaker();
+
+ Quite a bit clearer than the previous:
+
+ for (auto ancestor = renderer.parent(); ancestor; ancestor = ancestor->parent()) {
+ if (ancestor->isSVGRoot())
+ toRenderSVGRoot(ancestor)->makeMoneyShaker();
+ }
+
+ Reviewed by Antti Koivisto.
+
2013-10-25 Jer Noble <[email protected]>
[MSE] Add a SourceBufferPrivateClient interface for platform -> html communication.
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (158610 => 158611)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2013-11-05 00:12:56 UTC (rev 158611)
@@ -71,6 +71,7 @@
#include "RenderHTMLCanvas.h"
#include "RenderImage.h"
#include "RenderInline.h"
+#include "RenderIterator.h"
#include "RenderLayer.h"
#include "RenderLineBreak.h"
#include "RenderListBox.h"
@@ -79,6 +80,7 @@
#include "RenderMathMLFraction.h"
#include "RenderMathMLOperator.h"
#include "RenderMenuList.h"
+#include "RenderSVGRoot.h"
#include "RenderSVGShape.h"
#include "RenderText.h"
#include "RenderTextControl.h"
@@ -640,10 +642,8 @@
// Math operators create RenderText nodes on the fly that are not tied into the DOM in a reasonable way,
// so rangeOfContents does not work for them (nor does regular text selection).
if (m_renderer->isText() && isMathElement()) {
- for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) {
- if (parent->isRenderMathMLBlock() && toRenderMathMLBlock(parent)->isRenderMathMLOperator())
- return toRenderText(m_renderer)->text();
- }
+ if (ancestorsOfType<RenderMathMLOperator>(*m_renderer).first())
+ return toRenderText(*m_renderer).text();
}
#endif
@@ -873,12 +873,9 @@
Path path = toRenderSVGShape(m_renderer)->path();
// The SVG path is in terms of the parent's bounding box. The path needs to be offset to frame coordinates.
- for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) {
- if (parent->isSVGRoot()) {
- LayoutPoint parentOffset = axObjectCache()->getOrCreate(parent)->elementRect().location();
- path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
- break;
- }
+ if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) {
+ LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
+ path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
}
return path;
@@ -1169,10 +1166,8 @@
return accessibilityIgnoreAttachment();
// ignore popup menu items because AppKit does
- for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) {
- if (parent->isBoxModelObject() && toRenderBoxModelObject(parent)->isMenuList())
- return true;
- }
+ if (ancestorsOfType<RenderMenuList>(*m_renderer).first())
+ return true;
// find out if this element is inside of a label element.
// if so, it may be ignored because it's the label for a checkbox or radio button
Modified: trunk/Source/WebCore/rendering/RenderMenuList.h (158610 => 158611)
--- trunk/Source/WebCore/rendering/RenderMenuList.h 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/rendering/RenderMenuList.h 2013-11-05 00:12:56 UTC (rev 158611)
@@ -149,6 +149,7 @@
bool m_popupIsVisible;
};
+template<> inline bool isRendererOfType<const RenderMenuList>(const RenderObject& renderer) { return renderer.isMenuList(); }
RENDER_OBJECT_TYPE_CASTS(RenderMenuList, isMenuList())
}
Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.h (158610 => 158611)
--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.h 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.h 2013-11-05 00:12:56 UTC (rev 158611)
@@ -138,6 +138,7 @@
Timer<RenderNamedFlowThread> m_regionOversetChangeEventTimer;
};
+template<> inline bool isRendererOfType<const RenderNamedFlowThread>(const RenderObject& renderer) { return renderer.isRenderNamedFlowThread(); }
RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowThread, isRenderNamedFlowThread())
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (158610 => 158611)
--- trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-11-05 00:12:56 UTC (rev 158611)
@@ -38,6 +38,7 @@
#include "PaintInfo.h"
#include "Range.h"
#include "RenderBoxRegionInfo.h"
+#include "RenderIterator.h"
#include "RenderLayer.h"
#include "RenderNamedFlowThread.h"
#include "RenderView.h"
@@ -393,18 +394,19 @@
// By now the flow thread should already be added to the rendering tree,
// so we go up the rendering parents and check that this region is not part of the same
// flow that it actually needs to display. It would create a circular reference.
- RenderObject* parentObject = parent();
- m_parentNamedFlowThread = 0;
- for ( ; parentObject; parentObject = parentObject->parent()) {
- if (parentObject->isRenderNamedFlowThread()) {
- m_parentNamedFlowThread = toRenderNamedFlowThread(parentObject);
- // Do not take into account a region that links a flow with itself. The dependency
- // cannot change, so it is not worth adding it to the list.
- if (m_flowThread == m_parentNamedFlowThread)
- m_flowThread = 0;
- break;
- }
+
+ auto closestFlowThreadAncestor = ancestorsOfType<RenderNamedFlowThread>(*this).first();
+ if (!closestFlowThreadAncestor) {
+ m_parentNamedFlowThread = nullptr;
+ return;
}
+
+ m_parentNamedFlowThread = &*closestFlowThreadAncestor;
+
+ // Do not take into account a region that links a flow with itself. The dependency
+ // cannot change, so it is not worth adding it to the list.
+ if (m_flowThread == m_parentNamedFlowThread)
+ m_flowThread = nullptr;
}
void RenderRegion::attachRegion()
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (158610 => 158611)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h 2013-11-05 00:12:56 UTC (rev 158611)
@@ -112,6 +112,8 @@
// This will catch anyone doing an unnecessary cast.
void toRenderMathMLOperator(const RenderMathMLOperator*);
+template<> inline bool isRendererOfType<const RenderMathMLOperator>(const RenderObject& renderer) { return renderer.isRenderMathMLBlock() && toRenderMathMLBlock(&renderer)->isRenderMathMLOperator(); }
+
inline UChar convertHyphenMinusToMinusSign(UChar glyph)
{
// When rendered as a mathematical operator, minus glyph should be larger.
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h (158610 => 158611)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h 2013-11-05 00:09:03 UTC (rev 158610)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h 2013-11-05 00:12:56 UTC (rev 158611)
@@ -122,6 +122,7 @@
bool m_hasSVGShadow : 1;
};
+template<> inline bool isRendererOfType<const RenderSVGRoot>(const RenderObject& renderer) { return renderer.isSVGRoot(); }
RENDER_OBJECT_TYPE_CASTS(RenderSVGRoot, isSVGRoot())
} // namespace WebCore