Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2855523002: Deleted Widget/FrameViewBase (Closed)
Patch Set: Add back FrameView::paint_scrollbars_ to hold PaintLayer scrollbars Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 949239200fbfd984711f032480abda3384ebc675..f39ca45ff8fbc0d816a2351d5eb7f0cb2a8076bc 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -243,7 +243,7 @@ DEFINE_TRACE(FrameView) {
visitor->Trace(animating_scrollable_areas_);
visitor->Trace(auto_size_info_);
visitor->Trace(children_);
- visitor->Trace(scrollbars_);
+ visitor->Trace(paint_scrollbars_);
visitor->Trace(viewport_scrollable_area_);
visitor->Trace(visibility_observer_);
visitor->Trace(scroll_anchor_);
@@ -417,8 +417,6 @@ void FrameView::ScrollbarManager::SetHasHorizontalScrollbar(
if (has_scrollbar) {
h_bar_ = CreateScrollbar(kHorizontalScrollbar);
- scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
- h_bar_);
h_bar_is_attached_ = 1;
scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar);
h_bar_->StyleChanged();
@@ -436,8 +434,6 @@ void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) {
if (has_scrollbar) {
v_bar_ = CreateScrollbar(kVerticalScrollbar);
- scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
- v_bar_);
v_bar_is_attached_ = 1;
scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar);
v_bar_->StyleChanged();
@@ -475,8 +471,6 @@ void FrameView::ScrollbarManager::DestroyScrollbar(
return;
scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation);
- scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar(
- scrollbar);
scrollbar->DisconnectFromScrollableArea();
scrollbar = nullptr;
}
@@ -499,21 +493,19 @@ void FrameView::RecalculateCustomScrollbarStyle() {
}
void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() {
- bool uses_window_inactive_selector =
- frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector();
-
for (const auto& child : children_) {
if (child->IsFrameView())
ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged();
}
- for (const auto& scrollbar : scrollbars_) {
- if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar())
- scrollbar->StyleChanged();
- }
+ if (frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector()) {
dcheng 2017/05/09 08:05:55 Ditto: a separate CL for small cleanups like this
joelhockey 2017/05/10 04:17:13 reverted
+ for (const auto& paint_scrollbar : paint_scrollbars_) {
+ if (paint_scrollbar->IsCustomScrollbar())
+ paint_scrollbar->StyleChanged();
+ }
- if (uses_window_inactive_selector)
RecalculateCustomScrollbarStyle();
+ }
}
void FrameView::Clear() {
@@ -3885,16 +3877,14 @@ void FrameView::RemoveChild(FrameOrPlugin* child) {
children_.erase(child);
}
-void FrameView::RemoveScrollbar(Scrollbar* scrollbar) {
- DCHECK(scrollbars_.Contains(scrollbar));
- scrollbar->SetParent(nullptr);
- scrollbars_.erase(scrollbar);
+void FrameView::RemovePaintScrollbar(Scrollbar* scrollbar) {
+ DCHECK(paint_scrollbars_.Contains(scrollbar));
+ paint_scrollbars_.erase(scrollbar);
}
-void FrameView::AddScrollbar(Scrollbar* scrollbar) {
- DCHECK(!scrollbars_.Contains(scrollbar));
- scrollbar->SetParent(this);
- scrollbars_.insert(scrollbar);
+void FrameView::AddPaintScrollbar(Scrollbar* scrollbar) {
+ DCHECK(!paint_scrollbars_.Contains(scrollbar));
+ paint_scrollbars_.insert(scrollbar);
}
bool FrameView::VisualViewportSuppliesScrollbars() {
@@ -4746,6 +4736,46 @@ IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const {
return local_point;
}
+IntRect FrameView::ConvertFromRootFrame(
+ const IntRect& rect_in_root_frame) const {
+ if (parent_) {
+ IntRect parent_rect = parent_->ConvertFromRootFrame(rect_in_root_frame);
+ return ConvertFromContainingFrameView(parent_rect);
+ }
+ return rect_in_root_frame;
+}
+
+IntPoint FrameView::ConvertFromRootFrame(
+ const IntPoint& point_in_root_frame) const {
+ if (parent_) {
+ IntPoint parent_point = parent_->ConvertFromRootFrame(point_in_root_frame);
+ return ConvertFromContainingFrameView(parent_point);
+ }
+ return point_in_root_frame;
+}
+
+FloatPoint FrameView::ConvertFromRootFrame(
+ const FloatPoint& point_in_root_frame) const {
+ // FrameViews / windows are required to be IntPoint aligned, but we may
+ // need to convert FloatPoint values within them (eg. for event
+ // co-ordinates).
+ IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
+ FloatPoint parent_point = ConvertFromRootFrame(floored_point);
+ FloatSize window_fraction = point_in_root_frame - floored_point;
+ // Use linear interpolation handle any fractional value (eg. for iframes
+ // subject to a transform beyond just a simple translation).
+ // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
+ if (!window_fraction.IsEmpty()) {
+ const int kFactor = 1000;
+ IntPoint parent_line_end = ConvertFromRootFrame(
+ floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
+ FloatSize parent_fraction =
+ (parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
+ parent_point.Move(parent_fraction);
+ }
+ return parent_point;
+}
+
IntPoint FrameView::ConvertFromContainingFrameViewToScrollbar(
const Scrollbar& scrollbar,
const IntPoint& parent_point) const {

Powered by Google App Engine
This is Rietveld 408576698