Commit cfa6d61d authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-16 David Hyatt <hyatt@apple.com>

        Split continuation() into virtual and non-virtual versions so that the non-virtual version can
        be used whereever possible.  Eventually the virtual method can be eliminated completely.

        Reviewed by Sam Weinig and Oliver Hunt

        * html/HTMLAnchorElement.cpp:
        (WebCore::HTMLAnchorElement::isKeyboardFocusable):
        * page/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::anchorElement):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
        (WebCore::InlineFlowBox::paint):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::removeChild):
        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::updateBeforeAfterContentForContainer):
        * rendering/RenderFlow.h:
        (WebCore::RenderFlow::virtualContinuation):
        (WebCore::RenderFlow::continuation):
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::positionForCoordinates):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::absoluteRects):
        (WebCore::RenderObject::absoluteQuads):
        (WebCore::RenderObject::addFocusRingRects):
        (WebCore::RenderObject::repaintAfterLayoutIfNeeded):
        (WebCore::RenderObject::getAbsoluteRepaintRectWithOutline):
        (WebCore::RenderObject::handleDynamicFloatPositionChange):
        (WebCore::RenderObject::hoverAncestor):
        (WebCore::RenderObject::updateDragState):
        (WebCore::RenderObject::updateHitTestResult):
        (WebCore::RenderObject::getTextDecorationColors):
        (WebCore::RenderObject::adjustRectForOutlineAndShadow):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::virtualContinuation):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0327898f
2009-01-16 David Hyatt <hyatt@apple.com>
Split continuation() into virtual and non-virtual versions so that the non-virtual version can
be used whereever possible. Eventually the virtual method can be eliminated completely.
Reviewed by Sam Weinig and Oliver Hunt
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::isKeyboardFocusable):
* page/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::anchorElement):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
(WebCore::InlineFlowBox::paint):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::removeChild):
* rendering/RenderContainer.cpp:
(WebCore::RenderContainer::updateBeforeAfterContentForContainer):
* rendering/RenderFlow.h:
(WebCore::RenderFlow::virtualContinuation):
(WebCore::RenderFlow::continuation):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::positionForCoordinates):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::absoluteRects):
(WebCore::RenderObject::absoluteQuads):
(WebCore::RenderObject::addFocusRingRects):
(WebCore::RenderObject::repaintAfterLayoutIfNeeded):
(WebCore::RenderObject::getAbsoluteRepaintRectWithOutline):
(WebCore::RenderObject::handleDynamicFloatPositionChange):
(WebCore::RenderObject::hoverAncestor):
(WebCore::RenderObject::updateDragState):
(WebCore::RenderObject::updateHitTestResult):
(WebCore::RenderObject::getTextDecorationColors):
(WebCore::RenderObject::adjustRectForOutlineAndShadow):
* rendering/RenderObject.h:
(WebCore::RenderObject::virtualContinuation):
2009-01-16 David Hyatt <hyatt@apple.com>
Inline the methods of Font for obtaining metrics such as ascent, descent and line spacing.
......@@ -113,7 +113,7 @@ bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
// Before calling absoluteRects, check for the common case where the renderer
// or one of the continuations is non-empty, since this is a faster check and
// almost always returns true.
for (RenderObject* r = renderer(); r; r = r->continuation())
for (RenderObject* r = renderer(); r; r = r->virtualContinuation())
if (r->width() > 0 && r->height() > 0)
return true;
......
......@@ -459,8 +459,9 @@ Element* AccessibilityRenderObject::anchorElement() const
// Search up the render tree for a RenderObject with a DOM node. Defer to an earlier continuation, though.
for (currRenderer = m_renderer; currRenderer && !currRenderer->element(); currRenderer = currRenderer->parent()) {
if (currRenderer->continuation())
return cache->get(currRenderer->continuation())->anchorElement();
RenderFlow* continuation = currRenderer->virtualContinuation();
if (continuation)
return cache->get(continuation)->anchorElement();
}
// bail if none found
......
......@@ -249,11 +249,11 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, RenderObject* en
if (!flow->lastLineBox()->isConstructed()) {
if (ltr) {
if (!nextLineBox() &&
((lastLine && !object()->continuation()) || nextOnLineExists() || onEndChain(endObject)))
((lastLine && !flow->continuation()) || nextOnLineExists() || onEndChain(endObject)))
includeRightEdge = true;
} else {
if ((!prevLineBox() || prevLineBox()->isConstructed()) &&
((lastLine && !object()->continuation()) || prevOnLineExists() || onEndChain(endObject)))
((lastLine && !flow->continuation()) || prevOnLineExists() || onEndChain(endObject)))
includeLeftEdge = true;
}
}
......@@ -628,7 +628,7 @@ void InlineFlowBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
// Add ourselves to the paint info struct's list of inlines that need to paint their
// outlines.
if (object()->style()->visibility() == VISIBLE && object()->hasOutline() && !isRootInlineBox()) {
if ((object()->continuation() || object()->isInlineContinuation()) && !object()->hasLayer()) {
if ((flowObject()->continuation() || object()->isInlineContinuation()) && !object()->hasLayer()) {
// Add ourselves to the containing block of the entire continuation so that it can
// paint us atomically.
RenderBlock* block = object()->containingBlock()->containingBlock();
......
......@@ -372,7 +372,7 @@ void RenderBlock::removeChild(RenderObject *oldChild)
RenderObject* prev = oldChild->previousSibling();
RenderObject* next = oldChild->nextSibling();
bool canDeleteAnonymousBlocks = !documentBeingDestroyed() && !isInline() && !oldChild->isInline() &&
!oldChild->continuation() &&
!oldChild->virtualContinuation() &&
(!prev || (prev->isAnonymousBlock() && prev->childrenInline())) &&
(!next || (next->isAnonymousBlock() && next->childrenInline()));
if (canDeleteAnonymousBlocks && prev && next) {
......
......@@ -30,6 +30,7 @@
#include "Document.h"
#include "RenderCounter.h"
#include "RenderImageGeneratedContent.h"
#include "RenderInline.h"
#include "RenderLayer.h"
#include "RenderListItem.h"
#include "RenderTable.h"
......@@ -277,7 +278,7 @@ void RenderContainer::updateBeforeAfterContentForContainer(RenderStyle::PseudoId
// Similarly, if we're the beginning of a <q>, and there's an inline continuation for our object,
// then we don't generate the :after content.
if (newContentWanted && type == RenderStyle::AFTER && isRenderInline() && continuation())
if (newContentWanted && type == RenderStyle::AFTER && isRenderInline() && static_cast<RenderInline*>(this)->continuation())
newContentWanted = false;
// If we don't want generated content any longer, or if we have generated content, but it's no longer
......
......@@ -58,7 +58,8 @@ public:
virtual ~RenderFlow();
#endif
virtual RenderFlow* continuation() const { return m_continuation; }
virtual RenderFlow* virtualContinuation() const { return continuation(); }
RenderFlow* continuation() const { return m_continuation; }
void setContinuation(RenderFlow* c) { m_continuation = c; }
RenderFlow* continuationBefore(RenderObject* beforeChild);
......
......@@ -385,7 +385,7 @@ VisiblePosition RenderInline::positionForCoordinates(int x, int y)
RenderBlock* cb = containingBlock();
int parentBlockX = cb->xPos() + x;
int parentBlockY = cb->yPos() + y;
for (RenderObject* c = continuation(); c; c = c->continuation()) {
for (RenderFlow* c = continuation(); c; c = c->continuation()) {
RenderObject* contBlock = c;
if (c->isInline())
contBlock = c->containingBlock();
......
......@@ -242,11 +242,6 @@ bool RenderObject::canHaveChildren() const
return false;
}
RenderFlow* RenderObject::continuation() const
{
return 0;
}
bool RenderObject::isInlineContinuation() const
{
return false;
......@@ -1711,12 +1706,15 @@ void RenderObject::absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool to
// For blocks inside inlines, we go ahead and include margins so that we run right up to the
// inline boxes above and below us (thus getting merged with them to form a single irregular
// shape).
if (topLevel && continuation()) {
rects.append(IntRect(tx, ty - collapsedMarginTop(),
width(), height() + collapsedMarginTop() + collapsedMarginBottom()));
continuation()->absoluteRects(rects,
tx - xPos() + continuation()->containingBlock()->xPos(),
ty - yPos() + continuation()->containingBlock()->yPos(), topLevel);
if (topLevel) {
RenderFlow* continuation = virtualContinuation();
if (continuation) {
rects.append(IntRect(tx, ty - collapsedMarginTop(),
width(), height() + collapsedMarginTop() + collapsedMarginBottom()));
continuation->absoluteRects(rects,
tx - xPos() + continuation->containingBlock()->xPos(),
ty - yPos() + continuation->containingBlock()->yPos(), topLevel);
}
} else
rects.append(IntRect(tx, ty, width(), height() + borderTopExtra() + borderBottomExtra()));
}
......@@ -1760,11 +1758,14 @@ void RenderObject::absoluteQuads(Vector<FloatQuad>& quads, bool topLevel)
// For blocks inside inlines, we go ahead and include margins so that we run right up to the
// inline boxes above and below us (thus getting merged with them to form a single irregular
// shape).
if (topLevel && continuation()) {
FloatRect localRect(0, -collapsedMarginTop(),
width(), height() + collapsedMarginTop() + collapsedMarginBottom());
quads.append(localToAbsoluteQuad(localRect));
continuation()->absoluteQuads(quads, topLevel);
if (topLevel) {
RenderFlow* continuation = virtualContinuation();
if (continuation) {
FloatRect localRect(0, -collapsedMarginTop(),
width(), height() + collapsedMarginTop() + collapsedMarginBottom());
quads.append(localToAbsoluteQuad(localRect));
continuation->absoluteQuads(quads, topLevel);
}
} else
quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height() + borderTopExtra() + borderBottomExtra())));
}
......@@ -1805,11 +1806,12 @@ void RenderObject::addFocusRingRects(GraphicsContext* graphicsContext, int tx, i
// For blocks inside inlines, we go ahead and include margins so that we run right up to the
// inline boxes above and below us (thus getting merged with them to form a single irregular
// shape).
if (continuation()) {
RenderFlow* continuation = virtualContinuation();
if (continuation) {
graphicsContext->addFocusRingRect(IntRect(tx, ty - collapsedMarginTop(), width(), height() + collapsedMarginTop() + collapsedMarginBottom()));
continuation()->addFocusRingRects(graphicsContext,
tx - xPos() + continuation()->containingBlock()->xPos(),
ty - yPos() + continuation()->containingBlock()->yPos());
continuation->addFocusRingRects(graphicsContext,
tx - xPos() + continuation->containingBlock()->xPos(),
ty - yPos() + continuation->containingBlock()->yPos());
} else
graphicsContext->addFocusRingRect(IntRect(tx, ty, width(), height()));
}
......@@ -1958,7 +1960,8 @@ bool RenderObject::repaintAfterLayoutIfNeeded(const IntRect& oldBounds, const In
// We didn't move, but we did change size. Invalidate the delta, which will consist of possibly
// two rectangles (but typically only one).
RenderStyle* outlineStyle = !isInline() && continuation() ? continuation()->style() : style();
RenderFlow* continuation = virtualContinuation();
RenderStyle* outlineStyle = !isInline() && continuation ? continuation->style() : style();
int ow = outlineStyle->outlineSize();
ShadowData* boxShadow = style()->boxShadow();
int width = abs(newOutlineBox.width() - oldOutlineBox.width());
......@@ -2019,7 +2022,7 @@ IntRect RenderObject::getAbsoluteRepaintRectWithOutline(int ow)
IntRect r(absoluteClippedOverflowRect());
r.inflate(ow);
if (continuation() && !isInline())
if (virtualContinuation() && !isInline())
r.inflateY(collapsedMarginTop());
if (isInlineFlow()) {
......@@ -2178,7 +2181,7 @@ void RenderObject::handleDynamicFloatPositionChange()
RenderInline* parentInline = static_cast<RenderInline*>(parent());
RenderBlock* newBox = parentInline->createAnonymousBlock();
RenderFlow* oldContinuation = parent()->continuation();
RenderFlow* oldContinuation = parentInline->continuation();
parentInline->setContinuation(newBox);
RenderObject* beforeChild = nextSibling();
......@@ -2575,7 +2578,7 @@ RenderObject* RenderObject::container() const
// content (and perhaps XBL). That's why it uses the render tree and not the DOM tree.
RenderObject* RenderObject::hoverAncestor() const
{
return (!isInline() && continuation()) ? continuation() : parent();
return (!isInline() && virtualContinuation()) ? virtualContinuation() : parent();
}
bool RenderObject::isSelectionBorder() const
......@@ -2688,8 +2691,9 @@ void RenderObject::updateDragState(bool dragOn)
element()->setChanged();
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
curr->updateDragState(dragOn);
if (continuation())
continuation()->updateDragState(dragOn);
RenderFlow* continuation = virtualContinuation();
if (continuation)
continuation->updateDragState(dragOn);
}
bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const IntPoint& point, int tx, int ty, HitTestFilter hitTestFilter)
......@@ -2724,14 +2728,14 @@ void RenderObject::updateHitTestResult(HitTestResult& result, const IntPoint& po
IntPoint localPoint(point);
if (isRenderView())
node = document()->documentElement();
else if (!isInline() && continuation())
else if (!isInline() && virtualContinuation())
// We are in the margins of block elements that are part of a continuation. In
// this case we're actually still inside the enclosing inline element that was
// split. Go ahead and set our inner node accordingly.
node = continuation()->element();
node = virtualContinuation()->element();
if (node) {
if (node->renderer() && node->renderer()->continuation() && node->renderer() != this) {
if (node->renderer() && node->renderer()->virtualContinuation() && node->renderer() != this) {
// We're in the continuation of a split inline. Adjust our local point to be in the coordinate space
// of the principal renderer's containing block. This will end up being the innerNonSharedNode.
RenderObject* firstBlock = node->renderer()->containingBlock();
......@@ -2976,8 +2980,8 @@ void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co
}
}
curr = curr->parent();
if (curr && curr->isRenderBlock() && curr->continuation())
curr = curr->continuation();
if (curr && curr->isRenderBlock() && curr->virtualContinuation())
curr = curr->virtualContinuation();
} while (curr && decorations && (!quirksMode || !curr->element() ||
(!curr->element()->hasTagName(aTag) && !curr->element()->hasTagName(fontTag))));
......@@ -3160,7 +3164,7 @@ FloatQuad RenderObject::absoluteContentQuad() const
void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const
{
int outlineSize = !isInline() && continuation() ? continuation()->style()->outlineSize() : style()->outlineSize();
int outlineSize = !isInline() && virtualContinuation() ? virtualContinuation()->style()->outlineSize() : style()->outlineSize();
if (ShadowData* boxShadow = style()->boxShadow()) {
int shadowLeft = 0;
int shadowRight = 0;
......
......@@ -301,7 +301,7 @@ public:
virtual bool childrenInline() const { return false; }
virtual void setChildrenInline(bool) { }
virtual RenderFlow* continuation() const;
virtual RenderFlow* virtualContinuation() const { return 0; }
#if ENABLE(SVG)
virtual bool isSVGRoot() const { return false; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment