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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2834573005: Scrollbar no longer inherits from FrameViewBase. (Closed)
Patch Set: Update from upstream patch 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 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 235
236 DEFINE_TRACE(FrameView) { 236 DEFINE_TRACE(FrameView) {
237 visitor->Trace(frame_); 237 visitor->Trace(frame_);
238 visitor->Trace(fragment_anchor_); 238 visitor->Trace(fragment_anchor_);
239 visitor->Trace(scrollable_areas_); 239 visitor->Trace(scrollable_areas_);
240 visitor->Trace(animating_scrollable_areas_); 240 visitor->Trace(animating_scrollable_areas_);
241 visitor->Trace(auto_size_info_); 241 visitor->Trace(auto_size_info_);
242 visitor->Trace(children_); 242 visitor->Trace(children_);
243 visitor->Trace(plugins_); 243 visitor->Trace(plugins_);
244 visitor->Trace(scrollbars_);
244 visitor->Trace(viewport_scrollable_area_); 245 visitor->Trace(viewport_scrollable_area_);
245 visitor->Trace(visibility_observer_); 246 visitor->Trace(visibility_observer_);
246 visitor->Trace(scroll_anchor_); 247 visitor->Trace(scroll_anchor_);
247 visitor->Trace(anchoring_adjustment_queue_); 248 visitor->Trace(anchoring_adjustment_queue_);
248 visitor->Trace(scrollbar_manager_); 249 visitor->Trace(scrollbar_manager_);
249 visitor->Trace(print_context_); 250 visitor->Trace(print_context_);
250 FrameViewBase::Trace(visitor); 251 FrameViewBase::Trace(visitor);
251 ScrollableArea::Trace(visitor); 252 ScrollableArea::Trace(visitor);
252 } 253 }
253 254
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 409 }
409 } 410 }
410 411
411 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar( 412 void FrameView::ScrollbarManager::SetHasHorizontalScrollbar(
412 bool has_scrollbar) { 413 bool has_scrollbar) {
413 if (has_scrollbar == HasHorizontalScrollbar()) 414 if (has_scrollbar == HasHorizontalScrollbar())
414 return; 415 return;
415 416
416 if (has_scrollbar) { 417 if (has_scrollbar) {
417 h_bar_ = CreateScrollbar(kHorizontalScrollbar); 418 h_bar_ = CreateScrollbar(kHorizontalScrollbar);
418 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddChild( 419 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
419 h_bar_.Get()); 420 h_bar_);
420 h_bar_is_attached_ = 1; 421 h_bar_is_attached_ = 1;
421 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar); 422 scrollable_area_->DidAddScrollbar(*h_bar_, kHorizontalScrollbar);
422 h_bar_->StyleChanged(); 423 h_bar_->StyleChanged();
423 } else { 424 } else {
424 h_bar_is_attached_ = 0; 425 h_bar_is_attached_ = 0;
425 DestroyScrollbar(kHorizontalScrollbar); 426 DestroyScrollbar(kHorizontalScrollbar);
426 } 427 }
427 428
428 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); 429 scrollable_area_->SetScrollCornerNeedsPaintInvalidation();
429 } 430 }
430 431
431 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) { 432 void FrameView::ScrollbarManager::SetHasVerticalScrollbar(bool has_scrollbar) {
432 if (has_scrollbar == HasVerticalScrollbar()) 433 if (has_scrollbar == HasVerticalScrollbar())
433 return; 434 return;
434 435
435 if (has_scrollbar) { 436 if (has_scrollbar) {
436 v_bar_ = CreateScrollbar(kVerticalScrollbar); 437 v_bar_ = CreateScrollbar(kVerticalScrollbar);
437 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddChild( 438 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
438 v_bar_.Get()); 439 v_bar_);
439 v_bar_is_attached_ = 1; 440 v_bar_is_attached_ = 1;
440 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); 441 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar);
441 v_bar_->StyleChanged(); 442 v_bar_->StyleChanged();
442 } else { 443 } else {
443 v_bar_is_attached_ = 0; 444 v_bar_is_attached_ = 0;
444 DestroyScrollbar(kVerticalScrollbar); 445 DestroyScrollbar(kVerticalScrollbar);
445 } 446 }
446 447
447 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); 448 scrollable_area_->SetScrollCornerNeedsPaintInvalidation();
448 } 449 }
(...skipping 17 matching lines...) Expand all
466 void FrameView::ScrollbarManager::DestroyScrollbar( 467 void FrameView::ScrollbarManager::DestroyScrollbar(
467 ScrollbarOrientation orientation) { 468 ScrollbarOrientation orientation) {
468 Member<Scrollbar>& scrollbar = 469 Member<Scrollbar>& scrollbar =
469 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; 470 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_;
470 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ 471 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_
471 : !v_bar_is_attached_); 472 : !v_bar_is_attached_);
472 if (!scrollbar) 473 if (!scrollbar)
473 return; 474 return;
474 475
475 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); 476 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation);
476 scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveChild( 477 scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar(
477 scrollbar.Get()); 478 scrollbar);
478 scrollbar->DisconnectFromScrollableArea(); 479 scrollbar->DisconnectFromScrollableArea();
479 scrollbar = nullptr; 480 scrollbar = nullptr;
480 } 481 }
481 482
482 void FrameView::RecalculateCustomScrollbarStyle() { 483 void FrameView::RecalculateCustomScrollbarStyle() {
483 bool did_style_change = false; 484 bool did_style_change = false;
484 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { 485 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) {
485 HorizontalScrollbar()->StyleChanged(); 486 HorizontalScrollbar()->StyleChanged();
486 did_style_change = true; 487 did_style_change = true;
487 } 488 }
(...skipping 11 matching lines...) Expand all
499 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() { 500 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() {
500 bool uses_window_inactive_selector = 501 bool uses_window_inactive_selector =
501 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector(); 502 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector();
502 503
503 const ChildrenSet* view_children = Children(); 504 const ChildrenSet* view_children = Children();
504 for (const Member<FrameViewBase>& child : *view_children) { 505 for (const Member<FrameViewBase>& child : *view_children) {
505 FrameViewBase* frame_view_base = child.Get(); 506 FrameViewBase* frame_view_base = child.Get();
506 if (frame_view_base->IsFrameView()) { 507 if (frame_view_base->IsFrameView()) {
507 ToFrameView(frame_view_base) 508 ToFrameView(frame_view_base)
508 ->InvalidateAllCustomScrollbarsOnActiveChanged(); 509 ->InvalidateAllCustomScrollbarsOnActiveChanged();
509 } else if (uses_window_inactive_selector &&
510 frame_view_base->IsScrollbar() &&
511 ToScrollbar(frame_view_base)->IsCustomScrollbar()) {
512 ToScrollbar(frame_view_base)->StyleChanged();
513 } 510 }
514 } 511 }
512
513 for (const Member<Scrollbar>& scrollbar : *Scrollbars()) {
514 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar())
515 scrollbar->StyleChanged();
516 }
517
515 if (uses_window_inactive_selector) 518 if (uses_window_inactive_selector)
516 RecalculateCustomScrollbarStyle(); 519 RecalculateCustomScrollbarStyle();
517 } 520 }
518 521
519 void FrameView::Clear() { 522 void FrameView::Clear() {
520 Reset(); 523 Reset();
521 SetScrollbarsSuppressed(true); 524 SetScrollbarsSuppressed(true);
522 } 525 }
523 526
524 bool FrameView::DidFirstLayout() const { 527 bool FrameView::DidFirstLayout() const {
(...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 IntPoint point = frame_point; 3621 IntPoint point = frame_point;
3619 3622
3620 // Convert from FrameView coords into page ("absolute") coordinates. 3623 // Convert from FrameView coords into page ("absolute") coordinates.
3621 point += IntSize(ScrollX(), ScrollY()); 3624 point += IntSize(ScrollX(), ScrollY());
3622 3625
3623 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms)); 3626 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms));
3624 } 3627 }
3625 3628
3626 IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child, 3629 IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child,
3627 const IntPoint& point) const { 3630 const IntPoint& point) const {
3628 // TODO(joelhockey): Remove this check once Scrollbar no longer inherits from
3629 // FrameViewBase.
3630 DCHECK(!IsFrameViewScrollbar(child));
3631 IntPoint new_point = point; 3631 IntPoint new_point = point;
3632 new_point = FrameToContents(point); 3632 new_point = FrameToContents(point);
3633 new_point.MoveBy(-child->Location()); 3633 new_point.MoveBy(-child->Location());
3634 return new_point; 3634 return new_point;
3635 } 3635 }
3636 3636
3637 IntRect FrameView::ConvertToContainingFrameViewBase( 3637 IntRect FrameView::ConvertToContainingFrameViewBase(
3638 const IntRect& local_rect) const { 3638 const IntRect& local_rect) const {
3639 if (const FrameView* parent = ToFrameView(Parent())) { 3639 if (const FrameView* parent = ToFrameView(Parent())) {
3640 // Get our layoutObject in the parent view 3640 // Get our layoutObject in the parent view
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 plugins_.erase(plugin); 3852 plugins_.erase(plugin);
3853 } 3853 }
3854 3854
3855 void FrameView::AddPlugin(PluginView* plugin) { 3855 void FrameView::AddPlugin(PluginView* plugin) {
3856 DCHECK(!plugin->Parent()); 3856 DCHECK(!plugin->Parent());
3857 DCHECK(!plugins_.Contains(plugin)); 3857 DCHECK(!plugins_.Contains(plugin));
3858 plugin->SetParent(this); 3858 plugin->SetParent(this);
3859 plugins_.insert(plugin); 3859 plugins_.insert(plugin);
3860 } 3860 }
3861 3861
3862 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) {
3863 DCHECK(scrollbars_.Contains(scrollbar));
3864 scrollbar->SetParent(nullptr);
3865 scrollbars_.erase(scrollbar);
3866 }
3867
3868 void FrameView::AddScrollbar(Scrollbar* scrollbar) {
3869 DCHECK(!scrollbars_.Contains(scrollbar));
3870 scrollbar->SetParent(this);
3871 scrollbars_.insert(scrollbar);
3872 }
3873
3862 bool FrameView::VisualViewportSuppliesScrollbars() { 3874 bool FrameView::VisualViewportSuppliesScrollbars() {
3863 // On desktop, we always use the layout viewport's scrollbars. 3875 // On desktop, we always use the layout viewport's scrollbars.
3864 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() || 3876 if (!frame_->GetSettings() || !frame_->GetSettings()->GetViewportEnabled() ||
3865 !frame_->GetDocument() || !frame_->GetPage()) 3877 !frame_->GetDocument() || !frame_->GetPage())
3866 return false; 3878 return false;
3867 3879
3868 const TopDocumentRootScrollerController& controller = 3880 const TopDocumentRootScrollerController& controller =
3869 frame_->GetPage()->GlobalRootScrollerController(); 3881 frame_->GetPage()->GlobalRootScrollerController();
3870 3882
3871 if (!LayoutViewportScrollableArea()) 3883 if (!LayoutViewportScrollableArea())
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
5342 void FrameView::SetAnimationHost( 5354 void FrameView::SetAnimationHost(
5343 std::unique_ptr<CompositorAnimationHost> host) { 5355 std::unique_ptr<CompositorAnimationHost> host) {
5344 animation_host_ = std::move(host); 5356 animation_host_ = std::move(host);
5345 } 5357 }
5346 5358
5347 LayoutUnit FrameView::CaretWidth() const { 5359 LayoutUnit FrameView::CaretWidth() const {
5348 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5360 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5349 } 5361 }
5350 5362
5351 } // namespace blink 5363 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698