Skip to content

Commit

Permalink
Revert 198491 "Render opaque border with no shadow for web conte..."
Browse files Browse the repository at this point in the history
Broke the chromiumos bots:
http://build.chromium.org/p/chromium.chromiumos/builders/ChromiumOS%20%28daisy%29/builds/9294/steps/cbuildbot/logs/stdio

> Render opaque border with no shadow for web contents modal dialogs under Views/Win32 
> 
> This is a temporary kludge to get web contents modal dialog frames 
> displaying acceptably under Views/Win32. It's not possible to use 
> transparency in the frames on Win7 and earlier OSes unless the web 
> contents modal dialogs are top-level windows, which is undesirable. 
> Making web contents modal dialogs top-level imposes additional 
> complexities and burdens on managing focus, activation, and window 
> position relative to the browser window, soley for the View/Win32 case. 
> It's best to avoid this since we won't need it once we transition 
> to Aura. 
> 
> See screenshots at http://crbug.com/231012#c6. 
> 
> 
> BUG=231012, 166075
> 
> Review URL: https://chromiumcodereview.appspot.com/14742002

TBR=wittman@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198506 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tommi@chromium.org committed May 6, 2013
1 parent e4ad635 commit 5adc1a7
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 87 deletions.
21 changes: 2 additions & 19 deletions chrome/browser/ui/views/constrained_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "ui/gfx/path.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
#include "ui/views/border.h"
#include "ui/views/color_constants.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/focus/focus_manager.h"
Expand Down Expand Up @@ -116,15 +115,6 @@ class WebContentsModalDialogHostObserverViews
virtual void OnPositionRequiresUpdate() OVERRIDE {
gfx::Size size = target_widget_->GetWindowBoundsInScreen().size();
gfx::Point position = host_->GetDialogPosition(size);
views::Border* border =
target_widget_->non_client_view()->frame_view()->border();
// Border may be null during widget initialization.
if (border) {
// Align the first row of pixels inside the border. This is the apparent
// top of the dialog.
gfx::Insets border_insets = border->GetInsets();
position -= gfx::Vector2d(border_insets.left(), border_insets.top());
}
target_widget_->SetBounds(gfx::Rect(position, size));
}

Expand Down Expand Up @@ -680,15 +670,8 @@ views::Widget* CreateWebContentsModalDialogViews(
views::NonClientFrameView* CreateConstrainedStyleNonClientFrameView(
views::Widget* widget,
content::BrowserContext* browser_context) {
if (views::DialogDelegate::UseNewStyle()) {
#if defined(USE_AURA)
const bool force_opaque_border = false;
#else
const bool force_opaque_border = true;
#endif
return views::DialogDelegate::CreateNewStyleFrameView(widget,
force_opaque_border);
}
if (views::DialogDelegate::UseNewStyle())
return views::DialogDelegate::CreateNewStyleFrameView(widget);
#if defined(USE_ASH)
ConstrainedWindowFrameViewAsh* frame = new ConstrainedWindowFrameViewAsh;
frame->Init(widget);
Expand Down
4 changes: 0 additions & 4 deletions ui/views/bubble/bubble_border.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) {
set = new BorderImages(kShadowImages, kShadowArrows, 0, 0, 3);
break;
case BubbleBorder::NO_SHADOW:
case BubbleBorder::NO_SHADOW_OPAQUE_BORDER:
set = new BorderImages(kNoShadowImages, kNoShadowArrows, 6, 7, 4);
break;
case BubbleBorder::BIG_SHADOW:
Expand Down Expand Up @@ -333,9 +332,6 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
}

void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
canvas->DrawColor(border_->background_color());

// Clip out the client bounds to prevent overlapping transparent widgets.
if (!border_->client_bounds().IsEmpty()) {
SkRect client_rect(gfx::RectToSkRect(border_->client_bounds()));
Expand Down
1 change: 0 additions & 1 deletion ui/views/bubble/bubble_border.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class VIEWS_EXPORT BubbleBorder : public Border {
enum Shadow {
SHADOW = 0,
NO_SHADOW,
NO_SHADOW_OPAQUE_BORDER,
BIG_SHADOW,
SMALL_SHADOW,
SHADOW_COUNT,
Expand Down
38 changes: 1 addition & 37 deletions ui/views/bubble/bubble_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "grit/ui_resources.h"
#include "ui/base/hit_test.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/path.h"
#include "ui/gfx/screen.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/button/label_button.h"
Expand Down Expand Up @@ -97,42 +96,7 @@ int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
}

void BubbleFrameView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
return;

// Use a window mask roughly matching the border in the image assets.

// Stroke size in pixels of borders in image assets.
static const int kBorderStrokeSize = 1;

gfx::Insets border_insets = bubble_border_->GetInsets();
SkRect rect = {border_insets.left() - kBorderStrokeSize,
border_insets.top() - kBorderStrokeSize,
size.width() - border_insets.right() + kBorderStrokeSize,
size.height() - border_insets.bottom() + kBorderStrokeSize};

// Approximate rounded corners matching the border.
SkPoint polygon[] = {
{rect.left() + 2, rect.top()},
{rect.left() + 1, rect.top() + 1},
{rect.left(), rect.top() + 2},

{rect.left(), rect.bottom() - 3},
{rect.left() + 1, rect.bottom() - 2},
{rect.left() + 2, rect.bottom()},

{rect.right() - 3, rect.bottom()},
{rect.right() - 1, rect.bottom() - 2},
{rect.right(), rect.bottom() - 3},

{rect.right(), rect.top() + 2},
{rect.right() - 1, rect.top() + 1},
{rect.right() - 2, rect.top()}
};

window_mask->addPoly(polygon, sizeof(polygon)/sizeof(polygon[0]), true);
}
gfx::Path* window_mask) {}

void BubbleFrameView::ResetWindowControls() {}

Expand Down
20 changes: 2 additions & 18 deletions ui/views/window/dialog_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,11 @@ NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) {

// static
NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(Widget* widget) {
return CreateNewStyleFrameView(widget, false);
}

NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(
Widget* widget,
bool force_opaque_border) {
BubbleFrameView* frame = new BubbleFrameView(gfx::Insets());
const SkColor color = widget->GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_DialogBackground);
if (force_opaque_border) {
frame->SetBubbleBorder(new BubbleBorder(
BubbleBorder::NONE,
BubbleBorder::NO_SHADOW_OPAQUE_BORDER,
color));
} else {
frame->SetBubbleBorder(new BubbleBorder(BubbleBorder::FLOAT,
BubbleBorder::SMALL_SHADOW,
color));
}
frame->SetBubbleBorder(
new BubbleBorder(BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, color));
frame->SetTitle(widget->widget_delegate()->GetWindowTitle());
DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate();
if (delegate) {
Expand All @@ -180,8 +166,6 @@ NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(
}
frame->SetShowCloseButton(true);
frame->set_can_drag(true);
if (force_opaque_border)
widget->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM);
return frame;
}

Expand Down
8 changes: 0 additions & 8 deletions ui/views/window/dialog_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {

// Create a frame view using the new dialog style.
static NonClientFrameView* CreateNewStyleFrameView(Widget* widget);
// The semi-transparent border and shadow of the new style frame view does not
// work on child windows under Views/Win32. This is a kludge to get a
// reasonable-looking opaque border for the dialog. Note that this does not
// support arrows.
//
// TODO(wittman): Remove once WinAura is in place.
static NonClientFrameView* CreateNewStyleFrameView(Widget* widget,
bool force_opaque_border);

// Called when the window has been closed.
virtual void OnClose() {}
Expand Down

0 comments on commit 5adc1a7

Please sign in to comment.