| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ScrollableArea::setScrollOrigin(const IntPoint& origin) | 112 void ScrollableArea::setScrollOrigin(const IntPoint& origin) |
| 113 { | 113 { |
| 114 if (m_scrollOrigin != origin) { | 114 if (m_scrollOrigin != origin) { |
| 115 m_scrollOrigin = origin; | 115 m_scrollOrigin = origin; |
| 116 m_scrollOriginChanged = true; | 116 m_scrollOriginChanged = true; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 GraphicsLayer* ScrollableArea::layerForContainer() const | |
| 121 { | |
| 122 return layerForScrolling() ? layerForScrolling()->parent() : 0; | |
| 123 } | |
| 124 | |
| 125 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula
rity, float delta) | 120 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula
rity, float delta) |
| 126 { | 121 { |
| 127 ScrollbarOrientation orientation; | 122 ScrollbarOrientation orientation; |
| 128 | 123 |
| 129 if (direction == ScrollUp || direction == ScrollDown) | 124 if (direction == ScrollUp || direction == ScrollDown) |
| 130 orientation = VerticalScrollbar; | 125 orientation = VerticalScrollbar; |
| 131 else | 126 else |
| 132 orientation = HorizontalScrollbar; | 127 orientation = HorizontalScrollbar; |
| 133 | 128 |
| 134 if (!userInputScrollable(orientation)) | 129 if (!userInputScrollable(orientation)) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 187 |
| 193 IntPoint oldPosition = scrollPosition(); | 188 IntPoint oldPosition = scrollPosition(); |
| 194 // Tell the derived class to scroll its contents. | 189 // Tell the derived class to scroll its contents. |
| 195 setScrollOffset(position); | 190 setScrollOffset(position); |
| 196 | 191 |
| 197 Scrollbar* verticalScrollbar = this->verticalScrollbar(); | 192 Scrollbar* verticalScrollbar = this->verticalScrollbar(); |
| 198 | 193 |
| 199 // Tell the scrollbars to update their thumb postions. | 194 // Tell the scrollbars to update their thumb postions. |
| 200 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 195 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
| 201 horizontalScrollbar->offsetDidChange(); | 196 horizontalScrollbar->offsetDidChange(); |
| 202 if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalS
crollbar()) { | 197 if (horizontalScrollbar->isOverlayScrollbar()) { |
| 203 if (!verticalScrollbar) | 198 if (!verticalScrollbar) |
| 204 horizontalScrollbar->invalidate(); | 199 horizontalScrollbar->invalidate(); |
| 205 else { | 200 else { |
| 206 // If there is both a horizontalScrollbar and a verticalScrollba
r, | 201 // If there is both a horizontalScrollbar and a verticalScrollba
r, |
| 207 // then we must also invalidate the corner between them. | 202 // then we must also invalidate the corner between them. |
| 208 IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); | 203 IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); |
| 209 boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrol
lbar->width()); | 204 boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrol
lbar->width()); |
| 210 horizontalScrollbar->invalidateRect(boundsAndCorner); | 205 horizontalScrollbar->invalidateRect(boundsAndCorner); |
| 211 } | 206 } |
| 212 } | 207 } |
| 213 } | 208 } |
| 214 if (verticalScrollbar) { | 209 if (verticalScrollbar) { |
| 215 verticalScrollbar->offsetDidChange(); | 210 verticalScrollbar->offsetDidChange(); |
| 216 if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrol
lbar()) | 211 if (verticalScrollbar->isOverlayScrollbar()) |
| 217 verticalScrollbar->invalidate(); | 212 verticalScrollbar->invalidate(); |
| 218 } | 213 } |
| 219 | 214 |
| 220 if (scrollPosition() != oldPosition) | 215 if (scrollPosition() != oldPosition) |
| 221 scrollAnimator()->notifyContentAreaScrolled(scrollPosition() - oldPositi
on); | 216 scrollAnimator()->notifyContentAreaScrolled(scrollPosition() - oldPositi
on); |
| 222 } | 217 } |
| 223 | 218 |
| 224 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro
llBehavior& behavior) | 219 bool ScrollableArea::scrollBehaviorFromString(const String& behaviorString, Scro
llBehavior& behavior) |
| 225 { | 220 { |
| 226 if (behaviorString == "auto") | 221 if (behaviorString == "auto") |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 scrollbar->invalidate(); | 357 scrollbar->invalidate(); |
| 363 } | 358 } |
| 364 | 359 |
| 365 if (Scrollbar* scrollbar = verticalScrollbar()) { | 360 if (Scrollbar* scrollbar = verticalScrollbar()) { |
| 366 scrollbar->invalidate(); | 361 scrollbar->invalidate(); |
| 367 } | 362 } |
| 368 } | 363 } |
| 369 | 364 |
| 370 void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& re
ct) | 365 void ScrollableArea::invalidateScrollbar(Scrollbar* scrollbar, const IntRect& re
ct) |
| 371 { | 366 { |
| 372 if (scrollbar == horizontalScrollbar()) { | |
| 373 if (GraphicsLayer* graphicsLayer = layerForHorizontalScrollbar()) { | |
| 374 graphicsLayer->setNeedsDisplay(); | |
| 375 graphicsLayer->setContentsNeedsDisplay(); | |
| 376 return; | |
| 377 } | |
| 378 } else if (scrollbar == verticalScrollbar()) { | |
| 379 if (GraphicsLayer* graphicsLayer = layerForVerticalScrollbar()) { | |
| 380 graphicsLayer->setNeedsDisplay(); | |
| 381 graphicsLayer->setContentsNeedsDisplay(); | |
| 382 return; | |
| 383 } | |
| 384 } | |
| 385 invalidateScrollbarRect(scrollbar, rect); | 367 invalidateScrollbarRect(scrollbar, rect); |
| 386 } | 368 } |
| 387 | 369 |
| 388 bool ScrollableArea::hasLayerForHorizontalScrollbar() const | |
| 389 { | |
| 390 return layerForHorizontalScrollbar(); | |
| 391 } | |
| 392 | |
| 393 bool ScrollableArea::hasLayerForVerticalScrollbar() const | |
| 394 { | |
| 395 return layerForVerticalScrollbar(); | |
| 396 } | |
| 397 | |
| 398 bool ScrollableArea::scheduleAnimation() | 370 bool ScrollableArea::scheduleAnimation() |
| 399 { | 371 { |
| 400 WTF_LOG(ScriptedAnimationController, "ScrollableArea::scheduleAnimation: win
dow = %d", | 372 WTF_LOG(ScriptedAnimationController, "ScrollableArea::scheduleAnimation: win
dow = %d", |
| 401 hostWindow() ? 1 : 0); | 373 hostWindow() ? 1 : 0); |
| 402 if (HostWindow* window = hostWindow()) { | 374 if (HostWindow* window = hostWindow()) { |
| 403 window->scheduleAnimation(); | 375 window->scheduleAnimation(); |
| 404 return true; | 376 return true; |
| 405 } | 377 } |
| 406 return false; | 378 return false; |
| 407 } | 379 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 434 { | 406 { |
| 435 return scrollSize(orientation); | 407 return scrollSize(orientation); |
| 436 } | 408 } |
| 437 | 409 |
| 438 float ScrollableArea::pixelStep(ScrollbarOrientation) const | 410 float ScrollableArea::pixelStep(ScrollbarOrientation) const |
| 439 { | 411 { |
| 440 return 1; | 412 return 1; |
| 441 } | 413 } |
| 442 | 414 |
| 443 } // namespace blink | 415 } // namespace blink |
| OLD | NEW |