Skip to content

Commit

Permalink
Rename setInputRegion API to setShape, and update impl accordingly.
Browse files Browse the repository at this point in the history
BUG=314222

Review URL: https://codereview.chromium.org/84323002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237528 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
wez@chromium.org committed Nov 27, 2013
1 parent 11a5ece commit 8e9dc84
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 37 deletions.
4 changes: 2 additions & 2 deletions apps/shell_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ void ShellWindow::SetAppIconUrl(const GURL& url) {
image_loader_ptr_factory_.GetWeakPtr()));
}

void ShellWindow::UpdateInputRegion(scoped_ptr<SkRegion> region) {
native_app_window_->UpdateInputRegion(region.Pass());
void ShellWindow::UpdateShape(scoped_ptr<SkRegion> region) {
native_app_window_->UpdateShape(region.Pass());
}

void ShellWindow::UpdateDraggableRegions(
Expand Down
5 changes: 2 additions & 3 deletions apps/shell_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ class ShellWindow : public content::NotificationObserver,
// Specifies a url for the launcher icon.
void SetAppIconUrl(const GURL& icon_url);

// Set the region in the window that will accept input events.
// If |region| is NULL, then the entire window will accept input events.
void UpdateInputRegion(scoped_ptr<SkRegion> region);
// Set the window shape. Passing a NULL |region| sets the default shape.
void UpdateShape(scoped_ptr<SkRegion> region);

// Called from the render interface to modify the draggable regions.
void UpdateDraggableRegions(
Expand Down
6 changes: 3 additions & 3 deletions apps/ui/native_app_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class NativeAppWindow : public ui::BaseWindow,
// Returns the region used by frameless windows for dragging. May return NULL.
virtual SkRegion* GetDraggableRegion() = 0;

// Called when the region that accepts input events is changed.
// If |region| is NULL, then the entire window will accept input events.
virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) = 0;
// Called when the window shape is changed. If |region| is NULL then the
// window is restored to the default shape.
virtual void UpdateShape(scoped_ptr<SkRegion> region) = 0;

// Allows the window to handle unhandled keyboard messages coming back from
// the renderer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace SetMinHeight = app_current_window_internal::SetMinHeight;
namespace SetMaxWidth = app_current_window_internal::SetMaxWidth;
namespace SetMaxHeight = app_current_window_internal::SetMaxHeight;
namespace SetIcon = app_current_window_internal::SetIcon;
namespace SetInputRegion = app_current_window_internal::SetInputRegion;
namespace SetShape = app_current_window_internal::SetShape;
namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop;

using apps::ShellWindow;
Expand Down Expand Up @@ -224,7 +224,7 @@ bool AppCurrentWindowInternalSetIconFunction::RunWithWindow(
return true;
}

bool AppCurrentWindowInternalSetInputRegionFunction::RunWithWindow(
bool AppCurrentWindowInternalSetShapeFunction::RunWithWindow(
ShellWindow* window) {

const char* whitelist[] = {
Expand All @@ -243,20 +243,20 @@ bool AppCurrentWindowInternalSetInputRegionFunction::RunWithWindow(
return false;
}

scoped_ptr<SetInputRegion::Params> params(
SetInputRegion::Params::Create(*args_));
const Region& inputRegion = params->region;
scoped_ptr<SetShape::Params> params(
SetShape::Params::Create(*args_));
const Region& shape = params->region;

// Build a region from the supplied list of rects.
// If |rects| is missing, then the input region is removed. This clears the
// input region so that the entire window accepts input events.
// To specify an empty input region (so the window ignores all input),
// |rects| should be an empty list.
scoped_ptr<SkRegion> region(new SkRegion);
if (inputRegion.rects) {
if (shape.rects) {
for (std::vector<linked_ptr<RegionRect> >::const_iterator i =
inputRegion.rects->begin();
i != inputRegion.rects->end();
shape.rects->begin();
i != shape.rects->end();
++i) {
const RegionRect& inputRect = **i;
int32_t x = inputRect.left;
Expand All @@ -271,7 +271,7 @@ bool AppCurrentWindowInternalSetInputRegionFunction::RunWithWindow(
region.reset(NULL);
}

window->UpdateInputRegion(region.Pass());
window->UpdateShape(region.Pass());

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ class AppCurrentWindowInternalSetIconFunction
virtual bool RunWithWindow(apps::ShellWindow* window) OVERRIDE;
};

class AppCurrentWindowInternalSetInputRegionFunction
class AppCurrentWindowInternalSetShapeFunction
: public AppCurrentWindowInternalExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("app.currentWindowInternal.setInputRegion",
APP_CURRENTWINDOWINTERNAL_SETINPUTREGION)
DECLARE_EXTENSION_FUNCTION("app.currentWindowInternal.setShape",
APP_CURRENTWINDOWINTERNAL_SETSHAPE)

protected:
virtual ~AppCurrentWindowInternalSetInputRegionFunction() {}
virtual ~AppCurrentWindowInternalSetShapeFunction() {}
virtual bool RunWithWindow(apps::ShellWindow* window) OVERRIDE;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ enum HistogramValue {
METRICSPRIVATE_GETVARIATIONPARAMS,
WEBVIEW_SETPERMISSION,
DESKTOPCAPTURE_CHOOSEDESKTOPMEDIA,
APP_CURRENTWINDOWINTERNAL_SETINPUTREGION,
APP_CURRENTWINDOWINTERNAL_SETSHAPE,
PROCESSES_GETPROCESSINFO,
PROCESSES_GETPROCESSIDFORTAB,
PROCESSES_TERMINATE,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow,
virtual bool IsDetached() const OVERRIDE;
virtual void UpdateWindowIcon() OVERRIDE;
virtual void UpdateWindowTitle() OVERRIDE;
virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
virtual SkRegion* GetDraggableRegion() OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
[window() setTitle:base::SysUTF16ToNSString(title)];
}

void NativeAppWindowCocoa::UpdateInputRegion(scoped_ptr<SkRegion> region) {
void NativeAppWindowCocoa::UpdateShape(scoped_ptr<SkRegion> region) {
NOTIMPLEMENTED();
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ SkRegion* NativeAppWindowGtk::GetDraggableRegion() {
return draggable_region_.get();
}

void NativeAppWindowGtk::UpdateInputRegion(scoped_ptr<SkRegion> region) {
void NativeAppWindowGtk::UpdateShape(scoped_ptr<SkRegion> region) {
NOTIMPLEMENTED();
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/apps/native_app_window_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NativeAppWindowGtk : public apps::NativeAppWindow,
virtual void UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
virtual SkRegion* GetDraggableRegion() OVERRIDE;
virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual bool IsFrameless() const OVERRIDE;
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/ui/views/apps/native_app_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,11 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
}

bool NativeAppWindowViews::WidgetHasHitTestMask() const {
return input_region_ != NULL;
return shape_ != NULL;
}

void NativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const {
input_region_->getBoundaryPath(mask);
shape_->getBoundaryPath(mask);
}

bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling(
Expand Down Expand Up @@ -970,12 +970,12 @@ SkRegion* NativeAppWindowViews::GetDraggableRegion() {
return draggable_region_.get();
}

void NativeAppWindowViews::UpdateInputRegion(scoped_ptr<SkRegion> region) {
input_region_ = region.Pass();
void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) {
shape_ = region.Pass();

#if defined(USE_AURA)
if (input_region_)
window_->SetShape(new SkRegion(*input_region_));
if (shape_)
window_->SetShape(new SkRegion(*shape_));
else
window_->SetShape(NULL);
#endif // defined(USE_AURA)
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/ui/views/apps/native_app_window_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
virtual void UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
virtual SkRegion* GetDraggableRegion() OVERRIDE;
virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual bool IsFrameless() const OVERRIDE;
Expand All @@ -205,9 +205,9 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
views::Widget* window_;
bool is_fullscreen_;

// The region of the window that accepts input events.
// If this is not set, then the entire window accepts input events.
scoped_ptr<SkRegion> input_region_;
// Custom shape of the window. If this is not set then the window has a
// default shape, usually rectangular.
scoped_ptr<SkRegion> shape_;

scoped_ptr<SkRegion> draggable_region_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
static void setMaxWidth(optional long maxWidth);
static void setMaxHeight(optional long maxHeight);
static void setIcon(DOMString icon_url);
static void setInputRegion(Region region);
static void setShape(Region region);
static void setAlwaysOnTop(boolean always_on_top);
};

Expand Down

0 comments on commit 8e9dc84

Please sign in to comment.