| 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); | 470 scrollable_area_->DidAddScrollbar(*v_bar_, kVerticalScrollbar); |
| 471 v_bar_->StyleChanged(); | 471 v_bar_->StyleChanged(); |
| 472 } else { | 472 } else { |
| 473 v_bar_is_attached_ = 0; | 473 v_bar_is_attached_ = 0; |
| 474 DestroyScrollbar(kVerticalScrollbar); | 474 DestroyScrollbar(kVerticalScrollbar); |
| 475 } | 475 } |
| 476 | 476 |
| 477 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); | 477 scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 Scrollbar* LocalFrameView::ScrollbarManager::CreateScrollbar( | |
| 481 ScrollbarOrientation orientation) { | |
| 482 Element* custom_scrollbar_element = nullptr; | |
| 483 LayoutBox* box = scrollable_area_->GetLayoutBox(); | |
| 484 if (box->GetDocument().View()->ShouldUseCustomScrollbars( | |
| 485 custom_scrollbar_element)) { | |
| 486 return LayoutScrollbar::CreateCustomScrollbar( | |
| 487 scrollable_area_.Get(), orientation, custom_scrollbar_element); | |
| 488 } | |
| 489 | |
| 490 // Nobody set a custom style, so we just use a native scrollbar. | |
| 491 return Scrollbar::Create(scrollable_area_.Get(), orientation, | |
| 492 kRegularScrollbar, | |
| 493 &box->GetFrame()->GetPage()->GetChromeClient()); | |
| 494 } | |
| 495 | |
| 496 void LocalFrameView::ScrollbarManager::DestroyScrollbar( | |
| 497 ScrollbarOrientation orientation) { | |
| 498 Member<Scrollbar>& scrollbar = | |
| 499 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; | |
| 500 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ | |
| 501 : !v_bar_is_attached_); | |
| 502 if (!scrollbar) | |
| 503 return; | |
| 504 | |
| 505 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); | |
| 506 scrollbar->DisconnectFromScrollableArea(); | |
| 507 scrollbar = nullptr; | |
| 508 } | |
| 509 | |
| 510 void LocalFrameView::RecalculateCustomScrollbarStyle() { | 480 void LocalFrameView::RecalculateCustomScrollbarStyle() { |
| 511 bool did_style_change = false; | 481 bool did_style_change = false; |
| 512 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { | 482 if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { |
| 513 HorizontalScrollbar()->StyleChanged(); | 483 HorizontalScrollbar()->StyleChanged(); |
| 514 did_style_change = true; | 484 did_style_change = true; |
| 515 } | 485 } |
| 516 if (VerticalScrollbar() && VerticalScrollbar()->IsCustomScrollbar()) { | 486 if (VerticalScrollbar() && VerticalScrollbar()->IsCustomScrollbar()) { |
| 517 VerticalScrollbar()->StyleChanged(); | 487 VerticalScrollbar()->StyleChanged(); |
| 518 did_style_change = true; | 488 did_style_change = true; |
| 519 } | 489 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 644 |
| 675 ScrollbarMode new_horizontal_mode = horizontal_scrollbar_mode_; | 645 ScrollbarMode new_horizontal_mode = horizontal_scrollbar_mode_; |
| 676 if (can_have_scrollbars && horizontal_scrollbar_mode_ == kScrollbarAlwaysOff) | 646 if (can_have_scrollbars && horizontal_scrollbar_mode_ == kScrollbarAlwaysOff) |
| 677 new_horizontal_mode = kScrollbarAuto; | 647 new_horizontal_mode = kScrollbarAuto; |
| 678 else if (!can_have_scrollbars) | 648 else if (!can_have_scrollbars) |
| 679 new_horizontal_mode = kScrollbarAlwaysOff; | 649 new_horizontal_mode = kScrollbarAlwaysOff; |
| 680 | 650 |
| 681 SetScrollbarModes(new_horizontal_mode, new_vertical_mode); | 651 SetScrollbarModes(new_horizontal_mode, new_vertical_mode); |
| 682 } | 652 } |
| 683 | 653 |
| 684 bool LocalFrameView::ShouldUseCustomScrollbars( | 654 LayoutObject* LocalFrameView::LayoutObjectForScrollbarStyle() const { |
| 685 Element*& custom_scrollbar_element) const { | 655 LayoutViewItem layout_view_item = GetLayoutViewItem(); |
| 686 custom_scrollbar_element = nullptr; | 656 if (layout_view_item.IsNull()) |
| 657 return nullptr; |
| 687 | 658 |
| 688 if (Settings* settings = frame_->GetSettings()) { | 659 return layout_view_item.GetScrollableArea()->LayoutObjectForScrollbarStyle(); |
| 689 if (!settings->GetAllowCustomScrollbarInMainFrame() && | |
| 690 frame_->IsMainFrame()) | |
| 691 return false; | |
| 692 } | |
| 693 Document* doc = frame_->GetDocument(); | |
| 694 | |
| 695 // Try the <body> element first as a scrollbar source. | |
| 696 Element* body = doc ? doc->body() : 0; | |
| 697 if (body && body->GetLayoutObject() && | |
| 698 body->GetLayoutObject()->Style()->HasPseudoStyle(kPseudoIdScrollbar)) { | |
| 699 custom_scrollbar_element = body; | |
| 700 return true; | |
| 701 } | |
| 702 | |
| 703 // If the <body> didn't have a custom style, then the root element might. | |
| 704 Element* doc_element = doc ? doc->documentElement() : 0; | |
| 705 if (doc_element && doc_element->GetLayoutObject() && | |
| 706 doc_element->GetLayoutObject()->Style()->HasPseudoStyle( | |
| 707 kPseudoIdScrollbar)) { | |
| 708 custom_scrollbar_element = doc_element; | |
| 709 return true; | |
| 710 } | |
| 711 | |
| 712 return false; | |
| 713 } | 660 } |
| 714 | 661 |
| 715 Scrollbar* LocalFrameView::CreateScrollbar(ScrollbarOrientation orientation) { | 662 Scrollbar* LocalFrameView::CreateScrollbar(ScrollbarOrientation orientation) { |
| 716 return scrollbar_manager_.CreateScrollbar(orientation); | 663 return scrollbar_manager_.CreateScrollbar(orientation); |
| 717 } | 664 } |
| 718 | 665 |
| 719 void LocalFrameView::SetContentsSize(const IntSize& size) { | 666 void LocalFrameView::SetContentsSize(const IntSize& size) { |
| 720 if (size == ContentsSize()) | 667 if (size == ContentsSize()) |
| 721 return; | 668 return; |
| 722 | 669 |
| (...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 | 2130 |
| 2184 void LocalFrameView::ScrollbarExistenceMaybeChanged() { | 2131 void LocalFrameView::ScrollbarExistenceMaybeChanged() { |
| 2185 // We check to make sure the view is attached to a frame() as this method can | 2132 // We check to make sure the view is attached to a frame() as this method can |
| 2186 // be triggered before the view is attached by LocalFrame::createView(...) | 2133 // be triggered before the view is attached by LocalFrame::createView(...) |
| 2187 // setting various values such as setScrollBarModes(...) for example. An | 2134 // setting various values such as setScrollBarModes(...) for example. An |
| 2188 // ASSERT is triggered when a view is layout before being attached to a | 2135 // ASSERT is triggered when a view is layout before being attached to a |
| 2189 // frame(). | 2136 // frame(). |
| 2190 if (!GetFrame().View()) | 2137 if (!GetFrame().View()) |
| 2191 return; | 2138 return; |
| 2192 | 2139 |
| 2193 Element* custom_scrollbar_element = nullptr; | 2140 LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
| 2194 | |
| 2195 bool uses_overlay_scrollbars = | 2141 bool uses_overlay_scrollbars = |
| 2196 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && | 2142 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && |
| 2197 !ShouldUseCustomScrollbars(custom_scrollbar_element); | 2143 !(style_source && style_source->HasCustomScrollbarStyle()); |
| 2198 | 2144 |
| 2199 if (!uses_overlay_scrollbars && NeedsLayout()) | 2145 if (!uses_overlay_scrollbars && NeedsLayout()) |
| 2200 UpdateLayout(); | 2146 UpdateLayout(); |
| 2201 | 2147 |
| 2202 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) { | 2148 if (!GetLayoutViewItem().IsNull() && GetLayoutViewItem().UsesCompositing()) { |
| 2203 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange(); | 2149 GetLayoutViewItem().Compositor()->FrameViewScrollbarsExistenceDidChange(); |
| 2204 | 2150 |
| 2205 if (!uses_overlay_scrollbars) | 2151 if (!uses_overlay_scrollbars) |
| 2206 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize(); | 2152 GetLayoutViewItem().Compositor()->FrameViewDidChangeSize(); |
| 2207 } | 2153 } |
| (...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3996 } | 3942 } |
| 3997 | 3943 |
| 3998 void LocalFrameView::SetLayoutSizeInternal(const IntSize& size) { | 3944 void LocalFrameView::SetLayoutSizeInternal(const IntSize& size) { |
| 3999 if (layout_size_ == size) | 3945 if (layout_size_ == size) |
| 4000 return; | 3946 return; |
| 4001 | 3947 |
| 4002 layout_size_ = size; | 3948 layout_size_ = size; |
| 4003 ContentsResized(); | 3949 ContentsResized(); |
| 4004 } | 3950 } |
| 4005 | 3951 |
| 4006 void LocalFrameView::DidAddScrollbar(Scrollbar& scrollbar, | |
| 4007 ScrollbarOrientation orientation) { | |
| 4008 ScrollableArea::DidAddScrollbar(scrollbar, orientation); | |
| 4009 } | |
| 4010 | |
| 4011 PaintLayer* LocalFrameView::Layer() const { | 3952 PaintLayer* LocalFrameView::Layer() const { |
| 4012 LayoutViewItem layout_view = GetLayoutViewItem(); | 3953 LayoutViewItem layout_view = GetLayoutViewItem(); |
| 4013 if (layout_view.IsNull() || !layout_view.Compositor()) | 3954 if (layout_view.IsNull() || !layout_view.Compositor()) |
| 4014 return nullptr; | 3955 return nullptr; |
| 4015 | 3956 |
| 4016 return layout_view.Compositor()->RootLayer(); | 3957 return layout_view.Compositor()->RootLayer(); |
| 4017 } | 3958 } |
| 4018 | 3959 |
| 4019 IntSize LocalFrameView::MaximumScrollOffsetInt() const { | 3960 IntSize LocalFrameView::MaximumScrollOffsetInt() const { |
| 4020 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() | 3961 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 has_vertical_scrollbar != new_has_vertical_scrollbar; | 4289 has_vertical_scrollbar != new_has_vertical_scrollbar; |
| 4349 if (!scrollbar_existence_changed) | 4290 if (!scrollbar_existence_changed) |
| 4350 return false; | 4291 return false; |
| 4351 | 4292 |
| 4352 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar); | 4293 scrollbar_manager_.SetHasHorizontalScrollbar(new_has_horizontal_scrollbar); |
| 4353 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar); | 4294 scrollbar_manager_.SetHasVerticalScrollbar(new_has_vertical_scrollbar); |
| 4354 | 4295 |
| 4355 if (scrollbars_suppressed_) | 4296 if (scrollbars_suppressed_) |
| 4356 return true; | 4297 return true; |
| 4357 | 4298 |
| 4358 Element* custom_scrollbar_element = nullptr; | 4299 LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
| 4359 bool uses_overlay_scrollbars = | 4300 bool uses_overlay_scrollbars = |
| 4360 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && | 4301 ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && |
| 4361 !ShouldUseCustomScrollbars(custom_scrollbar_element); | 4302 !(style_source && style_source->HasCustomScrollbarStyle()); |
| 4362 | 4303 |
| 4363 if (!uses_overlay_scrollbars) | 4304 if (!uses_overlay_scrollbars) |
| 4364 SetNeedsLayout(); | 4305 SetNeedsLayout(); |
| 4365 | 4306 |
| 4366 ScrollbarExistenceMaybeChanged(); | 4307 ScrollbarExistenceMaybeChanged(); |
| 4367 return true; | 4308 return true; |
| 4368 } | 4309 } |
| 4369 | 4310 |
| 4370 bool LocalFrameView::NeedsScrollbarReconstruction() const { | 4311 bool LocalFrameView::NeedsScrollbarReconstruction() const { |
| 4371 Scrollbar* scrollbar = HorizontalScrollbar(); | 4312 Scrollbar* scrollbar = HorizontalScrollbar(); |
| 4372 if (!scrollbar) | 4313 if (!scrollbar) |
| 4373 scrollbar = VerticalScrollbar(); | 4314 scrollbar = VerticalScrollbar(); |
| 4374 if (!scrollbar) { | 4315 if (!scrollbar) { |
| 4375 // We have no scrollbar to reconstruct. | 4316 // We have no scrollbar to reconstruct. |
| 4376 return false; | 4317 return false; |
| 4377 } | 4318 } |
| 4378 Element* style_source = nullptr; | 4319 LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
| 4379 bool needs_custom = ShouldUseCustomScrollbars(style_source); | 4320 |
| 4321 bool needs_custom = style_source && style_source->HasCustomScrollbarStyle(); |
| 4380 bool is_custom = scrollbar->IsCustomScrollbar(); | 4322 bool is_custom = scrollbar->IsCustomScrollbar(); |
| 4381 if (needs_custom != is_custom) { | 4323 if (needs_custom != is_custom) { |
| 4382 // We have a native scrollbar that should be custom, or vice versa. | 4324 // We have a native scrollbar that should be custom, or vice versa. |
| 4383 return true; | 4325 return true; |
| 4384 } | 4326 } |
| 4385 if (!needs_custom) { | 4327 if (!needs_custom) { |
| 4386 // We have a native scrollbar that should remain native. | 4328 // We have a native scrollbar that should remain native. |
| 4387 return false; | 4329 return false; |
| 4388 } | 4330 } |
| 4389 DCHECK(needs_custom && is_custom); | 4331 DCHECK(needs_custom && is_custom); |
| 4390 DCHECK(style_source); | 4332 DCHECK(style_source); |
| 4391 if (ToLayoutScrollbar(scrollbar)->StyleSource() != | 4333 if (ToLayoutScrollbar(scrollbar)->StyleSource() != style_source) { |
| 4392 style_source->GetLayoutObject()) { | |
| 4393 // We have a custom scrollbar with a stale m_owner. | 4334 // We have a custom scrollbar with a stale m_owner. |
| 4394 return true; | 4335 return true; |
| 4395 } | 4336 } |
| 4396 return false; | 4337 return false; |
| 4397 } | 4338 } |
| 4398 | 4339 |
| 4399 bool LocalFrameView::ShouldIgnoreOverflowHidden() const { | 4340 bool LocalFrameView::ShouldIgnoreOverflowHidden() const { |
| 4400 return frame_->GetSettings()->GetIgnoreMainFrameOverflowHiddenQuirk() && | 4341 return frame_->GetSettings()->GetIgnoreMainFrameOverflowHiddenQuirk() && |
| 4401 frame_->IsMainFrame(); | 4342 frame_->IsMainFrame(); |
| 4402 } | 4343 } |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5473 void LocalFrameView::SetAnimationHost( | 5414 void LocalFrameView::SetAnimationHost( |
| 5474 std::unique_ptr<CompositorAnimationHost> host) { | 5415 std::unique_ptr<CompositorAnimationHost> host) { |
| 5475 animation_host_ = std::move(host); | 5416 animation_host_ = std::move(host); |
| 5476 } | 5417 } |
| 5477 | 5418 |
| 5478 LayoutUnit LocalFrameView::CaretWidth() const { | 5419 LayoutUnit LocalFrameView::CaretWidth() const { |
| 5479 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); | 5420 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); |
| 5480 } | 5421 } |
| 5481 | 5422 |
| 5482 } // namespace blink | 5423 } // namespace blink |
| OLD | NEW |