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

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

        Move layer() into RenderBox and make it non-virtual.  Move all of the scrolling functions from RenderObject
        to RenderBox and devirtualize as many as possible.  Clean up styleWillChange to factor code specific to
        RenderBox and RenderBlock into their appropriate subclasses.  Stubbed out an empty styleWillChange on
        RenderText, since none of the work done in styleWillChange was relevant to text nodes.

        Reviewed by Sam Weinig

        * dom/Document.cpp:
        (WebCore::Document::elementFromPoint):
        (WebCore::Document::renderView):
        (WebCore::Document::prepareMouseEvent):
        * dom/Document.h:
        * dom/Element.cpp:
        (WebCore::Element::scrollByUnits):
        * editing/SelectionController.cpp:
        (WebCore::SelectionController::contains):
        * html/HTMLMarqueeElement.cpp:
        (WebCore::HTMLMarqueeElement::start):
        (WebCore::HTMLMarqueeElement::stop):
        * page/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::topRenderer):
        (WebCore::AccessibilityRenderObject::visiblePositionForPoint):
        (WebCore::AccessibilityRenderObject::doAccessibilityHitTest):
        * page/AccessibilityRenderObject.h:
        * page/EventHandler.cpp:
        (WebCore::scrollAndAcceptEvent):
        (WebCore::EventHandler::handleMousePressEvent):
        (WebCore::EventHandler::handleMouseDraggedEvent):
        (WebCore::EventHandler::updateSelectionForMouseDrag):
        (WebCore::EventHandler::autoscrollTimerFired):
        (WebCore::EventHandler::updateAutoscrollRenderer):
        (WebCore::EventHandler::stopAutoscrollTimer):
        (WebCore::EventHandler::scrollOverflow):
        (WebCore::EventHandler::handleWheelEvent):
        (WebCore::EventHandler::hoverTimerFired):
        * page/Frame.cpp:
        (WebCore::Frame::clearTimers):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::styleWillChange):
        * rendering/RenderBlock.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::styleWillChange):
        (WebCore::RenderBox::verticalScrollbarWidth):
        (WebCore::RenderBox::horizontalScrollbarHeight):
        (WebCore::RenderBox::scroll):
        (WebCore::RenderBox::canBeProgramaticallyScrolled):
        (WebCore::RenderBox::autoscroll):
        (WebCore::RenderBox::panScroll):
        (WebCore::RenderBox::offsetFromContainer):
        (WebCore::RenderBox::computeAbsoluteRepaintRect):
        * rendering/RenderBox.h:
        (WebCore::RenderBox::layer):
        (WebCore::RenderBox::requiresLayer):
        (WebCore::RenderBox::stopAutoscroll):
        (WebCore::RenderBox::hasAutoVerticalScrollbar):
        (WebCore::RenderBox::hasAutoHorizontalScrollbar):
        (WebCore::RenderBox::scrollsOverflow):
        (WebCore::RenderBox::scrollsOverflowX):
        (WebCore::RenderBox::scrollsOverflowY):
        (WebCore::RenderBox::includeVerticalScrollbarSize):
        (WebCore::RenderBox::includeHorizontalScrollbarSize):
        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::absoluteClippedOverflowRect):
        (WebCore::RenderFlow::addFocusRingRects):
        * rendering/RenderForeignObject.cpp:
        * rendering/RenderForeignObject.h:
        (WebCore::RenderForeignObject::requiresLayer):
        * rendering/RenderInline.cpp:
        * rendering/RenderInline.h:
        (WebCore::RenderInline::requiresLayer):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::childrenClipRect):
        (WebCore::RenderLayer::selfClipRect):
        * rendering/RenderListBox.cpp:
        * rendering/RenderListBox.h:
        * rendering/RenderObject.cpp:
        (WebCore::addLayers):
        (WebCore::RenderObject::removeLayers):
        (WebCore::RenderObject::moveLayers):
        (WebCore::RenderObject::findNextLayer):
        (WebCore::RenderObject::enclosingLayer):
        (WebCore::RenderObject::setNeedsLayout):
        (WebCore::RenderObject::setNeedsPositionedMovementLayout):
        (WebCore::RenderObject::computeAbsoluteRepaintRect):
        (WebCore::RenderObject::styleWillChange):
        (WebCore::RenderObject::localToAbsolute):
        (WebCore::RenderObject::absoluteToLocal):
        (WebCore::RenderObject::localToAbsoluteQuad):
        (WebCore::RenderObject::offsetFromContainer):
        (WebCore::RenderObject::destroy):
        * rendering/RenderObject.h:
        * rendering/RenderPath.cpp:
        * rendering/RenderPath.h:
        (WebCore::RenderPath::requiresLayer):
        * rendering/RenderReplica.h:
        (WebCore::RenderReplica::requiresLayer):
        * rendering/RenderSVGContainer.cpp:
        * rendering/RenderSVGContainer.h:
        (WebCore::RenderSVGContainer::requiresLayer):
        * rendering/RenderSVGHiddenContainer.cpp:
        * rendering/RenderSVGHiddenContainer.h:
        (WebCore::RenderSVGHiddenContainer::requiresLayer):
        * rendering/RenderSVGImage.cpp:
        * rendering/RenderSVGImage.h:
        (WebCore::RenderSVGImage::requiresLayer):
        * rendering/RenderSVGInline.h:
        (WebCore::RenderSVGInline::requiresLayer):
        * rendering/RenderSVGInlineText.h:
        (WebCore::RenderSVGInlineText::requiresLayer):
        * rendering/RenderSVGText.cpp:
        * rendering/RenderSVGText.h:
        (WebCore::RenderSVGText::requiresLayer):
        * rendering/RenderScrollbarPart.h:
        (WebCore::RenderScrollbarPart::requiresLayer):
        * rendering/RenderSlider.cpp:
        (WebCore::RenderSlider::setCurrentPosition):
        * rendering/RenderTableCell.cpp:
        * rendering/RenderTableCell.h:
        (WebCore::RenderTableCell::requiresLayer):
        * rendering/RenderTableCol.h:
        (WebCore::RenderTableCol::requiresLayer):
        * rendering/RenderTableRow.h:
        (WebCore::RenderTableRow::requiresLayer):
        * rendering/RenderTableSection.cpp:
        (WebCore::RenderTableSection::layoutRows):
        * rendering/RenderText.h:
        (WebCore::RenderText::styleWillChange):
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::autoscroll):
        (WebCore::RenderTextControl::scroll):
        * rendering/RenderTextControl.h:
        * rendering/RenderTreeAsText.cpp:
        (WebCore::write):
        (WebCore::externalRepresentation):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 23b2fec3
2009-01-23 David Hyatt <hyatt@apple.com>
Move layer() into RenderBox and make it non-virtual. Move all of the scrolling functions from RenderObject
to RenderBox and devirtualize as many as possible. Clean up styleWillChange to factor code specific to
RenderBox and RenderBlock into their appropriate subclasses. Stubbed out an empty styleWillChange on
RenderText, since none of the work done in styleWillChange was relevant to text nodes.
Reviewed by Sam Weinig
* dom/Document.cpp:
(WebCore::Document::elementFromPoint):
(WebCore::Document::renderView):
(WebCore::Document::prepareMouseEvent):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::scrollByUnits):
* editing/SelectionController.cpp:
(WebCore::SelectionController::contains):
* html/HTMLMarqueeElement.cpp:
(WebCore::HTMLMarqueeElement::start):
(WebCore::HTMLMarqueeElement::stop):
* page/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::topRenderer):
(WebCore::AccessibilityRenderObject::visiblePositionForPoint):
(WebCore::AccessibilityRenderObject::doAccessibilityHitTest):
* page/AccessibilityRenderObject.h:
* page/EventHandler.cpp:
(WebCore::scrollAndAcceptEvent):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::autoscrollTimerFired):
(WebCore::EventHandler::updateAutoscrollRenderer):
(WebCore::EventHandler::stopAutoscrollTimer):
(WebCore::EventHandler::scrollOverflow):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::hoverTimerFired):
* page/Frame.cpp:
(WebCore::Frame::clearTimers):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleWillChange):
* rendering/RenderBlock.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleWillChange):
(WebCore::RenderBox::verticalScrollbarWidth):
(WebCore::RenderBox::horizontalScrollbarHeight):
(WebCore::RenderBox::scroll):
(WebCore::RenderBox::canBeProgramaticallyScrolled):
(WebCore::RenderBox::autoscroll):
(WebCore::RenderBox::panScroll):
(WebCore::RenderBox::offsetFromContainer):
(WebCore::RenderBox::computeAbsoluteRepaintRect):
* rendering/RenderBox.h:
(WebCore::RenderBox::layer):
(WebCore::RenderBox::requiresLayer):
(WebCore::RenderBox::stopAutoscroll):
(WebCore::RenderBox::hasAutoVerticalScrollbar):
(WebCore::RenderBox::hasAutoHorizontalScrollbar):
(WebCore::RenderBox::scrollsOverflow):
(WebCore::RenderBox::scrollsOverflowX):
(WebCore::RenderBox::scrollsOverflowY):
(WebCore::RenderBox::includeVerticalScrollbarSize):
(WebCore::RenderBox::includeHorizontalScrollbarSize):
* rendering/RenderFlow.cpp:
(WebCore::RenderFlow::absoluteClippedOverflowRect):
(WebCore::RenderFlow::addFocusRingRects):
* rendering/RenderForeignObject.cpp:
* rendering/RenderForeignObject.h:
(WebCore::RenderForeignObject::requiresLayer):
* rendering/RenderInline.cpp:
* rendering/RenderInline.h:
(WebCore::RenderInline::requiresLayer):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::childrenClipRect):
(WebCore::RenderLayer::selfClipRect):
* rendering/RenderListBox.cpp:
* rendering/RenderListBox.h:
* rendering/RenderObject.cpp:
(WebCore::addLayers):
(WebCore::RenderObject::removeLayers):
(WebCore::RenderObject::moveLayers):
(WebCore::RenderObject::findNextLayer):
(WebCore::RenderObject::enclosingLayer):
(WebCore::RenderObject::setNeedsLayout):
(WebCore::RenderObject::setNeedsPositionedMovementLayout):
(WebCore::RenderObject::computeAbsoluteRepaintRect):
(WebCore::RenderObject::styleWillChange):
(WebCore::RenderObject::localToAbsolute):
(WebCore::RenderObject::absoluteToLocal):
(WebCore::RenderObject::localToAbsoluteQuad):
(WebCore::RenderObject::offsetFromContainer):
(WebCore::RenderObject::destroy):
* rendering/RenderObject.h:
* rendering/RenderPath.cpp:
* rendering/RenderPath.h:
(WebCore::RenderPath::requiresLayer):
* rendering/RenderReplica.h:
(WebCore::RenderReplica::requiresLayer):
* rendering/RenderSVGContainer.cpp:
* rendering/RenderSVGContainer.h:
(WebCore::RenderSVGContainer::requiresLayer):
* rendering/RenderSVGHiddenContainer.cpp:
* rendering/RenderSVGHiddenContainer.h:
(WebCore::RenderSVGHiddenContainer::requiresLayer):
* rendering/RenderSVGImage.cpp:
* rendering/RenderSVGImage.h:
(WebCore::RenderSVGImage::requiresLayer):
* rendering/RenderSVGInline.h:
(WebCore::RenderSVGInline::requiresLayer):
* rendering/RenderSVGInlineText.h:
(WebCore::RenderSVGInlineText::requiresLayer):
* rendering/RenderSVGText.cpp:
* rendering/RenderSVGText.h:
(WebCore::RenderSVGText::requiresLayer):
* rendering/RenderScrollbarPart.h:
(WebCore::RenderScrollbarPart::requiresLayer):
* rendering/RenderSlider.cpp:
(WebCore::RenderSlider::setCurrentPosition):
* rendering/RenderTableCell.cpp:
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::requiresLayer):
* rendering/RenderTableCol.h:
(WebCore::RenderTableCol::requiresLayer):
* rendering/RenderTableRow.h:
(WebCore::RenderTableRow::requiresLayer):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::layoutRows):
* rendering/RenderText.h:
(WebCore::RenderText::styleWillChange):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::autoscroll):
(WebCore::RenderTextControl::scroll):
* rendering/RenderTextControl.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::write):
(WebCore::externalRepresentation):
2009-01-23 Anders Carlsson <andersca@apple.com>
Fix tyop.
......@@ -900,7 +900,7 @@ Element* Document::elementFromPoint(int x, int y) const
HitTestRequest request(true, true);
HitTestResult result(IntPoint(x, y));
renderer()->layer()->hitTest(request, result);
renderView()->layer()->hitTest(request, result);
Node* n = result.innerNode();
while (n && !n->isElementNode())
......@@ -1356,6 +1356,11 @@ void Document::removeAllDisconnectedNodeEventListeners()
m_disconnectedNodesWithEventListeners.clear();
}
RenderView* Document::renderView() const
{
return static_cast<RenderView*>(renderer());
}
void Document::clearAXObjectCache()
{
// clear cache in top document
......@@ -1995,7 +2000,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r
return MouseEventWithHitTestResults(event, HitTestResult(IntPoint()));
HitTestResult result(documentPoint);
renderer()->layer()->hitTest(request, result);
renderView()->layer()->hitTest(request, result);
if (!request.readonly)
updateRendering();
......
......@@ -96,6 +96,7 @@ namespace WebCore {
class Range;
class RegisteredEventListener;
class RenderArena;
class RenderView;
class SecurityOrigin;
class Settings;
class StyleSheet;
......@@ -411,6 +412,8 @@ public:
RenderArena* renderArena() { return m_renderArena; }
RenderView* renderView() const;
void clearAXObjectCache();
AXObjectCache* axObjectCache() const;
......
......@@ -217,7 +217,7 @@ void Element::scrollByUnits(int units, ScrollGranularity granularity)
direction = ScrollUp;
units = -units;
}
rend->layer()->scroll(direction, granularity, units);
RenderBox::toRenderBox(rend)->layer()->scroll(direction, granularity, units);
}
}
}
......
......@@ -996,7 +996,7 @@ bool SelectionController::contains(const IntPoint& point)
HitTestRequest request(true, true);
HitTestResult result(point);
document->renderer()->layer()->hitTest(request, result);
document->renderView()->layer()->hitTest(request, result);
Node* innerNode = result.innerNode();
if (!innerNode || !innerNode->renderer())
return false;
......
......@@ -109,14 +109,14 @@ void HTMLMarqueeElement::parseMappedAttribute(MappedAttribute *attr)
void HTMLMarqueeElement::start()
{
if (renderer() && renderer()->hasLayer() && renderer()->layer()->marquee())
renderer()->layer()->marquee()->start();
if (renderer() && renderer()->hasLayer() && renderBox()->layer()->marquee())
renderBox()->layer()->marquee()->start();
}
void HTMLMarqueeElement::stop()
{
if (renderer() && renderer()->hasLayer() && renderer()->layer()->marquee())
renderer()->layer()->marquee()->stop();
if (renderer() && renderer()->hasLayer() && renderBox()->layer()->marquee())
renderBox()->layer()->marquee()->stop();
}
} // namespace WebCore
......@@ -1438,9 +1438,9 @@ bool AccessibilityRenderObject::isEnabled() const
return m_renderer->element() ? m_renderer->element()->isEnabled() : true;
}
RenderObject* AccessibilityRenderObject::topRenderer() const
RenderView* AccessibilityRenderObject::topRenderer() const
{
return m_renderer->document()->topDocument()->renderer();
return m_renderer->document()->topDocument()->renderView();
}
Document* AccessibilityRenderObject::document() const
......@@ -1702,7 +1702,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
{
// convert absolute point to view coordinates
FrameView* frameView = m_renderer->document()->topDocument()->renderer()->view()->frameView();
RenderObject* renderer = topRenderer();
RenderView* renderView = topRenderer();
Node* innerNode = 0;
// locate the node containing the point
......@@ -1716,7 +1716,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
#endif
HitTestRequest request(true, true);
HitTestResult result(ourpoint);
renderer->layer()->hitTest(request, result);
renderView->layer()->hitTest(request, result);
innerNode = result.innerNode();
if (!innerNode || !innerNode->renderer())
return VisiblePosition();
......@@ -1724,7 +1724,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
pointResult = result.localPoint();
// done if hit something other than a widget
renderer = innerNode->renderer();
RenderObject* renderer = innerNode->renderer();
if (!renderer->isWidget())
break;
......@@ -1738,7 +1738,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
Document* document = frame->document();
if (!document)
break;
renderer = document->renderer();
renderView = document->renderView();
frameView = static_cast<FrameView*>(widget);
}
......@@ -1869,13 +1869,11 @@ IntRect AccessibilityRenderObject::doAXBoundsForRange(const PlainTextRange& rang
AccessibilityObject* AccessibilityRenderObject::doAccessibilityHitTest(const IntPoint& point) const
{
if (!m_renderer)
return 0;
RenderLayer* layer = m_renderer->layer();
if (!layer)
if (!m_renderer || !m_renderer->hasLayer())
return 0;
RenderLayer* layer = RenderBox::toRenderBox(m_renderer)->layer();
HitTestRequest request(true, true);
HitTestResult hitTestResult = HitTestResult(point);
layer->hitTest(request, hitTestResult);
......
......@@ -50,6 +50,7 @@ class Node;
class RenderObject;
class RenderListBox;
class RenderTextControl;
class RenderView;
class Selection;
class String;
class Widget;
......@@ -147,7 +148,7 @@ public:
void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
RenderObject* renderer() const { return m_renderer; }
RenderObject* topRenderer() const;
RenderView* topRenderer() const;
RenderTextControl* textControl() const;
Document* document() const;
FrameView* topDocumentFrameView() const;
......
......@@ -100,17 +100,17 @@ static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
static inline void scrollAndAcceptEvent(float delta, ScrollDirection positiveDirection, ScrollDirection negativeDirection, PlatformWheelEvent& e, Node* node)
{
if (!delta)
if (!delta || !node->renderBox())
return;
if (e.granularity() == ScrollByPageWheelEvent) {
if (node->renderer()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPage, 1))
if (node->renderBox()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPage, 1))
e.accept();
return;
}
float pixelsToScroll = delta > 0 ? delta : -delta;
if (e.granularity() == ScrollByLineWheelEvent)
pixelsToScroll *= cMouseWheelPixelsPerLineStep;
if (node->renderer()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPixel, pixelsToScroll))
if (node->renderBox()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPixel, pixelsToScroll))
e.accept();
}
......@@ -376,8 +376,8 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
swallowEvent = handleMousePressEventSingleClick(event);
}
m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect ||
(m_mousePressNode && m_mousePressNode->renderer() && m_mousePressNode->renderer()->canBeProgramaticallyScrolled(true));
m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect ||
(m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNode->renderBox()->canBeProgramaticallyScrolled(true));
return swallowEvent;
}
......@@ -404,7 +404,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
// If the selection is contained in a layer that can scroll, that layer should handle the autoscroll
// Otherwise, let the bridge handle it so the view can scroll itself.
RenderObject* renderer = targetNode->renderer();
while (renderer && !renderer->canBeProgramaticallyScrolled(false)) {
while (renderer && (!renderer->isBox() || !RenderBox::toRenderBox(renderer)->canBeProgramaticallyScrolled(false))) {
if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document()->ownerElement())
renderer = renderer->document()->ownerElement()->renderer();
else
......@@ -451,7 +451,7 @@ void EventHandler::updateSelectionForMouseDrag()
FrameView* view = m_frame->view();
if (!view)
return;
RenderObject* renderer = m_frame->contentRenderer();
RenderView* renderer = m_frame->contentRenderer();
if (!renderer)
return;
RenderLayer* layer = renderer->layer();
......@@ -594,7 +594,7 @@ void EventHandler::handleAutoscroll(RenderObject* renderer)
void EventHandler::autoscrollTimerFired(Timer<EventHandler>*)
{
RenderObject* r = autoscrollRenderer();
if (!r) {
if (!r || !r->isBox()) {
stopAutoscrollTimer();
return;
}
......@@ -604,7 +604,7 @@ void EventHandler::autoscrollTimerFired(Timer<EventHandler>*)
stopAutoscrollTimer();
return;
}
r->autoscroll();
RenderBox::toRenderBox(r)->autoscroll();
} else {
// we verify that the main frame hasn't received the order to stop the panScroll
if (!m_frame->page()->mainFrame()->eventHandler()->panScrollInProgress()) {
......@@ -665,7 +665,7 @@ void EventHandler::updateAutoscrollRenderer()
if (Node* nodeAtPoint = hitTest.innerNode())
m_autoscrollRenderer = nodeAtPoint->renderer();
while (m_autoscrollRenderer && !m_autoscrollRenderer->canBeProgramaticallyScrolled(false))
while (m_autoscrollRenderer && (!m_autoscrollRenderer->isBox() || !RenderBox::toRenderBox(m_autoscrollRenderer)->canBeProgramaticallyScrolled(false)))
m_autoscrollRenderer = m_autoscrollRenderer->parent();
}
......@@ -747,7 +747,7 @@ void EventHandler::stopAutoscrollTimer(bool rendererIsBeingDestroyed)
if (autoscrollRenderer()) {
if (!rendererIsBeingDestroyed && (m_autoscrollInProgress || m_panScrollInProgress))
autoscrollRenderer()->stopAutoscroll();
RenderBox::toRenderBox(autoscrollRenderer())->stopAutoscroll();
#if ENABLE(PAN_SCROLLING)
if (m_panScrollInProgress) {
m_frame->view()->removePanScrollIcon();
......@@ -787,9 +787,9 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
node = m_mousePressNode.get();
if (node) {
RenderObject *r = node->renderer();
if (r && !r->isListBox())
return r->scroll(direction, granularity);
RenderObject* r = node->renderer();
if (r && r->isBox() && !r->isListBox())
return RenderBox::toRenderBox(r)->scroll(direction, granularity);
}
return false;
......@@ -1587,7 +1587,7 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
HitTestRequest request(true, false);
HitTestResult result(vPoint);
doc->renderer()->layer()->hitTest(request, result);
doc->renderView()->layer()->hitTest(request, result);
Node* node = result.innerNode();
if (node) {
......@@ -1705,7 +1705,7 @@ void EventHandler::hoverTimerFired(Timer<EventHandler>*)
ASSERT(m_frame);
ASSERT(m_frame->document());
if (RenderObject* renderer = m_frame->contentRenderer()) {
if (RenderView* renderer = m_frame->contentRenderer()) {
HitTestResult result(m_frame->view()->windowToContents(m_currentMousePosition));
renderer->layer()->hitTest(HitTestRequest(false, false, true), result);
m_frame->document()->updateRendering();
......
......@@ -1401,7 +1401,7 @@ void Frame::clearTimers(FrameView *view, Document *document)
view->unscheduleRelayout();
if (view->frame()) {
if (document && document->renderer() && document->renderer()->hasLayer())
document->renderer()->layer()->suspendMarquees();
document->renderView()->layer()->suspendMarquees();
view->frame()->animation()->suspendAnimations(document);
view->frame()->eventHandler()->stopAutoscrollTimer();
}
......
......@@ -152,6 +152,29 @@ RenderBlock::~RenderBlock()
void RenderBlock::styleWillChange(RenderStyle::Diff diff, const RenderStyle* newStyle)
{
setReplaced(newStyle->isDisplayReplacedType());
if (style() && parent() && diff == RenderStyle::Layout && style()->position() != newStyle->position()) {
if (newStyle->position() == StaticPosition)
// Clear our positioned objects list. Our absolutely positioned descendants will be
// inserted into our containing block's positioned objects list during layout.
removePositionedObjects(0);
else if (style()->position() == StaticPosition) {
// Remove our absolutely positioned descendants from their current containing block.
// They will be inserted into our positioned objects list during layout.
RenderObject* cb = parent();
while (cb && (cb->style()->position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isRenderView()) {
if (cb->style()->position() == RelativePosition && cb->isInline() && !cb->isReplaced()) {
cb = cb->containingBlock();
break;
}
cb = cb->parent();
}
if (cb->isRenderBlock())
static_cast<RenderBlock*>(cb)->removePositionedObjects(this);
}
}
RenderFlow::styleWillChange(diff, newStyle);
}
......
......@@ -114,7 +114,7 @@ public:
void layoutPositionedObjects(bool relayoutChildren);
void insertPositionedObject(RenderBox*);
void removePositionedObject(RenderBox*);
virtual void removePositionedObjects(RenderBlock*);
void removePositionedObjects(RenderBlock*);
void addPercentHeightDescendant(RenderBox*);
static void removePercentHeightDescendant(RenderBox*);
......
......@@ -104,6 +104,65 @@ void RenderBox::styleWillChange(RenderStyle::Diff diff, const RenderStyle* newSt
s_wasFloating = isFloating();
s_hadOverflowClip = hasOverflowClip();
if (style()) {
// If our z-index changes value or our visibility changes,
// we need to dirty our stacking context's z-order list.
if (newStyle) {
if (hasLayer() && (style()->hasAutoZIndex() != newStyle->hasAutoZIndex() ||
style()->zIndex() != newStyle->zIndex() ||
style()->visibility() != newStyle->visibility())) {
layer()->dirtyStackingContextZOrderLists();
if (style()->hasAutoZIndex() != newStyle->hasAutoZIndex() || style()->visibility() != newStyle->visibility())
layer()->dirtyZOrderLists();
}
}
// The background of the root element or the body element could propagate up to
// the canvas. Just dirty the entire canvas when our style changes substantially.
if (diff >= RenderStyle::Repaint && element() &&
(element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
view()->repaint();
else if (parent() && !isText()) {
// Do a repaint with the old style first, e.g., for example if we go from
// having an outline to not having an outline.
if (diff == RenderStyle::RepaintLayer) {
layer()->repaintIncludingDescendants();
if (!(style()->clip() == newStyle->clip()))
layer()->clearClipRectsIncludingDescendants();
} else if (diff == RenderStyle::Repaint || newStyle->outlineSize() < style()->outlineSize())
repaint();
}
if (diff == RenderStyle::Layout) {
// When a layout hint happens, we go ahead and do a repaint of the layer, since the layer could
// end up being destroyed.
if (hasLayer()) {
if (style()->position() != newStyle->position() ||
style()->zIndex() != newStyle->zIndex() ||
style()->hasAutoZIndex() != newStyle->hasAutoZIndex() ||
!(style()->clip() == newStyle->clip()) ||
style()->hasClip() != newStyle->hasClip() ||
style()->opacity() != newStyle->opacity() ||
style()->transform() != newStyle->transform())
layer()->repaintIncludingDescendants();
} else if (newStyle->hasTransform() || newStyle->opacity() < 1) {
// If we don't have a layer yet, but we are going to get one because of transform or opacity,
// then we need to repaint the old position of the object.
repaint();
}
// When a layout hint happens and an object's position style changes, we have to do a layout
// to dirty the render tree using the old position value now.
if (parent() && style()->position() != newStyle->position()) {
markContainingBlocksForLayout();
if (style()->position() == StaticPosition)
repaint();
if (isFloating() && !isPositioned() && (newStyle->position() == AbsolutePosition || newStyle->position() == FixedPosition))
removeFromObjectLists();
}
}
}
RenderObject::styleWillChange(diff, newStyle);
}
......@@ -510,6 +569,44 @@ IntRect RenderBox::reflectedRect(const IntRect& r) const
return result;
}
int RenderBox::verticalScrollbarWidth() const
{
return includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0;
}
int RenderBox::horizontalScrollbarHeight() const
{
return includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0;
}
bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
{
RenderLayer* l = layer();
if (l && l->scroll(direction, granularity, multiplier))
return true;
RenderBlock* b = containingBlock();
if (b && !b->isRenderView())
return b->scroll(direction, granularity, multiplier);
return false;
}
bool RenderBox::canBeProgramaticallyScrolled(bool) const
{
return (hasOverflowClip() && (scrollsOverflow() || (node() && node()->isContentEditable()))) || (node() && node()->isDocumentNode());
}
void RenderBox::autoscroll()
{
if (layer())
layer()->autoscroll();
}
void RenderBox::panScroll(const IntPoint& source)
{
if (layer())
layer()->panScrollFromPoint(source);
}
int RenderBox::minPrefWidth() const
{
if (prefWidthsDirty())
......@@ -1372,7 +1469,7 @@ IntSize RenderBox::offsetFromContainer(RenderObject* o) const
}
if (o->hasOverflowClip())
offset -= o->layer()->scrolledContentOffset();
offset -= RenderBox::toRenderBox(o)->layer()->scrolledContentOffset();
if (style()->position() == AbsolutePosition)
offset += offsetForPositionedInContainer(o);
......@@ -1519,13 +1616,15 @@ void RenderBox::computeAbsoluteRepaintRect(IntRect& rect, bool fixed)
// FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout,
// its controlClipRect will be wrong. For overflow clip we use the values cached by the layer.
if (o->hasOverflowClip()) {
RenderBox* containerBox = RenderBox::toRenderBox(o);
// o->height() is inaccurate if we're in the middle of a layout of |o|, so use the
// layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
// anyway if its size does change.
topLeft -= o->layer()->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
topLeft -= containerBox->layer()->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
IntRect repaintRect(topLeft, rect.size());
IntRect boxRect(0, 0, o->layer()->width(), o->layer()->height());
IntRect boxRect(0, 0, containerBox->layer()->width(), containerBox->layer()->height());
rect = intersection(repaintRect, boxRect);
if (rect.isEmpty())
return;
......
......@@ -24,6 +24,7 @@
#define RenderBox_h
#include "RenderObject.h"