Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / contents_layout_manager.cc
index 2d018bd..0e9fcb9 100644 (file)
@@ -18,11 +18,12 @@ ContentsLayoutManager::ContentsLayoutManager(
 ContentsLayoutManager::~ContentsLayoutManager() {
 }
 
-void ContentsLayoutManager::SetContentsViewInsets(const gfx::Insets& insets) {
-  if (insets_ == insets)
+void ContentsLayoutManager::SetContentsResizingStrategy(
+    const DevToolsContentsResizingStrategy& strategy) {
+  if (strategy_.Equals(strategy))
     return;
 
-  insets_ = insets;
+  strategy_.CopyFrom(strategy);
   if (host_)
     host_->InvalidateLayout();
 }
@@ -42,18 +43,27 @@ void ContentsLayoutManager::Layout(views::View* contents_container) {
   int top = active_top_margin_;
   int height = std::max(0, contents_container->height() - top);
   int width = contents_container->width();
-  devtools_view_->SetBounds(0, top, width, height);
-
-  int contents_width = std::max(0, width - insets_.width());
-  int contents_height = std::max(0, height - insets_.height());
-  contents_view_->SetBounds(
-      std::min(insets_.left(), width),
-      top + std::min(insets_.top(), height),
-      contents_width,
-      contents_height);
+
+  gfx::Size container_size(width, height);
+  gfx::Rect new_devtools_bounds;
+  gfx::Rect new_contents_bounds;
+
+  ApplyDevToolsContentsResizingStrategy(strategy_, container_size,
+      &new_devtools_bounds, &new_contents_bounds);
+  new_devtools_bounds.Offset(0, top);
+  new_contents_bounds.Offset(0, top);
+
+  // DevTools cares about the specific position, so we have to compensate RTL
+  // layout here.
+  new_devtools_bounds.set_x(host_->GetMirroredXForRect(new_devtools_bounds));
+  new_contents_bounds.set_x(host_->GetMirroredXForRect(new_contents_bounds));
+
+  devtools_view_->SetBoundsRect(new_devtools_bounds);
+  contents_view_->SetBoundsRect(new_contents_bounds);
 }
 
-gfx::Size ContentsLayoutManager::GetPreferredSize(views::View* host) {
+gfx::Size ContentsLayoutManager::GetPreferredSize(
+    const views::View* host) const {
   return gfx::Size();
 }