Fixed API about ContentArea.
[platform/framework/native/uifw.git] / src / ui / FUi_Control.cpp
index 28d1221..078365e 100644 (file)
@@ -32,6 +32,7 @@
 #include <FBase_Log.h>
 #include <FGrp_BitmapImpl.h>
 #include <FSys_SystemInfoImpl.h>
+#include "FUi_Math.h"
 #include "FUi_Control.h"
 #include "FUi_ControlManager.h"
 #include "FUi_FocusManagerImpl.h"
@@ -55,6 +56,8 @@
 #include "FUiCtrl_Form.h"
 #include "FUiCtrl_Frame.h"
 #include "FUi_ContainerImpl.h"
+#include "FUi_DragAndDropItem.h"
+#include "FUi_UiEventManager.h"
 
 using namespace std;
 using namespace Tizen::Base;
@@ -425,7 +428,15 @@ public:
 
        FloatDimension GetItemContentSize(bool horizontalMode, bool verticalMode) const
        {
-               return __pControl->GetControlDelegate().GetContentSizeF(horizontalMode, verticalMode);
+               FloatRectangle rect = __pControl->GetContentAreaBoundsF();
+               if (rect == FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+               {
+                       return __pControl->GetControlDelegate().GetContentSizeF(horizontalMode, verticalMode);
+               }
+               else
+               {
+                       return FloatDimension(rect.width, rect.height);
+               }
        }
 
        FloatDimension GetItemMinimumSize(void) const
@@ -913,6 +924,12 @@ _Control::OnAncestorVisibleStateChanged(const _Control& control)
                {
                        SysLog(NID_UI, "VisibleState changed false, Call SetTouchCanceled");
                        pTouchManager->SetTouchCanceled(null);
+
+                       _UiEventManager* pUiEventManager = _UiEventManager::GetInstance();
+                       if (pUiEventManager)
+                       {
+                               pUiEventManager->ClearEventQueue();
+                       }
                }
        }
 }
@@ -1073,36 +1090,29 @@ _Control::Show(void)
 }
 
 void
-_Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
+_Control::ChangeLayout(_Control& control, _ControlOrientation orientation)
 {
-       ClearLastResult();
-
-       struct _Visitor
-               : public Visitor
+       if (control.__orientation != orientation)
        {
-               _Visitor(_ControlOrientation orientation)
-                       : __orientation(orientation){}
+               control.__orientation = orientation;
+               control.GetControlDelegate().OnChangeLayout(orientation);
+       }
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       if (control.__orientation != __orientation)
-                       {
-                               control.__orientation = __orientation;
-                               control.GetControlDelegate().OnChangeLayout(__orientation);
-                               ClearLastResult();
-                       }
-
-                       return VISIT_DOWNWARD;
+                       ChangeLayout(*pChild, orientation);
                }
+       }
+}
 
-private:
-               _ControlOrientation __orientation;
-       };
-
-       _Visitor visitor(orientation);
-       Accept(visitor);
-
-       SysAssert(GetLastResult() == E_SUCCESS);
+void
+_Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
+{
+       ClearLastResult();
+       ChangeLayout(*this, orientation);
 
        if (callRotation == true)
        {
@@ -1116,36 +1126,30 @@ private:
 }
 
 void
-_Control::ChangeLayout(_ControlRotation rotation)
+_Control::ChangeLayout(_Control& control, _ControlRotation rotation)
 {
-       ClearLastResult();
-
-       struct _Visitor
-               : public Visitor
+       if (control.__rotation != rotation)
        {
-               _Visitor(_ControlRotation rotation)
-                       : __rotation(rotation){}
+               control.__rotation = rotation;
+               control.GetControlDelegate().OnChangeLayout(rotation);
+               ClearLastResult();
+       }
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       if (control.__rotation != __rotation)
-                       {
-                               control.__rotation = __rotation;
-                               control.GetControlDelegate().OnChangeLayout(__rotation);
-                               ClearLastResult();
-                       }
-
-                       return VISIT_DOWNWARD;
+                       ChangeLayout(*pChild, rotation);
                }
+       }
+}
 
-private:
-               _ControlRotation __rotation;
-       };
-
-       _Visitor visitor(rotation);
-       Accept(visitor);
-
-       SysAssert(GetLastResult() == E_SUCCESS);
+void
+_Control::ChangeLayout(_ControlRotation rotation)
+{
+       ClearLastResult();
+       ChangeLayout(*this, rotation);
 }
 
 bool
@@ -1375,15 +1379,7 @@ _Control::AttachSystemChild(_Control& child)
        SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
 
        r = EndAttaching(child);
-       if (IsFailed(r))
-       {
-               result listResult = children.Remove(&child);
-               if (IsFailed(listResult))
-               {
-                       SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
-               }
-               return r;
-       }
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
 
        SysAssert(GetLastResult() == E_SUCCESS);
 
@@ -1649,69 +1645,48 @@ _Control::CallOnDetachingFromMainTree(_Control& control)
 }
 
 void
-_Control::CallOnAncestorVisibleStateChanged(void)
+_Control::CallOnAncestorVisibleStateChanged(_Control& control)
 {
-       struct _Visitor
-               : public Visitor
-       {
-               _Visitor(_Control& parent)
-                       : __parent(parent){}
+       control.GetControlDelegate().OnAncestorVisibleStateChanged(*this);
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
-                       return VISIT_DOWNWARD;
+                       CallOnAncestorVisibleStateChanged(*pChild);
                }
-
-               _Control& __parent;
-       };
-
-       _Visitor visitor(*this);
-       Accept(visitor);
+       }
 }
 
 void
-_Control::CallOnAncestorEnableStateChanged(void)
+_Control::CallOnAncestorEnableStateChanged(_Control& control)
 {
-       struct _Visitor
-               : public Visitor
-       {
-               _Visitor(_Control& parent)
-                       : __parent(parent){}
+       control.GetControlDelegate().OnAncestorEnableStateChanged(*this);
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
-                       return VISIT_DOWNWARD;
+                       CallOnAncestorEnableStateChanged(*pChild);
                }
-
-               _Control& __parent;
-       };
-
-       _Visitor visitor(*this);
-       Accept(visitor);
+       }
 }
 
 void
-_Control::CallOnAncestorInputEnableStateChanged(void)
+_Control::CallOnAncestorInputEnableStateChanged(_Control& control)
 {
-       struct _Visitor
-               : public Visitor
-       {
-               _Visitor(_Control& parent)
-                       : __parent(parent){}
+       control.GetControlDelegate().OnAncestorInputEnableStateChanged(*this);
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       control.GetControlDelegate().OnAncestorInputEnableStateChanged(__parent);
-                       return VISIT_DOWNWARD;
+                       CallOnAncestorInputEnableStateChanged(*pChild);
                }
-
-               _Control& __parent;
-       };
-
-       _Visitor visitor(*this);
-       Accept(visitor);
+       }
 }
 
 // E_INVALID_ARG
@@ -1788,8 +1763,8 @@ result
 _Control::EndAttaching(_Control& child)
 {
        child.SetParent(this);
-       child.InvalidateHierarchyRootWindow(*this);
-       child.InvalidateHierarchyAbsoluteBounds(*this);
+       InvalidateHierarchyRootWindow(child);
+       InvalidateHierarchyAbsoluteBounds(child);
 
        FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
 
@@ -1851,15 +1826,7 @@ _Control::AttachChild(_Control& child)
        r = GetVisualElement()->AttachChild(*child.GetVisualElement());
 
        r = EndAttaching(child);
-       if (IsFailed(r))
-       {
-               result listResult = children.Remove(&child);
-               if (IsFailed(listResult))
-               {
-                       SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
-               }
-               return r;
-       }
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
 
        SysAssert(GetLastResult() == E_SUCCESS);
        UpdateFocusList();
@@ -1899,7 +1866,7 @@ _Control::HasFocusRing(void)
 void
 _Control::SetFocusNavigateEnabled(bool enable)
 {
-       __isNavigatable = enable;       
+       __isNavigatable = enable;
 }
 
 bool
@@ -1937,15 +1904,7 @@ _Control::InsertChildToBottom(_Control& child)
        SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
 
        r = EndAttaching(child);
-       if (IsFailed(r))
-       {
-               result listResult = children.Remove(&child);
-               if (IsFailed(listResult))
-               {
-                       SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
-               }
-               return r;
-       }
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
 
        SysAssert(GetLastResult() == E_SUCCESS);
        return E_SUCCESS;
@@ -1981,15 +1940,7 @@ _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
        SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
 
        r = EndAttaching(child);
-       if (IsFailed(r))
-       {
-               result listResult = children.Remove(&child);
-               if (IsFailed(listResult))
-               {
-                       SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
-               }
-               return r;
-       }
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
 
        SysAssert(GetLastResult() == E_SUCCESS);
        return E_SUCCESS;
@@ -2025,15 +1976,7 @@ _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
        SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
 
        r = EndAttaching(child);
-       if (IsFailed(r))
-       {
-               result listResult = children.Remove(&child);
-               if (IsFailed(listResult))
-               {
-                       SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
-               }
-               return r;
-       }
+       SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
 
        SysAssert(GetLastResult() == E_SUCCESS);
        return E_SUCCESS;
@@ -2094,7 +2037,7 @@ _Control::DetachChild(_Control& child)
 
        SysAssert(GetLastResult() == E_SUCCESS);
        UpdateFocusList();
-       child.InvalidateHierarchyRootWindow(*this);
+       InvalidateHierarchyRootWindow(child);
 
        return E_SUCCESS;
 }
@@ -2516,45 +2459,23 @@ bool
 _Control::IsAncestorOf(const _Control& control) const
 {
        ClearLastResult();
+       return IsAncestorOf(control, *this);
+}
 
+bool
+_Control::IsAncestorOf(const _Control& control, const _Control& ancestor) const
+{
        const _Control* pParent = control.GetParent();
-       if (!pParent)
-       {
-               return false;
-       }
-
-       struct _Visitor
-               : public Visitor
+       if (pParent)
        {
-private:
-               const _Control& __ancestor;
-
-public:
-               bool yes;
-
-               _Visitor(const _Control& ancestor)
-                       : __ancestor(ancestor)
-                       , yes(false){}
-
-               virtual VisitType Visit(_Control& control)
+               if (pParent == &ancestor)
                {
-                       if (&__ancestor == &control)
-                       {
-                               yes = true;
-                               return VISIT_STOP;
-                       }
-                       else
-                       {
-                               return VISIT_UPWARD;
-                       }
+                       return true;
                }
-       };
-
-       _Visitor visitor(*this);
-       pParent->Accept(visitor);
+               return IsAncestorOf(*pParent, ancestor);
+       }
 
-       SysAssert(GetLastResult() == E_SUCCESS);
-       return visitor.yes;
+       return false;
 }
 
 _Window*
@@ -2567,35 +2488,23 @@ _Control::GetRootWindow(void) const
                return __pRootWindow;
        }
 
-       struct _Visitor
-               : public Visitor
-       {
-               _Window* pRoot;
-
-               _Visitor(void)
-                       : pRoot(null){}
+       _Window* pRoot = null;
+       _Control* pControl = const_cast<_Control*>(this);
 
-               virtual VisitType Visit(_Control& control)
+       while (pControl)
+       {
+               pRoot = dynamic_cast <_Window*>(pControl);
+               if (pRoot)
                {
-                       pRoot = dynamic_cast <_Window*>(&control);
-                       if (pRoot != null)
-                       {
-                               return VISIT_STOP;
-                       }
-
-                       return VISIT_UPWARD;
+                       break;
                }
-       };
-
-       _Visitor visitor;
-       Accept(visitor);
-
-       SysAssert(GetLastResult() == E_SUCCESS);
+               pControl = pControl->GetParent();
+       }
 
-       const_cast<_Control*>(this)->__pRootWindow = visitor.pRoot;
+       const_cast<_Control*>(this)->__pRootWindow = pRoot;
        const_cast<_Control*>(this)->__needRecalcRootWindow = false;
 
-       return visitor.pRoot;
+       return pRoot;
 }
 
 bool
@@ -2858,29 +2767,20 @@ _Control::IsEnabled(void) const
 {
        ClearLastResult();
 
-       struct _Visitor
-               : public Visitor
-       {
-               bool enabled;
-
-               _Visitor(void)
-                       : enabled(true){}
+       bool enabled = true;
+       const _Control* pControl = this;
 
-               virtual VisitType Visit(_Control& control)
+       while (pControl)
+       {
+               if (!pControl->GetEnableState())
                {
-                       if (!control.GetEnableState())
-                       {
-                               enabled = false;
-                               return VISIT_STOP;
-                       }
-
-                       return VISIT_UPWARD;
+                       enabled = false;
+                       break;
                }
-       };
+               pControl = pControl->GetParent();
+       }
 
-       _Visitor visitor;
-       Accept(visitor);
-       return visitor.enabled;
+       return enabled;
 }
 
 bool
@@ -2898,7 +2798,7 @@ _Control::SetEnableState(bool enabledState)
        if (changed)
        {
                __enabledState = enabledState;
-               CallOnAncestorEnableStateChanged();
+               CallOnAncestorEnableStateChanged(*this);
        }
        __pAccessibilityContainer->SetEnableState(enabledState);
 }
@@ -2908,29 +2808,20 @@ _Control::IsInputEventEnabled(void) const
 {
        ClearLastResult();
 
-       struct _Visitor
-               : public Visitor
-       {
-               bool inputEnabled;
-
-               _Visitor(void)
-                       : inputEnabled(true){}
+       bool inputEnabled = true;
+       const _Control* pControl = this;
 
-               virtual VisitType Visit(_Control& control)
+       while (pControl)
+       {
+               if (!pControl->GetInputEnableState())
                {
-                       if (!control.GetInputEnableState())
-                       {
-                               inputEnabled = false;
-                               return VISIT_STOP;
-                       }
-
-                       return VISIT_UPWARD;
+                       inputEnabled = false;
+                       break;
                }
-       };
+               pControl = pControl->GetParent();
+       }
 
-       _Visitor visitor;
-       Accept(visitor);
-       return visitor.inputEnabled;
+       return inputEnabled;
 }
 
 bool
@@ -2952,7 +2843,7 @@ void
 _Control::LockInputEvent(void)
 {
        __inputLockRefCount++;
-       CallOnAncestorInputEnableStateChanged();
+       CallOnAncestorInputEnableStateChanged(*this);
 }
 
 void
@@ -2976,31 +2867,20 @@ _Control::IsVisible(void) const
                return false;
        }
 
-       struct _Visitor
-               : public Visitor
-       {
-               bool visible;
-
-               _Visitor(void)
-                       : visible(true){}
+       bool visible = true;
+       const _Control* pControl = this;
 
-               virtual VisitType Visit(_Control& control)
+       while (pControl)
+       {
+               if (!pControl->GetVisibleState())
                {
-                       if (!control.GetVisibleState())
-                       {
-                               visible = false;
-                               return VISIT_STOP;
-                       }
-
-                       return VISIT_UPWARD;
+                       visible = false;
+                       break;
                }
-       };
-
-       _Visitor visitor;
-       Accept(visitor);
+               pControl = pControl->GetParent();
+       }
 
-       SysAssert(GetLastResult() == E_SUCCESS);
-       return visitor.visible;
+       return visible;
 }
 
 bool
@@ -3041,7 +2921,7 @@ _Control::SetVisibleState(bool visibleState)
        if (changed)
        {
                GetControlDelegate().OnVisibleStateChanged();
-               CallOnAncestorVisibleStateChanged();
+               CallOnAncestorVisibleStateChanged(*this);
                _Control* pParent = GetParent();
                if (pParent)
                {
@@ -3156,52 +3036,46 @@ _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
 }
 
 result
-_Control::AdjustAbsoluteBounds(void)
+_Control::AdjustAbsoluteBounds(_Control& control, bool update)
 {
-       struct _Visitor
-               : public Visitor
+       result r = E_SUCCESS;
+
+       if (update)
        {
-               _Visitor(_Control* pControl)
-                       : __pControl(pControl){}
+               FloatRectangle fbounds = control.GetBoundsF();
+
+               if (control.IsLayoutChangable() == false)
+               {
+                       r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
+               }
+               else
+               {
+                       r = control.UpdateBoundsOfVisualElement(fbounds);
+               }
+       }
 
-               virtual VisitType Visit(_Control& control)
+       for (int i = 0; i < control.GetChildCount(); ++i)
+       {
+               _Control* pChild = control.GetChild(i);
+               if (pChild)
                {
-                       result r = E_SUCCESS;
 
-                       if (__pControl == &control)
+                       if (pChild == this)
                        {
-                               return VISIT_DOWNWARD;
-                       }
-                       FloatRectangle fbounds = control.GetBoundsF();
-                       if (control.IsLayoutChangable() == false)
-                       {
-                               r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
+                               r = AdjustAbsoluteBounds(*pChild, false);
                        }
                        else
                        {
-                               r = control.UpdateBoundsOfVisualElement(fbounds);
+                               r = AdjustAbsoluteBounds(*pChild);
                        }
-
-                       ControlList& children = control.GetChildList();
-
-                       int childrenCount = children.GetCount();
-                       if (childrenCount <= 0)
-                       {
-                               return VISIT_STOP;
-                       }
-                       else
+                       if (IsFailed(r))
                        {
-                               return VISIT_DOWNWARD;
+                               SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
                        }
                }
-       private :
-               _Control* __pControl;
-       };
-
-       _Visitor visitor(this);
-       Accept(visitor);
+       }
 
-       return E_SUCCESS;
+       return r;
 }
 
 bool
@@ -3214,8 +3088,8 @@ _Control::IsInSizeRange(const Dimension& size) const
 bool
 _Control::IsInSizeRange(const FloatDimension& size) const
 {
-       return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
-                  (__minSize.height <= size.height) && (size.height <= __maxSize.height);
+       return (_FloatCompareLE(__minSize.width, size.width)) && (_FloatCompareLE(size.width, __maxSize.width)) &&
+                  (_FloatCompareLE(__minSize.height, size.height)) && (_FloatCompareLE(size.height, __maxSize.height));
 }
 
 // Custom Exception: ex) Location::Map
@@ -3342,9 +3216,9 @@ result
 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
 {
        SysTryReturn(NID_UI,
-                               IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG,
+                               IsInSizeRange(FloatDimension(bounds.width, bounds.height)), E_INVALID_ARG,
                                E_INVALID_ARG,
-                               "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).",
+                               "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%f, %f) to max size(%f, %f).",
                                bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
 
        SetUpdateLayoutState(true);
@@ -3360,6 +3234,8 @@ _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
 {
        ClearLastResult();
 
+       __isChangedPositionByUser = true;
+
        if (callBoundsChangeCallbacks)
        {
                SysTryReturn(NID_UI,
@@ -3379,6 +3255,8 @@ _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks
 {
        ClearLastResult();
 
+       __isChangedPositionByUser = true;
+
        if (callBoundsChangeCallbacks)
        {
                SysTryReturn(NID_UI,
@@ -3397,6 +3275,8 @@ _Control::SetPosition(const Point& position)
 {
        ClearLastResult();
 
+       __isChangedPositionByUser = true;
+
        SysTryReturn(NID_UI,
                                IsMovable(), E_UNSUPPORTED_OPERATION,
                                E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
@@ -3409,6 +3289,8 @@ _Control::SetPosition(const FloatPoint& position)
 {
        ClearLastResult();
 
+       __isChangedPositionByUser = true;
+
        SysTryReturn(NID_UI,
                                IsMovable(), E_UNSUPPORTED_OPERATION,
                                E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
@@ -3443,6 +3325,18 @@ _Control::SetSize(const FloatDimension& size)
        return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
 }
 
+bool
+_Control::IsChangedPositionByUser(void) const
+{
+       return __isChangedPositionByUser;
+}
+
+void
+_Control::SetChangedPositionByUser(bool change)
+{
+       __isChangedPositionByUser = change;
+}
+
 Dimension
 _Control::GetMinimumSize(void) const
 {
@@ -3753,7 +3647,7 @@ _Control::GetAbsoluteBoundsF(bool recalcAlways) const
        if (!recalcAlways && !__needRecalcAbsBoundsF)
        {
                return __absoluteBoundsF;
-       }       
+       }
 
        FloatPoint accumPoint;
        FloatRectangle absoluteBounds;
@@ -3814,7 +3708,7 @@ _Control::SetClientBounds(const Rectangle& bounds)
 
        if (moved || resized)
        {
-               result r = AdjustAbsoluteBounds();
+               result r = AdjustAbsoluteBounds(*this);
                SysTryReturn(NID_UI, r == E_SUCCESS, r,         r, "[%s] Propagating.", GetErrorMessage(r));
 
                SetUpdateLayoutState(true);
@@ -3838,7 +3732,7 @@ _Control::SetClientBounds(const FloatRectangle& bounds)
 
        if (moved || resized)
        {
-               result r = AdjustAbsoluteBounds();
+               result r = AdjustAbsoluteBounds(*this);
                SysTryReturn(NID_UI, r == E_SUCCESS, r,         r, "[%s] Propagating.", GetErrorMessage(r));
 
                SetUpdateLayoutState(true);
@@ -4004,6 +3898,7 @@ _Control::_Control(void)
        , __isFocusMode(false)
        , __isNavigatable(true)
        , __isFocusWindowActivationChecked(false)
+       , __isChangedPositionByUser(false)
        , __pVisualElementContentProvider(null)
        , __pVisualElement(null)
        , __pVisualElementEventListener(null)
@@ -4043,6 +3938,8 @@ _Control::_Control(void)
        , __fontFileName(L"")
        , __pPreviousFocus(null)
        , __pNextFocus(null)
+       , __pDragWindow(null)
+       , __isDragAndDropSource(false)
 {
        ClearLastResult();
 
@@ -4403,8 +4300,6 @@ _Control::DoBacktrace(Tizen::Base::Collection::ArrayListT<void*>* pBacktraceList
        void* pBuffer[ADDR_SIZE];
 
        retSize = backtrace(pBuffer, ADDR_SIZE);
-       SysSecureLog(NID_SHELL, " %d addresses", retSize);
-
        for (int i = 0; i < retSize; i++)
        {
                if (pBuffer[i])
@@ -4489,7 +4384,37 @@ _Control::GetContentAreaBounds(void) const
 FloatRectangle
 _Control::GetContentAreaBoundsF(void) const
 {
-       return __contentAreaBounds;
+       if (__contentAreaBounds != FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+       {
+               return __contentAreaBounds;
+       }
+       else
+       {
+               _Layout::Layout* pLayout = GetLayout();
+               if (pLayout)
+               {
+                       _Layout::LayoutMatchMode widthMatchMode = _Layout::NONE_MODE;
+                       _Layout::LayoutMatchMode heightMatchMode = _Layout::NONE_MODE;
+
+                       _Layout::LayoutItem& layoutItem = GetLayoutContainer();
+
+                       pLayout->GetItemWidthMatchMode(layoutItem, widthMatchMode);
+                       pLayout->GetItemHeightMatchMode(layoutItem, heightMatchMode);
+
+                       bool widthWrapContent = widthMatchMode == _Layout::WRAP_CONTENT;
+                       bool heightWrapContent = heightMatchMode == _Layout::WRAP_CONTENT;
+
+                       if (widthWrapContent || heightWrapContent)
+                       {
+                               FloatDimension contentSize = GetContentSizeF(widthWrapContent, heightWrapContent);
+                               return FloatRectangle(__bounds.x, __bounds.y, contentSize.width, contentSize.height);
+                       }
+                       else
+                       {
+                               return __contentAreaBounds;
+                       }
+               }
+       }
 }
 
 Bitmap*
@@ -4565,7 +4490,7 @@ _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
        ClearLastResult();
 
        bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
-       SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already");
+       SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "__pCoreGestureDetectors has gesture already");
 
        result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
        SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -5167,6 +5092,209 @@ _Control::PrintDescription(bool printChildren, int depth, int level)
        return totalCount;
 }
 
+void
+_Control::PrintBacktrace(bool printChildren, bool newBacktrace)
+{
+       int count = PrintBacktrace(printChildren, 0, newBacktrace);
+
+       SysSecureLog(NID_UI, "%d controls were printed.", count);
+}
+
+int
+_Control::PrintBacktrace(bool printChildren, int depth, bool newBacktrace)
+{
+       String indent(L"");
+       String format(L"");
+
+       format.Format(LOG_LEN_MAX, L"%d", depth);
+
+       for (int i = 0; i < depth; i++)
+       {
+               indent.Append(L"   ");
+       }
+
+       indent.Append(format);
+
+       String delimiter(L"-------------------------------------------------------------------------------------------");
+       SysSecureLog(NID_UI, "%ls", delimiter.GetPointer());
+
+       SysSecureLog(NID_UI, "%ls 0x%x(%d %ls)", indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer());
+
+       Tizen::Base::Collection::ArrayListT<void*>* pBacktraceList = null;
+
+       if (newBacktrace)
+       {
+               pBacktraceList = __pNewBacktrace.get();
+       }
+       else
+       {
+               pBacktraceList = __pDeleteBacktrace.get();
+       }
+
+       SysTryReturn(NID_UI, pBacktraceList, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int backtraceCount = pBacktraceList->GetCount();
+       SysTryReturn(NID_UI, backtraceCount > 0, 0, E_INVALID_ARG, "[E_INVALID_ARG].");
+
+       void** pBacktrace = new (std::nothrow) void*[backtraceCount];
+       SysTryReturn(NID_UI, pBacktrace, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       unique_ptr<IEnumeratorT<void*> > pEnumerator(pBacktraceList->GetEnumeratorN());
+       SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       int i = 0;
+       while (pEnumerator->MoveNext() == E_SUCCESS)
+       {
+               void* pAddr = null;
+               pEnumerator->GetCurrent(pAddr);
+
+               pBacktrace[i++] = pAddr;
+       }
+
+       char** pSymbols = backtrace_symbols(pBacktrace, backtraceCount);
+       SysTryReturn(NID_UI, pSymbols, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       for (int j = 0; j < backtraceCount; j++)
+       {
+               SysSecureLog(NID_UI, "%ls [%s]", indent.GetPointer(), pSymbols[j]);
+       }
+
+       free(pSymbols);
+       delete [] pBacktrace;
+
+       static int totalCount = 0;
+
+       if (depth == 0)
+       {
+               totalCount = 0;
+       }
+
+       if (printChildren)
+       {
+               depth ++;
+
+               int count = GetChildCount();
+               totalCount += count;
+
+               for (int i = count - 1; i >= 0; --i)
+               {
+                       _Control* pChild = GetChild(i);
+                       if (pChild)
+                       {
+                               pChild->PrintBacktrace(printChildren, depth, newBacktrace);
+                       }
+               }
+       }
+
+       return totalCount;
+}
+
+void
+_Control::DragAndDropBegin(const _DragAndDropItem& dragAndDropItem)
+{
+       _Window* pRootWindow = GetRootWindow();
+       if (!pRootWindow)
+       {
+               return;
+       }
+
+       __isDragAndDropSource = true;
+
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       if (!pEcoreEvas)
+       {
+               return;
+       }
+
+       pEcoreEvas->SetDragAndDropState(true);
+       pEcoreEvas->DragAndDropBegin(*pRootWindow, dragAndDropItem.GetData());
+       
+       __pDragWindow = GetControlDelegate().OnDragAndDropBeginning();
+}
+
+void
+_Control::DragAndDropDrop(void)
+{
+       _Window* pRootWindow = GetRootWindow();
+       if (!pRootWindow)
+       {
+               return;
+       }
+       
+       _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
+       pEcoreEvas->DragAndDropDrop(*pRootWindow);
+
+       GetControlDelegate().OnDragAndDropDropping();
+
+       // Check self drop.
+       Point dropPosition = pEcoreEvas->GetDropPosition();
+       Rectangle bounds = GetRootWindow()->GetBounds();
+       if (bounds.Contains(dropPosition))
+       {
+               _Control* pDropControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(dropPosition, true);
+               if (pDropControl)
+               {
+// Send dnd events to Source.
+#if 0
+                       if (pDropControl->IsDragAndDropSource() == false)
+#endif
+                       {
+                               int pid = pEcoreEvas->GetProcessId(pRootWindow->GetNativeHandle());
+                               String dropData = pEcoreEvas->GetDropData();
+                               SysLog(NID_UI, "[DND][S:%d] Call OnDragAndDropDropped(%ls) => %ls.", pid, dropData.GetPointer(), pDropControl->GetName().GetPointer());
+                               _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, dropData);
+                               pDropControl->GetControlDelegate().OnDragAndDropDropped(*pDragAndDropItem);
+                               delete pDragAndDropItem;
+                       }
+               }
+       }
+
+       __isDragAndDropSource = false;
+}
+
+_Window*
+_Control::GetDragWindow(void) const
+{
+       return __pDragWindow;
+}
+
+bool
+_Control::IsDragAndDropSource(void) const
+{
+       return __isDragAndDropSource;
+}
+
+_Window*
+_Control::OnDragAndDropBeginning(void)
+{
+       return null;
+}
+
+void
+_Control::OnDragAndDropDropping(void)
+{
+}
+
+void
+_Control::OnDragAndDropEntered(void)
+{
+}
+
+void
+_Control::OnDragAndDropMoved(const FloatPoint& position)
+{
+}
+
+void
+_Control::OnDragAndDropLeft(void)
+{
+}
+
+void
+_Control::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
+{
+}
+
 _ITouchEventPreviewer*
 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
 {
@@ -5494,11 +5622,11 @@ Tizen::Base::Collection::IListT<_Control*>*
 _Control::GetFocusListN(void) const
 {
        unique_ptr<IListT<_Control*> > pControlFocusList (new (std::nothrow) ArrayListT<_Control*>);
-       SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
        MakeFocusList(this, pControlFocusList.get());
 
        unique_ptr<IEnumeratorT<_Control*> > pEnum(pControlFocusList->GetEnumeratorN());
-       SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+       SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
        int i =0;
        int nextContainerIndex = -1;
        while (pEnum->MoveNext() == E_SUCCESS)
@@ -5533,4 +5661,3 @@ _Control::IsChildAttachable(_Control& child) const
 }
 
 }} // Tizen::Ui
-