Commit 5c3ba809 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Add general-purpose vlogs for ax_image_annotator.

This is enough to quickly check how many images it's trying to label
and what successes we got back. To use, run Chrome with:

--enable-logging=stderr --vmodule="*ax_image_annotator*=1"

Bug: 905419
Change-Id: If3ceedbbb1a4d673f2045319836046690ccf7ed9
Reviewed-on: https://chromium-review.googlesource.com/c/1493198
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636730}
parent 6cc10d03
......@@ -15,6 +15,7 @@
#include "third_party/blink/public/web/web_ax_object.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_node.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
......@@ -73,6 +74,8 @@ void AXImageAnnotator::OnImageAdded(blink::WebAXObject& image) {
image_id, image_info.GetImageProcessor(),
base::BindOnce(&AXImageAnnotator::OnImageAnnotated,
weak_factory_.GetWeakPtr(), image));
VLOG(1) << "Requesting annotation for " << image_id << " from page "
<< GetDocumentUrl();
}
void AXImageAnnotator::OnImageUpdated(blink::WebAXObject& image) {
......@@ -164,6 +167,8 @@ SkBitmap AXImageAnnotator::GetImageData(const blink::WebAXObject& image) {
if (node.IsNull() || !node.IsElementNode())
return SkBitmap();
blink::WebElement element = node.To<blink::WebElement>();
VLOG(1) << "Uploading pixels for " << element.ImageContents().width() << " x "
<< element.ImageContents().height() << " image";
return element.ImageContents();
}
......@@ -217,6 +222,15 @@ void AXImageAnnotator::OnImageAnnotated(
base::JoinString(contextualized_strings, base::ASCIIToUTF16(". ")));
image_annotations_.at(image.AxID()).set_annotation(contextualized_string);
render_accessibility_->MarkWebAXObjectDirty(image, false /* subtree */);
VLOG(1) << "Annotating image on page " << GetDocumentUrl() << " - "
<< contextualized_string;
}
std::string AXImageAnnotator::GetDocumentUrl() const {
const blink::WebLocalFrame* frame =
render_accessibility_->render_frame()->GetWebFrame();
return frame->GetDocument().Url().GetString().Utf8();
}
} // namespace content
......@@ -83,6 +83,9 @@ class AXImageAnnotator final : public base::CheckedObserver {
void OnImageAnnotated(const blink::WebAXObject& image,
image_annotation::mojom::AnnotateImageResultPtr result);
// Only for local logging when running with --v=1.
std::string GetDocumentUrl() const;
// Weak, owns us.
RenderAccessibilityImpl* const render_accessibility_;
......
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