Commit 724e08fe authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Don't pass preferred size from thumbnail capturing

Thumbnail capturing is a hidden capturer which should not have
side-effect. It should not prefer the capture size.

This CL is self-contained and tests by itself with the DCHECK in
WebContentsImpl::IncrementCapturerCount(). I've verified that all
callers now meet the requirement.

Also verified programatically that the thumbnail capturing won't cause
side effect of page rendering.

Bug: 1112607
Change-Id: I9f9618e75568cec02d48ddb4b73c43b6233b7fa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2380884Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803645}
parent b085ce5b
......@@ -64,10 +64,7 @@ class ScopedThumbnailCapture {
: web_contents_observer_(web_contents_observer) {
auto* const contents = web_contents_observer->web_contents();
if (contents) {
contents->IncrementCapturerCount(
gfx::ScaleToFlooredSize(GetMinimumThumbnailSize(),
kMinThumbnailScaleFactor),
/* stay_hidden */ true);
contents->IncrementCapturerCount(gfx::Size(), /* stay_hidden */ true);
captured_ = true;
}
}
......
......@@ -1700,10 +1700,14 @@ void WebContentsImpl::SetWasDiscarded(bool was_discarded) {
void WebContentsImpl::IncrementCapturerCount(const gfx::Size& capture_size,
bool stay_hidden) {
DCHECK(!is_being_destroyed_);
if (stay_hidden)
if (stay_hidden) {
// A hidden capture should not have side effect on the web contents, so it
// should not pass a non-empty |capture_size| which will cause side effect.
DCHECK(capture_size.IsEmpty());
++hidden_capturer_count_;
else
} else {
++visible_capturer_count_;
}
// Note: This provides a hint to upstream code to size the views optimally
// for quality (e.g., to avoid scaling).
......
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