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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 DEFINE_TRACE(FrameView) { 238 DEFINE_TRACE(FrameView) {
239 visitor->Trace(frame_); 239 visitor->Trace(frame_);
240 visitor->Trace(parent_); 240 visitor->Trace(parent_);
241 visitor->Trace(fragment_anchor_); 241 visitor->Trace(fragment_anchor_);
242 visitor->Trace(scrollable_areas_); 242 visitor->Trace(scrollable_areas_);
243 visitor->Trace(animating_scrollable_areas_); 243 visitor->Trace(animating_scrollable_areas_);
244 visitor->Trace(auto_size_info_); 244 visitor->Trace(auto_size_info_);
245 visitor->Trace(children_); 245 visitor->Trace(children_);
246 visitor->Trace(scrollbars_); 246 visitor->Trace(paint_scrollbars_);
247 visitor->Trace(viewport_scrollable_area_); 247 visitor->Trace(viewport_scrollable_area_);
248 visitor->Trace(visibility_observer_); 248 visitor->Trace(visibility_observer_);
249 visitor->Trace(scroll_anchor_); 249 visitor->Trace(scroll_anchor_);
250 visitor->Trace(anchoring_adjustment_queue_); 250 visitor->Trace(anchoring_adjustment_queue_);
251 visitor->Trace(scrollbar_manager_); 251 visitor->Trace(scrollbar_manager_);
252 visitor->Trace(print_context_); 252 visitor->Trace(print_context_);
253 ScrollableArea::Trace(visitor); 253 ScrollableArea::Trace(visitor);
254 } 254 }
255 255
256 void FrameView::Reset() { 256 void FrameView::Reset() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 410 }
411 } 411 }
412 412
413 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar( 413 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar(
414 bool has_scrollbar) { 414 bool has_scrollbar) {
415 if (has_scrollbar == HasHorizontalScrollbar()) 415 if (has_scrollbar == HasHorizontalScrollbar())
416 return; 416 return;
417 417
418 if (has_scrollbar) { 418 if (has_scrollbar) {
419 h_bar_ = CreateScrollbar(kHorizontalScrollbar); 419 h_bar_ = CreateScrollbar(kHorizontalScrollbar);
420 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
421 h_bar_);
422 h_bar_is_attached_ = 1; 420 h_bar_is_attached_ = 1;
423 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar); 421 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar);
424 h_bar_->StyleChanged(); 422 h_bar_->StyleChanged();
425 } else { 423 } else {
426 h_bar_is_attached_ = 0; 424 h_bar_is_attached_ = 0;
427 DestroyScrollbar(kHorizontalScrollbar); 425 DestroyScrollbar(kHorizontalScrollbar);
428 } 426 }
429 427
430 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); 428 scrollable_area_->SetScrollCornerNeedsPaintInvalidation();
431 } 429 }
432 430
433 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) { 431 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) {
434 if (has_scrollbar == HasVerticalScrollbar()) 432 if (has_scrollbar == HasVerticalScrollbar())
435 return; 433 return;
436 434
437 if (has_scrollbar) { 435 if (has_scrollbar) {
438 v_bar_ = CreateScrollbar(kVerticalScrollbar); 436 v_bar_ = CreateScrollbar(kVerticalScrollbar);
439 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
440 v_bar_);
441 v_bar_is_attached_ = 1; 437 v_bar_is_attached_ = 1;
442 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); 438 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar);
443 v_bar_->StyleChanged(); 439 v_bar_->StyleChanged();
444 } else { 440 } else {
445 v_bar_is_attached_ = 0; 441 v_bar_is_attached_ = 0;
446 DestroyScrollbar(kVerticalScrollbar); 442 DestroyScrollbar(kVerticalScrollbar);
447 } 443 }
448 444
449 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); 445 scrollable_area_->SetScrollCornerNeedsPaintInvalidation();
450 } 446 }
(...skipping 17 matching lines...) Expand all
468 void FrameView::ScrollbarManager::DestroyScrollbar( 464 void FrameView::ScrollbarManager::DestroyScrollbar(
469 ScrollbarOrientation orientation) { 465 ScrollbarOrientation orientation) {
470 Member<Scrollbar>& scrollbar = 466 Member<Scrollbar>& scrollbar =
471 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; 467 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_;
472 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ 468 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_
473 : !v_bar_is_attached_); 469 : !v_bar_is_attached_);
474 if (!scrollbar) 470 if (!scrollbar)
475 return; 471 return;
476 472
477 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); 473 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation);
478 scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar(
479 scrollbar);
480 scrollbar->DisconnectFromScrollableArea(); 474 scrollbar->DisconnectFromScrollableArea();
481 scrollbar = nullptr; 475 scrollbar = nullptr;
482 } 476 }
483 477
484 void FrameView::RecalculateCustomScrollbarStyle() { 478 void FrameView::RecalculateCustomScrollbarStyle() {
485 bool did_style_change = false; 479 bool did_style_change = false;
486 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { 480 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) {
487 HorizontalScrollbar()->StyleChanged(); 481 HorizontalScrollbar()->StyleChanged();
488 did_style_change = true; 482 did_style_change = true;
489 } 483 }
490 if (VerticalScrollbar() && VerticalScrollbar()->IsCustomScrollbar()) { 484 if (VerticalScrollbar() && VerticalScrollbar()->IsCustomScrollbar()) {
491 VerticalScrollbar()->StyleChanged(); 485 VerticalScrollbar()->StyleChanged();
492 did_style_change = true; 486 did_style_change = true;
493 } 487 }
494 if (did_style_change) { 488 if (did_style_change) {
495 UpdateScrollbarGeometry(); 489 UpdateScrollbarGeometry();
496 UpdateScrollCorner(); 490 UpdateScrollCorner();
497 PositionScrollbarLayers(); 491 PositionScrollbarLayers();
498 } 492 }
499 } 493 }
500 494
501 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() { 495 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() {
502 bool uses_window_inactive_selector =
503 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector();
504
505 for (const auto& child : children_) { 496 for (const auto& child : children_) {
506 if (child->IsFrameView()) 497 if (child->IsFrameView())
507 ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged(); 498 ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged();
508 } 499 }
509 500
510 for (const auto& scrollbar : scrollbars_) { 501 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
511 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar()) 502 for (const auto& paint_scrollbar : paint_scrollbars_) {
512 scrollbar->StyleChanged(); 503 if (paint_scrollbar->IsCustomScrollbar())
504 paint_scrollbar->StyleChanged();
505 }
506
507 RecalculateCustomScrollbarStyle();
513 } 508 }
514
515 if (uses_window_inactive_selector)
516 RecalculateCustomScrollbarStyle();
517 } 509 }
518 510
519 void FrameView::Clear() { 511 void FrameView::Clear() {
520 Reset(); 512 Reset();
521 SetScrollbarsSuppressed(true); 513 SetScrollbarsSuppressed(true);
522 } 514 }
523 515
524 bool FrameView::DidFirstLayout() const { 516 bool FrameView::DidFirstLayout() const {
525 return !first_layout_; 517 return !first_layout_;
526 } 518 }
(...skipping 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after
3878 DCHECK(child->Parent() == this); 3870 DCHECK(child->Parent() == this);
3879 3871
3880 if (child->IsFrameView() && 3872 if (child->IsFrameView() &&
3881 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 3873 !RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3882 RemoveScrollableArea(ToFrameView(child)); 3874 RemoveScrollableArea(ToFrameView(child));
3883 3875
3884 child->SetParent(nullptr); 3876 child->SetParent(nullptr);
3885 children_.erase(child); 3877 children_.erase(child);
3886 } 3878 }
3887 3879
3888 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { 3880 void FrameView::RemovePaintScrollbar(Scrollbar* scrollbar) {
3889 DCHECK(scrollbars_.Contains(scrollbar)); 3881 DCHECK(paint_scrollbars_.Contains(scrollbar));
3890 scrollbar->SetParent(nullptr); 3882 paint_scrollbars_.erase(scrollbar);
3891 scrollbars_.erase(scrollbar);
3892 } 3883 }
3893 3884
3894 void FrameView::AddScrollbar(Scrollbar* scrollbar) { 3885 void FrameView::AddPaintScrollbar(Scrollbar* scrollbar) {
3895 DCHECK(!scrollbars_.Contains(scrollbar)); 3886 DCHECK(!paint_scrollbars_.Contains(scrollbar));
3896 scrollbar->SetParent(this); 3887 paint_scrollbars_.insert(scrollbar);
3897 scrollbars_.insert(scrollbar);
3898 } 3888 }
3899 3889
3900 bool FrameView::VisualViewportSuppliesScrollbars() { 3890 bool FrameView::VisualViewportSuppliesScrollbars() {
3901 // On desktop, we always use the layout viewport's scrollbars. 3891 // On desktop, we always use the layout viewport's scrollbars.
3902 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() || 3892 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() ||
3903 !frame_->GetDocument() || !frame_->GetPage()) 3893 !frame_->GetDocument() || !frame_->GetPage())
3904 return false; 3894 return false;
3905 3895
3906 const TopDocumentRootScrollerController& controller = 3896 const TopDocumentRootScrollerController& controller =
3907 frame_->GetPage()->GlobalRootScrollerController(); 3897 frame_->GetPage()->GlobalRootScrollerController();
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 } 4729 }
4740 4730
4741 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { 4731 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const {
4742 if (parent_) { 4732 if (parent_) {
4743 IntPoint parent_point = ConvertToContainingFrameView(local_point); 4733 IntPoint parent_point = ConvertToContainingFrameView(local_point);
4744 return parent_->ConvertToRootFrame(parent_point); 4734 return parent_->ConvertToRootFrame(parent_point);
4745 } 4735 }
4746 return local_point; 4736 return local_point;
4747 } 4737 }
4748 4738
4739 IntRect FrameView::ConvertFromRootFrame(
4740 const IntRect& rect_in_root_frame) const {
4741 if (parent_) {
4742 IntRect parent_rect = parent_->ConvertFromRootFrame(rect_in_root_frame);
4743 return ConvertFromContainingFrameView(parent_rect);
4744 }
4745 return rect_in_root_frame;
4746 }
4747
4748 IntPoint FrameView::ConvertFromRootFrame(
4749 const IntPoint& point_in_root_frame) const {
4750 if (parent_) {
4751 IntPoint parent_point = parent_->ConvertFromRootFrame(point_in_root_frame);
4752 return ConvertFromContainingFrameView(parent_point);
4753 }
4754 return point_in_root_frame;
4755 }
4756
4757 FloatPoint FrameView::ConvertFromRootFrame(
4758 const FloatPoint& point_in_root_frame) const {
4759 // FrameViews / windows are required to be IntPoint aligned, but we may
4760 // need to convert FloatPoint values within them (eg. for event
4761 // co-ordinates).
4762 IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
4763 FloatPoint parent_point = ConvertFromRootFrame(floored_point);
4764 FloatSize window_fraction = point_in_root_frame - floored_point;
4765 // Use linear interpolation handle any fractional value (eg. for iframes
4766 // subject to a transform beyond just a simple translation).
4767 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
4768 if (!window_fraction.IsEmpty()) {
4769 const int kFactor = 1000;
4770 IntPoint parent_line_end = ConvertFromRootFrame(
4771 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
4772 FloatSize parent_fraction =
4773 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
4774 parent_point.Move(parent_fraction);
4775 }
4776 return parent_point;
4777 }
4778
4749 IntPoint FrameView::ConvertFromContainingFrameViewToScrollbar( 4779 IntPoint FrameView::ConvertFromContainingFrameViewToScrollbar(
4750 const Scrollbar& scrollbar, 4780 const Scrollbar& scrollbar,
4751 const IntPoint& parent_point) const { 4781 const IntPoint& parent_point) const {
4752 IntPoint new_point = parent_point; 4782 IntPoint new_point = parent_point;
4753 // Scrollbars won't be transformed within us 4783 // Scrollbars won't be transformed within us
4754 new_point.MoveBy(-scrollbar.Location()); 4784 new_point.MoveBy(-scrollbar.Location());
4755 return new_point; 4785 return new_point;
4756 } 4786 }
4757 4787
4758 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item, 4788 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item,
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
5360 void FrameView::SetAnimationHost( 5390 void FrameView::SetAnimationHost(
5361 std::unique_ptr<CompositorAnimationHost> host) { 5391 std::unique_ptr<CompositorAnimationHost> host) {
5362 animation_host_ = std::move(host); 5392 animation_host_ = std::move(host);
5363 } 5393 }
5364 5394
5365 LayoutUnit FrameView::CaretWidth() const { 5395 LayoutUnit FrameView::CaretWidth() const {
5366 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5396 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5367 } 5397 }
5368 5398
5369 } // namespace blink 5399 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698