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

Side by Side Diff: Source/core/platform/Scrollbar.cpp

Issue 26936002: Remove Widget's dependency upon its own inheritor aka ScrollView. This was nasty from an OO design… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Fix for clang compile error Created 7 years, 2 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
« no previous file with comments | « Source/core/platform/Scrollbar.h ('k') | Source/core/platform/Widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Scrollbar::~Scrollbar() 94 Scrollbar::~Scrollbar()
95 { 95 {
96 if (AXObjectCache* cache = existingAXObjectCache()) 96 if (AXObjectCache* cache = existingAXObjectCache())
97 cache->remove(this); 97 cache->remove(this);
98 98
99 stopTimerIfNeeded(); 99 stopTimerIfNeeded();
100 100
101 m_theme->unregisterScrollbar(this); 101 m_theme->unregisterScrollbar(this);
102 } 102 }
103 103
104 void Scrollbar::removeFromParent()
105 {
106 if (parent())
107 toScrollView(parent())->removeChild(this);
108 }
109
110 ScrollView* Scrollbar::parentScrollView() const
111 {
112 return toScrollView(parent());
113 }
114
115 ScrollView* Scrollbar::rootScrollView() const
116 {
117 return toScrollView(root());
118 }
119
104 ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const 120 ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const
105 { 121 {
106 return m_scrollableArea ? m_scrollableArea->scrollbarOverlayStyle() : Scroll barOverlayStyleDefault; 122 return m_scrollableArea ? m_scrollableArea->scrollbarOverlayStyle() : Scroll barOverlayStyleDefault;
107 } 123 }
108 124
109 void Scrollbar::getTickmarks(Vector<IntRect>& tickmarks) const 125 void Scrollbar::getTickmarks(Vector<IntRect>& tickmarks) const
110 { 126 {
111 if (m_scrollableArea) 127 if (m_scrollableArea)
112 m_scrollableArea->getTickmarks(tickmarks); 128 m_scrollableArea->getTickmarks(tickmarks);
113 } 129 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 489
474 autoscrollPressedPart(theme()->initialAutoscrollTimerDelay()); 490 autoscrollPressedPart(theme()->initialAutoscrollTimerDelay());
475 } 491 }
476 492
477 void Scrollbar::setFrameRect(const IntRect& rect) 493 void Scrollbar::setFrameRect(const IntRect& rect)
478 { 494 {
479 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov erlap 495 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov erlap
480 // if necessary. 496 // if necessary.
481 IntRect adjustedRect(rect); 497 IntRect adjustedRect(rect);
482 bool overlapsResizer = false; 498 bool overlapsResizer = false;
483 ScrollView* view = parent(); 499 ScrollView* view = parentScrollView();
484 if (view && !rect.isEmpty() && !view->windowResizerRect().isEmpty()) { 500 if (view && !rect.isEmpty() && !view->windowResizerRect().isEmpty()) {
485 IntRect resizerRect = view->convertFromContainingWindow(view->windowResi zerRect()); 501 IntRect resizerRect = view->convertFromContainingWindow(view->windowResi zerRect());
486 if (rect.intersects(resizerRect)) { 502 if (rect.intersects(resizerRect)) {
487 if (orientation() == HorizontalScrollbar) { 503 if (orientation() == HorizontalScrollbar) {
488 int overlap = rect.maxX() - resizerRect.x(); 504 int overlap = rect.maxX() - resizerRect.x();
489 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) { 505 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) {
490 adjustedRect.setWidth(rect.width() - overlap); 506 adjustedRect.setWidth(rect.width() - overlap);
491 overlapsResizer = true; 507 overlapsResizer = true;
492 } 508 }
493 } else { 509 } else {
494 int overlap = rect.maxY() - resizerRect.y(); 510 int overlap = rect.maxY() - resizerRect.y();
495 if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) { 511 if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) {
496 adjustedRect.setHeight(rect.height() - overlap); 512 adjustedRect.setHeight(rect.height() - overlap);
497 overlapsResizer = true; 513 overlapsResizer = true;
498 } 514 }
499 } 515 }
500 } 516 }
501 } 517 }
502 if (overlapsResizer != m_overlapsResizer) { 518 if (overlapsResizer != m_overlapsResizer) {
503 m_overlapsResizer = overlapsResizer; 519 m_overlapsResizer = overlapsResizer;
504 if (view) 520 if (view)
505 view->adjustScrollbarsAvoidingResizerCount(m_overlapsResizer ? 1 : - 1); 521 view->adjustScrollbarsAvoidingResizerCount(m_overlapsResizer ? 1 : - 1);
506 } 522 }
507 523
508 Widget::setFrameRect(adjustedRect); 524 Widget::setFrameRect(adjustedRect);
509 } 525 }
510 526
511 void Scrollbar::setParent(ScrollView* parentView) 527 void Scrollbar::setParent(Widget* parentView)
512 { 528 {
513 if (!parentView && m_overlapsResizer && parent()) 529 if (!parentView && m_overlapsResizer && parentScrollView())
514 parent()->adjustScrollbarsAvoidingResizerCount(-1); 530 parentScrollView()->adjustScrollbarsAvoidingResizerCount(-1);
515 Widget::setParent(parentView); 531 Widget::setParent(parentView);
516 } 532 }
517 533
518 void Scrollbar::setEnabled(bool e) 534 void Scrollbar::setEnabled(bool e)
519 { 535 {
520 if (m_enabled == e) 536 if (m_enabled == e)
521 return; 537 return;
522 m_enabled = e; 538 m_enabled = e;
523 theme()->updateEnabledState(this); 539 theme()->updateEnabledState(this);
524 invalidate(); 540 invalidate();
(...skipping 12 matching lines...) Expand all
537 return m_scrollableArea->scrollAnimator()->shouldScrollbarParticipateInHitTe sting(this); 553 return m_scrollableArea->scrollAnimator()->shouldScrollbarParticipateInHitTe sting(this);
538 } 554 }
539 555
540 bool Scrollbar::isWindowActive() const 556 bool Scrollbar::isWindowActive() const
541 { 557 {
542 return m_scrollableArea && m_scrollableArea->isActive(); 558 return m_scrollableArea && m_scrollableArea->isActive();
543 } 559 }
544 560
545 AXObjectCache* Scrollbar::existingAXObjectCache() const 561 AXObjectCache* Scrollbar::existingAXObjectCache() const
546 { 562 {
547 if (!parent()) 563 if (!parentScrollView())
548 return 0; 564 return 0;
549 565
550 return parent()->axObjectCache(); 566 return parentScrollView()->axObjectCache();
551 } 567 }
552 568
553 void Scrollbar::invalidateRect(const IntRect& rect) 569 void Scrollbar::invalidateRect(const IntRect& rect)
554 { 570 {
555 if (suppressInvalidation()) 571 if (suppressInvalidation())
556 return; 572 return;
557 573
558 if (m_scrollableArea) 574 if (m_scrollableArea)
559 m_scrollableArea->invalidateScrollbar(this, rect); 575 m_scrollableArea->invalidateScrollbar(this, rect);
560 } 576 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 if (!m_scrollableArea) 612 if (!m_scrollableArea)
597 return 0; 613 return 0;
598 614
599 if (m_orientation == HorizontalScrollbar) 615 if (m_orientation == HorizontalScrollbar)
600 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); 616 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x();
601 617
602 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); 618 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y();
603 } 619 }
604 620
605 } // namespace WebCore 621 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/Scrollbar.h ('k') | Source/core/platform/Widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698