COMMIT_MESSAGE

 12010-10-08 Mario Sanchez Prada <msanchez@igalia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 getTextAtOffset returns incorrect results if a link includes text and an image
 6 https://bugs.webkit.org/show_bug.cgi?id=47365
 7
 8 Properly consider text under a non-text renderer in textForObject.
 9
 10 We need to check all the children under a non-text renderer, if
 11 any, to consider when current object is not a text object but some
 12 of its children are, in order not to miss those portions of text
 13 by not properly handling those situations.
 14
 15 No new tests yet (TODO).
 16
 17 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
 18 (textForRenderer): New. Get the text for a RenderObject's children.
 19 (textForObject): Use the new textForRenderer function.

WebCore/ChangeLog

 12010-10-08 Mario Sanchez Prada <msanchez@igalia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 getTextAtOffset returns incorrect results if a link includes text and an image
 6 https://bugs.webkit.org/show_bug.cgi?id=47365
 7
 8 Properly consider text under a non-text renderer in textForObject.
 9
 10 We need to check all the children under a non-text renderer, if
 11 any, to consider when current object is not a text object but some
 12 of its children are, in order not to miss those portions of text
 13 by not properly handling those situations.
 14
 15 No new tests yet (TODO)
 16
 17 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
 18 (textForRenderer): New. Get the text for a RenderObject's children.
 19 (textForObject): Use the new textForRenderer function.
 20
1212010-09-30 Jochen Eisinger <jochen@chromium.org>
222
323 Reviewed by Jeremy Orlow.

WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

@@static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int fro
861861 return g_string_free(ret, FALSE);
862862}
863863
 864gchar* textForRenderer(RenderObject* renderer)
 865{
 866 GString* str = g_string_new(0);
 867
 868 if (!renderer)
 869 return g_string_free(str, FALSE);
 870
 871 // For RenderBlocks, piece together the text from the RenderText objects they contain.
 872 for (RenderObject* obj = renderer->firstChild(); obj; obj = obj->nextSibling()) {
 873 if (obj->isBR()) {
 874 g_string_append(str, "\n");
 875 continue;
 876 }
 877
 878 RenderText* renderText;
 879 if (obj->isText())
 880 renderText = toRenderText(obj);
 881 else {
 882 // We need to check children, if any, to consider when
 883 // current object is not a text object but some of its
 884 // children are, in order not to miss those portions of
 885 // text by not properly handling those situations
 886 if (obj->firstChild())
 887 g_string_append(str, textForRenderer(obj));
 888
 889 continue;
 890 }
 891
 892 InlineTextBox* box = renderText->firstTextBox();
 893 while (box) {
 894 gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
 895 g_string_append(str, text);
 896 // Newline chars in the source result in separate text boxes, so check
 897 // before adding a newline in the layout. See bug 25415 comment #78.
 898 // If the next sibling is a BR, we'll add the newline when we examine that child.
 899 if (!box->nextOnLineExists() && (!obj->nextSibling() || !obj->nextSibling()->isBR()))
 900 g_string_append(str, "\n");
 901 box = box->nextTextBox();
 902 }
 903 }
 904
 905 // Insert the text of the marker for list item in the right place, if present
 906 if (renderer->isListItem()) {
 907 String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
 908 if (renderer->style()->direction() == LTR)
 909 g_string_prepend(str, markerText.utf8().data());
 910 else
 911 g_string_append(str, markerText.utf8().data());
 912 }
 913
 914 return g_string_free(str, FALSE);
 915}
 916
864917gchar* textForObject(AccessibilityRenderObject* accObject)
865918{
866919 GString* str = g_string_new(0);

@@gchar* textForObject(AccessibilityRenderObject* accObject)
879932 g_string_append(str, "\n");
880933 range = accObject->doAXRangeForLine(++lineNumber);
881934 }
882  } else {
883  RenderObject* renderer = accObject->renderer();
884  if (!renderer)
885  return g_string_free(str, FALSE);
886 
887  // For RenderBlocks, piece together the text from the RenderText objects they contain.
888  for (RenderObject* obj = renderer->firstChild(); obj; obj = obj->nextSibling()) {
889  if (obj->isBR()) {
890  g_string_append(str, "\n");
891  continue;
892  }
893 
894  RenderText* renderText;
895  if (obj->isText())
896  renderText = toRenderText(obj);
897  else if (obj->firstChild() && obj->firstChild()->isText()) {
898  // Handle RenderInlines (and any other similiar RenderObjects).
899  renderText = toRenderText(obj->firstChild());
900  } else
901  continue;
902 
903  InlineTextBox* box = renderText->firstTextBox();
904  while (box) {
905  gchar* text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
906  g_string_append(str, text);
907  // Newline chars in the source result in separate text boxes, so check
908  // before adding a newline in the layout. See bug 25415 comment #78.
909  // If the next sibling is a BR, we'll add the newline when we examine that child.
910  if (!box->nextOnLineExists() && (!obj->nextSibling() || !obj->nextSibling()->isBR()))
911  g_string_append(str, "\n");
912  box = box->nextTextBox();
913  }
914  }
915 
916  // Insert the text of the marker for list item in the right place, if present
917  if (renderer->isListItem()) {
918  String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
919  if (renderer->style()->direction() == LTR)
920  g_string_prepend(str, markerText.utf8().data());
921  else
922  g_string_append(str, markerText.utf8().data());
923  }
924  }
 935 } else if (accObject->isAccessibilityRenderObject())
 936 g_string_append(str, textForRenderer(accObject->renderer()));
925937
926938 return g_string_free(str, FALSE);
927939}