Index: components/exo/display.cc |
diff --git a/components/exo/display.cc b/components/exo/display.cc |
index bb6a017bdbe294bc8a97f380a1dfa9ffbb76b26a..c6f51cd94ddd81ebb3b9778ccf516c8284f5eaf2 100644 |
--- a/components/exo/display.cc |
+++ b/components/exo/display.cc |
@@ -8,6 +8,7 @@ |
#include "base/trace_event/trace_event_argument.h" |
#include "components/exo/shared_memory.h" |
#include "components/exo/shell_surface.h" |
+#include "components/exo/sub_surface.h" |
#include "components/exo/surface.h" |
namespace exo { |
@@ -40,7 +41,30 @@ scoped_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { |
TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", |
surface->AsTracedValue()); |
+ if (surface->HasSurfaceDelegate()) { |
+ LOG(ERROR) << "Surface has already been assigned a role"; |
piman
2015/11/19 21:59:10
nit: DLOG here and below
reveman
2015/11/20 05:19:48
Done.
|
+ return nullptr; |
+ } |
+ |
return make_scoped_ptr(new ShellSurface(surface)); |
} |
+scoped_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, |
+ Surface* parent) { |
+ TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", |
+ surface->AsTracedValue(), "parent", parent->AsTracedValue()); |
+ |
+ if (surface == parent) { |
piman
2015/11/19 21:59:10
Is there a possibility that indirect cycles might
reveman
2015/11/20 05:19:48
Yes, that would cause bad behavior. I changed this
|
+ LOG(ERROR) << "Surface cannot be its own parent"; |
+ return nullptr; |
+ } |
+ |
+ if (surface->HasSurfaceDelegate()) { |
+ LOG(ERROR) << "Surface has already been assigned a role"; |
+ return nullptr; |
+ } |
+ |
+ return make_scoped_ptr(new SubSurface(surface, parent)); |
+} |
+ |
} // namespace exo |