Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chunhtai
Copy link
Contributor

Description

This PR rewire the dependency of these chromium code to be able to compile under the flutter.

Related Issues

flutter/flutter#23601

Tests

I added the following tests:

all the unittests are built and run in ci

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Reviewer Checklist

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@google-cla google-cla bot added the cla: yes label Dec 16, 2020
@chunhtai chunhtai requested review from dnfield and gw280 December 16, 2020 17:53
@dnfield
Copy link
Contributor

dnfield commented Dec 16, 2020

Trying to orient myself to this a bit - are there ways we could make this patch smaller and still have the same functionality?

For example, there's a large number of lines related to removing the mojom namespace. It seems like these are files that get generated in the Chromium repo but not ours - or perhaps they just live in a different component.

Is this something where we could just generate the files and check them in, or just add a namespace somewhere, or just create a new file with the expected members in the expected namespace?

I think that would make this patch easier to review, and make it a little more possible to compare this code to upstream as we go forward.

@gw280
Copy link
Contributor

gw280 commented Dec 16, 2020

There seems to be a lot of cosmetic changes in this which I'm not sure are necessary. For example, changing the header guards and namespaces. Is there a functional reason for these changes, or are they purely cosmetic?

@chunhtai
Copy link
Contributor Author

chunhtai commented Dec 16, 2020

@gw280 They are purely cosmetic. I feel keeping the ui namespace may be confusing because this does not related to ui.

Same thing for mojom namespace. are we ok with keeping the same namespace? Alternatively I can put up PR that is purely just namespace changes before this PR

@gw280
Copy link
Contributor

gw280 commented Dec 16, 2020

My vote would be to leave the namespaces as-is. The additional code churn will make it more difficult to cherry-pick changes from upstream.

ci/licenses.sh Outdated
local actualLicenseCount
actualLicenseCount="$(tail -n 1 flutter/ci/licenses_golden/licenses_flutter | tr -dc '0-9')"
local expectedLicenseCount=15 # When changing this number: Update the error message below as well describing all expected license types.
local expectedLicenseCount=12 # When changing this number: Update the error message below as well describing all expected license types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this simply a function of removing unused files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean by removing unused files. This make sure the license count does not change unexpectedly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is that this is that changes made in thsi patch are reducing the number of licenses we're including, so we're lowering this number.

Is that accurate? We've simply deleted files with different copyright years or whatever, so we no longer have as many?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is correct

@chunhtai
Copy link
Contributor Author

Reverted namespace header guard changes. ready for review

std::to_string(static_cast<int>(round(bounds.y()))) + ")-(" +
std::to_string(static_cast<int>(round(bounds.width()))) + ", " +
std::to_string(static_cast<int>(round(bounds.height()))) + ")";
// result += " transform=" + transform->ToString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code.

@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to completely rewrite this file because the upstream ax_platform_node_mac.mm is still WIP is not feature complete

// Please make sure that this ScopedObserver is always declared last in order
// to prevent any use-after-free.
ScopedObserver<AXTree, AXTreeObserver> tree_event_observer_{this};
// ScopedObserver<AXTree, AXTreeObserver> tree_event_observer_{this};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be removed?

imploded << tokens[i] << " | ";
}
}
return imploded.str();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to spin this out into a separate function


class AXTableInfo;
struct AXLanguageInfo;
// struct AXLanguageInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

//
// Returns nullptr if the node has no language info.
AXLanguageInfo* GetLanguageInfo() const;
// AXLanguageInfo* GetLanguageInfo() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

// This should only be called by LabelLanguageForSubtree and is used as part
// of the language detection feature.
void SetLanguageInfo(std::unique_ptr<AXLanguageInfo> lang_info);
// void SetLanguageInfo(std::unique_ptr<AXLanguageInfo> lang_info);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

return "kToken";
}

NOTREACHED();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE()

const AXTreeID& ax_tree_id) {
auto it = frame_to_ax_tree_id_map_.find(frame_id);
if (it != frame_to_ax_tree_id_map_.end()) {
NOTREACHED();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't realize we have that, thanks for reminding


NOTREACHED()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE()

@@ -1640,32 +1607,32 @@ int AXPlatformNodeBase::GetHypertextOffsetFromEndpoint(
if (endpoint_index_in_common_parent > index_in_common_parent)
return static_cast<int32_t>(GetHypertext().size());

NOTREACHED();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE()

}

NOTREACHED();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE()

Copy link
Contributor

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library is going to be used by embedder implementations and is not part of the core engine (vended via the Embedder API in //flutter/platform/embedder). Because of this, it cannot depend on internal engine libraries. Neither FML nor Skia is used today by embedder only libraries.

}

public_deps = [
"//flutter/fml",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML and Skia are engine internal libraries and may not be used by embedder implementations (or their dependencies).

deps = [
":accessibility",
":accessibility_fixtures",
"//flutter/testing",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an internal engine dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For unit test only target, do we need to worry about this?

@chunhtai
Copy link
Contributor Author

@chinmaygarde I am not familiar with the internal library dependency. I thought the embedder library also uses FML library?

@chinmaygarde
Copy link
Contributor

The public Embedder API is a single C header with no internal engine dependencies (see embedder.h). FML, Skia, and any of the libraries the engine uses internally are private implementation detail. Embedders are authored using just the stable interface defined in embedder.h. Imagine if the embedder were being authored out of tree, it would not have access to the engines Skia or FML libraries. The desktop embedders play by the same rules. You'll notice that none of the existing targets that are used by the embedder depend on Skia or FML.

@chunhtai chunhtai force-pushed the third_party branch 3 times, most recently from b4f4ae9 to a6b08b6 Compare December 21, 2020 21:45
@@ -1,608 +1,134 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to completely rewrite this class because the chromium uses skia to implement this class.

@chunhtai
Copy link
Contributor Author

@chinmaygarde @dnfield @gw280
I have rewritten the dependencies, This library does not depend on any non-std library now. I have also factored out a lot of string util so it should make the code a bit cleaner. This PR is ready for another look.

@gw280
Copy link
Contributor

gw280 commented Dec 29, 2020

A lot of the base types and classes seem to be mostly identical to std counterparts (e.g. base::Optional and std::optional). Would it be cleaner and reduce the amount of code churn if we just throw a bunch of using statements in a centralised header file somewhere? Not convinced whether it's the right direction to go down but would like to give it some thought.

@chunhtai
Copy link
Contributor Author

A lot of the base types and classes seem to be mostly identical to std counterparts (e.g. base::Optional and std::optional). Would it be cleaner and reduce the amount of code churn if we just throw a bunch of using statements in a centralised header file somewhere? Not convinced whether it's the right direction to go down but would like to give it some thought.

the two examples are base::Optional and base::string16. I have thought about this and I am a bit lean toward just replace them instead of using ... ... for two reasons:

  1. it is a simple enough change that is not too hard to cherry pick in the future
  2. the latter will make the code slightly confusing for other people to read the code, and it feel quite unnecessary.

That being said, those are not strong arguments. I am willing to change it if there are other good reason to do so

@gw280
Copy link
Contributor

gw280 commented Dec 29, 2020

That's reasonable. If it's just those two then let's just leave it.

@gw280 gw280 requested a review from cbracken January 5, 2021 23:39
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not review every line of this patch, but RSLGTM.

I think @chinmaygarde 's concerns have been addressed.

DOCUMENT_SELECTION_CHANGED,
DOCUMENT_TITLE_CHANGED,
DROPEFFECT_CHANGED,
// TODO(nektar): Deprecate this event and replace it with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these changes which have been pulled in from upstream? if so, is there a way we can separate those out as we can probably avoid reviewing them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted these change for now

@gw280
Copy link
Contributor

gw280 commented Jan 6, 2021

Sorry to be clear, I was mostly just curious where changes like that came from, rather than holding this up for merging. If Dan's ok with it, them it LGTM.

@chunhtai
Copy link
Contributor Author

chunhtai commented Jan 6, 2021

Since it won't affect the code and we can always pull it back if we need it in the future. The revert does make this pr less complex, i will continue merging with the revert.

@chunhtai chunhtai added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 6, 2021
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Mac Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants