Don't crash when SimpleCache index is corrupt.
[chromium-blink-merge.git] / ui / views / focus_border.cc
blob68fd430750438c21f6cf2db37107f806965a5979
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/focus_border.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/rect.h"
9 #include "ui/views/view.h"
11 namespace views {
12 namespace {
13 class DashedFocusBorder : public FocusBorder {
14 public:
15 DashedFocusBorder(
16 int left_inset, int top_inset, int right_inset, int bottom_inset)
17 : left_inset_(left_inset),
18 top_inset_(top_inset),
19 right_inset_(right_inset),
20 bottom_inset_(bottom_inset) {
23 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
24 gfx::Rect rect(view.GetLocalBounds());
25 rect.Inset(left_inset_, top_inset_, right_inset_, bottom_inset_);
26 canvas->DrawFocusRect(rect);
29 private:
30 int left_inset_;
31 int top_inset_;
32 int right_inset_;
33 int bottom_inset_;
35 DISALLOW_COPY_AND_ASSIGN(DashedFocusBorder);
37 } // namespace
39 FocusBorder::~FocusBorder() {
42 // static
43 FocusBorder* FocusBorder::CreateDashedFocusBorder() {
44 return new DashedFocusBorder(0, 0, 0, 0);
47 // static
48 FocusBorder* FocusBorder::CreateDashedFocusBorder(
49 int left, int top, int right, int bottom) {
50 return new DashedFocusBorder(left, top, right, bottom);
53 FocusBorder::FocusBorder() {
56 } // namespace views