diff options
author | Nicolas Roard <nicolas@android.com> | 2010-01-14 13:18:44 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-01-14 13:18:44 -0800 |
commit | 7e4ab561c4c9340f9ef887d1f0fbb7c2972d5bfd (patch) | |
tree | 997b89cc137d4296332c62dcae8f2943d9a51384 /WebCore | |
parent | 9686cffddc98f1b71724156c1cf38ee724f08e03 (diff) | |
parent | 93f808abccaf6f09c5c0226c01942c3be445031a (diff) | |
download | external_webkit-7e4ab561c4c9340f9ef887d1f0fbb7c2972d5bfd.zip external_webkit-7e4ab561c4c9340f9ef887d1f0fbb7c2972d5bfd.tar.gz external_webkit-7e4ab561c4c9340f9ef887d1f0fbb7c2972d5bfd.tar.bz2 |
am 93f808ab: am 388e461f: Add proper support for fixed position elements
Merge commit '93f808abccaf6f09c5c0226c01942c3be445031a'
* commit '93f808abccaf6f09c5c0226c01942c3be445031a':
Add proper support for fixed position elements
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 60 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.h | 17 |
3 files changed, 61 insertions, 23 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index f518ffb..6901f52 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -111,9 +111,10 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) : m_contentLayer->setIsRootLayer(renderLayer->isRootLayer()); RenderView* view = static_cast<RenderView*>(renderLayer->renderer()); if (view->isPositioned() && view->style()->position() == FixedPosition) { - FloatPoint position(view->style()->left().value(), - view->style()->right().value()); - m_contentLayer->setFixedPosition(position); + m_contentLayer->setFixedPosition(view->style()->left(), + view->style()->top(), + view->style()->right(), + view->style()->bottom()); } } gDebugGraphicsLayerAndroidInstances++; diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 347021a..3b5d5b5 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -62,9 +62,12 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : m_size(0, 0), m_position(0, 0), m_translation(0, 0), - m_fixedPosition(0, 0), m_anchorPoint(0, 0, 0), m_scale(1, 1, 1), + m_fixedLeft(Auto), + m_fixedTop(Auto), + m_fixedRight(Auto), + m_fixedBottom(Auto), m_recordingPicture(0) { gDebugLayerAndroidInstances++; @@ -84,9 +87,12 @@ LayerAndroid::LayerAndroid(LayerAndroid* layer) : m_size(layer->m_size), m_position(layer->m_position), m_translation(layer->m_translation), - m_fixedPosition(layer->m_fixedPosition), m_anchorPoint(layer->m_anchorPoint), - m_scale(layer->m_scale) + m_scale(layer->m_scale), + m_fixedLeft(layer->m_fixedLeft), + m_fixedRight(layer->m_fixedRight), + m_fixedTop(layer->m_fixedTop), + m_fixedBottom(layer->m_fixedBottom) { if (layer->m_recordingPicture) { layer->m_recordingPicture->ref(); @@ -167,9 +173,13 @@ void LayerAndroid::removeAnimation(const String& name) m_animations.remove(name); } -void LayerAndroid::setFixedPosition(FloatPoint position) +void LayerAndroid::setFixedPosition(Length left, Length top, + Length right, Length bottom) { - m_fixedPosition = position; + m_fixedLeft = left; + m_fixedTop = top; + m_fixedRight = right; + m_fixedBottom = bottom; m_isFixed = true; } @@ -205,10 +215,12 @@ void LayerAndroid::setBackgroundColor(const Color& color) static int gDebugChildLevel; -void LayerAndroid::paintOn(float scrollX, float scrollY, float scale, SkCanvas* canvas) +void LayerAndroid::paintOn(int scrollX, int scrollY, + int width, int height, + float scale, SkCanvas* canvas) { gDebugChildLevel = 0; - paintChildren(scrollX, scrollY, scale, canvas, 1); + paintChildren(scrollX, scrollY, width, height, scale, canvas, 1); } void LayerAndroid::setClip(SkCanvas* canvas) @@ -221,7 +233,8 @@ void LayerAndroid::setClip(SkCanvas* canvas) canvas->clipRect(clip); } -void LayerAndroid::paintChildren(float scrollX, float scrollY, +void LayerAndroid::paintChildren(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity) { @@ -230,7 +243,7 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, if (m_haveClip) setClip(canvas); - paintMe(scrollX, scrollY, scale, canvas, opacity); + paintMe(scrollX, scrollY, width, height, scale, canvas, opacity); canvas->translate(m_position.x() + m_translation.x(), m_position.y() + m_translation.y()); @@ -238,7 +251,8 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, LayerAndroid* layer = m_children[i].get(); if (layer) { gDebugChildLevel++; - layer->paintChildren(scrollX, scrollY, scale, canvas, opacity * m_opacity); + layer->paintChildren(scrollX, scrollY, width, height, scale, + canvas, opacity * m_opacity); gDebugChildLevel--; } } @@ -246,8 +260,10 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, canvas->restore(); } -void LayerAndroid::paintMe(float scrollX, - float scrollY, +void LayerAndroid::paintMe(int scrollX, + int scrollY, + int viewWidth, + int viewHeight, float scale, SkCanvas* canvas, float opacity) @@ -275,10 +291,24 @@ void LayerAndroid::paintMe(float scrollX, paintMode.setXfermodeMode(SkXfermode::kSrc_Mode); - float x, y; + float x = 0; + float y = 0; if (m_isFixed) { - x = m_fixedPosition.x() + (scrollX / scale); - y = m_fixedPosition.y() + (scrollY / scale); + float w = viewWidth / scale; + float h = viewHeight / scale; + float dx = scrollX / scale; + float dy = scrollY / scale; + + if (m_fixedLeft.type()) + x = dx + m_fixedLeft.calcFloatValue(w); + else if (m_fixedRight.type()) + x = dx + w - m_fixedRight.calcFloatValue(w) - m_size.width(); + + if (m_fixedTop.type()) + y = dy + m_fixedTop.calcFloatValue(h); + else if (m_fixedBottom.type()) + y = dy + h - m_fixedBottom.calcFloatValue(h) - m_size.height(); + } else { x = m_translation.x() + m_position.x(); y = m_translation.y() + m_position.y(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 284185d..467c7dd 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -25,6 +25,7 @@ #include "FloatSize.h" #include "GraphicsContext.h" #include "GraphicsLayer.h" +#include "Length.h" #include "RefPtr.h" #include "StringHash.h" #include "Vector.h" @@ -64,7 +65,7 @@ public: void setBackgroundColor(const Color& color); void setIsRootLayer(bool isRootLayer) { m_isRootLayer = isRootLayer; } - void paintOn(float scrollX, float scrollY, float scale, SkCanvas*); + void paintOn(int scrollX, int scrollY, int width, int height, float scale, SkCanvas*); GraphicsContext* paintContext(); void removeAllChildren() { m_children.clear(); } void addChildren(LayerAndroid* layer) { m_children.append(layer); } @@ -77,7 +78,7 @@ public: FloatPoint translation() { return m_translation; } FloatSize size() { return m_size; } - void setFixedPosition(FloatPoint position); + void setFixedPosition(Length left, Length top, Length right, Length bottom); void addAnimation(PassRefPtr<AndroidAnimation> anim); void removeAnimation(const String& name); Vector<RefPtr<AndroidAnimationValue> >* evaluateAnimations() const; @@ -87,11 +88,13 @@ public: private: - void paintChildren(float scrollX, float scrollY, + void paintChildren(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity); - void paintMe(float scrollX, float scrollY, + void paintMe(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity); @@ -110,10 +113,14 @@ private: FloatSize m_size; FloatPoint m_position; FloatPoint m_translation; - FloatPoint m_fixedPosition; FloatPoint3D m_anchorPoint; FloatPoint3D m_scale; + Length m_fixedLeft; + Length m_fixedTop; + Length m_fixedRight; + Length m_fixedBottom; + SkPicture* m_recordingPicture; Color m_backgroundColor; |