summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/Layer.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-09-21 15:43:37 +0100
committerSteve Block <steveblock@google.com>2011-09-22 22:57:10 +0100
commit8782ca1236bac0bb13e08a6b63f8743e0b01e75a (patch)
treeb3bf345515df5bf26b7df393ac4458c9dd57be86 /Source/WebCore/platform/graphics/android/Layer.cpp
parent06ab37f33e994114ce0ec9fbb35fe48249ed6dbc (diff)
downloadexternal_webkit-8782ca1236bac0bb13e08a6b63f8743e0b01e75a.zip
external_webkit-8782ca1236bac0bb13e08a6b63f8743e0b01e75a.tar.gz
external_webkit-8782ca1236bac0bb13e08a6b63f8743e0b01e75a.tar.bz2
Fix find-in-page to scroll scrollable layers
This requires the addition of the following methods ... - Layer::contentIsScrollable() - Layer::localToParent() - ScrollableLayerAndroid::scrollRectIntoView() Bug: 5262656 Change-Id: I2f1cf3342f73890f98a172f1b4e3f440c02dd9f4
Diffstat (limited to 'Source/WebCore/platform/graphics/android/Layer.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp
index 361cb4e..f650c52 100644
--- a/Source/WebCore/platform/graphics/android/Layer.cpp
+++ b/Source/WebCore/platform/graphics/android/Layer.cpp
@@ -124,23 +124,34 @@ void Layer::getLocalTransform(SkMatrix* matrix) const {
matrix->preTranslate(-tx, -ty);
}
-void Layer::localToGlobal(SkMatrix* matrix) const {
+void Layer::localToAncestor(const Layer* ancestor, SkMatrix* matrix) const {
+ if (this == ancestor) {
+ matrix->setIdentity();
+ return;
+ }
+
getLocalTransform(matrix);
+ // Fixed position layers simply use the root layer's transform.
if (shouldInheritFromRootTransform()) {
+ ASSERT(!ancestor);
matrix->postConcat(getRootLayer()->getMatrix());
return;
}
- const Layer* layer = this;
- while (layer->fParent != NULL) {
- layer = layer->fParent;
-
+ // Apply the local and child transforms for every layer between this layer
+ // and ancestor.
+ ASSERT(isAncestor(ancestor));
+ for (const Layer* layer = this->fParent; layer != ancestor; layer = layer->fParent) {
SkMatrix tmp;
layer->getLocalTransform(&tmp);
tmp.preConcat(layer->getChildrenMatrix());
matrix->postConcat(tmp);
}
+
+ // If ancestor is not the root layer, apply its child transformation too.
+ if (ancestor)
+ matrix->postConcat(ancestor->getChildrenMatrix());
}
///////////////////////////////////////////////////////////////////////////////
@@ -204,3 +215,13 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
}
}
}
+
+bool Layer::isAncestor(const Layer* possibleAncestor) const {
+ if (!possibleAncestor)
+ return true;
+ for (const Layer* layer = getParent(); layer; layer = layer->getParent()) {
+ if (layer == possibleAncestor)
+ return true;
+ }
+ return false;
+}