diff options
author | Patrick Scott <phanna@android.com> | 2010-07-16 12:43:07 -0400 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2010-07-22 08:16:26 -0400 |
commit | a8d0e5a36718ee59b84a577053458bded49e369a (patch) | |
tree | 510917186d198758676037c96296405d0a1b83f1 /WebCore/rendering | |
parent | 0286594a8b68c879fc5c11deb6f14c4ccadeef2a (diff) | |
download | external_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.zip external_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.tar.gz external_webkit-a8d0e5a36718ee59b84a577053458bded49e369a.tar.bz2 |
Enable scrollable divs.
Force a composite layer when the style says the content is scrollable.
Record the border and background in the main content picture. When
the contents of the layer are bigger than the size, record the
foreground contents in a separate picture which is clipped by the
border and size.
When updating the base layer, remember the scroll position of each
layer and update the new layer with the same position.
Bug: 1566791
Change-Id: If440e4f215db6bda9df32a781d754d1f5a238162
Diffstat (limited to 'WebCore/rendering')
-rw-r--r-- | WebCore/rendering/RenderLayer.cpp | 26 | ||||
-rw-r--r-- | WebCore/rendering/RenderLayerBacking.cpp | 40 | ||||
-rw-r--r-- | WebCore/rendering/RenderLayerCompositor.cpp | 15 |
3 files changed, 81 insertions, 0 deletions
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp index d9d2be1..75daa94 100644 --- a/WebCore/rendering/RenderLayer.cpp +++ b/WebCore/rendering/RenderLayer.cpp @@ -3237,8 +3237,17 @@ void RenderLayer::calculateRects(const RenderLayer* rootLayer, const IntRect& pa // Update the clip rects that will be passed to child layers. if (renderer()->hasOverflowClip() || renderer()->hasClip()) { // This layer establishes a clip of some kind. +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (renderer()->hasOverflowClip()) { + RenderBox* box = toRenderBox(renderer()); + layerBounds = backgroundRect = foregroundRect = outlineRect = + IntRect(x, y, box->borderLeft() + box->borderRight() + m_scrollWidth, + box->borderTop() + box->borderBottom() + m_scrollHeight); + } +#else if (renderer()->hasOverflowClip()) foregroundRect.intersect(toRenderBox(renderer())->overflowClipRect(x, y)); +#endif if (renderer()->hasClip()) { // Clip applies to *us* as well, so go ahead and update the damageRect. IntRect newPosClip = toRenderBox(renderer())->clipRect(x, y); @@ -3748,8 +3757,25 @@ bool RenderLayer::shouldBeNormalFlowOnly() const && !isTransparent(); } +#if ENABLE(ANDROID_OVERFLOW_SCROLL) +static bool hasOverflowScroll(const RenderLayer* l) +{ + RenderLayer* layer = const_cast<RenderLayer*>(l); + RenderBox* box = layer->renderBox(); + EOverflow x = box->style()->overflowX(); + EOverflow y = box->style()->overflowY(); + return (x == OAUTO || x == OSCROLL || y == OAUTO || y == OSCROLL) && + (layer->scrollWidth() > box->clientWidth() || + layer->scrollHeight() > box->clientHeight()); +} +#endif + bool RenderLayer::isSelfPaintingLayer() const { +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (hasOverflowScroll(this)) + return true; +#endif return !isNormalFlowOnly() || renderer()->hasReflection() || renderer()->hasMask() || renderer()->isTableRow() || renderer()->isVideo() || renderer()->isEmbeddedObject() || renderer()->isRenderIFrame(); } diff --git a/WebCore/rendering/RenderLayerBacking.cpp b/WebCore/rendering/RenderLayerBacking.cpp index ae01799..1153727 100644 --- a/WebCore/rendering/RenderLayerBacking.cpp +++ b/WebCore/rendering/RenderLayerBacking.cpp @@ -55,6 +55,10 @@ #include "RenderLayerBacking.h" +#if ENABLE(ANDROID_OVERFLOW_SCROLL) +#include "GraphicsLayerAndroid.h" +#endif + using namespace std; namespace WebCore { @@ -397,6 +401,18 @@ void RenderLayerBacking::updateGraphicsLayerGeometry() } m_graphicsLayer->setContentsRect(contentsBox()); +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (m_owningLayer->hasOverflowControls()) { + RenderBoxModelObject* box = renderer(); + IntRect clip = compositedBounds(); + IntPoint location = clip.location(); + location.move(box->borderLeft(), box->borderTop()); + clip.setLocation(location); + clip.setWidth(clip.width() - box->borderLeft() - box->borderRight()); + clip.setHeight(clip.height() - box->borderTop() - box->borderBottom()); + static_cast<GraphicsLayerAndroid*>(m_graphicsLayer.get())->setContentsClip(clip); + } +#endif updateDrawsContent(); updateAfterWidgetResize(); } @@ -819,6 +835,24 @@ IntRect RenderLayerBacking::contentsBox() const } else #endif contentsRect = toRenderBox(renderer())->contentBoxRect(); +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (m_owningLayer->hasOverflowControls()) { + // Update the contents rect to have the width and height of the entire + // contents. This rect is only used by the platform GraphicsLayer and + // the position of the rectangle is ignored. Use the layer's scroll + // width/height (which contain the padding). + RenderBox* box = toRenderBox(renderer()); + contentsRect.setWidth(box->borderLeft() + box->borderRight() + + m_owningLayer->scrollWidth()); + contentsRect.setHeight(box->borderTop() + box->borderBottom() + + m_owningLayer->scrollHeight()); + // Move the contents rect by the padding since + // RenderBox::contentBoxRect includes the padding. The end result is + // to have a box representing the entires contents plus border and + // padding. This will be the size of the underlying picture. + contentsRect.setLocation(IntPoint(0, 0)); + } +#endif IntSize contentOffset = contentOffsetInCompostingLayer(); contentsRect.move(contentOffset); @@ -1053,6 +1087,12 @@ void RenderLayerBacking::paintContents(const GraphicsLayer*, GraphicsContext& co // We have to use the same root as for hit testing, because both methods // can compute and cache clipRects. IntRect enclosingBBox = compositedBounds(); +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (m_owningLayer->hasOverflowControls()) { + enclosingBBox.setSize(contentsBox().size()); + enclosingBBox.setLocation(m_compositedBounds.location()); + } +#endif IntRect clipRect(clip); diff --git a/WebCore/rendering/RenderLayerCompositor.cpp b/WebCore/rendering/RenderLayerCompositor.cpp index c485acc..1a28c37 100644 --- a/WebCore/rendering/RenderLayerCompositor.cpp +++ b/WebCore/rendering/RenderLayerCompositor.cpp @@ -1153,6 +1153,18 @@ bool RenderLayerCompositor::requiresCompositingForMobileSites(const RenderLayer* } #endif +#if ENABLE(ANDROID_OVERFLOW_SCROLL) +static bool requiresCompositingForOverflowScroll(const RenderLayer* l) { + RenderLayer* layer = const_cast<RenderLayer*>(l); + RenderBox* box = layer->renderBox(); + EOverflow x = box->style()->overflowX(); + EOverflow y = box->style()->overflowY(); + return (x == OAUTO || x == OSCROLL || y == OAUTO || y == OSCROLL) && + (layer->scrollWidth() > box->contentWidth() || + layer->scrollHeight() > box->contentHeight()); +} +#endif + // Note: this specifies whether the RL needs a compositing layer for intrinsic reasons. // Use needsToBeComposited() to determine if a RL actually needs a compositing layer. // static @@ -1167,6 +1179,9 @@ bool RenderLayerCompositor::requiresCompositingLayer(const RenderLayer* layer) c return requiresCompositingForTransform(renderer) #if PLATFORM(ANDROID) || requiresCompositingForMobileSites(layer) +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + || requiresCompositingForOverflowScroll(layer) +#endif #endif || requiresCompositingForVideo(renderer) || requiresCompositingForCanvas(renderer) |