| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 LayoutScrollbarTheme::layoutScrollbarTheme()), | 55 LayoutScrollbarTheme::layoutScrollbarTheme()), |
| 56 m_styleSource(styleSource) { | 56 m_styleSource(styleSource) { |
| 57 DCHECK(styleSource); | 57 DCHECK(styleSource); |
| 58 | 58 |
| 59 // FIXME: We need to do this because LayoutScrollbar::styleChanged is called | 59 // FIXME: We need to do this because LayoutScrollbar::styleChanged is called |
| 60 // as soon as the scrollbar is created. | 60 // as soon as the scrollbar is created. |
| 61 | 61 |
| 62 // Update the scrollbar size. | 62 // Update the scrollbar size. |
| 63 IntRect rect(0, 0, 0, 0); | 63 IntRect rect(0, 0, 0, 0); |
| 64 updateScrollbarPart(ScrollbarBGPart); | 64 updateScrollbarPart(ScrollbarBGPart); |
| 65 if (LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { | 65 if (LayoutScrollbarPart* part = m_parts.at(ScrollbarBGPart)) { |
| 66 part->layout(); | 66 part->layout(); |
| 67 rect.setSize(flooredIntSize(part->size())); | 67 rect.setSize(flooredIntSize(part->size())); |
| 68 } else if (this->orientation() == HorizontalScrollbar) { | 68 } else if (this->orientation() == HorizontalScrollbar) { |
| 69 rect.setWidth(this->width()); | 69 rect.setWidth(this->width()); |
| 70 } else { | 70 } else { |
| 71 rect.setHeight(this->height()); | 71 rect.setHeight(this->height()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 setFrameRect(rect); | 74 setFrameRect(rect); |
| 75 } | 75 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 updateScrollbarPart(TrackBGPart, destroy); | 165 updateScrollbarPart(TrackBGPart, destroy); |
| 166 | 166 |
| 167 if (destroy) | 167 if (destroy) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 // See if the scrollbar's thickness changed. If so, we need to mark our | 170 // See if the scrollbar's thickness changed. If so, we need to mark our |
| 171 // owning object as needing a layout. | 171 // owning object as needing a layout. |
| 172 bool isHorizontal = orientation() == HorizontalScrollbar; | 172 bool isHorizontal = orientation() == HorizontalScrollbar; |
| 173 int oldThickness = isHorizontal ? height() : width(); | 173 int oldThickness = isHorizontal ? height() : width(); |
| 174 int newThickness = 0; | 174 int newThickness = 0; |
| 175 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart); | 175 LayoutScrollbarPart* part = m_parts.at(ScrollbarBGPart); |
| 176 if (part) { | 176 if (part) { |
| 177 part->layout(); | 177 part->layout(); |
| 178 newThickness = | 178 newThickness = |
| 179 (isHorizontal ? part->size().height() : part->size().width()).toInt(); | 179 (isHorizontal ? part->size().height() : part->size().width()).toInt(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 if (newThickness != oldThickness) { | 182 if (newThickness != oldThickness) { |
| 183 setFrameRect( | 183 setFrameRect( |
| 184 IntRect(location(), IntSize(isHorizontal ? width() : newThickness, | 184 IntRect(location(), IntSize(isHorizontal ? width() : newThickness, |
| 185 isHorizontal ? newThickness : height()))); | 185 isHorizontal ? newThickness : height()))); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 needLayoutObject = | 255 needLayoutObject = |
| 256 (buttonsPlacement == WebScrollbarButtonsPlacementSingle || | 256 (buttonsPlacement == WebScrollbarButtonsPlacementSingle || |
| 257 buttonsPlacement == WebScrollbarButtonsPlacementDoubleEnd || | 257 buttonsPlacement == WebScrollbarButtonsPlacementDoubleEnd || |
| 258 buttonsPlacement == WebScrollbarButtonsPlacementDoubleBoth); | 258 buttonsPlacement == WebScrollbarButtonsPlacementDoubleBoth); |
| 259 break; | 259 break; |
| 260 default: | 260 default: |
| 261 break; | 261 break; |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 LayoutScrollbarPart* partLayoutObject = m_parts.get(partType); | 265 LayoutScrollbarPart* partLayoutObject = m_parts.at(partType); |
| 266 if (!partLayoutObject && needLayoutObject && m_scrollableArea) { | 266 if (!partLayoutObject && needLayoutObject && m_scrollableArea) { |
| 267 partLayoutObject = LayoutScrollbarPart::createAnonymous( | 267 partLayoutObject = LayoutScrollbarPart::createAnonymous( |
| 268 &styleSource()->document(), m_scrollableArea, this, partType); | 268 &styleSource()->document(), m_scrollableArea, this, partType); |
| 269 m_parts.set(partType, partLayoutObject); | 269 m_parts.set(partType, partLayoutObject); |
| 270 setNeedsPaintInvalidation(partType); | 270 setNeedsPaintInvalidation(partType); |
| 271 } else if (partLayoutObject && !needLayoutObject) { | 271 } else if (partLayoutObject && !needLayoutObject) { |
| 272 m_parts.erase(partType); | 272 m_parts.erase(partType); |
| 273 partLayoutObject->destroy(); | 273 partLayoutObject->destroy(); |
| 274 partLayoutObject = nullptr; | 274 partLayoutObject = nullptr; |
| 275 if (!destroy) | 275 if (!destroy) |
| 276 setNeedsPaintInvalidation(partType); | 276 setNeedsPaintInvalidation(partType); |
| 277 } | 277 } |
| 278 | 278 |
| 279 if (partLayoutObject) | 279 if (partLayoutObject) |
| 280 partLayoutObject->setStyleWithWritingModeOfParent(std::move(partStyle)); | 280 partLayoutObject->setStyleWithWritingModeOfParent(std::move(partStyle)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 IntRect LayoutScrollbar::buttonRect(ScrollbarPart partType) const { | 283 IntRect LayoutScrollbar::buttonRect(ScrollbarPart partType) const { |
| 284 LayoutScrollbarPart* partLayoutObject = m_parts.get(partType); | 284 LayoutScrollbarPart* partLayoutObject = m_parts.at(partType); |
| 285 if (!partLayoutObject) | 285 if (!partLayoutObject) |
| 286 return IntRect(); | 286 return IntRect(); |
| 287 | 287 |
| 288 partLayoutObject->layout(); | 288 partLayoutObject->layout(); |
| 289 | 289 |
| 290 bool isHorizontal = orientation() == HorizontalScrollbar; | 290 bool isHorizontal = orientation() == HorizontalScrollbar; |
| 291 if (partType == BackButtonStartPart) | 291 if (partType == BackButtonStartPart) |
| 292 return IntRect( | 292 return IntRect( |
| 293 location(), | 293 location(), |
| 294 IntSize( | 294 IntSize( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 320 partLayoutObject->pixelSnappedWidth() | 320 partLayoutObject->pixelSnappedWidth() |
| 321 : x(), | 321 : x(), |
| 322 isHorizontal ? y() | 322 isHorizontal ? y() |
| 323 : y() + height() - followingButton.height() - | 323 : y() + height() - followingButton.height() - |
| 324 partLayoutObject->pixelSnappedHeight(), | 324 partLayoutObject->pixelSnappedHeight(), |
| 325 isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), | 325 isHorizontal ? partLayoutObject->pixelSnappedWidth() : width(), |
| 326 isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); | 326 isHorizontal ? height() : partLayoutObject->pixelSnappedHeight()); |
| 327 } | 327 } |
| 328 | 328 |
| 329 IntRect LayoutScrollbar::trackRect(int startLength, int endLength) const { | 329 IntRect LayoutScrollbar::trackRect(int startLength, int endLength) const { |
| 330 LayoutScrollbarPart* part = m_parts.get(TrackBGPart); | 330 LayoutScrollbarPart* part = m_parts.at(TrackBGPart); |
| 331 if (part) | 331 if (part) |
| 332 part->layout(); | 332 part->layout(); |
| 333 | 333 |
| 334 if (orientation() == HorizontalScrollbar) { | 334 if (orientation() == HorizontalScrollbar) { |
| 335 int marginLeft = part ? part->marginLeft().toInt() : 0; | 335 int marginLeft = part ? part->marginLeft().toInt() : 0; |
| 336 int marginRight = part ? part->marginRight().toInt() : 0; | 336 int marginRight = part ? part->marginRight().toInt() : 0; |
| 337 startLength += marginLeft; | 337 startLength += marginLeft; |
| 338 endLength += marginRight; | 338 endLength += marginRight; |
| 339 int totalLength = startLength + endLength; | 339 int totalLength = startLength + endLength; |
| 340 return IntRect(x() + startLength, y(), width() - totalLength, height()); | 340 return IntRect(x() + startLength, y(), width() - totalLength, height()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 int marginTop = part ? part->marginTop().toInt() : 0; | 343 int marginTop = part ? part->marginTop().toInt() : 0; |
| 344 int marginBottom = part ? part->marginBottom().toInt() : 0; | 344 int marginBottom = part ? part->marginBottom().toInt() : 0; |
| 345 startLength += marginTop; | 345 startLength += marginTop; |
| 346 endLength += marginBottom; | 346 endLength += marginBottom; |
| 347 int totalLength = startLength + endLength; | 347 int totalLength = startLength + endLength; |
| 348 | 348 |
| 349 return IntRect(x(), y() + startLength, width(), height() - totalLength); | 349 return IntRect(x(), y() + startLength, width(), height() - totalLength); |
| 350 } | 350 } |
| 351 | 351 |
| 352 IntRect LayoutScrollbar::trackPieceRectWithMargins( | 352 IntRect LayoutScrollbar::trackPieceRectWithMargins( |
| 353 ScrollbarPart partType, | 353 ScrollbarPart partType, |
| 354 const IntRect& oldRect) const { | 354 const IntRect& oldRect) const { |
| 355 LayoutScrollbarPart* partLayoutObject = m_parts.get(partType); | 355 LayoutScrollbarPart* partLayoutObject = m_parts.at(partType); |
| 356 if (!partLayoutObject) | 356 if (!partLayoutObject) |
| 357 return oldRect; | 357 return oldRect; |
| 358 | 358 |
| 359 partLayoutObject->layout(); | 359 partLayoutObject->layout(); |
| 360 | 360 |
| 361 IntRect rect = oldRect; | 361 IntRect rect = oldRect; |
| 362 if (orientation() == HorizontalScrollbar) { | 362 if (orientation() == HorizontalScrollbar) { |
| 363 rect.setX((rect.x() + partLayoutObject->marginLeft()).toInt()); | 363 rect.setX((rect.x() + partLayoutObject->marginLeft()).toInt()); |
| 364 rect.setWidth((rect.width() - partLayoutObject->marginWidth()).toInt()); | 364 rect.setWidth((rect.width() - partLayoutObject->marginWidth()).toInt()); |
| 365 } else { | 365 } else { |
| 366 rect.setY((rect.y() + partLayoutObject->marginTop()).toInt()); | 366 rect.setY((rect.y() + partLayoutObject->marginTop()).toInt()); |
| 367 rect.setHeight((rect.height() - partLayoutObject->marginHeight()).toInt()); | 367 rect.setHeight((rect.height() - partLayoutObject->marginHeight()).toInt()); |
| 368 } | 368 } |
| 369 return rect; | 369 return rect; |
| 370 } | 370 } |
| 371 | 371 |
| 372 int LayoutScrollbar::minimumThumbLength() const { | 372 int LayoutScrollbar::minimumThumbLength() const { |
| 373 LayoutScrollbarPart* partLayoutObject = m_parts.get(ThumbPart); | 373 LayoutScrollbarPart* partLayoutObject = m_parts.at(ThumbPart); |
| 374 if (!partLayoutObject) | 374 if (!partLayoutObject) |
| 375 return 0; | 375 return 0; |
| 376 partLayoutObject->layout(); | 376 partLayoutObject->layout(); |
| 377 return (orientation() == HorizontalScrollbar | 377 return (orientation() == HorizontalScrollbar |
| 378 ? partLayoutObject->size().width() | 378 ? partLayoutObject->size().width() |
| 379 : partLayoutObject->size().height()) | 379 : partLayoutObject->size().height()) |
| 380 .toInt(); | 380 .toInt(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts() { | 383 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts() { |
| 384 for (auto& part : m_parts) { | 384 for (auto& part : m_parts) { |
| 385 ObjectPaintInvalidator(*part.value) | 385 ObjectPaintInvalidator(*part.value) |
| 386 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( | 386 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( |
| 387 PaintInvalidationScroll); | 387 PaintInvalidationScroll); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 void LayoutScrollbar::setVisualRect(const LayoutRect& rect) { | 391 void LayoutScrollbar::setVisualRect(const LayoutRect& rect) { |
| 392 Scrollbar::setVisualRect(rect); | 392 Scrollbar::setVisualRect(rect); |
| 393 for (auto& part : m_parts) | 393 for (auto& part : m_parts) |
| 394 part.value->setPreviousVisualRect(rect); | 394 part.value->setPreviousVisualRect(rect); |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace blink | 397 } // namespace blink |
| OLD | NEW |