OLD | NEW |
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar( | 415 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar( |
416 bool has_scrollbar) { | 416 bool has_scrollbar) { |
417 if (has_scrollbar == HasHorizontalScrollbar()) | 417 if (has_scrollbar == HasHorizontalScrollbar()) |
418 return; | 418 return; |
419 | 419 |
420 if (has_scrollbar) { | 420 if (has_scrollbar) { |
421 h_bar_ = CreateScrollbar(kHorizontalScrollbar); | 421 h_bar_ = CreateScrollbar(kHorizontalScrollbar); |
422 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar( | |
423 h_bar_); | |
424 h_bar_is_attached_ = 1; | 422 h_bar_is_attached_ = 1; |
425 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar); | 423 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar); |
426 h_bar_->StyleChanged(); | 424 h_bar_->StyleChanged(); |
427 } else { | 425 } else { |
428 h_bar_is_attached_ = 0; | 426 h_bar_is_attached_ = 0; |
429 DestroyScrollbar(kHorizontalScrollbar); | 427 DestroyScrollbar(kHorizontalScrollbar); |
430 } | 428 } |
431 | 429 |
432 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); | 430 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); |
433 } | 431 } |
434 | 432 |
435 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) { | 433 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) { |
436 if (has_scrollbar == HasVerticalScrollbar()) | 434 if (has_scrollbar == HasVerticalScrollbar()) |
437 return; | 435 return; |
438 | 436 |
439 if (has_scrollbar) { | 437 if (has_scrollbar) { |
440 v_bar_ = CreateScrollbar(kVerticalScrollbar); | 438 v_bar_ = CreateScrollbar(kVerticalScrollbar); |
441 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar( | |
442 v_bar_); | |
443 v_bar_is_attached_ = 1; | 439 v_bar_is_attached_ = 1; |
444 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); | 440 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); |
445 v_bar_->StyleChanged(); | 441 v_bar_->StyleChanged(); |
446 } else { | 442 } else { |
447 v_bar_is_attached_ = 0; | 443 v_bar_is_attached_ = 0; |
448 DestroyScrollbar(kVerticalScrollbar); | 444 DestroyScrollbar(kVerticalScrollbar); |
449 } | 445 } |
450 | 446 |
451 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); | 447 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); |
452 } | 448 } |
(...skipping 17 matching lines...) Expand all Loading... |
470 void FrameView::ScrollbarManager::DestroyScrollbar( | 466 void FrameView::ScrollbarManager::DestroyScrollbar( |
471 ScrollbarOrientation orientation) { | 467 ScrollbarOrientation orientation) { |
472 Member<Scrollbar>& scrollbar = | 468 Member<Scrollbar>& scrollbar = |
473 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; | 469 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; |
474 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ | 470 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ |
475 : !v_bar_is_attached_); | 471 : !v_bar_is_attached_); |
476 if (!scrollbar) | 472 if (!scrollbar) |
477 return; | 473 return; |
478 | 474 |
479 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); | 475 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); |
480 scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar( | |
481 scrollbar); | |
482 scrollbar->DisconnectFromScrollableArea(); | 476 scrollbar->DisconnectFromScrollableArea(); |
483 scrollbar = nullptr; | 477 scrollbar = nullptr; |
484 } | 478 } |
485 | 479 |
486 void FrameView::RecalculateCustomScrollbarStyle() { | 480 void FrameView::RecalculateCustomScrollbarStyle() { |
487 bool did_style_change = false; | 481 bool did_style_change = false; |
488 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { | 482 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { |
489 HorizontalScrollbar()->StyleChanged(); | 483 HorizontalScrollbar()->StyleChanged(); |
490 did_style_change = true; | 484 did_style_change = true; |
491 } | 485 } |
(...skipping 3380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3872 if (child->IsFrameView() && | 3866 if (child->IsFrameView() && |
3873 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 3867 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
3874 RemoveScrollableArea(ToFrameView(child)); | 3868 RemoveScrollableArea(ToFrameView(child)); |
3875 | 3869 |
3876 child->SetParent(nullptr); | 3870 child->SetParent(nullptr); |
3877 children_.erase(child); | 3871 children_.erase(child); |
3878 } | 3872 } |
3879 | 3873 |
3880 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { | 3874 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { |
3881 DCHECK(scrollbars_.Contains(scrollbar)); | 3875 DCHECK(scrollbars_.Contains(scrollbar)); |
3882 scrollbar->SetParent(nullptr); | |
3883 scrollbars_.erase(scrollbar); | 3876 scrollbars_.erase(scrollbar); |
3884 } | 3877 } |
3885 | 3878 |
3886 void FrameView::AddScrollbar(Scrollbar* scrollbar) { | 3879 void FrameView::AddScrollbar(Scrollbar* scrollbar) { |
3887 DCHECK(!scrollbars_.Contains(scrollbar)); | 3880 DCHECK(!scrollbars_.Contains(scrollbar)); |
3888 scrollbar->SetParent(this); | |
3889 scrollbars_.insert(scrollbar); | 3881 scrollbars_.insert(scrollbar); |
3890 } | 3882 } |
3891 | 3883 |
3892 bool FrameView::VisualViewportSuppliesScrollbars() { | 3884 bool FrameView::VisualViewportSuppliesScrollbars() { |
3893 // On desktop, we always use the layout viewport's scrollbars. | 3885 // On desktop, we always use the layout viewport's scrollbars. |
3894 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() || | 3886 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() || |
3895 !frame_->GetDocument() || !frame_->GetPage()) | 3887 !frame_->GetDocument() || !frame_->GetPage()) |
3896 return false; | 3888 return false; |
3897 | 3889 |
3898 const TopDocumentRootScrollerController& controller = | 3890 const TopDocumentRootScrollerController& controller = |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4731 } | 4723 } |
4732 | 4724 |
4733 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { | 4725 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { |
4734 if (parent_) { | 4726 if (parent_) { |
4735 IntPoint parent_point = ConvertToContainingFrameViewBase(local_point); | 4727 IntPoint parent_point = ConvertToContainingFrameViewBase(local_point); |
4736 return parent_->ConvertToRootFrame(parent_point); | 4728 return parent_->ConvertToRootFrame(parent_point); |
4737 } | 4729 } |
4738 return local_point; | 4730 return local_point; |
4739 } | 4731 } |
4740 | 4732 |
| 4733 IntRect FrameView::ConvertFromRootFrame( |
| 4734 const IntRect& rect_in_root_frame) const { |
| 4735 if (parent_) { |
| 4736 IntRect parent_rect = parent_->ConvertFromRootFrame(rect_in_root_frame); |
| 4737 return ConvertFromContainingFrameViewBase(parent_rect); |
| 4738 } |
| 4739 return rect_in_root_frame; |
| 4740 } |
| 4741 |
| 4742 IntPoint FrameView::ConvertFromRootFrame( |
| 4743 const IntPoint& point_in_root_frame) const { |
| 4744 if (parent_) { |
| 4745 IntPoint parent_point = parent_->ConvertFromRootFrame(point_in_root_frame); |
| 4746 return ConvertFromContainingFrameViewBase(parent_point); |
| 4747 } |
| 4748 return point_in_root_frame; |
| 4749 } |
| 4750 |
| 4751 FloatPoint FrameView::ConvertFromRootFrame( |
| 4752 const FloatPoint& point_in_root_frame) const { |
| 4753 // FrameViews / windows are required to be IntPoint aligned, but we may |
| 4754 // need to convert FloatPoint values within them (eg. for event |
| 4755 // co-ordinates). |
| 4756 IntPoint floored_point = FlooredIntPoint(point_in_root_frame); |
| 4757 FloatPoint parent_point = ConvertFromRootFrame(floored_point); |
| 4758 FloatSize window_fraction = point_in_root_frame - floored_point; |
| 4759 // Use linear interpolation handle any fractional value (eg. for iframes |
| 4760 // subject to a transform beyond just a simple translation). |
| 4761 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. |
| 4762 if (!window_fraction.IsEmpty()) { |
| 4763 const int kFactor = 1000; |
| 4764 IntPoint parent_line_end = ConvertFromRootFrame( |
| 4765 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor))); |
| 4766 FloatSize parent_fraction = |
| 4767 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor); |
| 4768 parent_point.Move(parent_fraction); |
| 4769 } |
| 4770 return parent_point; |
| 4771 } |
| 4772 |
4741 IntPoint FrameView::ConvertFromContainingFrameViewBaseToScrollbar( | 4773 IntPoint FrameView::ConvertFromContainingFrameViewBaseToScrollbar( |
4742 const Scrollbar& scrollbar, | 4774 const Scrollbar& scrollbar, |
4743 const IntPoint& parent_point) const { | 4775 const IntPoint& parent_point) const { |
4744 IntPoint new_point = parent_point; | 4776 IntPoint new_point = parent_point; |
4745 // Scrollbars won't be transformed within us | 4777 // Scrollbars won't be transformed within us |
4746 new_point.MoveBy(-scrollbar.Location()); | 4778 new_point.MoveBy(-scrollbar.Location()); |
4747 return new_point; | 4779 return new_point; |
4748 } | 4780 } |
4749 | 4781 |
4750 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item, | 4782 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item, |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5357 void FrameView::SetAnimationHost( | 5389 void FrameView::SetAnimationHost( |
5358 std::unique_ptr<CompositorAnimationHost> host) { | 5390 std::unique_ptr<CompositorAnimationHost> host) { |
5359 animation_host_ = std::move(host); | 5391 animation_host_ = std::move(host); |
5360 } | 5392 } |
5361 | 5393 |
5362 LayoutUnit FrameView::CaretWidth() const { | 5394 LayoutUnit FrameView::CaretWidth() const { |
5363 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); | 5395 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); |
5364 } | 5396 } |
5365 | 5397 |
5366 } // namespace blink | 5398 } // namespace blink |
OLD | NEW |