Commit ac822cd6 authored by Tommy Martino's avatar Tommy Martino Committed by Commit Bot

[SH iOS] Roll deps to fix ambiguous cases

This CL rolls DEPS to the latest version of text-fragments-polyfill,
which fixes a few known issues:
- Link generation should fail if the range includes a block boundary.
- No highlight should be shown if the fragment is ambiguous (i.e., if
  it could correspond to multiple different places on the page).

This version changes the return type of a util function we are using, so
a small update to the Chromium-side JS is needed. (The function now
returns a list of ranges, rather than a list of <mark>s, and Chromium is
responsible for invoking the code to wrap these in <mark> tags.)

Bug: 1136043
Change-Id: Icf9c79dc0d9b9fca23f2826438e3c17c07340bec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511429Reviewed-by: default avatarSebastien Lalancette <seblalancette@chromium.org>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Tommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823367}
parent 19006ca0
......@@ -1428,7 +1428,7 @@ deps = {
Var('swiftshader_git') + '/SwiftShader.git' + '@' + Var('swiftshader_revision'),
'src/third_party/text-fragments-polyfill/src': {
'url': Var('chromium_git') + '/external/github.com/GoogleChromeLabs/text-fragments-polyfill.git' + '@' + '67c7cc58095686e5108f76fdcc6c0471cf171ce5',
'url': Var('chromium_git') + '/external/github.com/GoogleChromeLabs/text-fragments-polyfill.git' + '@' + '25a1809c179748f854f4bf0d8f9e47bc2646f5ed',
'condition': 'checkout_ios',
},
......
......@@ -42,17 +42,22 @@ const utils = goog.require(
for (const fragment of fragments) {
// Process the fragments, then filter out any that evaluate to false.
const newMarks = utils.processTextFragmentDirective(fragment)
const foundRanges = utils.processTextFragmentDirective(fragment)
.filter((mark) => { return !!mark });
if (Array.isArray(newMarks)) {
if (newMarks.length > 0) {
if (Array.isArray(foundRanges)) {
// If length < 1, then nothing was found. If length > 1, then the
// fragment in the URL is ambiguous (i.e., it could identify multiple
// different places on the page) so we discard it as well.
if (foundRanges.length === 1) {
++successCount;
}
let newMarks = utils.markRange(foundRanges[0]);
if (Array.isArray(newMarks)) {
marks.push(...newMarks);
}
}
}
}
if (scroll && marks.length > 0)
utils.scrollElementIntoView(marks[0]);
......
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