diff options
author | raymes <raymes@chromium.org> | 2015-02-08 18:36:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-09 02:36:36 +0000 |
commit | 8a9c0f30c6a73cc644da0a1a736f6bb0e6fd81b5 (patch) | |
tree | c17e6f8eb2fb851191f1d2e1180565170a183b50 /pdf | |
parent | 8533a5153222d72c6f5485581663db13f285bfaf (diff) | |
download | chromium_src-8a9c0f30c6a73cc644da0a1a736f6bb0e6fd81b5.zip chromium_src-8a9c0f30c6a73cc644da0a1a736f6bb0e6fd81b5.tar.gz chromium_src-8a9c0f30c6a73cc644da0a1a736f6bb0e6fd81b5.tar.bz2 |
Make the PDF viewer background color a property of the instance.
This simplifies how the background color is set and makes it work for
print preview.
BUG= 456621
Review URL: https://codereview.chromium.org/874663006
Cr-Commit-Position: refs/heads/master@{#315256}
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/instance.cc | 6 | ||||
-rw-r--r-- | pdf/instance.h | 1 | ||||
-rw-r--r-- | pdf/out_of_process_instance.cc | 16 | ||||
-rw-r--r-- | pdf/out_of_process_instance.h | 8 | ||||
-rw-r--r-- | pdf/pdf_engine.h | 8 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 18 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.h | 5 | ||||
-rw-r--r-- | pdf/preview_mode_client.cc | 5 | ||||
-rw-r--r-- | pdf/preview_mode_client.h | 1 |
9 files changed, 35 insertions, 33 deletions
diff --git a/pdf/instance.cc b/pdf/instance.cc index d348717..93daf6f 100644 --- a/pdf/instance.cc +++ b/pdf/instance.cc @@ -367,8 +367,6 @@ bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { CreatePageIndicator(IsPrintPreviewUrl(url)); - engine_->SetBackgroundColor(kBackgroundColor); - if (!full_) { // For PDFs embedded in a frame, we don't get the data automatically like we // do for full-frame loads. Start loading the data manually. @@ -2643,6 +2641,10 @@ bool Instance::IsPrintPreview() { return IsPrintPreviewUrl(url_); } +uint32 Instance::GetBackgroundColor() { + return kBackgroundColor; +} + int Instance::GetPageNumberToDisplay() { int page = engine_->GetMostVisiblePage(); if (IsPrintPreview() && !print_preview_page_numbers_.empty()) { diff --git a/pdf/instance.h b/pdf/instance.h index e5c2c5d..bdb5243 100644 --- a/pdf/instance.h +++ b/pdf/instance.h @@ -174,6 +174,7 @@ class Instance : public pp::InstancePrivate, void DocumentLoadProgress(uint32 available, uint32 doc_size) override; void FormTextFieldFocusChange(bool in_focus) override; bool IsPrintPreview() override; + uint32 GetBackgroundColor() override; // ControlOwner implementation. void OnEvent(uint32 control_id, uint32 event_id, void* data) override; diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index 0ccfa36..169a440 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -271,7 +271,8 @@ OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) recently_sent_find_update_(false), received_viewport_message_(false), did_call_start_loading_(false), - stop_scrolling_(false) { + stop_scrolling_(false), + background_color_(kBackgroundColor) { loader_factory_.Initialize(this); timer_factory_.Initialize(this); form_factory_.Initialize(this); @@ -348,10 +349,9 @@ bool OutOfProcessInstance::Init(uint32_t argc, } if (is_material) - engine_->SetBackgroundColor(kBackgroundColorMaterial); + background_color_ = kBackgroundColorMaterial; else - engine_->SetBackgroundColor(kBackgroundColor); - + background_color_ = kBackgroundColor; // TODO(raymes): This is a hack to ensure that if no headers are passed in // then we get the right MIME type. When the in process plugin is removed we @@ -675,7 +675,7 @@ void OutOfProcessInstance::OnPaint( if (first_paint_) { first_paint_ = false; pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); - FillRect(rect, engine_->GetBackgroundColor()); + FillRect(rect, background_color_); ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); } @@ -768,7 +768,7 @@ void OutOfProcessInstance::CalculateBackgroundParts() { // horizontal centering. BackgroundPart part = { pp::Rect(0, 0, left_width, bottom), - engine_->GetBackgroundColor() + background_color_ }; if (!part.location.IsEmpty()) background_parts_.push_back(part); @@ -1347,6 +1347,10 @@ bool OutOfProcessInstance::IsPrintPreview() { return IsPrintPreviewUrl(url_); } +uint32 OutOfProcessInstance::GetBackgroundColor() { + return background_color_; +} + void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, int dst_page_index) { if (!IsPrintPreview()) diff --git a/pdf/out_of_process_instance.h b/pdf/out_of_process_instance.h index eb30458..58e9b29 100644 --- a/pdf/out_of_process_instance.h +++ b/pdf/out_of_process_instance.h @@ -136,6 +136,7 @@ class OutOfProcessInstance : public pp::Instance, void DocumentLoadProgress(uint32 available, uint32 doc_size) override; void FormTextFieldFocusChange(bool in_focus) override; bool IsPrintPreview() override; + uint32 GetBackgroundColor() override; // PreviewModeClient::Client implementation. void PreviewDocumentLoadComplete() override; @@ -283,6 +284,9 @@ class OutOfProcessInstance : public pp::Instance, // Used for printing without re-entrancy issues. pp::CompletionCallbackFactory<OutOfProcessInstance> print_callback_factory_; + // The callback for receiving the password from the page. + scoped_ptr<pp::CompletionCallbackWithOutput<pp::Var> > password_callback_; + // True if we haven't painted the plugin viewport yet. bool first_paint_; @@ -339,8 +343,8 @@ class OutOfProcessInstance : public pp::Instance, // zooming the plugin so that flickering doesn't occur while zooming. bool stop_scrolling_; - // The callback for receiving the password from the page. - scoped_ptr<pp::CompletionCallbackWithOutput<pp::Var> > password_callback_; + // The background color of the PDF viewer. + uint32 background_color_; }; } // namespace chrome_pdf diff --git a/pdf/pdf_engine.h b/pdf/pdf_engine.h index e843459..befb1b8 100644 --- a/pdf/pdf_engine.h +++ b/pdf/pdf_engine.h @@ -173,6 +173,9 @@ class PDFEngine { // Returns true if the plugin has been opened within print preview. virtual bool IsPrintPreview() = 0; + + // Get the background color of the PDF. + virtual uint32 GetBackgroundColor() = 0; }; // Factory method to create an instance of the PDF Engine. @@ -246,11 +249,6 @@ class PDFEngine { // Returns number of copies to be printed. virtual int GetCopiesToPrint() = 0; - // Retrieve the background color of the PDF viewer. - virtual uint32 GetBackgroundColor() = 0; - // Set the background color of the PDF viewer. - virtual void SetBackgroundColor(uint32 background_color) = 0; - // Returns a VarArray of Bookmarks, each a VarDictionary containing the // following key/values: // - "title" - a string Var. diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 2990f40..294ab2f 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -600,7 +600,6 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) most_visible_page_(-1), called_do_document_action_(false), render_grayscale_(false), - background_color_(0), progressive_paint_timeout_(0), getting_password_(false) { find_factory_.Initialize(this); @@ -2368,14 +2367,6 @@ int PDFiumEngine::GetNumberOfPages() { return pages_.size(); } -uint32 PDFiumEngine::GetBackgroundColor() { - return background_color_; -} - -void PDFiumEngine::SetBackgroundColor(uint32 background_color) { - background_color_ = background_color; -} - pp::VarArray PDFiumEngine::GetBookmarks() { pp::VarDictionary dict = TraverseBookmarks(doc_, NULL); // The root bookmark contains no useful information. @@ -2947,7 +2938,7 @@ void PDFiumEngine::FillPageSides(int progressive_index) { FPDFBitmap_FillRect(bitmap, left.x() - dirty_in_screen.x(), left.y() - dirty_in_screen.y(), left.width(), - left.height(), background_color_); + left.height(), client_->GetBackgroundColor()); } if (page_rect.right() < document_size_.width()) { @@ -2961,7 +2952,7 @@ void PDFiumEngine::FillPageSides(int progressive_index) { FPDFBitmap_FillRect(bitmap, right.x() - dirty_in_screen.x(), right.y() - dirty_in_screen.y(), right.width(), - right.height(), background_color_); + right.height(), client_->GetBackgroundColor()); } // Paint separator. @@ -2973,7 +2964,7 @@ void PDFiumEngine::FillPageSides(int progressive_index) { FPDFBitmap_FillRect(bitmap, bottom.x() - dirty_in_screen.x(), bottom.y() - dirty_in_screen.y(), bottom.width(), - bottom.height(), background_color_); + bottom.height(), client_->GetBackgroundColor()); } void PDFiumEngine::PaintPageShadow(int progressive_index, @@ -3425,7 +3416,8 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc, // We need to check depth only to verify our copy of shadow matrix is correct. if (!page_shadow_.get() || page_shadow_->depth() != depth) - page_shadow_.reset(new ShadowMatrix(depth, factor, background_color_)); + page_shadow_.reset(new ShadowMatrix(depth, factor, + client_->GetBackgroundColor())); DCHECK(!image_data->is_null()); DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); diff --git a/pdf/pdfium/pdfium_engine.h b/pdf/pdfium/pdfium_engine.h index 331d37b..d7b4835 100644 --- a/pdf/pdfium/pdfium_engine.h +++ b/pdf/pdfium/pdfium_engine.h @@ -80,8 +80,6 @@ class PDFiumEngine : public PDFEngine, virtual bool HasPermission(DocumentPermission permission) const; virtual void SelectAll(); virtual int GetNumberOfPages(); - virtual uint32 GetBackgroundColor(); - virtual void SetBackgroundColor(uint32 backgroundColor); virtual pp::VarArray GetBookmarks(); virtual int GetNamedDestinationPage(const std::string& destination); virtual pp::VarDictionary GetNamedDestinations(); @@ -683,9 +681,6 @@ class PDFiumEngine : public PDFEngine, // Whether to render in grayscale or in color. bool render_grayscale_; - // Background color of the PDF. - uint32 background_color_; - // The link currently under the cursor. std::string link_under_cursor_; diff --git a/pdf/preview_mode_client.cc b/pdf/preview_mode_client.cc index 8b9919b..a315f88 100644 --- a/pdf/preview_mode_client.cc +++ b/pdf/preview_mode_client.cc @@ -159,4 +159,9 @@ bool PreviewModeClient::IsPrintPreview() { return false; } +uint32 PreviewModeClient::GetBackgroundColor() { + NOTREACHED(); + return 0; +} + } // namespace chrome_pdf diff --git a/pdf/preview_mode_client.h b/pdf/preview_mode_client.h index 0e766f9..a6e6467 100644 --- a/pdf/preview_mode_client.h +++ b/pdf/preview_mode_client.h @@ -67,6 +67,7 @@ class PreviewModeClient : public PDFEngine::Client { virtual void DocumentLoadProgress(uint32 available, uint32 doc_size); virtual void FormTextFieldFocusChange(bool in_focus); virtual bool IsPrintPreview(); + virtual uint32 GetBackgroundColor(); private: Client* client_; |