Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Unified Diff: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm

Issue 11028125: Remove legacy draggable region code and refactor to share common draggable region code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
index 70f678c1efc0d148a4832c0a7bc9c06b5ade2024..f9375e0f67de0217a02a72ac641c98a57d476e96 100644
--- a/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm
@@ -17,7 +17,6 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "third_party/skia/include/core/SkRegion.h"
@interface NSWindow (NSPrivateApis)
- (void)setBottomCornerRounded:(BOOL)rounded;
@@ -167,10 +166,8 @@
- (NSView*)hitTest:(NSPoint)aPoint {
if (shellWindow_->use_system_drag())
return nil;
- if (!shellWindow_->draggable_region() ||
- !shellWindow_->draggable_region()->contains(aPoint.x, aPoint.y)) {
+ if (!shellWindow_->IsInsideDraggableRegions(aPoint.x, aPoint.y))
return nil;
- }
return self;
}
@@ -190,8 +187,8 @@
ShellWindowCocoa::ShellWindowCocoa(ShellWindow* shell_window,
const ShellWindow::CreateParams& params)
- : shell_window_(shell_window),
- has_frame_(params.frame == ShellWindow::CreateParams::FRAME_CHROME),
+ : NativeShellWindow(params),
+ shell_window_(shell_window),
attention_request_id_(0),
use_system_drag_(true) {
// Flip coordinates based on the primary screen.
@@ -214,14 +211,14 @@ ShellWindowCocoa::ShellWindowCocoa(ShellWindow* shell_window,
NSMiniaturizableWindowMask | NSResizableWindowMask |
NSTexturedBackgroundWindowMask;
scoped_nsobject<NSWindow> window;
- if (has_frame_) {
- window.reset([[ShellNSWindow alloc]
+ if (frameless()) {
+ window.reset([[ShellFramelessNSWindow alloc]
initWithContentRect:cocoa_bounds
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO]);
} else {
- window.reset([[ShellFramelessNSWindow alloc]
+ window.reset([[ShellNSWindow alloc]
initWithContentRect:cocoa_bounds
styleMask:style_mask
backing:NSBackingStoreBuffered
@@ -250,7 +247,7 @@ ShellWindowCocoa::ShellWindowCocoa(ShellWindow* shell_window,
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
// By default, the whole frameless window is not draggable.
- if (!has_frame_) {
+ if (frameless()) {
gfx::Rect window_bounds(
0, 0, NSWidth(cocoa_bounds), NSHeight(cocoa_bounds));
system_drag_exclude_areas_.push_back(window_bounds);
@@ -270,10 +267,7 @@ ShellWindowCocoa::ShellWindowCocoa(ShellWindow* shell_window,
void ShellWindowCocoa::InstallView() {
NSView* view = web_contents()->GetView()->GetNativeView();
- if (has_frame_) {
- [view setFrame:[[window() contentView] bounds]];
- [[window() contentView] addSubview:view];
- } else {
+ if (frameless()) {
// TODO(jeremya): find a cleaner way to send this information to the
// WebContentsViewCocoa view.
DCHECK([view
@@ -289,6 +283,9 @@ void ShellWindowCocoa::InstallView() {
[[window() standardWindowButton:NSWindowCloseButton] setHidden:YES];
InstallDraggableRegionViews();
+ } else {
+ [view setFrame:[[window() contentView] bounds]];
+ [[window() contentView] addSubview:view];
}
}
@@ -464,7 +461,7 @@ void ShellWindowCocoa::UpdateWindowTitle() {
void ShellWindowCocoa::UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) {
// Draggable region is not supported for non-frameless window.
- if (has_frame_)
+ if (!frameless())
return;
// To use system drag, the window has to be marked as draggable with
@@ -583,36 +580,7 @@ void ShellWindowCocoa::UpdateDraggableRegionsForCustomDrag(
// Aggregate the draggable areas and non-draggable areas such that hit test
// could be performed easily.
- SkRegion* draggable_region = new SkRegion;
- for (std::vector<extensions::DraggableRegion>::const_iterator iter =
- regions.begin();
- iter != regions.end();
- ++iter) {
- const extensions::DraggableRegion& region = *iter;
- draggable_region->op(
- region.bounds.x(),
- region.bounds.y(),
- region.bounds.right(),
- region.bounds.bottom(),
- region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
- }
- draggable_region_.reset(draggable_region);
-}
-
-void ShellWindowCocoa::UpdateLegacyDraggableRegions(
- const std::vector<extensions::DraggableRegion>& regions) {
- // Draggable region is not supported for non-frameless window.
- if (has_frame_)
- return;
-
- system_drag_exclude_areas_.clear();
- for (std::vector<extensions::DraggableRegion>::const_iterator iter =
- regions.begin();
- iter != regions.end();
- ++iter) {
- system_drag_exclude_areas_.push_back(iter->bounds);
- }
- InstallDraggableRegionViews();
+ NativeShellWindow::UpdateDraggableRegions(regions);
}
void ShellWindowCocoa::HandleKeyboardEvent(
@@ -625,7 +593,7 @@ void ShellWindowCocoa::HandleKeyboardEvent(
}
void ShellWindowCocoa::InstallDraggableRegionViews() {
- DCHECK(!has_frame_);
+ DCHECK(frameless());
// All ControlRegionViews should be added as children of the WebContentsView,
// because WebContentsView will be removed and re-added when entering and

Powered by Google App Engine
This is Rietveld 408576698