move children into SkLayer
make SkLayer inherit from SkRefCnt.h
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index b1662f4..9470bb9 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -121,7 +121,7 @@
     m_currentTranslateY(0),
     m_currentPosition(0, 0)
 {
-    m_contentLayer = adoptRef(new LayerAndroid(true));
+    m_contentLayer = new LayerAndroid(true);
     if (client) {
         RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(client);
         RenderLayer* renderLayer = backing->owningLayer();
@@ -141,6 +141,7 @@
 
 GraphicsLayerAndroid::~GraphicsLayerAndroid()
 {
+    m_contentLayer->unref();
     gDebugGraphicsLayerAndroidInstances--;
 }
 
@@ -406,7 +407,7 @@
 
     if (rootGraphicsLayer->m_frame
         && rootGraphicsLayer->m_frame->view()) {
-        LayerAndroid* copyLayer = new LayerAndroid(m_contentLayer.get());
+        LayerAndroid* copyLayer = new LayerAndroid(*m_contentLayer);
         TLOG("(%x) sendImmediateRepaint, copy the layer, (%.2f,%.2f => %.2f,%.2f)",
             this, m_contentLayer->size().width(), m_contentLayer->size().height(),
             copyLayer->size().width(), copyLayer->size().height());
@@ -801,7 +802,7 @@
 PlatformLayer* GraphicsLayerAndroid::platformLayer() const
 {
     LOG("platformLayer");
-    return (PlatformLayer*) m_contentLayer.get();
+    return (PlatformLayer*) m_contentLayer;
 }
 
 #ifndef NDEBUG
@@ -830,9 +831,9 @@
 void GraphicsLayerAndroid::syncChildren()
 {
     if (m_needsSyncChildren) {
-        m_contentLayer->removeAllChildren();
+        m_contentLayer->removeChildren();
         for (unsigned int i = 0; i < m_children.size(); i++) {
-            m_contentLayer->addChildren(
+            m_contentLayer->addChild(
                 (static_cast<GraphicsLayerAndroid*>(m_children[i]))->contentLayer());
         }
         m_needsSyncChildren = false;
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index 591a261..8c80586 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -119,7 +119,7 @@
     void notifyClientAnimationStarted();
 
     void sendImmediateRepaint();
-    LayerAndroid* contentLayer() { return m_contentLayer.get(); }
+    LayerAndroid* contentLayer() { return m_contentLayer; }
 
     static int instancesCount();
 
@@ -148,7 +148,7 @@
 
     Vector<FloatRect> m_invalidatedRects;
 
-    RefPtr<LayerAndroid> m_contentLayer;
+    LayerAndroid* m_contentLayer;
 };
 
 } // namespace WebCore
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 14b9a96..52a457d 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -43,11 +43,6 @@
     int m_previousOpacity;
 };
 
-PassRefPtr<LayerAndroid> LayerAndroid::create(bool isRootLayer)
-{
-    return adoptRef(new LayerAndroid(isRootLayer));
-}
-
 LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(),
     m_isRootLayer(isRootLayer),
     m_haveContents(false),
@@ -59,21 +54,21 @@
     gDebugLayerAndroidInstances++;
 }
 
-LayerAndroid::LayerAndroid(LayerAndroid* layer) : SkLayer(layer),
-    m_isRootLayer(layer->m_isRootLayer),
-    m_haveContents(layer->m_haveContents),
-    m_drawsContent(layer->m_drawsContent),
-    m_haveImage(layer->m_haveImage),
-    m_haveClip(layer->m_haveClip)
+LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
+    m_isRootLayer(layer.m_isRootLayer),
+    m_haveContents(layer.m_haveContents),
+    m_drawsContent(layer.m_drawsContent),
+    m_haveImage(layer.m_haveImage),
+    m_haveClip(layer.m_haveClip)
 {
-    m_recordingPicture = layer->m_recordingPicture;
+    m_recordingPicture = layer.m_recordingPicture;
     SkSafeRef(m_recordingPicture);
 
-    for (unsigned int i = 0; i < layer->m_children.size(); i++)
-        m_children.append(adoptRef(new LayerAndroid(layer->m_children[i].get())));
+    for (int i = 0; i < layer.countChildren(); i++)
+        addChild(new LayerAndroid(*static_cast<LayerAndroid*>(layer.getChild(i))))->unref();
 
-    KeyframesMap::const_iterator end = layer->m_animations.end();
-    for (KeyframesMap::const_iterator it = layer->m_animations.begin(); it != end; ++it)
+    KeyframesMap::const_iterator end = layer.m_animations.end();
+    for (KeyframesMap::const_iterator it = layer.m_animations.begin(); it != end; ++it)
         m_animations.add((it->second)->name(), (it->second)->copy());
 
     gDebugLayerAndroidInstances++;
@@ -81,8 +76,8 @@
 
 LayerAndroid::~LayerAndroid()
 {
+    removeChildren();
     m_recordingPicture->safeUnref();
-    m_children.clear();
     m_animations.clear();
     gDebugLayerAndroidInstances--;
 }
@@ -98,8 +93,8 @@
 
 bool LayerAndroid::hasAnimations() const
 {
-    for (unsigned int i = 0; i < m_children.size(); i++) {
-        if (m_children[i]->hasAnimations())
+    for (int i = 0; i < countChildren(); i++) {
+        if (static_cast<LayerAndroid*>(getChild(i))->hasAnimations())
             return true;
     }
     return !!m_animations.size();
@@ -108,8 +103,8 @@
 bool LayerAndroid::evaluateAnimations(double time) const
 {
     bool hasRunningAnimations = false;
-    for (unsigned int i = 0; i < m_children.size(); i++) {
-        if (m_children[i]->evaluateAnimations(time))
+    for (int i = 0; i < countChildren(); i++) {
+        if (static_cast<LayerAndroid*>(getChild(i))->evaluateAnimations(time))
             hasRunningAnimations = true;
     }
     KeyframesMap::const_iterator end = m_animations.end();
@@ -137,8 +132,8 @@
 void LayerAndroid::setDrawsContent(bool drawsContent)
 {
     m_drawsContent = drawsContent;
-    for (unsigned int i = 0; i < m_children.size(); i++) {
-        LayerAndroid* layer = m_children[i].get();
+    for (int i = 0; i < countChildren(); i++) {
+        LayerAndroid* layer = static_cast<LayerAndroid*>(getChild(i));
         layer->setDrawsContent(drawsContent);
     }
 }
@@ -209,8 +204,8 @@
     canvas->translate(m_position.fX + m_translation.fX,
                       m_position.fY + m_translation.fY);
 
-    for (unsigned int i = 0; i < m_children.size(); i++) {
-        LayerAndroid* layer = m_children[i].get();
+    for (int i = 0; i < countChildren(); i++) {
+        LayerAndroid* layer = static_cast<LayerAndroid*>(getChild(i));
         if (layer) {
             gDebugChildLevel++;
             layer->paintChildren(scrollX, scrollY, width, height, scale,
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 911a2f9..e6dbfb9 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -39,12 +39,11 @@
 class AndroidAnimation;
 class AndroidAnimationValue;
 
-class LayerAndroid : public SkLayer, public RefCounted<LayerAndroid> {
+class LayerAndroid : public SkLayer {
 
 public:
-    static PassRefPtr<LayerAndroid> create(bool isRootLayer);
     LayerAndroid(bool isRootLayer);
-    LayerAndroid(LayerAndroid* layer);
+    LayerAndroid(const LayerAndroid& layer);
     virtual ~LayerAndroid();
 
     static int instancesCount();
@@ -59,8 +58,6 @@
 
     void paintOn(int scrollX, int scrollY, int width, int height, float scale, SkCanvas*);
     void paintOn(SkPoint offset, SkSize size, SkScalar scale, SkCanvas*);
-    void removeAllChildren() { m_children.clear(); }
-    void addChildren(LayerAndroid* layer) { m_children.append(layer); }
     bool prepareContext(bool force = false);
     void startRecording();
     void stopRecording();
@@ -77,8 +74,6 @@
                       float scale, float* xPtr, float* yPtr);
 
     SkPicture* picture() const { return m_recordingPicture; }
-    const LayerAndroid* child(unsigned i) const { return m_children[i].get(); }
-    unsigned childCount() const { return m_children.size(); }
 
 private:
 
@@ -100,7 +95,6 @@
 
     SkPicture* m_recordingPicture;
 
-    Vector<RefPtr<LayerAndroid> > m_children;
     typedef HashMap<String, RefPtr<AndroidAnimation> > KeyframesMap;
     KeyframesMap m_animations;
 };
diff --git a/WebCore/platform/graphics/android/SkLayer.h b/WebCore/platform/graphics/android/SkLayer.h
deleted file mode 100644
index 3e6f4d2..0000000
--- a/WebCore/platform/graphics/android/SkLayer.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SkLayer_h
-#define SkLayer_h
-
-#include "SkCanvas.h"
-#include "SkRefCnt.h"
-#include "SkTDArray.h"
-#include "SkColor.h"
-#include "SkPoint.h"
-#include "SkSize.h"
-
-class SkPicture;
-
-
-struct SkLength {
-  enum SkLengthType { Undefined, Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic };
-  SkLengthType type;
-  SkScalar value;
-  SkLength() {
-    type = Undefined;
-    value = 0;
-  }
-  bool defined() const {
-    if (type == Undefined)
-      return false;
-    return true;
-  }
-  float calcFloatValue(float max) const {
-    switch (type) {
-      case Percent:
-        return (max * value) / 100.0f;
-      case Fixed:
-        return value;
-      default:
-        return value;
-    }
-  }
-};
-
-class SkLayer /*: public SkRefCnt*/ {
-
-public:
-    SkLayer() {
-      m_doRotation = false;
-      m_isFixed = false;
-      m_backgroundColorSet = false;
-      m_angleTransform = 0;
-      m_opacity = 1;
-      m_size.set(0, 0);
-      m_translation.set(0, 0);
-      m_anchorPoint.set(0.5, 0.5);
-      m_scale.set(1, 1);
-    }
-
-    SkLayer(SkLayer* layer) {
-      memcpy(this, layer, sizeof(*this));
-    }
-
-    virtual ~SkLayer() {};
-
-    // setters
-
-    void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); }
-    void setOpacity(SkScalar opacity) { m_opacity = opacity; }
-    void setTranslation(SkScalar x, SkScalar y) { m_translation.set(x, y); }
-    void setRotation(SkScalar a) { m_angleTransform = a; m_doRotation = true; }
-    void setScale(SkScalar x, SkScalar y) { m_scale.set(x, y); }
-    void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); }
-    void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); }
-    virtual void setBackgroundColor(SkColor color) { m_backgroundColor = color; m_backgroundColorSet = true; }
-    void setFixedPosition(SkLength left, SkLength top, SkLength right, SkLength bottom) {
-      m_fixedLeft = left;
-      m_fixedTop = top;
-      m_fixedRight = right;
-      m_fixedBottom = bottom;
-      m_isFixed = true;
-    }
-
-    // getters
-
-    SkPoint position() const { return m_position; }
-    SkPoint translation() const { return m_translation; }
-    SkSize  size() const { return m_size; }
-    SkRect  bounds() const {
-      SkRect rect;
-      rect.set(m_position.fX, m_position.fY,
-               m_position.fX + m_size.width(),
-               m_position.fY + m_size.height());
-      rect.offset(m_translation.fX, m_translation.fY);
-      return rect;
-    }
-
-    // paint method
-
-    virtual void paintOn(SkPoint offset, SkSize size, SkScalar scale, SkCanvas*) = 0;
-
-    // children manipulation
-
-//    void removeAllChildren();
-//    void addChildren(LayerAndroid* layer);
-
-public:
-
-    bool m_doRotation;
-    bool m_isFixed;
-    bool m_backgroundColorSet;
-
-    // layers properties
-
-    SkScalar m_angleTransform;
-    SkScalar m_opacity;
-
-    SkSize m_size;
-    SkPoint m_position;
-    SkPoint m_translation;
-    SkPoint m_anchorPoint;
-    SkPoint m_scale;
-
-    SkLength m_fixedLeft;
-    SkLength m_fixedTop;
-    SkLength m_fixedRight;
-    SkLength m_fixedBottom;
-
-    SkColor m_backgroundColor;
-
-//    SkTDArray<SkLayer*> m_children;
-};
-
-#endif