diff options
author | Nicolas Roard <nicolas@android.com> | 2010-03-17 21:15:55 +0000 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2010-03-18 15:16:50 +0000 |
commit | a9fc241ad9f93bcec6abf9dd251c079ae8bbea12 (patch) | |
tree | 6a51bc0d279131d3a8f1c7c59053799cafa14b4c /WebCore | |
parent | 8026280044128436d8e89736519a0b32b6540201 (diff) | |
download | external_webkit-a9fc241ad9f93bcec6abf9dd251c079ae8bbea12.zip external_webkit-a9fc241ad9f93bcec6abf9dd251c079ae8bbea12.tar.gz external_webkit-a9fc241ad9f93bcec6abf9dd251c079ae8bbea12.tar.bz2 |
Fix click issues when using fixed elements. This CL also fix the positioning
of a fixed layer when no position is defined, and also only use the screen
to position only the fixed elements, not other types of positioned elements.
Bug:2521087
The click issues were due to not returning the fixed element when looking
for a parent stackingContext in RenderLayer::stackingContext().
This resulted in incorrect coordinates for the layers children of a
fixed layer, that we then had to recompute in
RenderLayer::convertToLayerCoords(), but this in turns was invaliding
hit test detection...
Fixed elements are now positioned relative to the screen instead of the
virtual viewport (ANDROID_FIXED_ELEMENTS); but this was applying
indiscriminantly to all positioned elements, absolute elements included.
The CL modify RenderBox::containingBlockWidthForPositioned() and
RenderBox::containingBlockHeightForPositioned() to only do this for
fixed elements.
Finally, fixed layers were wrongly positioned if the positions were not
fully set (e.g. only setting top:0 but no left or right). The change to
LayerAndroid::updateFixedLayersPositions() fixes this.
Change-Id: I07a179dd631a2bc1a313e33ffcf69ef388ecb7ca
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 16 | ||||
-rw-r--r-- | WebCore/rendering/RenderBox.cpp | 4 | ||||
-rw-r--r-- | WebCore/rendering/RenderLayer.cpp | 25 | ||||
-rw-r--r-- | WebCore/rendering/RenderLayerCompositor.cpp | 2 |
4 files changed, 20 insertions, 27 deletions
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index c17a034..3b1743d 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -245,25 +245,25 @@ const LayerAndroid* LayerAndroid::find(int x, int y) const /////////////////////////////////////////////////////////////////////////////// -void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) { - +void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) +{ if (m_isFixed) { - float x = 0; - float y = 0; float w = viewport.width(); float h = viewport.height(); float dx = viewport.fLeft; float dy = viewport.fTop; + float x = dx; + float y = dy; if (m_fixedLeft.defined()) - x = dx + m_fixedLeft.calcFloatValue(w); + x += m_fixedLeft.calcFloatValue(w); else if (m_fixedRight.defined()) - x = dx + w - m_fixedRight.calcFloatValue(w) - m_fixedWidth; + x += w - m_fixedRight.calcFloatValue(w) - m_fixedWidth; if (m_fixedTop.defined()) - y = dy + m_fixedTop.calcFloatValue(h); + y += m_fixedTop.calcFloatValue(h); else if (m_fixedBottom.defined()) - y = dy + h - m_fixedBottom.calcFloatValue(h) - m_fixedHeight; + y += h - m_fixedBottom.calcFloatValue(h) - m_fixedHeight; this->setPosition(x, y); } diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index 722b772..91f72ed 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -1791,7 +1791,7 @@ void RenderBox::calcVerticalMargins() int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const { #ifdef ANDROID_FIXED_ELEMENTS - if (containingBlock->isRenderView()) { + if (style()->position() == FixedPosition && containingBlock->isRenderView()) { const RenderView* view = toRenderView(containingBlock); return PlatformBridge::screenWidth(view->frameView()); } @@ -1827,7 +1827,7 @@ int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* con int RenderBox::containingBlockHeightForPositioned(const RenderBoxModelObject* containingBlock) const { #ifdef ANDROID_FIXED_ELEMENTS - if (containingBlock->isRenderView()) { + if (style()->position() == FixedPosition && containingBlock->isRenderView()) { const RenderView* view = toRenderView(containingBlock); return PlatformBridge::screenHeight(view->frameView()); } diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp index db079c7..6dbb413 100644 --- a/WebCore/rendering/RenderLayer.cpp +++ b/WebCore/rendering/RenderLayer.cpp @@ -648,7 +648,16 @@ FloatPoint RenderLayer::perspectiveOrigin() const RenderLayer* RenderLayer::stackingContext() const { RenderLayer* layer = parent(); +#if ENABLE(COMPOSITED_FIXED_ELEMENTS) + // When using composited fixed elements, they are turned into a stacking + // context and we thus need to return them. + // We can simplify the while loop by using isStackingContext(); with + // composited fixed elements turned on, this will return true for them, + // and is otherwise equivalent to the replaced statements. + while (layer && !layer->renderer()->isRoot() && !layer->isStackingContext()) +#else while (layer && !layer->renderer()->isRenderView() && !layer->renderer()->isRoot() && layer->renderer()->style()->hasAutoZIndex()) +#endif layer = layer->parent(); return layer; } @@ -1039,22 +1048,6 @@ RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, int& xPos, i } } -#if ENABLE(COMPOSITED_FIXED_ELEMENTS) - // If fixed layers are composited, we need to look up for a parent layer - // that would be fixed, and compute the correct offset relative to it. - int intermediateX = 0; - int intermediateY = 0; - const RenderLayer* currLayer = this; - while ((currLayer = currLayer->parent())) { - if (currLayer->isComposited() && currLayer->isFixed()) { - xPos = x() + intermediateX; - yPos = y() + intermediateY; - return; - } - intermediateX += currLayer->x(); - intermediateY += currLayer->y(); - } -#endif RenderLayer* parentLayer; if (position == AbsolutePosition || position == FixedPosition) { diff --git a/WebCore/rendering/RenderLayerCompositor.cpp b/WebCore/rendering/RenderLayerCompositor.cpp index 2768461..b50148f 100644 --- a/WebCore/rendering/RenderLayerCompositor.cpp +++ b/WebCore/rendering/RenderLayerCompositor.cpp @@ -506,7 +506,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O #if ENABLE(COMPOSITED_FIXED_ELEMENTS) // If we are a fixed layer, signal it to our siblings if (layer->isFixed()) - compositingState.m_fixedSibling = true; + compositingState.m_fixedSibling = true; if (!willBeComposited && compositingState.m_fixedSibling) layer->setMustOverlapCompositedLayers(true); |