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
+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.
--- /dev/null
+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!
--- /dev/null
+<!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.
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();
#include "Pair.h"
#include "Rect.h"
#include "RenderBox.h"
-#include "RenderLayer.h"
#include "RenderStyle.h"
#include "RenderView.h"
#include "ShadowValue.h"
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())
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.
#include "ProcessingInstruction.h"
#include "RegisteredEventListener.h"
#include "RenderArena.h"
-#include "RenderLayer.h"
-#include "RenderLayerBacking.h"
#include "RenderNamedFlowThread.h"
#include "RenderTextControl.h"
#include "RenderView.h"
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)
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
HitTestResult result(point);
- renderView->layer()->hitTest(request, result);
+ renderView->hitTest(request, result);
if (localPoint)
*localPoint = result.localPoint();
return MouseEventWithHitTestResults(event, HitTestResult(LayoutPoint()));
HitTestResult result(documentPoint);
- renderView()->layer()->hitTest(request, result);
+ renderView()->hitTest(request, result);
if (!request.readOnly())
updateStyleIfNeeded();
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)
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;
#include "InlineTextBox.h"
#include "Position.h"
#include "RenderBlock.h"
-#include "RenderLayer.h"
#include "RenderObject.h"
#include "RenderedPosition.h"
#include "Text.h"
#include "HTMLTextAreaElement.h"
#include "MouseEvent.h"
#include "Page.h"
-#include "RenderLayer.h"
#include "RenderTextControlSingleLine.h"
#include "RenderView.h"
#include "ScriptController.h"
#include "Node.h"
#include "Page.h"
#include "PlatformEvent.h"
-#include "RenderLayer.h"
#include "RenderObject.h"
#include "ReplaceSelectionCommand.h"
#include "ResourceRequest.h"
#include "PlatformKeyboardEvent.h"
#include "RenderFileUploadControl.h"
#include "RenderImage.h"
-#include "RenderLayer.h"
#include "RenderView.h"
#include "ReplaceSelectionCommand.h"
#include "ResourceRequest.h"
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())
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);
}
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);
}
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);
}
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();
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) {
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;
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();
}
}
// 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());
#include "KeyboardEvent.h"
#include "Page.h"
#include "Range.h"
-#include "RenderLayer.h"
#include "RenderObject.h"
#include "RenderWidget.h"
#include "ScrollAnimator.h"
#include "Page.h"
#include "PageGroup.h"
#include "RegularExpression.h"
-#include "RenderLayer.h"
#include "RenderPart.h"
#include "RenderTableCell.h"
#include "RenderTextControl.h"
{
#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;
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());
#include "Page.h"
#include "RenderBoxModelObject.h"
#include "RenderInline.h"
-#include "RenderLayer.h"
#include "RenderObject.h"
namespace WebCore {
#include "GraphicsContext.h"
#include "Frame.h"
#include "FrameView.h"
-#include "RenderLayer.h"
#include "RenderView.h"
#include <wtf/text/WTFString.h>
#include "PluginDebug.h"
#include "PluginMainThreadScheduler.h"
#include "PluginPackage.h"
-#include "RenderLayer.h"
+#include "RenderObject.h"
#include "Settings.h"
#include "SpatialNavigation.h"
#include "JSDOMBinding.h"
#include "PluginDebug.h"
#include "PluginPackage.h"
#include "PluginMainThreadScheduler.h"
-#include "RenderLayer.h"
#include "ScriptController.h"
#include "Settings.h"
#include "npruntime_impl.h"
#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)
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;
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&);
{
}
+bool RenderView::hitTest(const HitTestRequest& request, HitTestResult& result)
+{
+ return layer()->hitTest(request, result);
+}
+
void RenderView::computeLogicalHeight()
{
if (!printing() && m_frameView)
RenderView(Node*, FrameView*);
virtual ~RenderView();
+ bool hitTest(const HitTestRequest&, HitTestResult&);
+
virtual const char* renderName() const { return "RenderView"; }
virtual bool isRenderView() const { return true; }