Clang format pdf/
Review-Url: https://codereview.chromium.org/2828413005 Cr-Commit-Position: refs/heads/master@{#466403}
This commit is contained in:
pdf
chunk_stream.ccchunk_stream.hdocument_loader.ccdocument_loader.hdraw_utils.ccout_of_process_instance.ccout_of_process_instance.hpaint_aggregator.ccpaint_manager.ccpaint_manager.hpdf.cc
pdfium
pdfium_api_string_buffer_adapter.ccpdfium_engine.ccpdfium_engine.hpdfium_mem_buffer_file_read.ccpdfium_mem_buffer_file_write.ccpdfium_mem_buffer_file_write.hpdfium_page.ccpdfium_page.hpdfium_range.cc
preview_mode_client.cc@ -18,11 +18,9 @@
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
ChunkStream::ChunkStream() : stream_size_(0) {
|
||||
}
|
||||
ChunkStream::ChunkStream() : stream_size_(0) {}
|
||||
|
||||
ChunkStream::~ChunkStream() {
|
||||
}
|
||||
ChunkStream::~ChunkStream() {}
|
||||
|
||||
void ChunkStream::Clear() {
|
||||
chunks_.clear();
|
||||
@ -87,8 +85,9 @@ bool ChunkStream::ReadData(size_t offset, size_t size, void* buffer) const {
|
||||
}
|
||||
|
||||
bool ChunkStream::GetMissedRanges(
|
||||
size_t offset, size_t size,
|
||||
std::vector<std::pair<size_t, size_t> >* ranges) const {
|
||||
size_t offset,
|
||||
size_t size,
|
||||
std::vector<std::pair<size_t, size_t>>* ranges) const {
|
||||
if (IsRangeAvailable(offset, size))
|
||||
return false;
|
||||
|
||||
@ -125,8 +124,8 @@ bool ChunkStream::GetMissedRanges(
|
||||
|
||||
// Add last chunk.
|
||||
if (cur_offset < offset + size)
|
||||
ranges->push_back(std::pair<size_t, size_t>(cur_offset,
|
||||
offset + size - cur_offset));
|
||||
ranges->push_back(
|
||||
std::pair<size_t, size_t>(cur_offset, offset + size - cur_offset));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,8 +29,9 @@ class ChunkStream {
|
||||
bool ReadData(size_t offset, size_t size, void* buffer) const;
|
||||
|
||||
// Returns vector of pairs where first is an offset, second is a size.
|
||||
bool GetMissedRanges(size_t offset, size_t size,
|
||||
std::vector<std::pair<size_t, size_t> >* ranges) const;
|
||||
bool GetMissedRanges(size_t offset,
|
||||
size_t size,
|
||||
std::vector<std::pair<size_t, size_t>>* ranges) const;
|
||||
bool IsRangeAvailable(size_t offset, size_t size) const;
|
||||
size_t GetFirstMissingByte() const;
|
||||
|
||||
|
@ -80,31 +80,33 @@ bool ResponseStatusSuccess(const pp::URLLoader& loader) {
|
||||
}
|
||||
|
||||
bool IsValidContentType(const std::string& type) {
|
||||
return (base::EndsWith(type, "/pdf", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, ".pdf", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/x-pdf",
|
||||
base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/*", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/acrobat",
|
||||
base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/unknown",
|
||||
base::CompareCase::INSENSITIVE_ASCII));
|
||||
return base::EndsWith(type, "/pdf", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, ".pdf", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/x-pdf", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/*", base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/acrobat",
|
||||
base::CompareCase::INSENSITIVE_ASCII) ||
|
||||
base::EndsWith(type, "/unknown", base::CompareCase::INSENSITIVE_ASCII);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DocumentLoader::Client::~Client() {
|
||||
}
|
||||
DocumentLoader::Client::~Client() {}
|
||||
|
||||
DocumentLoader::DocumentLoader(Client* client)
|
||||
: client_(client), partial_document_(false), request_pending_(false),
|
||||
current_pos_(0), current_chunk_size_(0), current_chunk_read_(0),
|
||||
document_size_(0), header_request_(true), is_multipart_(false) {
|
||||
: client_(client),
|
||||
partial_document_(false),
|
||||
request_pending_(false),
|
||||
current_pos_(0),
|
||||
current_chunk_size_(0),
|
||||
current_chunk_read_(0),
|
||||
document_size_(0),
|
||||
header_request_(true),
|
||||
is_multipart_(false) {
|
||||
loader_factory_.Initialize(this);
|
||||
}
|
||||
|
||||
DocumentLoader::~DocumentLoader() {
|
||||
}
|
||||
DocumentLoader::~DocumentLoader() {}
|
||||
|
||||
bool DocumentLoader::Init(const pp::URLLoader& loader,
|
||||
const std::string& url,
|
||||
@ -181,8 +183,7 @@ bool DocumentLoader::Init(const pp::URLLoader& loader,
|
||||
|
||||
// Enable partial loading only if file size is above the threshold.
|
||||
// It will allow avoiding latency for multiple requests.
|
||||
if (content_length > kMinFileSize &&
|
||||
accept_ranges_bytes &&
|
||||
if (content_length > kMinFileSize && accept_ranges_bytes &&
|
||||
!content_encoded) {
|
||||
LoadPartialDocument();
|
||||
} else {
|
||||
@ -223,7 +224,7 @@ uint32_t DocumentLoader::GetAvailableData() const {
|
||||
return current_pos_;
|
||||
}
|
||||
|
||||
std::vector<std::pair<size_t, size_t> > ranges;
|
||||
std::vector<std::pair<size_t, size_t>> ranges;
|
||||
chunk_stream_.GetMissedRanges(0, document_size_, &ranges);
|
||||
uint32_t available = document_size_;
|
||||
for (const auto& range : ranges)
|
||||
@ -232,8 +233,7 @@ uint32_t DocumentLoader::GetAvailableData() const {
|
||||
}
|
||||
|
||||
void DocumentLoader::ClearPendingRequests() {
|
||||
pending_requests_.erase(pending_requests_.begin(),
|
||||
pending_requests_.end());
|
||||
pending_requests_.erase(pending_requests_.begin(), pending_requests_.end());
|
||||
}
|
||||
|
||||
bool DocumentLoader::GetBlock(uint32_t position,
|
||||
@ -266,7 +266,7 @@ void DocumentLoader::RequestData(uint32_t position, uint32_t size) {
|
||||
void DocumentLoader::RemoveCompletedRanges() {
|
||||
// Split every request that has been partially downloaded already into smaller
|
||||
// requests.
|
||||
std::vector<std::pair<size_t, size_t> > ranges;
|
||||
std::vector<std::pair<size_t, size_t>> ranges;
|
||||
auto it = pending_requests_.begin();
|
||||
while (it != pending_requests_.end()) {
|
||||
chunk_stream_.GetMissedRanges(it->first, it->second, &ranges);
|
||||
@ -416,7 +416,7 @@ void DocumentLoader::DidOpen(int32_t result) {
|
||||
|
||||
void DocumentLoader::ReadMore() {
|
||||
pp::CompletionCallback callback =
|
||||
loader_factory_.NewCallback(&DocumentLoader::DidRead);
|
||||
loader_factory_.NewCallback(&DocumentLoader::DidRead);
|
||||
int rv = loader_.ReadResponseBody(buffer_, sizeof(buffer_), callback);
|
||||
if (rv != PP_OK_COMPLETIONPENDING)
|
||||
callback.Run(rv);
|
||||
@ -515,7 +515,7 @@ void DocumentLoader::DidRead(int32_t result) {
|
||||
|
||||
bool DocumentLoader::SatisfyingRequest(size_t offset, size_t size) const {
|
||||
return offset <= current_pos_ + kDefaultRequestSize &&
|
||||
current_pos_ < offset + size;
|
||||
current_pos_ < offset + size;
|
||||
}
|
||||
|
||||
void DocumentLoader::ReadComplete() {
|
||||
|
@ -110,7 +110,7 @@ class DocumentLoader {
|
||||
ChunkStream chunk_stream_;
|
||||
bool partial_document_;
|
||||
bool request_pending_;
|
||||
typedef std::list<std::pair<size_t, size_t> > PendingRequests;
|
||||
typedef std::list<std::pair<size_t, size_t>> PendingRequests;
|
||||
PendingRequests pending_requests_;
|
||||
// The starting position of the HTTP request currently being processed.
|
||||
size_t current_request_offset_;
|
||||
@ -130,7 +130,7 @@ class DocumentLoader {
|
||||
bool is_multipart_;
|
||||
std::string multipart_boundary_;
|
||||
uint32_t requests_count_;
|
||||
std::vector<std::vector<unsigned char> > chunk_buffer_;
|
||||
std::vector<std::vector<unsigned char>> chunk_buffer_;
|
||||
};
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -36,9 +36,8 @@ inline uint32_t MakePixel(uint8_t red,
|
||||
uint8_t blue,
|
||||
uint8_t alpha) {
|
||||
return (static_cast<uint32_t>(alpha) << 24) |
|
||||
(static_cast<uint32_t>(red) << 16) |
|
||||
(static_cast<uint32_t>(green) << 8) |
|
||||
static_cast<uint32_t>(blue);
|
||||
(static_cast<uint32_t>(red) << 16) |
|
||||
(static_cast<uint32_t>(green) << 8) | static_cast<uint32_t>(blue);
|
||||
}
|
||||
|
||||
inline uint8_t ProcessColor(uint8_t src_color,
|
||||
@ -69,9 +68,9 @@ ShadowMatrix::ShadowMatrix(uint32_t depth, double factor, uint32_t background)
|
||||
for (uint32_t x = 0; x <= y; x++) {
|
||||
// Fill cache if needed.
|
||||
if (pow_pv[x] == 0.0)
|
||||
pow_pv[x] = pow(x, pv);
|
||||
pow_pv[x] = pow(x, pv);
|
||||
if (pow_pv[y] == 0.0)
|
||||
pow_pv[y] = pow(y, pv);
|
||||
pow_pv[y] = pow(y, pv);
|
||||
|
||||
// v - is a value for the smoothing function.
|
||||
// If x == 0 simplify calculations.
|
||||
@ -103,8 +102,7 @@ ShadowMatrix::ShadowMatrix(uint32_t depth, double factor, uint32_t background)
|
||||
}
|
||||
}
|
||||
|
||||
ShadowMatrix::~ShadowMatrix() {
|
||||
}
|
||||
ShadowMatrix::~ShadowMatrix() {}
|
||||
|
||||
void PaintShadow(pp::ImageData* image,
|
||||
const pp::Rect& clip_rc,
|
||||
@ -152,13 +150,13 @@ void DrawShadow(pp::ImageData* image,
|
||||
PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
|
||||
|
||||
// Fill bottom part.
|
||||
rc = pp::Rect(shadow_rc.x(), object_rc.bottom(),
|
||||
shadow_rc.width(), shadow_rc.bottom() - object_rc.bottom());
|
||||
rc = pp::Rect(shadow_rc.x(), object_rc.bottom(), shadow_rc.width(),
|
||||
shadow_rc.bottom() - object_rc.bottom());
|
||||
PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
|
||||
|
||||
// Fill left part.
|
||||
rc = pp::Rect(shadow_rc.x(), object_rc.y(),
|
||||
object_rc.x() - shadow_rc.x(), object_rc.height());
|
||||
rc = pp::Rect(shadow_rc.x(), object_rc.y(), object_rc.x() - shadow_rc.x(),
|
||||
object_rc.height());
|
||||
PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
|
||||
|
||||
// Fill right part.
|
||||
@ -168,4 +166,3 @@ void DrawShadow(pp::ImageData* image,
|
||||
}
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm> // for min/max()
|
||||
#include <algorithm> // for min/max()
|
||||
#define _USE_MATH_DEFINES // for M_PI
|
||||
#include <cmath> // for log() and pow()
|
||||
#include <math.h>
|
||||
#include <cmath> // for log() and pow()
|
||||
#include <list>
|
||||
|
||||
#include "base/logging.h"
|
||||
@ -177,8 +177,7 @@ PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) {
|
||||
}
|
||||
|
||||
void Transform(PP_Instance instance, PP_PrivatePageTransformType type) {
|
||||
void* object =
|
||||
pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface);
|
||||
void* object = pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface);
|
||||
if (object) {
|
||||
OutOfProcessInstance* obj_instance =
|
||||
static_cast<OutOfProcessInstance*>(object);
|
||||
@ -215,17 +214,15 @@ void EnableAccessibility(PP_Instance instance) {
|
||||
}
|
||||
|
||||
const PPP_Pdf ppp_private = {
|
||||
&GetLinkAtPosition,
|
||||
&Transform,
|
||||
&GetPrintPresetOptionsFromDocument,
|
||||
&EnableAccessibility,
|
||||
&GetLinkAtPosition, &Transform, &GetPrintPresetOptionsFromDocument,
|
||||
&EnableAccessibility,
|
||||
};
|
||||
|
||||
int ExtractPrintPreviewPageIndex(const std::string& src_url) {
|
||||
// Sample |src_url| format: chrome://print/id/page_index/print.pdf
|
||||
std::vector<std::string> url_substr = base::SplitString(
|
||||
src_url.substr(strlen(kChromePrint)), "/",
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
std::vector<std::string> url_substr =
|
||||
base::SplitString(src_url.substr(strlen(kChromePrint)), "/",
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
if (url_substr.size() != 3)
|
||||
return -1;
|
||||
|
||||
@ -267,7 +264,7 @@ pp::Var ModalDialog(const pp::Instance* instance,
|
||||
pp::Module::Get()->GetBrowserInterface(
|
||||
PPB_INSTANCE_PRIVATE_INTERFACE));
|
||||
pp::VarPrivate window(pp::PASS_REF,
|
||||
interface->GetWindowObject(instance->pp_instance()));
|
||||
interface->GetWindowObject(instance->pp_instance()));
|
||||
if (default_answer.empty())
|
||||
return window.Call(type, message);
|
||||
return window.Call(type, message, default_answer);
|
||||
@ -334,8 +331,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
|
||||
std::string document_url = document_url_var.AsString();
|
||||
base::StringPiece document_url_piece(document_url);
|
||||
is_print_preview_ = document_url_piece.starts_with(kChromePrint);
|
||||
if (!document_url_piece.starts_with(kChromeExtension) &&
|
||||
!is_print_preview_) {
|
||||
if (!document_url_piece.starts_with(kChromeExtension) && !is_print_preview_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -404,8 +400,7 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
|
||||
std::string type = dict.Get(kType).AsString();
|
||||
|
||||
if (type == kJSViewportType &&
|
||||
dict.Get(pp::Var(kJSXOffset)).is_number() &&
|
||||
if (type == kJSViewportType && dict.Get(pp::Var(kJSXOffset)).is_number() &&
|
||||
dict.Get(pp::Var(kJSYOffset)).is_number() &&
|
||||
dict.Get(pp::Var(kJSZoom)).is_number() &&
|
||||
dict.Get(pp::Var(kJSPinchPhase)).is_number()) {
|
||||
@ -466,24 +461,24 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
pinch_vector = pp::Point();
|
||||
last_bitmap_smaller_ = true;
|
||||
} else if (last_bitmap_smaller_) {
|
||||
pinch_center = pp::Point((plugin_size_.width() / device_scale_) / 2,
|
||||
(plugin_size_.height() / device_scale_) / 2);
|
||||
const double zoom_when_doc_covers_plugin_width =
|
||||
zoom_ * plugin_size_.width() / GetDocumentPixelWidth();
|
||||
paint_offset = pp::Point(
|
||||
(1 - zoom / zoom_when_doc_covers_plugin_width) * pinch_center.x(),
|
||||
(1 - zoom_ratio) * pinch_center.y());
|
||||
pinch_vector = pp::Point();
|
||||
scroll_delta =
|
||||
pp::Point((scroll_offset.x() -
|
||||
scroll_offset_at_last_raster_.x() * zoom_ratio),
|
||||
(scroll_offset.y() -
|
||||
scroll_offset_at_last_raster_.y() * zoom_ratio));
|
||||
pinch_center = pp::Point((plugin_size_.width() / device_scale_) / 2,
|
||||
(plugin_size_.height() / device_scale_) / 2);
|
||||
const double zoom_when_doc_covers_plugin_width =
|
||||
zoom_ * plugin_size_.width() / GetDocumentPixelWidth();
|
||||
paint_offset = pp::Point(
|
||||
(1 - zoom / zoom_when_doc_covers_plugin_width) * pinch_center.x(),
|
||||
(1 - zoom_ratio) * pinch_center.y());
|
||||
pinch_vector = pp::Point();
|
||||
scroll_delta =
|
||||
pp::Point((scroll_offset.x() -
|
||||
scroll_offset_at_last_raster_.x() * zoom_ratio),
|
||||
(scroll_offset.y() -
|
||||
scroll_offset_at_last_raster_.y() * zoom_ratio));
|
||||
}
|
||||
|
||||
paint_manager_.SetTransform(zoom_ratio, pinch_center,
|
||||
pinch_vector + paint_offset + scroll_delta,
|
||||
true);
|
||||
pinch_vector + paint_offset + scroll_delta,
|
||||
true);
|
||||
needs_reraster_ = false;
|
||||
return;
|
||||
}
|
||||
@ -559,8 +554,7 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
// isn't a print preview one.
|
||||
CHECK(IsPrintPreview());
|
||||
CHECK(IsPrintPreviewUrl(url));
|
||||
ProcessPreviewPageInfo(url,
|
||||
dict.Get(pp::Var(kJSPreviewPageIndex)).AsInt());
|
||||
ProcessPreviewPageInfo(url, dict.Get(pp::Var(kJSPreviewPageIndex)).AsInt());
|
||||
} else if (type == kJSStopScrollingType) {
|
||||
stop_scrolling_ = true;
|
||||
} else if (type == kJSGetSelectedTextType) {
|
||||
@ -585,8 +579,7 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
}
|
||||
}
|
||||
|
||||
bool OutOfProcessInstance::HandleInputEvent(
|
||||
const pp::InputEvent& event) {
|
||||
bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
// To simplify things, convert the event into device coordinates if it is
|
||||
// a mouse event.
|
||||
pp::InputEvent event_device_res(event);
|
||||
@ -597,15 +590,10 @@ bool OutOfProcessInstance::HandleInputEvent(
|
||||
pp::Point movement = mouse_event.GetMovement();
|
||||
ScalePoint(device_scale_, &point);
|
||||
ScalePoint(device_scale_, &movement);
|
||||
mouse_event = pp::MouseInputEvent(
|
||||
this,
|
||||
event.GetType(),
|
||||
event.GetTimeStamp(),
|
||||
event.GetModifiers(),
|
||||
mouse_event.GetButton(),
|
||||
point,
|
||||
mouse_event.GetClickCount(),
|
||||
movement);
|
||||
mouse_event =
|
||||
pp::MouseInputEvent(this, event.GetType(), event.GetTimeStamp(),
|
||||
event.GetModifiers(), mouse_event.GetButton(),
|
||||
point, mouse_event.GetClickCount(), movement);
|
||||
event_device_res = mouse_event;
|
||||
}
|
||||
}
|
||||
@ -622,13 +610,8 @@ bool OutOfProcessInstance::HandleInputEvent(
|
||||
pp::Point point = mouse_event.GetPosition();
|
||||
point.set_x(point.x() - available_area_.x());
|
||||
offset_event = pp::MouseInputEvent(
|
||||
this,
|
||||
event.GetType(),
|
||||
event.GetTimeStamp(),
|
||||
event.GetModifiers(),
|
||||
mouse_event.GetButton(),
|
||||
point,
|
||||
mouse_event.GetClickCount(),
|
||||
this, event.GetType(), event.GetTimeStamp(), event.GetModifiers(),
|
||||
mouse_event.GetButton(), point, mouse_event.GetClickCount(),
|
||||
mouse_event.GetMovement());
|
||||
break;
|
||||
}
|
||||
@ -663,14 +646,11 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) {
|
||||
|
||||
paint_manager_.SetSize(view_device_size, device_scale_);
|
||||
|
||||
pp::Size new_image_data_size = PaintManager::GetNewContextSize(
|
||||
image_data_.size(),
|
||||
plugin_size_);
|
||||
pp::Size new_image_data_size =
|
||||
PaintManager::GetNewContextSize(image_data_.size(), plugin_size_);
|
||||
if (new_image_data_size != image_data_.size()) {
|
||||
image_data_ = pp::ImageData(this,
|
||||
PP_IMAGEDATAFORMAT_BGRA_PREMUL,
|
||||
new_image_data_size,
|
||||
false);
|
||||
image_data_ = pp::ImageData(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
|
||||
new_image_data_size, false);
|
||||
first_paint_ = true;
|
||||
}
|
||||
|
||||
@ -725,8 +705,8 @@ void OutOfProcessInstance::LoadAccessibility() {
|
||||
doc_info.page_count = engine_->GetNumberOfPages();
|
||||
doc_info.text_accessible = PP_FromBool(
|
||||
engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE));
|
||||
doc_info.text_copyable = PP_FromBool(
|
||||
engine_->HasPermission(PDFEngine::PERMISSION_COPY));
|
||||
doc_info.text_copyable =
|
||||
PP_FromBool(engine_->HasPermission(PDFEngine::PERMISSION_COPY));
|
||||
|
||||
pp::PDF::SetAccessibilityDocInfo(GetPluginInstance(), &doc_info);
|
||||
|
||||
@ -789,10 +769,9 @@ void OutOfProcessInstance::SendNextAccessibilityPage(int32_t page_index) {
|
||||
// can be computed from the bounds of the text run.
|
||||
pp::FloatRect char_bounds = engine_->GetCharBounds(page_index, char_index);
|
||||
for (uint32_t i = 0; i < text_run_info.len - 1; i++) {
|
||||
DCHECK_LT(char_index + i + 1,
|
||||
static_cast<uint32_t>(char_count));
|
||||
pp::FloatRect next_char_bounds = engine_->GetCharBounds(
|
||||
page_index, char_index + i + 1);
|
||||
DCHECK_LT(char_index + i + 1, static_cast<uint32_t>(char_count));
|
||||
pp::FloatRect next_char_bounds =
|
||||
engine_->GetCharBounds(page_index, char_index + i + 1);
|
||||
chars[char_index + i].char_width = next_char_bounds.x() - char_bounds.x();
|
||||
char_bounds = next_char_bounds;
|
||||
}
|
||||
@ -821,8 +800,7 @@ void OutOfProcessInstance::SendAccessibilityViewportInfo() {
|
||||
pp::PDF::SetAccessibilityViewportInfo(GetPluginInstance(), &viewport_info);
|
||||
}
|
||||
|
||||
pp::Var OutOfProcessInstance::GetLinkAtPosition(
|
||||
const pp::Point& point) {
|
||||
pp::Var OutOfProcessInstance::GetLinkAtPosition(const pp::Point& point) {
|
||||
pp::Point offset_point(point);
|
||||
ScalePoint(device_scale_, &offset_point);
|
||||
offset_point.set_x(offset_point.x() - available_area_.x());
|
||||
@ -889,10 +867,9 @@ void OutOfProcessInstance::StopFind() {
|
||||
SetTickmarks(tickmarks_);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::OnPaint(
|
||||
const std::vector<pp::Rect>& paint_rects,
|
||||
std::vector<PaintManager::ReadyRect>* ready,
|
||||
std::vector<pp::Rect>* pending) {
|
||||
void OutOfProcessInstance::OnPaint(const std::vector<pp::Rect>& paint_rects,
|
||||
std::vector<PaintManager::ReadyRect>* ready,
|
||||
std::vector<pp::Rect>* pending) {
|
||||
if (image_data_.is_null()) {
|
||||
DCHECK(plugin_size_.IsEmpty());
|
||||
return;
|
||||
@ -912,8 +889,7 @@ void OutOfProcessInstance::OnPaint(
|
||||
for (const auto& paint_rect : paint_rects) {
|
||||
// Intersect with plugin area since there could be pending invalidates from
|
||||
// when the plugin area was larger.
|
||||
pp::Rect rect =
|
||||
paint_rect.Intersect(pp::Rect(pp::Point(), plugin_size_));
|
||||
pp::Rect rect = paint_rect.Intersect(pp::Rect(pp::Point(), plugin_size_));
|
||||
if (rect.IsEmpty())
|
||||
continue;
|
||||
|
||||
@ -936,8 +912,9 @@ void OutOfProcessInstance::OnPaint(
|
||||
}
|
||||
|
||||
// Ensure the region above the first page (if any) is filled;
|
||||
int32_t first_page_ypos = engine_->GetNumberOfPages() == 0 ?
|
||||
0 : engine_->GetPageScreenRect(0).y();
|
||||
int32_t first_page_ypos = engine_->GetNumberOfPages() == 0
|
||||
? 0
|
||||
: engine_->GetPageScreenRect(0).y();
|
||||
if (rect.y() < first_page_ypos) {
|
||||
pp::Rect region = rect.Intersect(pp::Rect(
|
||||
pp::Point(), pp::Size(plugin_size_.width(), first_page_ypos)));
|
||||
@ -964,7 +941,7 @@ void OutOfProcessInstance::DidOpen(int32_t result) {
|
||||
document_load_state_ = LOAD_STATE_LOADING;
|
||||
DocumentLoadFailed();
|
||||
}
|
||||
} else if (result != PP_ERROR_ABORTED) { // Can happen in tests.
|
||||
} else if (result != PP_ERROR_ABORTED) { // Can happen in tests.
|
||||
NOTREACHED();
|
||||
DocumentLoadFailed();
|
||||
}
|
||||
@ -1002,17 +979,14 @@ void OutOfProcessInstance::CalculateBackgroundParts() {
|
||||
|
||||
// Add the left, right, and bottom rectangles. Note: we assume only
|
||||
// horizontal centering.
|
||||
BackgroundPart part = {
|
||||
pp::Rect(0, 0, left_width, bottom),
|
||||
background_color_
|
||||
};
|
||||
BackgroundPart part = {pp::Rect(0, 0, left_width, bottom), background_color_};
|
||||
if (!part.location.IsEmpty())
|
||||
background_parts_.push_back(part);
|
||||
part.location = pp::Rect(right_start, 0, right_width, bottom);
|
||||
if (!part.location.IsEmpty())
|
||||
background_parts_.push_back(part);
|
||||
part.location = pp::Rect(
|
||||
0, bottom, plugin_size_.width(), plugin_size_.height() - bottom);
|
||||
part.location =
|
||||
pp::Rect(0, bottom, plugin_size_.width(), plugin_size_.height() - bottom);
|
||||
if (!part.location.IsEmpty())
|
||||
background_parts_.push_back(part);
|
||||
}
|
||||
@ -1036,7 +1010,7 @@ void OutOfProcessInstance::FillRect(const pp::Rect& rect, uint32_t color) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x)
|
||||
*(ptr + x) = color;
|
||||
ptr += stride /4;
|
||||
ptr += stride / 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1116,14 +1090,15 @@ void OutOfProcessInstance::UpdateCursor(PP_CursorType_Dev cursor) {
|
||||
|
||||
const PPB_CursorControl_Dev* cursor_interface =
|
||||
reinterpret_cast<const PPB_CursorControl_Dev*>(
|
||||
pp::Module::Get()->GetBrowserInterface(PPB_CURSOR_CONTROL_DEV_INTERFACE));
|
||||
pp::Module::Get()->GetBrowserInterface(
|
||||
PPB_CURSOR_CONTROL_DEV_INTERFACE));
|
||||
if (!cursor_interface) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
cursor_interface->SetCursor(
|
||||
pp_instance(), cursor_, pp::ImageData().pp_resource(), nullptr);
|
||||
cursor_interface->SetCursor(pp_instance(), cursor_,
|
||||
pp::ImageData().pp_resource(), nullptr);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::UpdateTickMarks(
|
||||
@ -1152,11 +1127,10 @@ void OutOfProcessInstance::NotifyNumberOfFindResultsChanged(int total,
|
||||
NumberOfFindResultsChanged(total, final_result);
|
||||
SetTickmarks(tickmarks_);
|
||||
recently_sent_find_update_ = true;
|
||||
pp::CompletionCallback callback =
|
||||
timer_factory_.NewCallback(
|
||||
&OutOfProcessInstance::ResetRecentlySentFindUpdate);
|
||||
pp::Module::Get()->core()->CallOnMainThread(kFindResultCooldownMs,
|
||||
callback, 0);
|
||||
pp::CompletionCallback callback = timer_factory_.NewCallback(
|
||||
&OutOfProcessInstance::ResetRecentlySentFindUpdate);
|
||||
pp::Module::Get()->core()->CallOnMainThread(kFindResultCooldownMs, callback,
|
||||
0);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::NotifySelectedFindResultChanged(
|
||||
@ -1273,8 +1247,8 @@ pp::URLLoader OutOfProcessInstance::CreateURLLoader() {
|
||||
// Disable save and print until the document is fully loaded, since they
|
||||
// would generate an incomplete document. Need to do this each time we
|
||||
// call DidStartLoading since that resets the content restrictions.
|
||||
pp::PDF::SetContentRestriction(this, CONTENT_RESTRICTION_SAVE |
|
||||
CONTENT_RESTRICTION_PRINT);
|
||||
pp::PDF::SetContentRestriction(
|
||||
this, CONTENT_RESTRICTION_SAVE | CONTENT_RESTRICTION_PRINT);
|
||||
}
|
||||
|
||||
return CreateURLLoaderInternal();
|
||||
@ -1286,19 +1260,16 @@ void OutOfProcessInstance::ScheduleCallback(int id, int delay_in_ms) {
|
||||
pp::Module::Get()->core()->CallOnMainThread(delay_in_ms, callback, id);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::SearchString(const base::char16* string,
|
||||
const base::char16* term,
|
||||
bool case_sensitive,
|
||||
std::vector<SearchStringResult>* results) {
|
||||
void OutOfProcessInstance::SearchString(
|
||||
const base::char16* string,
|
||||
const base::char16* term,
|
||||
bool case_sensitive,
|
||||
std::vector<SearchStringResult>* results) {
|
||||
PP_PrivateFindResult* pp_results;
|
||||
int count = 0;
|
||||
pp::PDF::SearchString(
|
||||
this,
|
||||
reinterpret_cast<const unsigned short*>(string),
|
||||
reinterpret_cast<const unsigned short*>(term),
|
||||
case_sensitive,
|
||||
&pp_results,
|
||||
&count);
|
||||
pp::PDF::SearchString(this, reinterpret_cast<const unsigned short*>(string),
|
||||
reinterpret_cast<const unsigned short*>(term),
|
||||
case_sensitive, &pp_results, &count);
|
||||
|
||||
results->resize(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -1310,8 +1281,7 @@ void OutOfProcessInstance::SearchString(const base::char16* string,
|
||||
memory.MemFree(pp_results);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::DocumentPaintOccurred() {
|
||||
}
|
||||
void OutOfProcessInstance::DocumentPaintOccurred() {}
|
||||
|
||||
void OutOfProcessInstance::DocumentLoadComplete(int page_count) {
|
||||
// Clear focus state for OSK.
|
||||
@ -1398,7 +1368,7 @@ void OutOfProcessInstance::PreviewDocumentLoadComplete() {
|
||||
int dest_page_index = preview_pages_info_.front().second;
|
||||
int src_page_index =
|
||||
ExtractPrintPreviewPageIndex(preview_pages_info_.front().first);
|
||||
if (src_page_index > 0 && dest_page_index > -1 && preview_engine_.get())
|
||||
if (src_page_index > 0 && dest_page_index > -1 && preview_engine_.get())
|
||||
engine_->AppendPage(preview_engine_.get(), dest_page_index);
|
||||
|
||||
preview_pages_info_.pop();
|
||||
@ -1559,7 +1529,7 @@ void OutOfProcessInstance::LoadPreviewUrl(const std::string& url) {
|
||||
void OutOfProcessInstance::LoadUrlInternal(
|
||||
const std::string& url,
|
||||
pp::URLLoader* loader,
|
||||
void (OutOfProcessInstance::* method)(int32_t)) {
|
||||
void (OutOfProcessInstance::*method)(int32_t)) {
|
||||
pp::URLRequestInfo request(this);
|
||||
request.SetURL(url);
|
||||
request.SetMethod("GET");
|
||||
@ -1634,8 +1604,7 @@ void OutOfProcessInstance::LoadAvailablePreviewPage() {
|
||||
std::string url = preview_pages_info_.front().first;
|
||||
int dst_page_index = preview_pages_info_.front().second;
|
||||
int src_page_index = ExtractPrintPreviewPageIndex(url);
|
||||
if (src_page_index < 1 ||
|
||||
dst_page_index >= print_preview_page_count_ ||
|
||||
if (src_page_index < 1 || dst_page_index >= print_preview_page_count_ ||
|
||||
preview_document_load_state_ == LOAD_STATE_LOADING) {
|
||||
return;
|
||||
}
|
||||
@ -1644,8 +1613,7 @@ void OutOfProcessInstance::LoadAvailablePreviewPage() {
|
||||
LoadPreviewUrl(url);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::UserMetricsRecordAction(
|
||||
const std::string& action) {
|
||||
void OutOfProcessInstance::UserMetricsRecordAction(const std::string& action) {
|
||||
// TODO(raymes): Move this function to PPB_UMA_Private.
|
||||
pp::PDF::UserMetricsRecordAction(this, pp::Var(action));
|
||||
}
|
||||
|
@ -68,9 +68,8 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
// pp::Printing_Dev implementation.
|
||||
uint32_t QuerySupportedPrintOutputFormats() override;
|
||||
int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) override;
|
||||
pp::Resource PrintPages(
|
||||
const PP_PrintPageNumberRange_Dev* page_ranges,
|
||||
uint32_t page_range_count) override;
|
||||
pp::Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges,
|
||||
uint32_t page_range_count) override;
|
||||
void PrintEnd() override;
|
||||
bool IsPrintScalingDisabled() override;
|
||||
|
||||
@ -166,8 +165,9 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
|
||||
void LoadUrl(const std::string& url);
|
||||
void LoadPreviewUrl(const std::string& url);
|
||||
void LoadUrlInternal(const std::string& url, pp::URLLoader* loader,
|
||||
void (OutOfProcessInstance::* method)(int32_t));
|
||||
void LoadUrlInternal(const std::string& url,
|
||||
pp::URLLoader* loader,
|
||||
void (OutOfProcessInstance::*method)(int32_t));
|
||||
|
||||
// Creates a URL loader and allows it to access all urls, i.e. not just the
|
||||
// frame's origin.
|
||||
@ -270,9 +270,7 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
std::vector<BackgroundPart> background_parts_;
|
||||
|
||||
struct PrintSettings {
|
||||
PrintSettings() {
|
||||
Clear();
|
||||
}
|
||||
PrintSettings() { Clear(); }
|
||||
void Clear() {
|
||||
is_printing = false;
|
||||
print_pages_called_ = false;
|
||||
|
@ -40,12 +40,10 @@ PaintAggregator::PaintUpdate::PaintUpdate(const PaintUpdate& that) = default;
|
||||
|
||||
PaintAggregator::PaintUpdate::~PaintUpdate() = default;
|
||||
|
||||
PaintAggregator::InternalPaintUpdate::InternalPaintUpdate() :
|
||||
synthesized_scroll_damage_rect_(false) {
|
||||
}
|
||||
PaintAggregator::InternalPaintUpdate::InternalPaintUpdate()
|
||||
: synthesized_scroll_damage_rect_(false) {}
|
||||
|
||||
PaintAggregator::InternalPaintUpdate::~InternalPaintUpdate() {
|
||||
}
|
||||
PaintAggregator::InternalPaintUpdate::~InternalPaintUpdate() {}
|
||||
|
||||
pp::Rect PaintAggregator::InternalPaintUpdate::GetScrollDamage() const {
|
||||
// Should only be scrolling in one direction at a time.
|
||||
@ -83,8 +81,7 @@ pp::Rect PaintAggregator::InternalPaintUpdate::GetScrollDamage() const {
|
||||
return scroll_rect.Intersect(damaged_rect);
|
||||
}
|
||||
|
||||
PaintAggregator::PaintAggregator() {
|
||||
}
|
||||
PaintAggregator::PaintAggregator() {}
|
||||
|
||||
bool PaintAggregator::HasPendingUpdate() const {
|
||||
return !update_.scroll_rect.IsEmpty() || !update_.paint_rects.empty();
|
||||
@ -121,8 +118,8 @@ PaintAggregator::PaintUpdate PaintAggregator::GetPendingUpdate() {
|
||||
void PaintAggregator::SetIntermediateResults(
|
||||
const std::vector<ReadyRect>& ready,
|
||||
const std::vector<pp::Rect>& pending) {
|
||||
update_.ready_rects.insert(
|
||||
update_.ready_rects.end(), ready.begin(), ready.end());
|
||||
update_.ready_rects.insert(update_.ready_rects.end(), ready.begin(),
|
||||
ready.end());
|
||||
update_.paint_rects = pending;
|
||||
}
|
||||
|
||||
@ -283,8 +280,7 @@ void PaintAggregator::InvalidateRectInternal(const pp::Rect& rect_old,
|
||||
|
||||
// If the new paint overlaps with a scroll, then also invalidate the rect in
|
||||
// its new position.
|
||||
if (check_scroll &&
|
||||
!update_.scroll_rect.IsEmpty() &&
|
||||
if (check_scroll && !update_.scroll_rect.IsEmpty() &&
|
||||
update_.scroll_rect.Intersects(rect)) {
|
||||
InvalidateRectInternal(ScrollPaintRect(rect, update_.scroll_delta), false);
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ PaintManager::PaintManager(pp::Instance* instance,
|
||||
DCHECK(client);
|
||||
}
|
||||
|
||||
PaintManager::~PaintManager() {
|
||||
}
|
||||
PaintManager::~PaintManager() {}
|
||||
|
||||
// static
|
||||
pp::Size PaintManager::GetNewContextSize(const pp::Size& current_context_size,
|
||||
@ -77,10 +76,10 @@ pp::Size PaintManager::GetNewContextSize(const pp::Size& current_context_size,
|
||||
plugin_size.height() > current_context_size.height() ||
|
||||
plugin_size.width() < min_size.width() ||
|
||||
plugin_size.height() < min_size.height()) {
|
||||
// Create a larger context than needed so that if we only resize by a
|
||||
// small margin, we don't need a new context.
|
||||
result = pp::Size(plugin_size.width() + kBufferSize,
|
||||
plugin_size.height() + kBufferSize);
|
||||
// Create a larger context than needed so that if we only resize by a
|
||||
// small margin, we don't need a new context.
|
||||
result = pp::Size(plugin_size.width() + kBufferSize,
|
||||
plugin_size.height() + kBufferSize);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -188,8 +187,7 @@ void PaintManager::EnsureCallbackPending() {
|
||||
return;
|
||||
|
||||
pp::Module::Get()->core()->CallOnMainThread(
|
||||
0,
|
||||
callback_factory_.NewCallback(&PaintManager::OnManualCallbackComplete),
|
||||
0, callback_factory_.NewCallback(&PaintManager::OnManualCallbackComplete),
|
||||
0);
|
||||
manual_callback_pending_ = true;
|
||||
}
|
||||
@ -281,8 +279,8 @@ void PaintManager::DoPaint() {
|
||||
}
|
||||
|
||||
for (const auto& ready_rect : ready_now) {
|
||||
graphics_.PaintImageData(
|
||||
ready_rect.image_data, ready_rect.offset, ready_rect.rect);
|
||||
graphics_.PaintImageData(ready_rect.image_data, ready_rect.offset,
|
||||
ready_rect.rect);
|
||||
}
|
||||
|
||||
Flush();
|
||||
|
@ -116,7 +116,8 @@ class PaintManager {
|
||||
|
||||
// You must call this function before using if you use the 0-arg constructor.
|
||||
// See the constructor for what these arguments mean.
|
||||
void Initialize(pp::Instance* instance, Client* client,
|
||||
void Initialize(pp::Instance* instance,
|
||||
Client* client,
|
||||
bool is_always_opaque);
|
||||
|
||||
// Sets the size of the plugin. If the size is the same as the previous call,
|
||||
|
@ -26,8 +26,7 @@ bool g_sdk_initialized_via_pepper = false;
|
||||
|
||||
} // namespace
|
||||
|
||||
PDFModule::PDFModule() {
|
||||
}
|
||||
PDFModule::PDFModule() {}
|
||||
|
||||
PDFModule::~PDFModule() {
|
||||
if (g_sdk_initialized_via_pepper) {
|
||||
@ -59,7 +58,6 @@ pp::Instance* PDFModule::CreateInstance(PP_Instance instance) {
|
||||
return new OutOfProcessInstance(instance);
|
||||
}
|
||||
|
||||
|
||||
// Implementation of Global PPP functions ---------------------------------
|
||||
int32_t PPP_InitializeModule(PP_Module module_id,
|
||||
PPB_GetInterface get_browser_interface) {
|
||||
|
@ -23,8 +23,7 @@ PDFiumAPIStringBufferAdapter<StringType>::PDFiumAPIStringBufferAdapter(
|
||||
data_(base::WriteInto(str, expected_size + 1)),
|
||||
expected_size_(expected_size),
|
||||
check_expected_size_(check_expected_size),
|
||||
is_closed_(false) {
|
||||
}
|
||||
is_closed_(false) {}
|
||||
|
||||
template <class StringType>
|
||||
PDFiumAPIStringBufferAdapter<StringType>::~PDFiumAPIStringBufferAdapter() {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -136,6 +136,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
public:
|
||||
explicit SelectionChangeInvalidator(PDFiumEngine* engine);
|
||||
~SelectionChangeInvalidator();
|
||||
|
||||
private:
|
||||
// Sets the given container to the all the currently visible selection
|
||||
// rectangles, in screen coordinates.
|
||||
@ -182,7 +183,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
size_t IncrementIndex();
|
||||
|
||||
private:
|
||||
bool valid_; // Whether |index_| is valid or not.
|
||||
bool valid_; // Whether |index_| is valid or not.
|
||||
size_t index_; // The current search result, 0-based.
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FindTextIndex);
|
||||
@ -199,16 +200,16 @@ class PDFiumEngine : public PDFEngine,
|
||||
};
|
||||
|
||||
// PDFium interface to get block of data.
|
||||
static int GetBlock(void* param, unsigned long position,
|
||||
unsigned char* buffer, unsigned long size);
|
||||
static int GetBlock(void* param,
|
||||
unsigned long position,
|
||||
unsigned char* buffer,
|
||||
unsigned long size);
|
||||
|
||||
// PDFium interface to check is block of data is available.
|
||||
static FPDF_BOOL IsDataAvail(FX_FILEAVAIL* param,
|
||||
size_t offset, size_t size);
|
||||
static FPDF_BOOL IsDataAvail(FX_FILEAVAIL* param, size_t offset, size_t size);
|
||||
|
||||
// PDFium interface to request download of the block of data.
|
||||
static void AddSegment(FX_DOWNLOADHINTS* param,
|
||||
size_t offset, size_t size);
|
||||
static void AddSegment(FX_DOWNLOADHINTS* param, size_t offset, size_t size);
|
||||
|
||||
// We finished getting the pdf file, so load it. This will complete
|
||||
// asynchronously (due to password fetching) and may be run multiple times.
|
||||
@ -225,8 +226,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
void GetPasswordAndLoad();
|
||||
|
||||
// Called when the password has been retrieved.
|
||||
void OnGetPasswordComplete(int32_t result,
|
||||
const pp::Var& password);
|
||||
void OnGetPasswordComplete(int32_t result, const pp::Var& password);
|
||||
|
||||
// Continues loading the document when the password has been retrieved, or if
|
||||
// there is no password. If there is no password, then |password| is empty.
|
||||
@ -380,8 +380,12 @@ class PDFiumEngine : public PDFEngine,
|
||||
|
||||
// Given a rectangle in screen coordinates, returns the coordinates in the
|
||||
// units that PDFium rendering functions expect.
|
||||
void GetPDFiumRect(int page_index, const pp::Rect& rect, int* start_x,
|
||||
int* start_y, int* size_x, int* size_y) const;
|
||||
void GetPDFiumRect(int page_index,
|
||||
const pp::Rect& rect,
|
||||
int* start_x,
|
||||
int* start_y,
|
||||
int* size_x,
|
||||
int* size_y) const;
|
||||
|
||||
// Returns the rendering flags to pass to PDFium.
|
||||
int GetRenderingFlags() const;
|
||||
@ -674,7 +678,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
|
||||
// Used to manage timers that form fill API needs. The pair holds the timer
|
||||
// period, in ms, and the callback function.
|
||||
std::map<int, std::pair<int, TimerCallback> > timers_;
|
||||
std::map<int, std::pair<int, TimerCallback>> timers_;
|
||||
int next_timer_id_;
|
||||
|
||||
// Holds the zero-based page index of the last page that the mouse clicked on.
|
||||
|
@ -17,8 +17,7 @@ PDFiumMemBufferFileRead::PDFiumMemBufferFileRead(const void* data,
|
||||
data_ = reinterpret_cast<const unsigned char*>(data);
|
||||
}
|
||||
|
||||
PDFiumMemBufferFileRead::~PDFiumMemBufferFileRead() {
|
||||
}
|
||||
PDFiumMemBufferFileRead::~PDFiumMemBufferFileRead() {}
|
||||
|
||||
int PDFiumMemBufferFileRead::GetBlock(void* param,
|
||||
unsigned long position,
|
||||
|
@ -11,8 +11,7 @@ PDFiumMemBufferFileWrite::PDFiumMemBufferFileWrite() {
|
||||
WriteBlock = &WriteBlockImpl;
|
||||
}
|
||||
|
||||
PDFiumMemBufferFileWrite::~PDFiumMemBufferFileWrite() {
|
||||
}
|
||||
PDFiumMemBufferFileWrite::~PDFiumMemBufferFileWrite() {}
|
||||
|
||||
int PDFiumMemBufferFileWrite::WriteBlockImpl(FPDF_FILEWRITE* this_file_write,
|
||||
const void* data,
|
||||
@ -28,6 +27,4 @@ int PDFiumMemBufferFileWrite::DoWriteBlock(const void* data,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_
|
||||
#define PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_
|
||||
#ifndef PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_H_
|
||||
#define PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@ -24,7 +24,8 @@ class PDFiumMemBufferFileWrite : public FPDF_FILEWRITE {
|
||||
|
||||
private:
|
||||
int DoWriteBlock(const void* data, unsigned long size);
|
||||
static int WriteBlockImpl(FPDF_FILEWRITE* this_file_write, const void* data,
|
||||
static int WriteBlockImpl(FPDF_FILEWRITE* this_file_write,
|
||||
const void* data,
|
||||
unsigned long size);
|
||||
|
||||
std::basic_string<unsigned char> buffer_;
|
||||
@ -32,5 +33,4 @@ class PDFiumMemBufferFileWrite : public FPDF_FILEWRITE {
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
||||
#endif // PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_
|
||||
|
||||
#endif // PDF_PDFIUM_PDFIUM_MEM_BUFFER_FILE_WRITE_H_
|
||||
|
@ -69,9 +69,9 @@ pp::FloatRect GetFloatCharRectInPixels(FPDF_PAGE page,
|
||||
return FloatPageRectToPixelRect(page, page_coords);
|
||||
}
|
||||
|
||||
bool OverlapsOnYAxis(const pp::FloatRect &a, const pp::FloatRect& b) {
|
||||
return !(a.IsEmpty() || b.IsEmpty() ||
|
||||
a.bottom() < b.y() || b.bottom() < a.y());
|
||||
bool OverlapsOnYAxis(const pp::FloatRect& a, const pp::FloatRect& b) {
|
||||
return !(a.IsEmpty() || b.IsEmpty() || a.bottom() < b.y() ||
|
||||
b.bottom() < a.y());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -188,8 +188,8 @@ void PDFiumPage::GetTextRunInfo(int start_char_index,
|
||||
if (!base::IsUnicodeWhitespace(character)) {
|
||||
// TODO(dmazzoni): this assumes horizontal text.
|
||||
// https://crbug.com/580311
|
||||
pp::FloatRect char_rect = GetFloatCharRectInPixels(
|
||||
page, text_page, char_index);
|
||||
pp::FloatRect char_rect =
|
||||
GetFloatCharRectInPixels(page, text_page, char_index);
|
||||
if (!char_rect.IsEmpty() && !OverlapsOnYAxis(text_run_bounds, char_rect))
|
||||
break;
|
||||
|
||||
@ -244,11 +244,11 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point,
|
||||
pp::Point point2 = point - rect_.point();
|
||||
double new_x;
|
||||
double new_y;
|
||||
FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
|
||||
rotation, point2.x(), point2.y(), &new_x, &new_y);
|
||||
FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(), rotation,
|
||||
point2.x(), point2.y(), &new_x, &new_y);
|
||||
|
||||
int rv = FPDFText_GetCharIndexAtPos(
|
||||
GetTextPage(), new_x, new_y, kTolerance, kTolerance);
|
||||
int rv = FPDFText_GetCharIndexAtPos(GetTextPage(), new_x, new_y, kTolerance,
|
||||
kTolerance);
|
||||
*char_index = rv;
|
||||
|
||||
FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
|
||||
@ -305,39 +305,41 @@ int PDFiumPage::GetCharCount() {
|
||||
}
|
||||
|
||||
PDFiumPage::Area PDFiumPage::GetLinkTarget(
|
||||
FPDF_LINK link, PDFiumPage::LinkTarget* target) const {
|
||||
FPDF_LINK link,
|
||||
PDFiumPage::LinkTarget* target) const {
|
||||
FPDF_DEST dest = FPDFLink_GetDest(engine_->doc(), link);
|
||||
if (dest)
|
||||
return GetDestinationTarget(dest, target);
|
||||
|
||||
FPDF_ACTION action = FPDFLink_GetAction(link);
|
||||
if (action) {
|
||||
// TODO(gene): We don't support PDFACTION_REMOTEGOTO and
|
||||
// PDFACTION_LAUNCH at the moment.
|
||||
switch (FPDFAction_GetType(action)) {
|
||||
case PDFACTION_GOTO: {
|
||||
FPDF_DEST dest = FPDFAction_GetDest(engine_->doc(), action);
|
||||
if (dest)
|
||||
return GetDestinationTarget(dest, target);
|
||||
// TODO(gene): We don't fully support all types of the in-document
|
||||
// links. Need to implement that. There is a bug to track that:
|
||||
// http://code.google.com/p/chromium/issues/detail?id=55776
|
||||
} break;
|
||||
FPDF_DEST dest = FPDFAction_GetDest(engine_->doc(), action);
|
||||
if (dest)
|
||||
return GetDestinationTarget(dest, target);
|
||||
// TODO(gene): We don't fully support all types of the in-document
|
||||
// links. Need to implement that. There is a bug to track that:
|
||||
// http://code.google.com/p/chromium/issues/detail?id=55776
|
||||
break;
|
||||
}
|
||||
case PDFACTION_URI: {
|
||||
if (target) {
|
||||
size_t buffer_size =
|
||||
FPDFAction_GetURIPath(engine_->doc(), action, nullptr, 0);
|
||||
if (buffer_size > 0) {
|
||||
PDFiumAPIStringBufferAdapter<std::string> api_string_adapter(
|
||||
&target->url, buffer_size, true);
|
||||
void* data = api_string_adapter.GetData();
|
||||
size_t bytes_written = FPDFAction_GetURIPath(
|
||||
engine_->doc(), action, data, buffer_size);
|
||||
api_string_adapter.Close(bytes_written);
|
||||
}
|
||||
if (target) {
|
||||
size_t buffer_size =
|
||||
FPDFAction_GetURIPath(engine_->doc(), action, nullptr, 0);
|
||||
if (buffer_size > 0) {
|
||||
PDFiumAPIStringBufferAdapter<std::string> api_string_adapter(
|
||||
&target->url, buffer_size, true);
|
||||
void* data = api_string_adapter.GetData();
|
||||
size_t bytes_written = FPDFAction_GetURIPath(engine_->doc(), action,
|
||||
data, buffer_size);
|
||||
api_string_adapter.Close(bytes_written);
|
||||
}
|
||||
return WEBLINK_AREA;
|
||||
} break;
|
||||
// TODO(gene): We don't support PDFACTION_REMOTEGOTO and PDFACTION_LAUNCH
|
||||
// at the moment.
|
||||
}
|
||||
return WEBLINK_AREA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,7 +347,8 @@ PDFiumPage::Area PDFiumPage::GetLinkTarget(
|
||||
}
|
||||
|
||||
PDFiumPage::Area PDFiumPage::GetDestinationTarget(
|
||||
FPDF_DEST destination, PDFiumPage::LinkTarget* target) const {
|
||||
FPDF_DEST destination,
|
||||
PDFiumPage::LinkTarget* target) const {
|
||||
if (target)
|
||||
target->page = FPDFDest_GetPageIndex(engine_->doc(), destination);
|
||||
return DOCLINK_AREA;
|
||||
|
@ -21,10 +21,7 @@ class PDFiumEngine;
|
||||
// Wrapper around a page from the document.
|
||||
class PDFiumPage {
|
||||
public:
|
||||
PDFiumPage(PDFiumEngine* engine,
|
||||
int i,
|
||||
const pp::Rect& r,
|
||||
bool available);
|
||||
PDFiumPage(PDFiumEngine* engine, int i, const pp::Rect& r, bool available);
|
||||
PDFiumPage(const PDFiumPage& that);
|
||||
~PDFiumPage();
|
||||
|
||||
@ -70,8 +67,11 @@ class PDFiumPage {
|
||||
// index if it's near a character, and also the type of text.
|
||||
// Target is optional. It will be filled in for WEBLINK_AREA or
|
||||
// DOCLINK_AREA only.
|
||||
Area GetCharIndex(const pp::Point& point, int rotation, int* char_index,
|
||||
int* form_type, LinkTarget* target);
|
||||
Area GetCharIndex(const pp::Point& point,
|
||||
int rotation,
|
||||
int* char_index,
|
||||
int* form_type,
|
||||
LinkTarget* target);
|
||||
|
||||
// Gets the character at the given index.
|
||||
base::char16 GetCharAtIndex(int index);
|
||||
@ -94,7 +94,7 @@ class PDFiumPage {
|
||||
bool available() const { return available_; }
|
||||
void set_available(bool available) { available_ = available; }
|
||||
void set_calculated_links(bool calculated_links) {
|
||||
calculated_links_ = calculated_links;
|
||||
calculated_links_ = calculated_links;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -14,8 +14,7 @@ PDFiumRange::PDFiumRange(PDFiumPage* page, int char_index, int char_count)
|
||||
: page_(page),
|
||||
char_index_(char_index),
|
||||
char_count_(char_count),
|
||||
cached_screen_rects_zoom_(0) {
|
||||
}
|
||||
cached_screen_rects_zoom_(0) {}
|
||||
|
||||
PDFiumRange::PDFiumRange(const PDFiumRange& that) = default;
|
||||
|
||||
@ -68,8 +67,7 @@ base::string16 PDFiumRange::GetText() const {
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv,
|
||||
count,
|
||||
PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv, count,
|
||||
false);
|
||||
unsigned short* data =
|
||||
reinterpret_cast<unsigned short*>(api_string_adapter.GetData());
|
||||
|
@ -10,12 +10,9 @@
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
PreviewModeClient::PreviewModeClient(Client* client)
|
||||
: client_(client) {
|
||||
}
|
||||
PreviewModeClient::PreviewModeClient(Client* client) : client_(client) {}
|
||||
|
||||
void PreviewModeClient::DocumentSizeUpdated(const pp::Size& size) {
|
||||
}
|
||||
void PreviewModeClient::DocumentSizeUpdated(const pp::Size& size) {}
|
||||
|
||||
void PreviewModeClient::Invalidate(const pp::Rect& rect) {
|
||||
NOTREACHED();
|
||||
|
Reference in New Issue
Block a user