Revert "[unseasoned-pdf] Block 100% loading on PDF layout"
This reverts commit 76d6ade99f
.
Causes AnnotationsFeatureEnabled to fail on linux-chromeos-chrome. This
is a partial revert, due to some merge conflicts with later changes.
Bug: 1237952
Change-Id: I504d9a9471332eea265e9260c68d303866cd5839
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3131376
Commit-Queue: K. Moon <kmoon@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Auto-Submit: K. Moon <kmoon@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#916626}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
952798081e
commit
b2960260f1
@@ -412,7 +412,6 @@ if (enable_pdf) {
|
|||||||
":ppapi_migration",
|
":ppapi_migration",
|
||||||
"//base",
|
"//base",
|
||||||
"//ppapi/cpp:objects",
|
"//ppapi/cpp:objects",
|
||||||
"//testing/gmock",
|
|
||||||
"//testing/gtest",
|
"//testing/gtest",
|
||||||
"//third_party/blink/public/common:headers",
|
"//third_party/blink/public/common:headers",
|
||||||
"//ui/gfx:geometry_skia",
|
"//ui/gfx:geometry_skia",
|
||||||
|
@@ -327,6 +327,7 @@ void PdfViewPluginBase::DocumentLoadComplete() {
|
|||||||
SendAttachments();
|
SendAttachments();
|
||||||
SendBookmarks();
|
SendBookmarks();
|
||||||
SendMetadata();
|
SendMetadata();
|
||||||
|
SendLoadingProgress(/*percentage=*/100);
|
||||||
|
|
||||||
if (accessibility_state_ == AccessibilityState::kPending)
|
if (accessibility_state_ == AccessibilityState::kPending)
|
||||||
LoadAccessibility();
|
LoadAccessibility();
|
||||||
@@ -389,6 +390,7 @@ void PdfViewPluginBase::DocumentLoadProgress(uint32_t available,
|
|||||||
if (progress <= last_progress_sent_ + 1)
|
if (progress <= last_progress_sent_ + 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
last_progress_sent_ = progress;
|
||||||
SendLoadingProgress(progress);
|
SendLoadingProgress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +568,6 @@ void PdfViewPluginBase::ConsumeSaveToken(const std::string& token) {
|
|||||||
|
|
||||||
void PdfViewPluginBase::SendLoadingProgress(double percentage) {
|
void PdfViewPluginBase::SendLoadingProgress(double percentage) {
|
||||||
DCHECK(percentage == -1 || (percentage >= 0 && percentage <= 100));
|
DCHECK(percentage == -1 || (percentage >= 0 && percentage <= 100));
|
||||||
last_progress_sent_ = percentage;
|
|
||||||
|
|
||||||
base::Value message(base::Value::Type::DICTIONARY);
|
base::Value message(base::Value::Type::DICTIONARY);
|
||||||
message.SetStringKey("type", "loadProgress");
|
message.SetStringKey("type", "loadProgress");
|
||||||
@@ -1150,10 +1151,6 @@ void PdfViewPluginBase::HandleViewportMessage(const base::Value& message) {
|
|||||||
// TODO(crbug.com/1013800): Eliminate need to get document size from here.
|
// TODO(crbug.com/1013800): Eliminate need to get document size from here.
|
||||||
document_size_ = engine()->ApplyDocumentLayout(layout_options);
|
document_size_ = engine()->ApplyDocumentLayout(layout_options);
|
||||||
OnGeometryChanged(zoom_, device_scale_);
|
OnGeometryChanged(zoom_, device_scale_);
|
||||||
|
|
||||||
// Send 100% loading progress only after initial layout negotiated.
|
|
||||||
if (last_progress_sent_ < 100)
|
|
||||||
SendLoadingProgress(/*percentage=*/100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::PointF scroll_position(message.FindDoubleKey("xOffset").value(),
|
gfx::PointF scroll_position(message.FindDoubleKey("xOffset").value(),
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include "pdf/buildflags.h"
|
#include "pdf/buildflags.h"
|
||||||
#include "pdf/content_restriction.h"
|
#include "pdf/content_restriction.h"
|
||||||
#include "pdf/document_attachment_info.h"
|
#include "pdf/document_attachment_info.h"
|
||||||
#include "pdf/document_layout.h"
|
|
||||||
#include "pdf/document_metadata.h"
|
#include "pdf/document_metadata.h"
|
||||||
#include "pdf/pdf_engine.h"
|
#include "pdf/pdf_engine.h"
|
||||||
#include "pdf/ppapi_migration/callback.h"
|
#include "pdf/ppapi_migration/callback.h"
|
||||||
@@ -36,7 +35,6 @@ namespace chrome_pdf {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ::testing::ElementsAre;
|
|
||||||
using ::testing::IsEmpty;
|
using ::testing::IsEmpty;
|
||||||
using ::testing::SaveArg;
|
using ::testing::SaveArg;
|
||||||
|
|
||||||
@@ -338,6 +336,13 @@ base::Value CreateExpectedNoMetadataResponse() {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base::Value CreateExpectedLoadingProgressResponse() {
|
||||||
|
base::Value message(base::Value::Type::DICTIONARY);
|
||||||
|
message.SetStringKey("type", "loadProgress");
|
||||||
|
message.SetDoubleKey("progress", 100);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
base::Value CreateSaveRequestMessage(PdfViewPluginBase::SaveRequestType type,
|
base::Value CreateSaveRequestMessage(PdfViewPluginBase::SaveRequestType type,
|
||||||
const std::string& token) {
|
const std::string& token) {
|
||||||
base::Value message(base::Value::Type::DICTIONARY);
|
base::Value message(base::Value::Type::DICTIONARY);
|
||||||
@@ -374,8 +379,8 @@ class PdfViewPluginBaseTest : public testing::Test {
|
|||||||
class PdfViewPluginBaseWithEngineTest : public PdfViewPluginBaseTest {
|
class PdfViewPluginBaseWithEngineTest : public PdfViewPluginBaseTest {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
auto engine =
|
std::unique_ptr<TestPDFiumEngine> engine =
|
||||||
std::make_unique<testing::NiceMock<TestPDFiumEngine>>(&fake_plugin_);
|
std::make_unique<TestPDFiumEngine>(&fake_plugin_);
|
||||||
fake_plugin_.InitializeEngine(std::move(engine));
|
fake_plugin_.InitializeEngine(std::move(engine));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -532,7 +537,7 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
fake_plugin_.accessibility_state());
|
fake_plugin_.accessibility_state());
|
||||||
|
|
||||||
// Check all the sent messages.
|
// Check all the sent messages.
|
||||||
ASSERT_EQ(4u, fake_plugin_.sent_messages().size());
|
ASSERT_EQ(5u, fake_plugin_.sent_messages().size());
|
||||||
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
||||||
fake_plugin_.sent_messages()[0]);
|
fake_plugin_.sent_messages()[0]);
|
||||||
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
||||||
@@ -541,6 +546,8 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
||||||
fake_plugin_.sent_messages()[2]);
|
fake_plugin_.sent_messages()[2]);
|
||||||
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
||||||
|
EXPECT_EQ(CreateExpectedLoadingProgressResponse(),
|
||||||
|
fake_plugin_.sent_messages()[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
||||||
@@ -572,7 +579,7 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
fake_plugin_.accessibility_state());
|
fake_plugin_.accessibility_state());
|
||||||
|
|
||||||
// Check all the sent messages.
|
// Check all the sent messages.
|
||||||
ASSERT_EQ(4u, fake_plugin_.sent_messages().size());
|
ASSERT_EQ(5u, fake_plugin_.sent_messages().size());
|
||||||
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
||||||
fake_plugin_.sent_messages()[0]);
|
fake_plugin_.sent_messages()[0]);
|
||||||
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
||||||
@@ -581,6 +588,8 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
||||||
fake_plugin_.sent_messages()[2]);
|
fake_plugin_.sent_messages()[2]);
|
||||||
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
||||||
|
EXPECT_EQ(CreateExpectedLoadingProgressResponse(),
|
||||||
|
fake_plugin_.sent_messages()[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
||||||
@@ -604,7 +613,7 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
fake_plugin_.document_load_state());
|
fake_plugin_.document_load_state());
|
||||||
|
|
||||||
// Check all the sent messages.
|
// Check all the sent messages.
|
||||||
ASSERT_EQ(4u, fake_plugin_.sent_messages().size());
|
ASSERT_EQ(5u, fake_plugin_.sent_messages().size());
|
||||||
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
||||||
fake_plugin_.sent_messages()[0]);
|
fake_plugin_.sent_messages()[0]);
|
||||||
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
EXPECT_EQ(CreateExpectedAttachmentsResponse(),
|
||||||
@@ -613,6 +622,8 @@ TEST_F(PdfViewPluginBaseWithDocInfoTest,
|
|||||||
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
CreateExpectedBookmarksResponse(fake_plugin_.engine()->GetBookmarks()),
|
||||||
fake_plugin_.sent_messages()[2]);
|
fake_plugin_.sent_messages()[2]);
|
||||||
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
EXPECT_EQ(CreateExpectedMetadataResponse(), fake_plugin_.sent_messages()[3]);
|
||||||
|
EXPECT_EQ(CreateExpectedLoadingProgressResponse(),
|
||||||
|
fake_plugin_.sent_messages()[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithoutDocInfoTest, DocumentLoadCompletePostMessages) {
|
TEST_F(PdfViewPluginBaseWithoutDocInfoTest, DocumentLoadCompletePostMessages) {
|
||||||
@@ -630,11 +641,13 @@ TEST_F(PdfViewPluginBaseWithoutDocInfoTest, DocumentLoadCompletePostMessages) {
|
|||||||
|
|
||||||
// Check the sent messages when the document doesn't have any metadata,
|
// Check the sent messages when the document doesn't have any metadata,
|
||||||
// attachments or bookmarks.
|
// attachments or bookmarks.
|
||||||
ASSERT_EQ(2u, fake_plugin_.sent_messages().size());
|
ASSERT_EQ(3u, fake_plugin_.sent_messages().size());
|
||||||
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
EXPECT_EQ(CreateExpectedFormTextFieldFocusChangeResponse(),
|
||||||
fake_plugin_.sent_messages()[0]);
|
fake_plugin_.sent_messages()[0]);
|
||||||
EXPECT_EQ(CreateExpectedNoMetadataResponse(),
|
EXPECT_EQ(CreateExpectedNoMetadataResponse(),
|
||||||
fake_plugin_.sent_messages()[1]);
|
fake_plugin_.sent_messages()[1]);
|
||||||
|
EXPECT_EQ(CreateExpectedLoadingProgressResponse(),
|
||||||
|
fake_plugin_.sent_messages()[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseTest, DocumentLoadFailedWithNotifiedRenderFrame) {
|
TEST_F(PdfViewPluginBaseTest, DocumentLoadFailedWithNotifiedRenderFrame) {
|
||||||
@@ -875,66 +888,6 @@ TEST_F(PdfViewPluginBaseTest, HandleSetBackgroundColorMessage) {
|
|||||||
EXPECT_EQ(kNewBackgroundColor, fake_plugin_.GetBackgroundColor());
|
EXPECT_EQ(kNewBackgroundColor, fake_plugin_.GetBackgroundColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithEngineTest, HandleViewportMessageInitially) {
|
|
||||||
auto* engine = static_cast<TestPDFiumEngine*>(fake_plugin_.engine());
|
|
||||||
EXPECT_CALL(*engine, ApplyDocumentLayout(DocumentLayout::Options()));
|
|
||||||
|
|
||||||
fake_plugin_.HandleMessage(base::test::ParseJson(R"({
|
|
||||||
"type": "viewport",
|
|
||||||
"userInitiated": false,
|
|
||||||
"zoom": 1,
|
|
||||||
"layoutOptions": {
|
|
||||||
"defaultPageOrientation": 0,
|
|
||||||
"twoUpViewEnabled": false,
|
|
||||||
},
|
|
||||||
"xOffset": 0,
|
|
||||||
"yOffset": 0,
|
|
||||||
"pinchPhase": 0,
|
|
||||||
})"));
|
|
||||||
|
|
||||||
EXPECT_THAT(fake_plugin_.sent_messages(), ElementsAre(base::test::IsJson(R"({
|
|
||||||
"type": "loadProgress",
|
|
||||||
"progress": 100.0,
|
|
||||||
})")));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithEngineTest, HandleViewportMessageSubsequently) {
|
|
||||||
auto* engine = static_cast<TestPDFiumEngine*>(fake_plugin_.engine());
|
|
||||||
|
|
||||||
fake_plugin_.HandleMessage(base::test::ParseJson(R"({
|
|
||||||
"type": "viewport",
|
|
||||||
"userInitiated": false,
|
|
||||||
"zoom": 1,
|
|
||||||
"layoutOptions": {
|
|
||||||
"defaultPageOrientation": 0,
|
|
||||||
"twoUpViewEnabled": false,
|
|
||||||
},
|
|
||||||
"xOffset": 0,
|
|
||||||
"yOffset": 0,
|
|
||||||
"pinchPhase": 0,
|
|
||||||
})"));
|
|
||||||
fake_plugin_.clear_sent_messages();
|
|
||||||
|
|
||||||
DocumentLayout::Options two_up_options;
|
|
||||||
two_up_options.set_page_spread(DocumentLayout::PageSpread::kTwoUpOdd);
|
|
||||||
EXPECT_CALL(*engine, ApplyDocumentLayout(two_up_options));
|
|
||||||
|
|
||||||
fake_plugin_.HandleMessage(base::test::ParseJson(R"({
|
|
||||||
"type": "viewport",
|
|
||||||
"userInitiated": false,
|
|
||||||
"zoom": 1,
|
|
||||||
"layoutOptions": {
|
|
||||||
"defaultPageOrientation": 0,
|
|
||||||
"twoUpViewEnabled": true,
|
|
||||||
},
|
|
||||||
"xOffset": 0,
|
|
||||||
"yOffset": 0,
|
|
||||||
"pinchPhase": 0,
|
|
||||||
})"));
|
|
||||||
|
|
||||||
EXPECT_THAT(fake_plugin_.sent_messages(), IsEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(PdfViewPluginBaseWithEngineTest, GetContentRestrictions) {
|
TEST_F(PdfViewPluginBaseWithEngineTest, GetContentRestrictions) {
|
||||||
auto* engine = static_cast<TestPDFiumEngine*>(fake_plugin_.engine());
|
auto* engine = static_cast<TestPDFiumEngine*>(fake_plugin_.engine());
|
||||||
static constexpr int kContentRestrictionCutPaste =
|
static constexpr int kContentRestrictionCutPaste =
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include "pdf/document_metadata.h"
|
#include "pdf/document_metadata.h"
|
||||||
#include "pdf/pdf_engine.h"
|
#include "pdf/pdf_engine.h"
|
||||||
#include "pdf/pdfium/pdfium_engine.h"
|
#include "pdf/pdfium/pdfium_engine.h"
|
||||||
#include "testing/gmock/include/gmock/gmock.h"
|
|
||||||
#include "third_party/blink/public/common/input/web_mouse_event.h"
|
#include "third_party/blink/public/common/input/web_mouse_event.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
@@ -41,11 +40,6 @@ class TestPDFiumEngine : public PDFiumEngine {
|
|||||||
|
|
||||||
~TestPDFiumEngine() override;
|
~TestPDFiumEngine() override;
|
||||||
|
|
||||||
MOCK_METHOD(gfx::Size,
|
|
||||||
ApplyDocumentLayout,
|
|
||||||
(const DocumentLayout::Options&),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// Sets a scaled mouse event for testing.
|
// Sets a scaled mouse event for testing.
|
||||||
bool HandleInputEvent(const blink::WebInputEvent& scaled_event) override;
|
bool HandleInputEvent(const blink::WebInputEvent& scaled_event) override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user