Commit 1c17236e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Avoid using directives in vector icon templates.

Such directives violate the style guide.  Instead pull in just the actual
vector commands, via individual using declarations, via a macro.

Bug: 82078
Change-Id: I0f3208916285d6e2788932302714e394f1d92d87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810618
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698693}
parent d30b5a3d
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "ash/components/shortcut_viewer/vector_icons/vector_icons.h" #include "ash/components/shortcut_viewer/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace keyboard_shortcut_viewer { namespace keyboard_shortcut_viewer {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} // namespace keyboard_shortcut_viewer } // namespace keyboard_shortcut_viewer
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "ash/public/cpp/app_list/vector_icons/vector_icons.h" #include "ash/public/cpp/app_list/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace app_list { namespace app_list {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} // namespace app_list } // namespace app_list
...@@ -5,20 +5,20 @@ ...@@ -5,20 +5,20 @@
// vector_icons.cc.template is used to generate vector_icons.cc. Edit the former // vector_icons.cc.template is used to generate vector_icons.cc. Edit the former
// rather than the latter. // rather than the latter.
#include "ash/public/cpp/vector_icons/vector_icons.h"
#include "base/logging.h"
#include "ui/gfx/vector_icon_types.h"
// Some of the icons in this target are passed over Mojo and thus rely on having // Some of the icons in this target are passed over Mojo and thus rely on having
// a unique ID, so make sure there's a prefix that won't be reused elsewhere. // a unique ID, so make sure there's a prefix that won't be reused elsewhere.
#define VECTOR_ICON_ID_PREFIX "ash_public::" #define VECTOR_ICON_ID_PREFIX "ash_public::"
#include "ash/public/cpp/vector_icons/vector_icons.h"
#include "base/logging.h"
#include "components/vector_icons/cc_macros.h" #include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h"
namespace ash { #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
using namespace gfx; namespace ash {
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace ash { namespace ash {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} // namespace ash } // namespace ash
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/animation/tween.h" #include "ui/gfx/animation/tween.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "chrome/browser/vr/vector_icons/vector_icons.h" #include "chrome/browser/vr/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace vr { namespace vr {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} // namespace vr } // namespace vr
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "components/omnibox/browser/vector_icons.h" #include "components/omnibox/browser/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace omnibox { namespace omnibox {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} }
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace vector_icons { namespace vector_icons {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} // namespace vector_icons } // namespace vector_icons
...@@ -11,55 +11,67 @@ ...@@ -11,55 +11,67 @@
namespace gfx { namespace gfx {
// This macro allows defining the list of commands in this file, then pulling
// them each in to the template files via using-declarations. Files which want
// to do this should do the following:
// #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
// DECLARE_VECTOR_COMMANDS
// The alternative would be to have the template files pull in the whole gfx
// namespace via using-directives, which is banned by the style guide.
#define DECLARE_VECTOR_COMMANDS \
/* A new <path> element. For the first path, this is assumed. */ \
DECLARE_VECTOR_COMMAND(NEW_PATH) \
/* Sets the alpha for the current path. */ \
DECLARE_VECTOR_COMMAND(PATH_COLOR_ALPHA) \
/* Sets the color for the current path. */ \
DECLARE_VECTOR_COMMAND(PATH_COLOR_ARGB) \
/* Sets the path to clear mode (Skia's kClear_Mode). */ \
DECLARE_VECTOR_COMMAND(PATH_MODE_CLEAR) \
/* By default, the path will be filled. This changes the paint action to */ \
/* stroke at the given width. */ \
DECLARE_VECTOR_COMMAND(STROKE) \
/* By default, a stroke has a round cap. This sets it to square. */ \
DECLARE_VECTOR_COMMAND(CAP_SQUARE) \
/* These correspond to pathing commands. */ \
DECLARE_VECTOR_COMMAND(MOVE_TO) \
DECLARE_VECTOR_COMMAND(R_MOVE_TO) \
DECLARE_VECTOR_COMMAND(ARC_TO) \
DECLARE_VECTOR_COMMAND(R_ARC_TO) \
DECLARE_VECTOR_COMMAND(LINE_TO) \
DECLARE_VECTOR_COMMAND(R_LINE_TO) \
DECLARE_VECTOR_COMMAND(H_LINE_TO) \
DECLARE_VECTOR_COMMAND(R_H_LINE_TO) \
DECLARE_VECTOR_COMMAND(V_LINE_TO) \
DECLARE_VECTOR_COMMAND(R_V_LINE_TO) \
DECLARE_VECTOR_COMMAND(CUBIC_TO) \
DECLARE_VECTOR_COMMAND(R_CUBIC_TO) \
DECLARE_VECTOR_COMMAND(CUBIC_TO_SHORTHAND) \
DECLARE_VECTOR_COMMAND(CIRCLE) \
DECLARE_VECTOR_COMMAND(ROUND_RECT) \
DECLARE_VECTOR_COMMAND(CLOSE) \
/* Sets the dimensions of the canvas in dip. */ \
DECLARE_VECTOR_COMMAND(CANVAS_DIMENSIONS) \
/* Sets a bounding rect for the path. This allows fine adjustment because */ \
/* it can tweak edge anti-aliasing. Args are x, y, w, h. */ \
DECLARE_VECTOR_COMMAND(CLIP) \
/* Disables anti-aliasing for this path. */ \
DECLARE_VECTOR_COMMAND(DISABLE_AA) \
/* Flips the x-axis in RTL locales. Default is false, this command sets */ \
/* it to true. */ \
DECLARE_VECTOR_COMMAND(FLIPS_IN_RTL) \
/* Defines a timed transition for other elements. */ \
DECLARE_VECTOR_COMMAND(TRANSITION_FROM) \
DECLARE_VECTOR_COMMAND(TRANSITION_TO) \
/* Parameters are delay (ms), duration (ms), and tween type */ \
/* (gfx::Tween::Type). */ \
DECLARE_VECTOR_COMMAND(TRANSITION_END)
#define DECLARE_VECTOR_COMMAND(x) x,
// A command to Skia. // A command to Skia.
enum CommandType { enum CommandType { DECLARE_VECTOR_COMMANDS };
// A new <path> element. For the first path, this is assumed.
NEW_PATH, #undef DECLARE_VECTOR_COMMAND
// Sets the alpha for the current path.
PATH_COLOR_ALPHA,
// Sets the color for the current path.
PATH_COLOR_ARGB,
// Sets the path to clear mode (Skia's kClear_Mode).
PATH_MODE_CLEAR,
// By default, the path will be filled. This changes the paint action to
// stroke at the given width.
STROKE,
// By default, a stroke has a round cap. This sets it to square.
CAP_SQUARE,
// These correspond to pathing commands.
MOVE_TO,
R_MOVE_TO,
ARC_TO,
R_ARC_TO,
LINE_TO,
R_LINE_TO,
H_LINE_TO,
R_H_LINE_TO,
V_LINE_TO,
R_V_LINE_TO,
CUBIC_TO,
R_CUBIC_TO,
CUBIC_TO_SHORTHAND,
CIRCLE,
ROUND_RECT,
CLOSE,
// Sets the dimensions of the canvas in dip.
CANVAS_DIMENSIONS,
// Sets a bounding rect for the path. This allows fine adjustment because it
// can tweak edge anti-aliasing. Args are x, y, w, h.
CLIP,
// Disables anti-aliasing for this path.
DISABLE_AA,
// Flips the x-axis in RTL locales. Default is false, this command sets it to
// true.
FLIPS_IN_RTL,
// Defines a timed transition for other elements.
TRANSITION_FROM,
TRANSITION_TO,
// Parameters are delay (ms), duration (ms), and tween type
// (gfx::Tween::Type).
TRANSITION_END,
};
// A POD that describes either a path command or an argument for it. // A POD that describes either a path command or an argument for it.
struct PathElement { struct PathElement {
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "ui/message_center/vector_icons.h" #include "ui/message_center/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace message_center { namespace message_center {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} }
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
#include "ui/views/vector_icons.h" #include "ui/views/vector_icons.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
#include "components/vector_icons/cc_macros.h" #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
namespace views { namespace views {
using namespace gfx;
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
} }
...@@ -11,9 +11,10 @@ ...@@ -11,9 +11,10 @@
#include "components/vector_icons/cc_macros.h" #include "components/vector_icons/cc_macros.h"
#include "ui/gfx/vector_icon_types.h" #include "ui/gfx/vector_icon_types.h"
namespace views { #define DECLARE_VECTOR_COMMAND(x) using gfx::x;
DECLARE_VECTOR_COMMANDS
using namespace gfx; namespace views {
TEMPLATE_PLACEHOLDER TEMPLATE_PLACEHOLDER
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment