Commit 6c21f7a3 authored by Kevin Babbitt's avatar Kevin Babbitt Committed by Commit Bot

Normalize line endings when generating accessibility tree dumps

We already tolerate \r characters that exist in accessibility tree dump
files, but some PDFs have been observed to produce \r characters in the
generated "actual" tree dump, which can throw off the diff. This change
normalizes line endings when generating a tree dump.

Bug: 974397
Change-Id: I40f3f78398d890ef2f3536bfb0f807c455a96dbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1673840Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#672098}
parent 824eac1a
...@@ -101,6 +101,9 @@ void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( ...@@ -101,6 +101,9 @@ void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree(
if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos) if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos)
return; return;
// Normalize any Windows-style line endings by removing \r.
base::RemoveChars(line, base::ASCIIToUTF16("\r"), &line);
// Replace literal newlines with "<newline>" // Replace literal newlines with "<newline>"
base::ReplaceChars(line, base::ASCIIToUTF16("\n"), base::ReplaceChars(line, base::ASCIIToUTF16("\n"),
base::ASCIIToUTF16("<newline>"), &line); base::ASCIIToUTF16("<newline>"), &line);
......
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