Commit 9dbf6d18 authored by jchaffraix@webkit.org's avatar jchaffraix@webkit.org

Reduce the use of RenderLayer outside of the rendering code

https://bugs.webkit.org/show_bug.cgi?id=83728

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/layers/scrollByLines-overflow-no-layer.html

This is mostly a layering violation change. This changes reduces the number of
RenderLayer use outside rendering/ by a third but there are still numerous uses.

While auditing the different uses of RenderLayer, I found a potential crasher
and fixed it which is why we have a test case.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::visiblePositionForPoint):
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
(WebCore::Document::handleZeroPadding):
(WebCore::nodeFromPoint):
(WebCore::Document::prepareMouseEvent):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::contains):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::eventMayStartDrag):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::hoverTimerFired):
(WebCore::EventHandler::handleDrag):
Updated these call sites to use RenderView::hitTest.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* page/FrameView.cpp:
(WebCore::FrameView::contentsInCompositedLayer):
(WebCore::FrameView::scrollContentsFastPath):
Updated these call sites to use RenderObject::isComposited().

* dom/Element.cpp:
(WebCore::Element::scrollByUnits):
Call directly RenderBox::scroll instead of calling the layer.
This actually fixes a crasher that slipped through the cracks.

* editing/visible_units.cpp:
* html/shadow/TextControlInnerElements.cpp:
* page/ContextMenuController.cpp:
* page/FocusController.cpp:
* page/Frame.cpp:
* page/GestureTapHighlighter.cpp:
* page/PrintContext.cpp:
* plugins/mac/PluginViewMac.mm:
Removed unneeded #include.

* plugins/gtk/PluginViewGtk.cpp:
* plugins/qt/PluginViewQt.cpp:
Replaced RenderLayer.h #include with RenderObject.h as
we use RenderObject::absoluteToLocal.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::isComposited):
* rendering/RenderObject.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::hitTest):
* rendering/RenderView.h:
Added 2 new functions that pipe through the RenderLayer.

LayoutTests:

The test checks that calling scrollByUnit without a RenderLayer doesn't crash.

* fast/layers/scrollByLines-overflow-no-layer.html: Added.
* fast/layers/scrollByLines-overflow-no-layer-expected.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113990 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 02b2c2a1
2012-04-12 Julien Chaffraix <jchaffraix@webkit.org>
Reduce the use of RenderLayer outside of the rendering code
https://bugs.webkit.org/show_bug.cgi?id=83728
Reviewed by Simon Fraser.
The test checks that calling scrollByUnit without a RenderLayer doesn't crash.
* fast/layers/scrollByLines-overflow-no-layer.html: Added.
* fast/layers/scrollByLines-overflow-no-layer-expected.txt: Added.
2012-04-12 Alexei Filippov <alexeif@chromium.org>
Web Inspector: Move meta node out of nodes in snapshot serialization.
bug 83728: Reduce the use of RenderLayer outside of the rendering code
This test passes if you see PASSED below.
PASSED: The test did not crash!
<!DOCTYPE>
<html>
<head>
<style>
#overflow {
height: 100px;
width: 100px;
overflow: hidden;
}
</style>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
function testScrollByLine()
{
var overflowDiv = document.getElementById("overflow");
overflowDiv.scrollByLines(10);
overflowDiv.scrollByPages(10);
overflowDiv.innerHTML = "PASSED: The test did not crash!";
}
window.addEventListener("load", testScrollByLine, false);
</script>
</head>
<body>
<div><a href="https://bugs.webkit.org/show_bug.cgi?id=83728">bug 83728</a>: Reduce the use of RenderLayer outside of the rendering code</div>
<div>This test passes if you see PASSED below.</div>
<div id="overflow">FAILED</div>
<body>
</html>
2012-04-12 Julien Chaffraix <jchaffraix@webkit.org>
Reduce the use of RenderLayer outside of the rendering code
https://bugs.webkit.org/show_bug.cgi?id=83728
Reviewed by Simon Fraser.
Test: fast/layers/scrollByLines-overflow-no-layer.html
This is mostly a layering violation change. This changes reduces the number of
RenderLayer use outside rendering/ by a third but there are still numerous uses.
While auditing the different uses of RenderLayer, I found a potential crasher
and fixed it which is why we have a test case.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::visiblePositionForPoint):
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
(WebCore::Document::handleZeroPadding):
(WebCore::nodeFromPoint):
(WebCore::Document::prepareMouseEvent):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::contains):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::eventMayStartDrag):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::hoverTimerFired):
(WebCore::EventHandler::handleDrag):
Updated these call sites to use RenderView::hitTest.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* page/FrameView.cpp:
(WebCore::FrameView::contentsInCompositedLayer):
(WebCore::FrameView::scrollContentsFastPath):
Updated these call sites to use RenderObject::isComposited().
* dom/Element.cpp:
(WebCore::Element::scrollByUnits):
Call directly RenderBox::scroll instead of calling the layer.
This actually fixes a crasher that slipped through the cracks.
* editing/visible_units.cpp:
* html/shadow/TextControlInnerElements.cpp:
* page/ContextMenuController.cpp:
* page/FocusController.cpp:
* page/Frame.cpp:
* page/GestureTapHighlighter.cpp:
* page/PrintContext.cpp:
* plugins/mac/PluginViewMac.mm:
Removed unneeded #include.
* plugins/gtk/PluginViewGtk.cpp:
* plugins/qt/PluginViewQt.cpp:
Replaced RenderLayer.h #include with RenderObject.h as
we use RenderObject::absoluteToLocal.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::isComposited):
* rendering/RenderObject.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::hitTest):
* rendering/RenderView.h:
Added 2 new functions that pipe through the RenderLayer.
2012-04-12 Pravinin D <pravind.2k4@gmail.com>
font-size:0 text runs has non zero width in case of Windows Safari.
......@@ -2712,7 +2712,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
HitTestRequest request(HitTestRequest::ReadOnly |
HitTestRequest::Active);
HitTestResult result(ourpoint);
renderView->layer()->hitTest(request, result);
renderView->hitTest(request, result);
innerNode = result.innerNode();
if (!innerNode)
return VisiblePosition();
......
......@@ -54,7 +54,6 @@
#include "Pair.h"
#include "Rect.h"
#include "RenderBox.h"
#include "RenderLayer.h"
#include "RenderStyle.h"
#include "RenderView.h"
#include "ShadowValue.h"
......@@ -672,11 +671,6 @@ static LayoutRect sizingBox(RenderObject* renderer)
return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
}
static inline bool hasCompositedLayer(RenderObject* renderer)
{
return renderer && renderer->hasLayer() && toRenderBoxModelObject(renderer)->layer()->isComposited();
}
static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
{
if (!renderer || style->transform().operations().isEmpty())
......@@ -1328,7 +1322,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
RenderObject* renderer = node->renderer();
RefPtr<RenderStyle> style;
if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
if (m_pseudoElementSpecifier) {
// FIXME: This cached pseudo style will only exist if the animation has been run at least once.
......
......@@ -123,8 +123,6 @@
#include "ProcessingInstruction.h"
#include "RegisteredEventListener.h"
#include "RenderArena.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "RenderNamedFlowThread.h"
#include "RenderTextControl.h"
#include "RenderView.h"
......@@ -1274,14 +1272,14 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned
enum ShadowContentFilterPolicy shadowContentFilterPolicy = allowShadowContent ? AllowShadowContent : DoNotAllowShadowContent;
HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding, shadowContentFilterPolicy);
renderView()->layer()->hitTest(request, result);
renderView()->hitTest(request, result);
return StaticHashSetNodeList::adopt(result.rectBasedTestResult());
}
PassRefPtr<NodeList> Document::handleZeroPadding(const HitTestRequest& request, HitTestResult& result) const
{
renderView()->layer()->hitTest(request, result);
renderView()->hitTest(request, result);
Node* node = result.innerNode();
if (!node)
......@@ -1309,7 +1307,7 @@ static Node* nodeFromPoint(Frame* frame, RenderView* renderView, int x, int y, L
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(point);
renderView->layer()->hitTest(request, result);
renderView->hitTest(request, result);
if (localPoint)
*localPoint = result.localPoint();
......@@ -2957,7 +2955,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r
return MouseEventWithHitTestResults(event, HitTestResult(LayoutPoint()));
HitTestResult result(documentPoint);
renderView()->layer()->hitTest(request, result);
renderView()->hitTest(request, result);
if (!request.readOnly())
updateStyleIfNeeded();
......
......@@ -282,7 +282,8 @@ void Element::scrollByUnits(int units, ScrollGranularity granularity)
direction = ScrollUp;
units = -units;
}
toRenderBox(renderer())->layer()->scroll(direction, granularity, units);
Node* stopNode = this;
toRenderBox(renderer())->scroll(direction, granularity, units, &stopNode);
}
void Element::scrollByLines(int lines)
......
......@@ -1477,7 +1477,7 @@ bool FrameSelection::contains(const LayoutPoint& point)
HitTestRequest request(HitTestRequest::ReadOnly |
HitTestRequest::Active);
HitTestResult result(point);
document->renderView()->layer()->hitTest(request, result);
document->renderView()->hitTest(request, result);
Node* innerNode = result.innerNode();
if (!innerNode || !innerNode->renderer())
return false;
......
......@@ -32,7 +32,6 @@
#include "InlineTextBox.h"
#include "Position.h"
#include "RenderBlock.h"
#include "RenderLayer.h"
#include "RenderObject.h"
#include "RenderedPosition.h"
#include "Text.h"
......
......@@ -37,7 +37,6 @@
#include "HTMLTextAreaElement.h"
#include "MouseEvent.h"
#include "Page.h"
#include "RenderLayer.h"
#include "RenderTextControlSingleLine.h"
#include "RenderView.h"
#include "ScriptController.h"
......
......@@ -59,7 +59,6 @@
#include "Node.h"
#include "Page.h"
#include "PlatformEvent.h"
#include "RenderLayer.h"
#include "RenderObject.h"
#include "ReplaceSelectionCommand.h"
#include "ResourceRequest.h"
......
......@@ -58,7 +58,6 @@
#include "PlatformKeyboardEvent.h"
#include "RenderFileUploadControl.h"
#include "RenderImage.h"
#include "RenderLayer.h"
#include "RenderView.h"
#include "ReplaceSelectionCommand.h"
#include "ResourceRequest.h"
......@@ -286,7 +285,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(point);
documentUnderMouse->renderView()->layer()->hitTest(request, result);
documentUnderMouse->renderView()->hitTest(request, result);
Node* n = result.innerNode();
while (n && !n->isElementNode())
......
......@@ -699,7 +699,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
if (m_selectionInitiationState != ExtendedSelection) {
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(m_mouseDownPos);
m_frame->document()->renderView()->layer()->hitTest(request, result);
m_frame->document()->renderView()->hitTest(request, result);
updateSelectionForMouseDrag(result);
}
......@@ -730,7 +730,7 @@ bool EventHandler::eventMayStartDrag(const PlatformMouseEvent& event) const
updateDragSourceActionsAllowed();
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestResult result(view->windowToContents(event.position()));
m_frame->contentRenderer()->layer()->hitTest(request, result);
m_frame->contentRenderer()->hitTest(request, result);
DragState state;
return result.innerNode() && page->dragController()->draggableNode(m_frame, result.innerNode(), roundedIntPoint(result.point()), state);
}
......@@ -743,15 +743,12 @@ void EventHandler::updateSelectionForMouseDrag()
RenderView* renderer = m_frame->contentRenderer();
if (!renderer)
return;
RenderLayer* layer = renderer->layer();
if (!layer)
return;
HitTestRequest request(HitTestRequest::ReadOnly |
HitTestRequest::Active |
HitTestRequest::Move);
HitTestResult result(view->windowToContents(m_currentMousePosition));
layer->hitTest(request, result);
renderer->hitTest(request, result);
updateSelectionForMouseDrag(result);
}
......@@ -1047,7 +1044,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
return result;
if (ignoreClipping)
hitType |= HitTestRequest::IgnoreClipping;
m_frame->contentRenderer()->layer()->hitTest(HitTestRequest(hitType), result);
m_frame->contentRenderer()->hitTest(HitTestRequest(hitType), result);
while (true) {
Node* n = result.innerNode();
......@@ -1064,7 +1061,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, bool
LayoutPoint widgetPoint(result.localPoint().x() + view->scrollX() - renderWidget->borderLeft() - renderWidget->paddingLeft(),
result.localPoint().y() + view->scrollY() - renderWidget->borderTop() - renderWidget->paddingTop());
HitTestResult widgetHitTestResult(widgetPoint, padding.height(), padding.width(), padding.height(), padding.width(), shadowContentFilterPolicy);
frame->contentRenderer()->layer()->hitTest(HitTestRequest(hitType), widgetHitTestResult);
frame->contentRenderer()->hitTest(HitTestRequest(hitType), widgetHitTestResult);
result = widgetHitTestResult;
if (testScrollbars == ShouldHitTestScrollbars) {
......@@ -2300,7 +2297,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestResult result(vPoint);
doc->renderView()->layer()->hitTest(request, result);
doc->renderView()->hitTest(request, result);
#if PLATFORM(MAC)
m_useLatchedWheelEventNode = e.momentumPhase() == PlatformWheelEventPhaseBegan || e.momentumPhase() == PlatformWheelEventPhaseChanged;
......@@ -2675,7 +2672,7 @@ void EventHandler::hoverTimerFired(Timer<EventHandler>*)
if (FrameView* view = m_frame->view()) {
HitTestRequest request(HitTestRequest::Move);
HitTestResult result(view->windowToContents(m_currentMousePosition));
renderer->layer()->hitTest(request, result);
renderer->hitTest(request, result);
m_frame->document()->updateStyleIfNeeded();
}
}
......@@ -3045,7 +3042,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event)
// try to find an element that wants to be dragged
HitTestRequest request(HitTestRequest::ReadOnly);
HitTestResult result(m_mouseDownPos);
m_frame->contentRenderer()->layer()->hitTest(request, result);
m_frame->contentRenderer()->hitTest(request, result);
Node* node = result.innerNode();
if (node && m_frame->page())
dragState().m_dragSrc = m_frame->page()->dragController()->draggableNode(m_frame, node, m_mouseDownPos, dragState());
......
......@@ -49,7 +49,6 @@
#include "KeyboardEvent.h"
#include "Page.h"
#include "Range.h"
#include "RenderLayer.h"
#include "RenderObject.h"
#include "RenderWidget.h"
#include "ScrollAnimator.h"
......
......@@ -68,7 +68,6 @@
#include "Page.h"
#include "PageGroup.h"
#include "RegularExpression.h"
#include "RenderLayer.h"
#include "RenderPart.h"
#include "RenderTableCell.h"
#include "RenderTextControl.h"
......
......@@ -1290,7 +1290,7 @@ bool FrameView::contentsInCompositedLayer() const
{
#if USE(ACCELERATED_COMPOSITING)
RenderView* root = rootRenderer(this);
if (root && root->layer()->isComposited()) {
if (root && root->isComposited()) {
GraphicsLayer* layer = root->layer()->backing()->graphicsLayer();
if (layer && layer->drawsContent())
return true;
......@@ -1469,7 +1469,7 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect
if (renderBox->style()->position() != FixedPosition)
continue;
#if USE(ACCELERATED_COMPOSITING)
if (renderBox->layer()->isComposited())
if (renderBox->isComposited())
continue;
#endif
IntRect updateRect = pixelSnappedIntRect(renderBox->layer()->repaintRectIncludingDescendants());
......
......@@ -39,7 +39,6 @@
#include "Page.h"
#include "RenderBoxModelObject.h"
#include "RenderInline.h"
#include "RenderLayer.h"
#include "RenderObject.h"
namespace WebCore {
......
......@@ -24,7 +24,6 @@
#include "GraphicsContext.h"
#include "Frame.h"
#include "FrameView.h"
#include "RenderLayer.h"
#include "RenderView.h"
#include <wtf/text/WTFString.h>
......
......@@ -56,7 +56,7 @@
#include "PluginDebug.h"
#include "PluginMainThreadScheduler.h"
#include "PluginPackage.h"
#include "RenderLayer.h"
#include "RenderObject.h"
#include "Settings.h"
#include "SpatialNavigation.h"
#include "JSDOMBinding.h"
......
......@@ -55,7 +55,6 @@
#include "PluginDebug.h"
#include "PluginPackage.h"
#include "PluginMainThreadScheduler.h"
#include "RenderLayer.h"
#include "ScriptController.h"
#include "Settings.h"
#include "npruntime_impl.h"
......
......@@ -63,7 +63,7 @@
#include "PluginPackage.h"
#include "PluginMainThreadScheduler.h"
#include "QWebPageClient.h"
#include "RenderLayer.h"
#include "RenderObject.h"
#include "Settings.h"
#include "npruntime_impl.h"
#if USE(JSC)
......
......@@ -2398,6 +2398,11 @@ void RenderObject::updateDragState(bool dragOn)
curr->updateDragState(dragOn);
}
bool RenderObject::isComposited() const
{
return hasLayer() && toRenderBoxModelObject(this)->layer()->isComposited();
}
bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter hitTestFilter)
{
bool inside = false;
......
......@@ -611,6 +611,8 @@ public:
void collectDashboardRegions(Vector<DashboardRegionValue>&);
#endif
bool isComposited() const;
bool hitTest(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
......
......@@ -77,6 +77,11 @@ RenderView::~RenderView()
{
}
bool RenderView::hitTest(const HitTestRequest& request, HitTestResult& result)
{
return layer()->hitTest(request, result);
}
void RenderView::computeLogicalHeight()
{
if (!printing() && m_frameView)
......
......@@ -42,6 +42,8 @@ public:
RenderView(Node*, FrameView*);
virtual ~RenderView();
bool hitTest(const HitTestRequest&, HitTestResult&);
virtual const char* renderName() const { return "RenderView"; }
virtual bool isRenderView() const { return true; }
......
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