Revert of Handle long press in PDF documents. (patchset #8 id:140001 of https://codereview.chromium.org/2855953003/ )
Reason for revert:
Breaks Mac bots. See https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzZlNTE2NTNlMDZkMTc0MGI1ZmU3MGIzZWY5YzJlNmZlOTU5ZTM5NjgM
https://build.chromium.org/p/chromium.mac/builders/Mac10.11%20Tests/builds/12082
[ RUN ] PDFExtensionTest.TouchHandling
[21973:14375:0506/122844.659425:WARNING:notification_platform_bridge_mac.mm(493)] AlertNotificationService: XPC connection invalidated.
2017-05-06 12:28:44.811 browser_tests[21973:153848] NSWindow warning: adding an unknown subview: <FullSizeContentView: 0x7fb0f2d756b0>. Break on NSLog to debug.
2017-05-06 12:28:44.812 browser_tests[21973:153848] Call stack:
(
"+callStackSymbols disabled for performance reasons"
)
[21973:87319:0506/122847.139773:WARNING:embedded_test_server.cc(219)] Request not handled. Returning 404: /favicon.ico
[21973:35843:0506/122850.985727:ERROR:service_manager.cc(137)] Connection InterfaceProviderSpec prevented service: content_plugin from binding interface: memory_instrumentation::mojom::Coordinator exposed by: content_browser
[21973:775:0506/122851.245843:INFO:CONSOLE(0)] "[SUCCESS] testContextMenuSingleTouch", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
[21973:775:0506/122851.307976:INFO:CONSOLE(0)] "[SUCCESS] testContextMenuDoubleTouch", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
[21973:775:0506/122851.669523:INFO:CONSOLE(0)] "[SUCCESS] testLongPressSelectsText", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
[21973:775:0506/122851.674726:INFO:CONSOLE(0)] "[FAIL] testLongPressSelectsText: API Test Error in testLongPressSelectsText
Actual:
Expected: some
Error
at Object.handleRequest (extensions::binding:63:27)
at Object.<anonymous> (extensions::binding:422:32)
at Object.<anonymous> (extensions::test:215:18)
at Object.handleRequest (extensions::binding:63:27)
at Object.<anonymous> (extensions::binding:422:32)
at <anonymous>:192:21
at safeFunctionApply (extensions::test:260:26)
at PDFScriptingAPI.selectedTextCallback_ (extensions::test:285:18)
at PDFScriptingAPI.<anonymous> (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js:81:16)", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
[21973:775:0506/122851.676537:INFO:CONSOLE(263)] "Uncaught chrome.test.failure", source: extensions::test (263)
../../chrome/browser/pdf/pdf_extension_test.cc:165: Failure
Failed
Failed 1 of 3 tests
[ FAILED ] PDFExtensionTest.TouchHandling, where TypeParam = and GetParam() = (8405 ms)
Original issue's description:
> Handle long press in PDF documents.
>
> This Cl updates the touch handlers for PDF documents to better support
> long press. The long press context menu is suppressed and the wonder
> under the press is of sufficient time.
>
> BUG=chromium:490184
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
>
> Review-Url: https://codereview.chromium.org/2855953003
> Cr-Commit-Position: refs/heads/master@{#469849}
> Committed: 6e51653e06
TBR=mcnee@chromium.org,thestig@chromium.org,dsinclair@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:490184
Review-Url: https://codereview.chromium.org/2864603006
Cr-Commit-Position: refs/heads/master@{#469890}
This commit is contained in:
@ -395,10 +395,6 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, GestureDetector) {
|
||||
RunTestsInFile("gesture_detector_test.js", "test.pdf");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TouchHandling) {
|
||||
RunTestsInFile("touch_handling_test.js", "test.pdf");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Elements) {
|
||||
// Although this test file does not require a PDF to be loaded, loading the
|
||||
// elements without loading a PDF is difficult.
|
||||
|
@ -26,7 +26,6 @@ class GestureDetector {
|
||||
'touchcancel', this.onTouch_.bind(this), { passive: true });
|
||||
|
||||
this.pinchStartEvent_ = null;
|
||||
this.lastTouchTouchesCount_ = 0;
|
||||
this.lastEvent_ = null;
|
||||
|
||||
this.listeners_ = new Map([
|
||||
@ -47,14 +46,6 @@ class GestureDetector {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the last touch start was a two finger touch.
|
||||
* @return {boolean} True if the last touch start was a two finger touch.
|
||||
*/
|
||||
wasTwoFingerTouch() {
|
||||
return this.lastTouchTouchesCount_ == 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the relevant listeners with the given |pinchEvent|.
|
||||
* @private
|
||||
@ -73,16 +64,14 @@ class GestureDetector {
|
||||
* @param {!TouchEvent} event Touch event on the element.
|
||||
*/
|
||||
onTouchStart_(event) {
|
||||
this.lastTouchTouchesCount_ = event.touches.length;
|
||||
if (!this.wasTwoFingerTouch())
|
||||
return;
|
||||
|
||||
this.pinchStartEvent_ = event;
|
||||
this.lastEvent_ = event;
|
||||
this.notify_({
|
||||
type: 'pinchstart',
|
||||
center: GestureDetector.center_(event)
|
||||
});
|
||||
if (event.touches.length == 2) {
|
||||
this.pinchStartEvent_ = event;
|
||||
this.lastEvent_ = event;
|
||||
this.notify_({
|
||||
type: 'pinchstart',
|
||||
center: GestureDetector.center_(event)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,8 +245,6 @@ function PDFViewer(browserApi) {
|
||||
document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
|
||||
document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
|
||||
document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
|
||||
document.addEventListener('contextmenu',
|
||||
this.handleContextMenuEvent_.bind(this));
|
||||
|
||||
var tabId = this.browserApi_.getStreamInfo().tabId;
|
||||
this.navigator_ = new Navigator(
|
||||
@ -412,17 +410,6 @@ PDFViewer.prototype = {
|
||||
this.toolbarManager_.hideToolbarsForMouseOut();
|
||||
},
|
||||
|
||||
handleContextMenuEvent_: function(e) {
|
||||
// Stop Chrome from popping up the context menu on long press. We need to
|
||||
// make sure the start event did not have 2 touches because we don't want
|
||||
// to block two finger tap opening the context menu. We check for
|
||||
// firesTouchEvents in order to not block the context menu on right click.
|
||||
if (e.sourceCapabilities.firesTouchEvents &&
|
||||
!this.gestureDetector_.wasTwoFingerTouch()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Rotate the plugin clockwise.
|
||||
|
@ -211,43 +211,6 @@ chrome.test.runTests(function() {
|
||||
chrome.test.assertEq('pinchupdate', pinchListener.lastEvent.type);
|
||||
chrome.test.assertTrue(pinchUpdateEvent.defaultPrevented);
|
||||
|
||||
chrome.test.succeed();
|
||||
},
|
||||
|
||||
function testWasTwoFingerTouch() {
|
||||
let stubElement = new StubElement();
|
||||
let gestureDetector = new GestureDetector(stubElement);
|
||||
|
||||
|
||||
chrome.test.assertFalse(gestureDetector.wasTwoFingerTouch(),
|
||||
"Should not have two finger touch before first touch event.");
|
||||
|
||||
stubElement.sendEvent(new MockTouchEvent('touchstart', [
|
||||
{clientX: 0, clientY: 0}
|
||||
]));
|
||||
chrome.test.assertFalse(gestureDetector.wasTwoFingerTouch(),
|
||||
"Should not have a two finger touch with one touch.");
|
||||
|
||||
stubElement.sendEvent(new MockTouchEvent('touchstart', [
|
||||
{clientX: 0, clientY: 0},
|
||||
{clientX: 2, clientY: 2}
|
||||
]));
|
||||
chrome.test.assertTrue(gestureDetector.wasTwoFingerTouch(),
|
||||
"Should have a two finger touch.");
|
||||
|
||||
// Make sure we keep |wasTwoFingerTouch| true after the end event.
|
||||
stubElement.sendEvent(new MockTouchEvent('touchend', []));
|
||||
chrome.test.assertTrue(gestureDetector.wasTwoFingerTouch(),
|
||||
"Should maintain two finger touch after touchend.");
|
||||
|
||||
stubElement.sendEvent(new MockTouchEvent('touchstart', [
|
||||
{clientX: 0, clientY: 0},
|
||||
{clientX: 2, clientY: 2},
|
||||
{clientX: 4, clientY: 4}
|
||||
]));
|
||||
chrome.test.assertFalse(gestureDetector.wasTwoFingerTouch(),
|
||||
"Should not have two finger touch with 3 touches.");
|
||||
|
||||
chrome.test.succeed();
|
||||
}
|
||||
];
|
||||
|
@ -1,72 +0,0 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
function sendTouchStart(touches) {
|
||||
var id = 0;
|
||||
let touchList = touches.map(function(xy) {
|
||||
var touchInit = {
|
||||
identifier: id++,
|
||||
target: viewer.plugin_,
|
||||
clientX: xy.x,
|
||||
clientY: xy.y,
|
||||
};
|
||||
|
||||
return new window.Touch(touchInit);
|
||||
});
|
||||
|
||||
viewer.plugin_.dispatchEvent(new TouchEvent('touchstart', {
|
||||
touches: touchList,
|
||||
targetTouches: touchList,
|
||||
changedtouches: touchList
|
||||
}));
|
||||
}
|
||||
|
||||
function createContextMenuEvent() {
|
||||
return new MouseEvent('contextmenu', {
|
||||
cancelable: true,
|
||||
sourceCapabilities: new InputDeviceCapabilities({firesTouchEvents: true})
|
||||
});
|
||||
}
|
||||
|
||||
var tests = [
|
||||
// Test suppression of the context menu on single touch.
|
||||
function testContextMenuSingleTouch() {
|
||||
sendTouchStart([{x: 10, y: 10}]);
|
||||
|
||||
let event = createContextMenuEvent();
|
||||
// Dispatch event will be false if the event is cancellable and one of the
|
||||
// handlers called preventDefault.
|
||||
chrome.test.assertFalse(document.dispatchEvent(event),
|
||||
"Should have called preventDefault() for single touch.");
|
||||
chrome.test.succeed();
|
||||
},
|
||||
|
||||
// Test allowing of context menu on double touch.
|
||||
function testContextMenuDoubleTouch() {
|
||||
sendTouchStart([{x: 10, y: 10}, {x: 15, y: 15}]);
|
||||
|
||||
let event = createContextMenuEvent();
|
||||
chrome.test.assertTrue(document.dispatchEvent(event),
|
||||
"Should not have called preventDefault() for double touch.");
|
||||
chrome.test.succeed();
|
||||
},
|
||||
|
||||
// Test long press selects word.
|
||||
function testLongPressSelectsText() {
|
||||
var client = new PDFScriptingAPI(window, window);
|
||||
|
||||
sendTouchStart([{x: 336, y: 163}]);
|
||||
window.setTimeout(function() {
|
||||
client.getSelectedText(chrome.test.callbackPass(function(selectedText) {
|
||||
chrome.test.assertEq('some', selectedText);
|
||||
}));
|
||||
chrome.test.succeed();
|
||||
}, 350);
|
||||
}
|
||||
];
|
||||
|
||||
var scriptingAPI = new PDFScriptingAPI(window, window);
|
||||
scriptingAPI.setLoadCallback(function() {
|
||||
chrome.test.runTests(tests);
|
||||
});
|
@ -239,11 +239,6 @@ bool IsPrintPreviewUrl(base::StringPiece url) {
|
||||
return url.starts_with(kChromePrint);
|
||||
}
|
||||
|
||||
void ScaleFloatPoint(float scale, pp::FloatPoint* point) {
|
||||
point->set_x(point->x() * scale);
|
||||
point->set_y(point->y() * scale);
|
||||
}
|
||||
|
||||
void ScalePoint(float scale, pp::Point* point) {
|
||||
point->set_x(static_cast<int>(point->x() * scale));
|
||||
point->set_y(static_cast<int>(point->y() * scale));
|
||||
@ -580,7 +575,8 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
|
||||
}
|
||||
|
||||
bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
// To simplify things, convert the event into device coordinates.
|
||||
// To simplify things, convert the event into device coordinates if it is
|
||||
// a mouse event.
|
||||
pp::InputEvent event_device_res(event);
|
||||
{
|
||||
pp::MouseInputEvent mouse_event(event);
|
||||
@ -588,8 +584,6 @@ bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
pp::Point point = mouse_event.GetPosition();
|
||||
pp::Point movement = mouse_event.GetMovement();
|
||||
ScalePoint(device_scale_, &point);
|
||||
point.set_x(point.x() - available_area_.x());
|
||||
|
||||
ScalePoint(device_scale_, &movement);
|
||||
mouse_event =
|
||||
pp::MouseInputEvent(this, event.GetType(), event.GetTimeStamp(),
|
||||
@ -598,39 +592,28 @@ bool OutOfProcessInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
event_device_res = mouse_event;
|
||||
}
|
||||
}
|
||||
{
|
||||
pp::TouchInputEvent touch_event(event);
|
||||
if (!touch_event.is_null()) {
|
||||
pp::TouchInputEvent new_touch_event = pp::TouchInputEvent(
|
||||
this, touch_event.GetType(), touch_event.GetTimeStamp(),
|
||||
touch_event.GetModifiers());
|
||||
|
||||
for (uint32_t i = 0;
|
||||
i < touch_event.GetTouchCount(PP_TOUCHLIST_TYPE_TARGETTOUCHES);
|
||||
i++) {
|
||||
pp::TouchPoint touch_point =
|
||||
touch_event.GetTouchByIndex(PP_TOUCHLIST_TYPE_TARGETTOUCHES, i);
|
||||
|
||||
pp::FloatPoint point = touch_point.position();
|
||||
|
||||
// Account for the scroll position. Touch events are in DOM coordinates
|
||||
// where mouse events appear to be in screen coordinates.
|
||||
point.set_x(scroll_offset_.x() + point.x());
|
||||
point.set_y(scroll_offset_.y() + point.y());
|
||||
ScaleFloatPoint(device_scale_, &point);
|
||||
|
||||
point.set_x(point.x() - available_area_.x());
|
||||
|
||||
new_touch_event.AddTouchPoint(
|
||||
PP_TOUCHLIST_TYPE_TARGETTOUCHES,
|
||||
{touch_point.id(), point, touch_point.radii(),
|
||||
touch_point.rotation_angle(), touch_point.pressure()});
|
||||
}
|
||||
event_device_res = new_touch_event;
|
||||
pp::InputEvent offset_event(event_device_res);
|
||||
switch (offset_event.GetType()) {
|
||||
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
|
||||
case PP_INPUTEVENT_TYPE_MOUSEUP:
|
||||
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
|
||||
case PP_INPUTEVENT_TYPE_MOUSEENTER:
|
||||
case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
|
||||
pp::MouseInputEvent mouse_event(event_device_res);
|
||||
pp::MouseInputEvent mouse_event_dip(event);
|
||||
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(),
|
||||
mouse_event.GetMovement());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (engine_->HandleEvent(event_device_res))
|
||||
if (engine_->HandleEvent(offset_event))
|
||||
return true;
|
||||
|
||||
// Middle click is used for scrolling and is handled by the container page.
|
||||
@ -675,13 +658,13 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) {
|
||||
}
|
||||
|
||||
if (!stop_scrolling_) {
|
||||
scroll_offset_ = view.GetScrollOffset();
|
||||
pp::Point scroll_offset(view.GetScrollOffset());
|
||||
// Because view messages come from the DOM, the coordinates of the viewport
|
||||
// are 0-based (i.e. they do not correspond to the viewport's coordinates in
|
||||
// JS), so we need to subtract the toolbar height to convert them into
|
||||
// viewport coordinates.
|
||||
pp::FloatPoint scroll_offset_float(
|
||||
scroll_offset_.x(), scroll_offset_.y() - top_toolbar_height_);
|
||||
pp::FloatPoint scroll_offset_float(scroll_offset.x(),
|
||||
scroll_offset.y() - top_toolbar_height_);
|
||||
scroll_offset_float = BoundScrollOffsetToDocument(scroll_offset_float);
|
||||
engine_->ScrolledToXPosition(scroll_offset_float.x() * device_scale_);
|
||||
engine_->ScrolledToYPosition(scroll_offset_float.y() * device_scale_);
|
||||
@ -978,10 +961,6 @@ void OutOfProcessInstance::DidOpenPreview(int32_t result) {
|
||||
}
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::OnClientTouchTimerFired(int32_t id) {
|
||||
engine_->OnTouchTimerCallback(id);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::OnClientTimerFired(int32_t id) {
|
||||
engine_->OnCallback(id);
|
||||
}
|
||||
@ -1270,12 +1249,6 @@ pp::URLLoader OutOfProcessInstance::CreateURLLoader() {
|
||||
return CreateURLLoaderInternal();
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScheduleTouchTimerCallback(int id, int delay_in_ms) {
|
||||
pp::CompletionCallback callback = callback_factory_.NewCallback(
|
||||
&OutOfProcessInstance::OnClientTouchTimerFired);
|
||||
pp::Module::Get()->core()->CallOnMainThread(delay_in_ms, callback, id);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScheduleCallback(int id, int delay_in_ms) {
|
||||
pp::CompletionCallback callback =
|
||||
callback_factory_.NewCallback(&OutOfProcessInstance::OnClientTimerFired);
|
||||
|
@ -84,7 +84,6 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
|
||||
// Called when the timer is fired.
|
||||
void OnClientTimerFired(int32_t id);
|
||||
void OnClientTouchTimerFired(int32_t id);
|
||||
|
||||
// Called to print without re-entrancy issues.
|
||||
void OnPrint(int32_t);
|
||||
@ -121,7 +120,6 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
std::string ShowFileSelectionDialog() override;
|
||||
pp::URLLoader CreateURLLoader() override;
|
||||
void ScheduleCallback(int id, int delay_in_ms) override;
|
||||
void ScheduleTouchTimerCallback(int id, int delay_in_ms) override;
|
||||
void SearchString(const base::char16* string,
|
||||
const base::char16* term,
|
||||
bool case_sensitive,
|
||||
@ -230,8 +228,6 @@ class OutOfProcessInstance : public pp::Instance,
|
||||
// Size of entire document in pixels (i.e. if each page is 800 pixels high and
|
||||
// there are 10 pages, the height will be 8000).
|
||||
pp::Size document_size_;
|
||||
// The scroll offset in CSS pixels.
|
||||
pp::Point scroll_offset_;
|
||||
|
||||
// Enumeration of pinch states.
|
||||
// This should match PinchPhase enum in
|
||||
|
@ -140,12 +140,9 @@ class PDFEngine {
|
||||
// Creates and returns new URL loader for partial document requests.
|
||||
virtual pp::URLLoader CreateURLLoader() = 0;
|
||||
|
||||
// Calls the client's OnCallback() function in |delay_in_ms| with the given
|
||||
// |id|.
|
||||
// Calls the client's OnCallback() function in delay_in_ms with the given
|
||||
// id.
|
||||
virtual void ScheduleCallback(int id, int delay_in_ms) = 0;
|
||||
// Calls the client's OnTouchTimerCallback() function in |delay_in_ms| with
|
||||
// the given |id|.
|
||||
virtual void ScheduleTouchTimerCallback(int id, int delay_in_ms) = 0;
|
||||
|
||||
// Searches the given string for "term" and returns the results. Unicode-
|
||||
// aware.
|
||||
@ -254,8 +251,6 @@ class PDFEngine {
|
||||
virtual void SetGrayscale(bool grayscale) = 0;
|
||||
// Callback for timer that's set with ScheduleCallback().
|
||||
virtual void OnCallback(int id) = 0;
|
||||
// Callback for timer that's set with ScheduleTouchTimerCallback().
|
||||
virtual void OnTouchTimerCallback(int id) = 0;
|
||||
// Get the number of characters on a given page.
|
||||
virtual int GetCharCount(int page_index) = 0;
|
||||
// Get the bounds in page pixels of a character on a given page.
|
||||
|
@ -88,8 +88,6 @@ const int32_t kFormHighlightAlpha = 100;
|
||||
|
||||
const int32_t kMaxPasswordTries = 3;
|
||||
|
||||
const int32_t kTouchLongPressTimeoutMs = 300;
|
||||
|
||||
// See Table 3.20 in
|
||||
// http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf
|
||||
const uint32_t kPDFPermissionPrintLowQualityMask = 1 << 2;
|
||||
@ -683,8 +681,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
|
||||
permissions_(0),
|
||||
permissions_handler_revision_(-1),
|
||||
fpdf_availability_(nullptr),
|
||||
next_formfill_timer_id_(0),
|
||||
next_touch_timer_id_(0),
|
||||
next_timer_id_(0),
|
||||
last_page_mouse_down_(-1),
|
||||
most_visible_page_(-1),
|
||||
called_do_document_action_(false),
|
||||
@ -1338,21 +1335,6 @@ bool PDFiumEngine::HandleEvent(const pp::InputEvent& event) {
|
||||
case PP_INPUTEVENT_TYPE_CHAR:
|
||||
rv = OnChar(pp::KeyboardInputEvent(event));
|
||||
break;
|
||||
case PP_INPUTEVENT_TYPE_TOUCHSTART: {
|
||||
KillTouchTimer(next_touch_timer_id_);
|
||||
|
||||
pp::TouchInputEvent touch_event(event);
|
||||
if (touch_event.GetTouchCount(PP_TOUCHLIST_TYPE_TARGETTOUCHES) == 1)
|
||||
ScheduleTouchTimer(touch_event);
|
||||
break;
|
||||
}
|
||||
case PP_INPUTEVENT_TYPE_TOUCHEND:
|
||||
KillTouchTimer(next_touch_timer_id_);
|
||||
break;
|
||||
case PP_INPUTEVENT_TYPE_TOUCHMOVE:
|
||||
// TODO(dsinclair): This should allow a little bit of movement (up to the
|
||||
// touch radii) to account for finger jiggle.
|
||||
KillTouchTimer(next_touch_timer_id_);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2482,36 +2464,12 @@ void PDFiumEngine::SetGrayscale(bool grayscale) {
|
||||
}
|
||||
|
||||
void PDFiumEngine::OnCallback(int id) {
|
||||
if (!formfill_timers_.count(id))
|
||||
if (!timers_.count(id))
|
||||
return;
|
||||
|
||||
formfill_timers_[id].second(id);
|
||||
if (formfill_timers_.count(id)) // The callback might delete the timer.
|
||||
client_->ScheduleCallback(id, formfill_timers_[id].first);
|
||||
}
|
||||
|
||||
void PDFiumEngine::OnTouchTimerCallback(int id) {
|
||||
if (!touch_timers_.count(id))
|
||||
return;
|
||||
|
||||
HandleLongPress(touch_timers_[id]);
|
||||
KillTouchTimer(id);
|
||||
}
|
||||
|
||||
void PDFiumEngine::HandleLongPress(const pp::TouchInputEvent& event) {
|
||||
pp::FloatPoint fp =
|
||||
event.GetTouchByIndex(PP_TOUCHLIST_TYPE_TARGETTOUCHES, 0).position();
|
||||
pp::Point point;
|
||||
point.set_x(fp.x());
|
||||
point.set_y(fp.y());
|
||||
|
||||
// Send a fake mouse down to trigger the multi-click selection code.
|
||||
pp::MouseInputEvent mouse_event(
|
||||
client_->GetPluginInstance(), PP_INPUTEVENT_TYPE_MOUSEDOWN,
|
||||
event.GetTimeStamp(), event.GetModifiers(),
|
||||
PP_INPUTEVENT_MOUSEBUTTON_LEFT, point, 2, point);
|
||||
|
||||
OnMouseDown(mouse_event);
|
||||
timers_[id].second(id);
|
||||
if (timers_.count(id)) // The callback might delete the timer.
|
||||
client_->ScheduleCallback(id, timers_[id].first);
|
||||
}
|
||||
|
||||
int PDFiumEngine::GetCharCount(int page_index) {
|
||||
@ -3580,16 +3538,6 @@ void PDFiumEngine::SetSelecting(bool selecting) {
|
||||
client_->IsSelectingChanged(selecting);
|
||||
}
|
||||
|
||||
void PDFiumEngine::ScheduleTouchTimer(const pp::TouchInputEvent& evt) {
|
||||
touch_timers_[++next_touch_timer_id_] = evt;
|
||||
client_->ScheduleTouchTimerCallback(next_touch_timer_id_,
|
||||
kTouchLongPressTimeoutMs);
|
||||
}
|
||||
|
||||
void PDFiumEngine::KillTouchTimer(int timer_id) {
|
||||
touch_timers_.erase(timer_id);
|
||||
}
|
||||
|
||||
bool PDFiumEngine::PageIndexInBounds(int index) const {
|
||||
return index >= 0 && index < static_cast<int>(pages_.size());
|
||||
}
|
||||
@ -3641,15 +3589,15 @@ int PDFiumEngine::Form_SetTimer(FPDF_FORMFILLINFO* param,
|
||||
int elapse,
|
||||
TimerCallback timer_func) {
|
||||
PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
|
||||
engine->formfill_timers_[++engine->next_formfill_timer_id_] =
|
||||
engine->timers_[++engine->next_timer_id_] =
|
||||
std::pair<int, TimerCallback>(elapse, timer_func);
|
||||
engine->client_->ScheduleCallback(engine->next_formfill_timer_id_, elapse);
|
||||
return engine->next_formfill_timer_id_;
|
||||
engine->client_->ScheduleCallback(engine->next_timer_id_, elapse);
|
||||
return engine->next_timer_id_;
|
||||
}
|
||||
|
||||
void PDFiumEngine::Form_KillTimer(FPDF_FORMFILLINFO* param, int timer_id) {
|
||||
PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
|
||||
engine->formfill_timers_.erase(timer_id);
|
||||
engine->timers_.erase(timer_id);
|
||||
}
|
||||
|
||||
FPDF_SYSTEMTIME PDFiumEngine::Form_GetLocalTime(FPDF_FORMFILLINFO* param) {
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/dev/buffer_dev.h"
|
||||
#include "ppapi/cpp/image_data.h"
|
||||
#include "ppapi/cpp/input_event.h"
|
||||
#include "ppapi/cpp/point.h"
|
||||
#include "ppapi/cpp/var_array.h"
|
||||
#include "third_party/pdfium/public/fpdf_dataavail.h"
|
||||
@ -32,6 +31,11 @@
|
||||
#include "third_party/pdfium/public/fpdf_progressive.h"
|
||||
#include "third_party/pdfium/public/fpdfview.h"
|
||||
|
||||
namespace pp {
|
||||
class KeyboardInputEvent;
|
||||
class MouseInputEvent;
|
||||
}
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
class ShadowMatrix;
|
||||
@ -86,7 +90,6 @@ class PDFiumEngine : public PDFEngine,
|
||||
int GetVerticalScrollbarYPosition() override;
|
||||
void SetGrayscale(bool grayscale) override;
|
||||
void OnCallback(int id) override;
|
||||
void OnTouchTimerCallback(int id) override;
|
||||
int GetCharCount(int page_index) override;
|
||||
pp::FloatRect GetCharBounds(int page_index, int char_index) override;
|
||||
uint32_t GetCharUnicode(int page_index, int char_index) override;
|
||||
@ -442,10 +445,6 @@ class PDFiumEngine : public PDFEngine,
|
||||
|
||||
bool PageIndexInBounds(int index) const;
|
||||
|
||||
void ScheduleTouchTimer(const pp::TouchInputEvent& event);
|
||||
void KillTouchTimer(int timer_id);
|
||||
void HandleLongPress(const pp::TouchInputEvent& event);
|
||||
|
||||
// FPDF_FORMFILLINFO callbacks.
|
||||
static void Form_Invalidate(FPDF_FORMFILLINFO* param,
|
||||
FPDF_PAGE page,
|
||||
@ -679,12 +678,8 @@ 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>> formfill_timers_;
|
||||
int next_formfill_timer_id_;
|
||||
|
||||
// Used to manage timers for touch long press.
|
||||
std::map<int, pp::TouchInputEvent> touch_timers_;
|
||||
int next_touch_timer_id_;
|
||||
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.
|
||||
int last_page_mouse_down_;
|
||||
|
@ -115,10 +115,6 @@ void PreviewModeClient::ScheduleCallback(int id, int delay_in_ms) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void PreviewModeClient::ScheduleTouchTimerCallback(int id, int delay_in_ms) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void PreviewModeClient::SearchString(const base::char16* string,
|
||||
const base::char16* term,
|
||||
bool case_sensitive,
|
||||
|
@ -58,7 +58,6 @@ class PreviewModeClient : public PDFEngine::Client {
|
||||
std::string ShowFileSelectionDialog() override;
|
||||
pp::URLLoader CreateURLLoader() override;
|
||||
void ScheduleCallback(int id, int delay_in_ms) override;
|
||||
void ScheduleTouchTimerCallback(int id, int delay_in_ms) override;
|
||||
void SearchString(const base::char16* string,
|
||||
const base::char16* term,
|
||||
bool case_sensitive,
|
||||
|
Reference in New Issue
Block a user