Skip to content

Commit

Permalink
[iOS] Convert fill_element_inference_util to TS
Browse files Browse the repository at this point in the history
To expedite the conversion process of the file, each function's
parameters and return type were set to any. In a follow up CL, each of
these any types will be converted to their true type values.

Bug: 1430814
Change-Id: I7e5d99a0f91c52eb7f0a151380c730ebc7178d5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939230
Commit-Queue: Daniel White <danieltwhite@google.com>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1211516}
  • Loading branch information
Daniel White authored and Chromium LUCI CQ committed Oct 18, 2023
1 parent 8bf5788 commit 184faf3
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 87 deletions.
2 changes: 1 addition & 1 deletion components/autofill/ios/form_util/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ compile_ts("fill_js_dependencies") {
"resources/create_fill_namespace.ts",
"resources/fill_constants.ts",
"resources/fill_element_inference.js",
"resources/fill_element_inference_util.js",
"resources/fill_element_inference_util.ts",
"resources/fill_util.js",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,25 @@ __gCrWeb.fill.inferLabelForElement = function(element) {
let inferredLabel;
if (__gCrWeb.fill.isCheckableElement(element)) {
inferredLabel = __gCrWeb.fill.inferLabelFromNext(element);
if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}
}

inferredLabel = __gCrWeb.fill.inferLabelFromPrevious(element);
if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}

// If we didn't find a label, check for the placeholder case.
inferredLabel = __gCrWeb.fill.inferLabelFromPlaceholder(element);
if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}

// If we didn't find a placeholder, check for the aria-label case.
inferredLabel = __gCrWeb.fill.getAriaLabel(element);
if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}

Expand All @@ -581,7 +581,7 @@ __gCrWeb.fill.inferLabelForElement = function(element) {
inferredLabel = __gCrWeb.fill.inferLabelFromDivTable(element);
} else if (tagName === 'TD') {
inferredLabel = __gCrWeb.fill.inferLabelFromTableColumn(element);
if (!inferenceUtil.IsLabelValid(inferredLabel)) {
if (!inferenceUtil.isLabelValid(inferredLabel)) {
inferredLabel = __gCrWeb.fill.inferLabelFromTableRow(element);
}
} else if (tagName === 'DD') {
Expand All @@ -592,13 +592,13 @@ __gCrWeb.fill.inferLabelForElement = function(element) {
break;
}

if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}
}
// If we didn't find a label, check for the value attribute case.
inferredLabel = __gCrWeb.fill.InferLabelFromValueAttr(element);
if (inferenceUtil.IsLabelValid(inferredLabel)) {
if (inferenceUtil.isLabelValid(inferredLabel)) {
return inferredLabel;
}

Expand Down

0 comments on commit 184faf3

Please sign in to comment.