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

Issue 2326933002: MacViews: Fix gn check fail for mac_views_browser on Aura dependencies. (Closed)

Created:
4 years, 3 months ago by Patti Lor
Modified:
4 years, 2 months ago
Reviewers:
tapted
CC:
chromium-reviews, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

MacViews: Fix gn check fail for mac_views_browser on Aura dependencies. GN doesn't know about preprocessor hash defines, so it fails on a gn check when these hash defines are false. In this case, USE_AURA is false on macOS, so GN doesn't add Aura dependencies as correctly specified in the BUILD files. But when running `gn check`, it sees the Aura #includes, not knowing it's actually wrapped in a preprocessor #ifdef. Make exceptions for these files by adding // nogncheck comments to skip gn checks on the lines inside these #ifdefs. BUG=644138

Patch Set 1 #

Patch Set 2 : Fix *all* the gn check errors. #

Patch Set 3 : Typo. #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+37 lines, -39 lines) Patch
M components/constrained_window/native_web_contents_modal_dialog_manager_views.cc View 1 chunk +5 lines, -5 lines 0 comments Download
M content/browser/browser_main_loop.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_guest.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M content/shell/browser/layout_test/layout_test_download_manager_delegate.cc View 1 1 chunk +3 lines, -3 lines 0 comments Download
M content/shell/browser/shell_download_manager_delegate.cc View 1 1 chunk +3 lines, -3 lines 0 comments Download
M ui/snapshot/screenshot_grabber.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/controls/button/custom_button.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/controls/button/custom_button_unittest.cc View 1 1 chunk +3 lines, -3 lines 0 comments Download
M ui/views/controls/button/menu_button_unittest.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M ui/views/controls/menu/menu_controller.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/controls/menu/menu_controller_unittest.cc View 1 2 chunks +3 lines, -5 lines 0 comments Download
M ui/views/controls/menu/menu_host.cc View 1 2 2 chunks +3 lines, -3 lines 1 comment Download
M ui/views/examples/examples_main.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/test/scoped_views_test_helper.cc View 1 1 chunk +1 line, -1 line 1 comment Download
M ui/views/views_test_suite.cc View 1 1 chunk +1 line, -1 line 2 comments Download
M ui/views/widget/widget_aura_utils.h View 1 1 chunk +1 line, -1 line 1 comment Download
M ui/views/widget/widget_unittest.cc View 1 1 chunk +2 lines, -2 lines 1 comment Download

Messages

Total messages: 16 (14 generated)
Patti Lor
Hi Trent, PTAL - this is a fix for all the targets using Aura and ...
4 years, 3 months ago (2016-09-19 01:24:19 UTC) #15
tapted
4 years, 3 months ago (2016-09-19 03:23:37 UTC) #16
I started at the bottom, so read these comments backwards :). Then I stopped at
menu_host.cc - you might see nice fixes for the others. But the approach should
probably be:
 - investigate widget_unittest.cc (see comment)
 - Send to sky@ to see how he feels about // nogncheck

nogncheck should usually be considered a last-resort. For this stuff, we need to
strike a balance -- it might not be worth restructuring things in these files to
handle non-aura cases, since we eventually do want aura on Mac, and then most of
this becomes unnecessary.

https://codereview.chromium.org/2326933002/diff/40001/ui/views/controls/menu/...
File ui/views/controls/menu/menu_host.cc (right):

https://codereview.chromium.org/2326933002/diff/40001/ui/views/controls/menu/...
ui/views/controls/menu/menu_host.cc:38: class PreMenuEventDispatchHandler :
public ui::EventHandler,
This should be moved to a file like
ui/views/controls/menu/pre_menu_event_dispatch_handler_aura.cc

https://codereview.chromium.org/2326933002/diff/40001/ui/views/test/scoped_vi...
File ui/views/test/scoped_views_test_helper.cc (right):

https://codereview.chromium.org/2326933002/diff/40001/ui/views/test/scoped_vi...
ui/views/test/scoped_views_test_helper.cc:33: ui::ContextFactory*
old_context_factory = nullptr;
This looks like it could easily be moved to ViewsTestHelperAura::SetUp() - this
block just needs to happen before the call to AuraTestHelper::SetUp(), and the
block below happens after.

https://codereview.chromium.org/2326933002/diff/40001/ui/views/views_test_sui...
File ui/views/views_test_suite.cc (right):

https://codereview.chromium.org/2326933002/diff/40001/ui/views/views_test_sui...
ui/views/views_test_suite.cc:19: #include <memory>
this is in the views_test_suite.h header, so redundant here

https://codereview.chromium.org/2326933002/diff/40001/ui/views/views_test_sui...
ui/views/views_test_suite.cc:50: env_ = aura::Env::CreateInstance();
Things using ViewsTestSuite probably also use ViewsTestHelper or AuraTestHelper,
both of which also use a unique_ptr<aura::Env>, but in a way that encapsulates
its use to aura-only files. It would be interesting to see if anything actually
relies on this... if it's only a couple of things, maybe they can be updated.
But if lots breaks, this should be kept. (an alternative could be to declare
something like

// views_test_suite.h
class ViewsTestSuite::PlatformPart {
 public:
  virtual ~PlatformPart() {}
  static unique_ptr<PlatformPart> Create();
 protected:
  PlatformPart() {} 
};

#if !defined(USE_AURA)
unique_ptr<ViewsTestSuite::PlatformPart> ViewsTestSuite::PlatformPart::Create()
{
  return MakeUnique(new PlatformPart);
}
#endif

views_test_suite_aura.cc
namespace {
class PlatformPartAura : public ViewsTestSuite::PlatformPart {
 / *etc */
};
}

unique_ptr<ViewsTestSuite::PlatformPart> ViewsTestSuite::PlatformPart::Create()
{
  return MakeUnique(new PlatformPartAura);
}



I think here, this would be a bit of overkill and // nogncheck is fine. However,
a similar pattern applied to the other cases could be an improvement to code
health.

https://codereview.chromium.org/2326933002/diff/40001/ui/views/widget/widget_...
File ui/views/widget/widget_aura_utils.h (right):

https://codereview.chromium.org/2326933002/diff/40001/ui/views/widget/widget_...
ui/views/widget/widget_aura_utils.h:9: #include "ui/wm/public/window_types.h" 
// nogncheck
yeah - this one doesn't feel right, since it's not inside an #ifdef guard.

I think the right fix for this is just to change bridged_native_widget.mm's
PositionWindowInScreenCoordinates() to switch based on Widget::InitParams::Type
so that it returns `true` for {FRAMELESS, POPUP, BUBBLE, DRAG}. The other types
should still be listed in the switch statement rather than having a default:
case - this helps mitigate the potential for the implementations to drift apart.

https://codereview.chromium.org/2326933002/diff/40001/ui/views/widget/widget_...
File ui/views/widget/widget_unittest.cc (right):

https://codereview.chromium.org/2326933002/diff/40001/ui/views/widget/widget_...
ui/views/widget/widget_unittest.cc:40: #include "ui/aura/window_tree_host.h"  //
nogncheck
So the "alternative" to // nogncheck is to move the code that requires these
headers into a separate file. We should investigate all the cases in this CL -
it might not make sense to do that in all cases, but widget_unittest is probably
a good place to try it out. For example, the tests here that rely on these aura
headers might:
 - belong instead in native_widget_aura_unittest.cc, OR
 - sill be widget tests, but aura-specific so belong in a new file like
widget_aura_unittest.cc, OR
 - need to be enabled on Mac but are missing the right abstraction (e.g. a
generic interface in widget_test.h [similar to IsNativeWindowVisible()] that is
implemented in widget_test_mac.mm and widget_test_aura.cc

Powered by Google App Engine
This is Rietveld 408576698