Commit 41dca3ca authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Spaces getting eaten between words in rare cases

When two spans are separated by a line break, and the second span's text node
also begins with a line break, the space shown in the layout is not rendered
in the accessibility presentation.

The computation to determine if there is rendered space adjacent to a space-only
node must use the inline text boxes to get the most accurate representation
of what is ultimately rendered.

Bug: 821906
Change-Id: Ie81134a95a8878d22a370e97b330e0eae5101d67
Reviewed-on: https://chromium-review.googlesource.com/988375
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547589}
parent c7535dc3
...@@ -86,4 +86,33 @@ rootWebArea ...@@ -86,4 +86,33 @@ rootWebArea
++++staticText name=' ' ++++staticText name=' '
++++++inlineTextBox name=' ' ++++++inlineTextBox name=' '
++++staticText name='space' ++++staticText name='space'
++++++inlineTextBox name='space' ++++++inlineTextBox name='space'
\ No newline at end of file ++paragraph
++++staticText name='K4. Keep '
++++++inlineTextBox name='K4. Keep '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
++++staticText name='K5. Keep'
++++++inlineTextBox name='K5. Keep'
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
++++staticText name='K6. Keep '
++++++inlineTextBox name='K6. Keep '
++++staticText name='space'
++++++inlineTextBox name='space'
++paragraph
++++staticText name='K7. Keep'
++++++inlineTextBox name='K7. Keep'
++++staticText name=' space'
++++++inlineTextBox name=' space'
++paragraph
++++staticText name='K8. Keep'
++++++inlineTextBox name='K8. Keep'
++++staticText name=' '
++++++inlineTextBox name=' '
++++staticText name='space'
++++++inlineTextBox name='space'
...@@ -50,4 +50,21 @@ AXWebArea ...@@ -50,4 +50,21 @@ AXWebArea
++AXGroup ++AXGroup
++++AXStaticText AXValue='K3. Keep' ++++AXStaticText AXValue='K3. Keep'
++++AXStaticText AXValue=' ' ++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space' ++++AXStaticText AXValue='space'
\ No newline at end of file ++AXGroup
++++AXStaticText AXValue='K4. Keep '
++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='K5. Keep'
++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='K6. Keep '
++++AXStaticText AXValue='space'
++AXGroup
++++AXStaticText AXValue='K7. Keep'
++++AXStaticText AXValue=' space'
++AXGroup
++++AXStaticText AXValue='K8. Keep'
++++AXStaticText AXValue=' '
++++AXStaticText AXValue='space'
...@@ -50,4 +50,21 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ...@@ -50,4 +50,21 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++IA2_ROLE_PARAGRAPH ++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K3. Keep' ++++ROLE_SYSTEM_STATICTEXT name='K3. Keep'
++++ROLE_SYSTEM_STATICTEXT name=' ' ++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space' ++++ROLE_SYSTEM_STATICTEXT name='space'
\ No newline at end of file ++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K4. Keep '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K5. Keep'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K6. Keep '
++++ROLE_SYSTEM_STATICTEXT name='space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K7. Keep'
++++ROLE_SYSTEM_STATICTEXT name=' space'
++IA2_ROLE_PARAGRAPH
++++ROLE_SYSTEM_STATICTEXT name='K8. Keep'
++++ROLE_SYSTEM_STATICTEXT name=' '
++++ROLE_SYSTEM_STATICTEXT name='space'
...@@ -36,5 +36,26 @@ ...@@ -36,5 +36,26 @@
<p> <p>
<span>K3. Keep</span><i><b> </b></i><span>space</span> <span>K3. Keep</span><i><b> </b></i><span>space</span>
</p> </p>
</body>
</html> <!-- Blank line between spans and at end of first text node -->
<p><span>K4. Keep
</span>
<span>space</span></p>
<!-- Blank line between spans and at start of second text node-->
<p><span>K5. Keep</span>
<span>
space</span></p>
<!-- Blank line at end of first text node -->
<p><span>K6. Keep
</span><span>space</span></p>
<!-- Blank line at start of second text node -->
<p><span>K7. Keep</span><span>
space</span></p>
<!-- Blank line between spans -->
<p><span>K8. Keep</span>
<span>space</span></p>
</body></html>
...@@ -774,9 +774,14 @@ bool AXLayoutObject::CanIgnoreSpaceNextTo(LayoutObject* layout, ...@@ -774,9 +774,14 @@ bool AXLayoutObject::CanIgnoreSpaceNextTo(LayoutObject* layout,
LayoutText* layout_text = ToLayoutText(layout); LayoutText* layout_text = ToLayoutText(layout);
if (layout_text->HasEmptyText()) if (layout_text->HasEmptyText())
return false; return false;
auto text = layout_text->GetText().Impl(); if (layout_text->GetText().Impl()->ContainsOnlyWhitespace())
return true;
DCHECK(layout_text->HasTextBoxes());
InlineTextBox* adjacent =
is_after ? layout_text->FirstTextBox() : layout_text->LastTextBox();
auto text = adjacent->GetText();
auto adjacent_char = auto adjacent_char =
text->CharacterStartingAt(is_after ? 0 : text->length() - 1); text.CharacterStartingAt(is_after ? 0 : text.length() - 1);
return adjacent_char == ' ' || adjacent_char == '\n' || return adjacent_char == ' ' || adjacent_char == '\n' ||
adjacent_char == '\t'; adjacent_char == '\t';
} }
......
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