| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 // (OnMsgInputEventAck) method, but not on other platforms; using | 1561 // (OnMsgInputEventAck) method, but not on other platforms; using |
| 1562 // 'void' instead is just as safe (since NotificationSource | 1562 // 'void' instead is just as safe (since NotificationSource |
| 1563 // is not actually typesafe) and avoids this error. | 1563 // is not actually typesafe) and avoids this error. |
| 1564 NotificationService::current()->Notify( | 1564 NotificationService::current()->Notify( |
| 1565 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 1565 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
| 1566 Source<void>(this), | 1566 Source<void>(this), |
| 1567 Details<int>(&type)); | 1567 Details<int>(&type)); |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 void RenderWidgetHostImpl::OnMsgBeginSmoothScroll( | 1570 void RenderWidgetHostImpl::OnMsgBeginSmoothScroll( |
| 1571 bool scroll_down, bool scroll_far) { | 1571 int gesture_id, bool scroll_down, bool scroll_far) { |
| 1572 if (!view_) | 1572 if (!view_) |
| 1573 return; | 1573 return; |
| 1574 active_smooth_scroll_gesture_.reset( | 1574 active_smooth_scroll_gestures_.insert( |
| 1575 view_->CreateSmoothScrollGesture(scroll_down, scroll_far)); | 1575 std::make_pair(gesture_id, |
| 1576 view_->CreateSmoothScrollGesture( |
| 1577 scroll_down, scroll_far))); |
| 1576 TickActiveSmoothScrollGesture(); | 1578 TickActiveSmoothScrollGesture(); |
| 1577 } | 1579 } |
| 1578 | 1580 |
| 1579 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { | 1581 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { |
| 1580 if (!active_smooth_scroll_gesture_.get()) | 1582 if (active_smooth_scroll_gestures_.size() == 0) |
| 1581 return; | 1583 return; |
| 1582 | 1584 |
| 1583 TimeTicks now = TimeTicks::HighResNow(); | 1585 TimeTicks now = TimeTicks::HighResNow(); |
| 1584 | 1586 |
| 1585 // Post the next tick right away so it is regular. | 1587 // Post the next tick right away so it is regular. |
| 1586 MessageLoop::current()->PostDelayedTask( | 1588 MessageLoop::current()->PostDelayedTask( |
| 1587 FROM_HERE, | 1589 FROM_HERE, |
| 1588 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1590 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
| 1589 weak_factory_.GetWeakPtr()), | 1591 weak_factory_.GetWeakPtr()), |
| 1590 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs)); | 1592 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs)); |
| 1591 | 1593 |
| 1594 // Separate ticking of gestures from sending their completion messages. |
| 1595 std::vector<int> ids_that_are_done; |
| 1596 for (SmoothScrollGestureMap::iterator it = |
| 1597 active_smooth_scroll_gestures_.begin(); |
| 1598 it != active_smooth_scroll_gestures_.end(); |
| 1599 ++it) { |
| 1592 | 1600 |
| 1593 bool active = active_smooth_scroll_gesture_->ForwardInputEvents(now, this); | 1601 bool active = it->second->ForwardInputEvents(now, this); |
| 1594 if (!active) { | 1602 if (!active) |
| 1595 active_smooth_scroll_gesture_.reset(); | 1603 ids_that_are_done.push_back(it->first); |
| 1596 // TODO(nduca): send "smooth scroll done" event to RenderWidget. | 1604 } |
| 1605 |
| 1606 // Delete completed gestures and send their completion event. |
| 1607 for(size_t i = 0; i < ids_that_are_done.size(); i++) { |
| 1608 int id = ids_that_are_done[i]; |
| 1609 SmoothScrollGestureMap::iterator it = |
| 1610 active_smooth_scroll_gestures_.find(id); |
| 1611 DCHECK(it != active_smooth_scroll_gestures_.end()); |
| 1612 active_smooth_scroll_gestures_.erase(it); |
| 1613 |
| 1614 Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id)); |
| 1597 } | 1615 } |
| 1598 } | 1616 } |
| 1599 | 1617 |
| 1600 void RenderWidgetHostImpl::OnMsgSelectRangeAck() { | 1618 void RenderWidgetHostImpl::OnMsgSelectRangeAck() { |
| 1601 select_range_pending_ = false; | 1619 select_range_pending_ = false; |
| 1602 if (next_selection_range_.get()) { | 1620 if (next_selection_range_.get()) { |
| 1603 scoped_ptr<SelectionRange> next(next_selection_range_.Pass()); | 1621 scoped_ptr<SelectionRange> next(next_selection_range_.Pass()); |
| 1604 SelectRange(next->start, next->end); | 1622 SelectRange(next->start, next->end); |
| 1605 } | 1623 } |
| 1606 } | 1624 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 // indicate that no callback is in progress (i.e. without this line | 2032 // indicate that no callback is in progress (i.e. without this line |
| 2015 // DelayedAutoResized will not get called again). | 2033 // DelayedAutoResized will not get called again). |
| 2016 new_auto_size_.SetSize(0, 0); | 2034 new_auto_size_.SetSize(0, 0); |
| 2017 if (!should_auto_resize_) | 2035 if (!should_auto_resize_) |
| 2018 return; | 2036 return; |
| 2019 | 2037 |
| 2020 OnRenderAutoResized(new_size); | 2038 OnRenderAutoResized(new_size); |
| 2021 } | 2039 } |
| 2022 | 2040 |
| 2023 } // namespace content | 2041 } // namespace content |
| OLD | NEW |