Commit 72648da9 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Set VisualViewport size from SVG images

SVG images are hosted from their own Page object which has its own
VisualViewport. Currently, we don't set the size on the VisualViewport
in this configuration which breaks some functaionality in the class, for
example, the maximum scroll offset is wrong since the size is empty but
the FrameView's (the visual viewport's scrollable contents) isn't.

This doesn't cause issues at the moment because the visual viewport
isn't consulted in painting the SVG. However, with
blink-gen-property-trees turned on, the visual viewport will add its own
paint property nodes which can cause problems if the viewport's state is
inconsistent.

Bug: 840017
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: If62c0e18fa9a6eb9cfe7f059ff5604f262af82fd
Reviewed-on: https://chromium-review.googlesource.com/1096010
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566385}
parent 70e693f2
......@@ -37,6 +37,7 @@
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h"
......@@ -490,6 +491,7 @@ sk_sp<PaintRecord> SVGImage::PaintRecordForCurrentFrame(const IntRect& bounds,
DCHECK(page_);
LocalFrameView* view = ToLocalFrame(page_->MainFrame())->View();
view->Resize(ContainerSize());
page_->GetVisualViewport().SetSize(ContainerSize());
// Always call processUrlFragment, even if the url is empty, because
// there may have been a previous url/fragment that needs to be reset.
......
......@@ -242,6 +242,7 @@ class CORE_EXPORT SVGImage final : public Image {
Persistent<SVGImageLocalFrameClient> frame_client_;
FRIEND_TEST_ALL_PREFIXES(SVGImageTest, SupportsSubsequenceCaching);
FRIEND_TEST_ALL_PREFIXES(SVGImageTest, JankTrackerDisabled);
FRIEND_TEST_ALL_PREFIXES(SVGImageTest, SetSizeOnVisualViewport);
};
DEFINE_IMAGE_TYPE_CASTS(SVGImage);
......
......@@ -10,6 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/svg/graphics/svg_image_chrome_client.h"
......@@ -178,4 +179,19 @@ TEST_F(SVGImageTest, JankTrackerDisabled) {
EXPECT_FALSE(jank_tracker.IsActive());
}
TEST_F(SVGImageTest, SetSizeOnVisualViewport) {
const bool kDontPause = false;
Load(
"<svg xmlns='http://www.w3.org/2000/svg'>"
" <rect id='green' width='100%' height='100%' fill='green' />"
"</svg>",
kDontPause);
PumpFrame();
LocalFrame* local_frame =
ToLocalFrame(GetImage().GetPageForTesting()->MainFrame());
ASSERT_FALSE(local_frame->View()->VisibleContentRect().IsEmpty());
EXPECT_EQ(local_frame->View()->VisibleContentRect().Size(),
GetImage().GetPageForTesting()->GetVisualViewport().Size());
}
} // namespace blink
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