De-virtualize containingBlock() and make RenderView return 0 instead
of itself to make the construction of normal loops that terminate via
a null-check possible.
Fix the only two places in the tree that needed null checks.
Eliminating RenderTableCell::containingBlock() is fine since the base class
does the same thing anyway.
Reviewed by Simon Fraser.
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::lineDirectionPointForBlockDirectionNavigation):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::containingBlock):
* rendering/RenderObject.h:
* rendering/RenderTableCell.cpp:
* rendering/RenderTableCell.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):
* rendering/RenderView.cpp:
* rendering/RenderView.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95573
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-20 David Hyatt <hyatt@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=68480
+
+ De-virtualize containingBlock() and make RenderView return 0 instead
+ of itself to make the construction of normal loops that terminate via
+ a null-check possible.
+
+ Fix the only two places in the tree that needed null checks.
+
+ Eliminating RenderTableCell::containingBlock() is fine since the base class
+ does the same thing anyway.
+
+ Reviewed by Simon Fraser.
+
+ * editing/VisiblePosition.cpp:
+ (WebCore::VisiblePosition::lineDirectionPointForBlockDirectionNavigation):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::containingBlock):
+ * rendering/RenderObject.h:
+ * rendering/RenderTableCell.cpp:
+ * rendering/RenderTableCell.h:
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::RenderTreeAsText::writeRenderObject):
+ * rendering/RenderView.cpp:
+ * rendering/RenderView.h:
+
2011-09-20 Anders Carlsson <andersca@apple.com>
Remove ScrollView::platformContentsSize
// without consulting transforms, so that 'up' in transformed text is 'up'
// relative to the text, not absolute 'up'.
FloatPoint caretPoint = renderer->localToAbsolute(localRect.location());
- return renderer->containingBlock()->isHorizontalWritingMode() ? caretPoint.x() : caretPoint.y();
+ RenderObject* containingBlock = renderer->containingBlock();
+ if (!containingBlock)
+ containingBlock = renderer; // Just use ourselves to determine the writing mode if we have no containing block.
+ return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPoint.y();
}
#ifndef NDEBUG
RenderBlock* RenderObject::containingBlock() const
{
- ASSERT(!isTableCell());
- ASSERT(!isRenderView());
-
RenderObject* o = parent();
if (!isText() && m_style->position() == FixedPosition) {
while (o && !o->isRenderView() && !(o->hasTransform() && o->isRenderBlock()))
void setStyleInternal(PassRefPtr<RenderStyle>);
// returns the containing block level element for this element.
- virtual RenderBlock* containingBlock() const;
+ RenderBlock* containingBlock() const;
// Convert the given local point to absolute coordinates
// FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
setHasBoxDecorations(true);
}
-RenderBlock* RenderTableCell::containingBlock() const
-{
- if (parent() && section())
- return table();
- return 0;
-}
-
// The following rules apply for resolving conflicts and figuring out which border
// to use.
// (1) Borders with the 'border-style' of 'hidden' take precedence over all other conflicting
virtual bool isTableCell() const { return true; }
- virtual RenderBlock* containingBlock() const;
-
virtual void willBeDestroyed();
virtual void computeLogicalWidth();
}
}
- bool adjustForTableCells = o.containingBlock()->isTableCell();
+ RenderBlock* cb = o.containingBlock();
+ bool adjustForTableCells = cb ? cb->isTableCell() : false;
IntRect r;
if (o.isText()) {
return true;
}
-RenderBlock* RenderView::containingBlock() const
-{
- return const_cast<RenderView*>(this);
-}
-
void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
{
if (!shouldRepaint(ur))
private:
bool shouldRepaint(const IntRect& r) const;
-
- virtual RenderBlock* containingBlock() const;
// These functions may only be accessed by LayoutStateMaintainer.
void pushLayoutState(RenderFlowThread*);