| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 * version of this file only under the terms of one of those two | 35 * version of this file only under the terms of one of those two |
| 36 * licenses (the MPL or the GPL) and not to allow others to use your | 36 * licenses (the MPL or the GPL) and not to allow others to use your |
| 37 * version of this file under the LGPL, indicate your decision by | 37 * version of this file under the LGPL, indicate your decision by |
| 38 * deletingthe provisions above and replace them with the notice and | 38 * deletingthe provisions above and replace them with the notice and |
| 39 * other provisions required by the MPL or the GPL, as the case may be. | 39 * other provisions required by the MPL or the GPL, as the case may be. |
| 40 * If you do not delete the provisions above, a recipient may use your | 40 * If you do not delete the provisions above, a recipient may use your |
| 41 * version of this file under any of the LGPL, the MPL or the GPL. | 41 * version of this file under any of the LGPL, the MPL or the GPL. |
| 42 */ | 42 */ |
| 43 | 43 |
| 44 #include "config.h" | 44 #include "config.h" |
| 45 #include "core/rendering/RenderLayer.h" | 45 #include "core/layout/Layer.h" |
| 46 | 46 |
| 47 #include "core/css/PseudoStyleRequest.h" | 47 #include "core/css/PseudoStyleRequest.h" |
| 48 #include "core/dom/AXObjectCache.h" | 48 #include "core/dom/AXObjectCache.h" |
| 49 #include "core/dom/Node.h" | 49 #include "core/dom/Node.h" |
| 50 #include "core/dom/shadow/ShadowRoot.h" | 50 #include "core/dom/shadow/ShadowRoot.h" |
| 51 #include "core/editing/FrameSelection.h" | 51 #include "core/editing/FrameSelection.h" |
| 52 #include "core/frame/FrameView.h" | 52 #include "core/frame/FrameView.h" |
| 53 #include "core/frame/LocalFrame.h" | 53 #include "core/frame/LocalFrame.h" |
| 54 #include "core/frame/Settings.h" | 54 #include "core/frame/Settings.h" |
| 55 #include "core/html/HTMLFrameOwnerElement.h" | 55 #include "core/html/HTMLFrameOwnerElement.h" |
| 56 #include "core/inspector/InspectorInstrumentation.h" | 56 #include "core/inspector/InspectorInstrumentation.h" |
| 57 #include "core/layout/LayoutTheme.h" | 57 #include "core/layout/LayoutTheme.h" |
| 58 #include "core/layout/compositing/CompositedLayerMapping.h" | 58 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 59 #include "core/layout/compositing/RenderLayerCompositor.h" | 59 #include "core/layout/compositing/LayerCompositor.h" |
| 60 #include "core/page/Chrome.h" | 60 #include "core/page/Chrome.h" |
| 61 #include "core/page/EventHandler.h" | 61 #include "core/page/EventHandler.h" |
| 62 #include "core/page/FocusController.h" | 62 #include "core/page/FocusController.h" |
| 63 #include "core/page/Page.h" | 63 #include "core/page/Page.h" |
| 64 #include "core/page/scrolling/ScrollingCoordinator.h" | 64 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 65 #include "core/rendering/RenderGeometryMap.h" | 65 #include "core/rendering/RenderGeometryMap.h" |
| 66 #include "core/rendering/RenderScrollbar.h" | 66 #include "core/rendering/RenderScrollbar.h" |
| 67 #include "core/rendering/RenderScrollbarPart.h" | 67 #include "core/rendering/RenderScrollbarPart.h" |
| 68 #include "core/rendering/RenderView.h" | 68 #include "core/rendering/RenderView.h" |
| 69 #include "platform/PlatformGestureEvent.h" | 69 #include "platform/PlatformGestureEvent.h" |
| 70 #include "platform/PlatformMouseEvent.h" | 70 #include "platform/PlatformMouseEvent.h" |
| 71 #include "platform/graphics/GraphicsContextStateSaver.h" | 71 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 72 #include "platform/graphics/GraphicsLayer.h" | 72 #include "platform/graphics/GraphicsLayer.h" |
| 73 #include "platform/graphics/paint/DrawingRecorder.h" | 73 #include "platform/graphics/paint/DrawingRecorder.h" |
| 74 #include "platform/scroll/ScrollAnimator.h" | 74 #include "platform/scroll/ScrollAnimator.h" |
| 75 #include "platform/scroll/ScrollbarTheme.h" | 75 #include "platform/scroll/ScrollbarTheme.h" |
| 76 #include "public/platform/Platform.h" | 76 #include "public/platform/Platform.h" |
| 77 | 77 |
| 78 namespace blink { | 78 namespace blink { |
| 79 | 79 |
| 80 const int ResizerControlExpandRatioForTouch = 2; | 80 const int ResizerControlExpandRatioForTouch = 2; |
| 81 | 81 |
| 82 RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer& layer) | 82 LayerScrollableArea::LayerScrollableArea(Layer& layer) |
| 83 : m_layer(layer) | 83 : m_layer(layer) |
| 84 , m_inResizeMode(false) | 84 , m_inResizeMode(false) |
| 85 , m_scrollsOverflow(false) | 85 , m_scrollsOverflow(false) |
| 86 , m_scrollDimensionsDirty(true) | 86 , m_scrollDimensionsDirty(true) |
| 87 , m_inOverflowRelayout(false) | 87 , m_inOverflowRelayout(false) |
| 88 , m_nextTopmostScrollChild(0) | 88 , m_nextTopmostScrollChild(0) |
| 89 , m_topmostScrollChild(0) | 89 , m_topmostScrollChild(0) |
| 90 , m_needsCompositedScrolling(false) | 90 , m_needsCompositedScrolling(false) |
| 91 , m_scrollCorner(nullptr) | 91 , m_scrollCorner(nullptr) |
| 92 , m_resizer(nullptr) | 92 , m_resizer(nullptr) |
| 93 { | 93 { |
| 94 ScrollableArea::setConstrainsScrollingToContentEdge(false); | 94 ScrollableArea::setConstrainsScrollingToContentEdge(false); |
| 95 | 95 |
| 96 Node* node = box().node(); | 96 Node* node = box().node(); |
| 97 if (node && node->isElementNode()) { | 97 if (node && node->isElementNode()) { |
| 98 // We save and restore only the scrollOffset as the other scroll values
are recalculated. | 98 // We save and restore only the scrollOffset as the other scroll values
are recalculated. |
| 99 Element* element = toElement(node); | 99 Element* element = toElement(node); |
| 100 m_scrollOffset = element->savedLayerScrollOffset(); | 100 m_scrollOffset = element->savedLayerScrollOffset(); |
| 101 if (!m_scrollOffset.isZero()) | 101 if (!m_scrollOffset.isZero()) |
| 102 scrollAnimator()->setCurrentPosition(FloatPoint(m_scrollOffset.width
(), m_scrollOffset.height())); | 102 scrollAnimator()->setCurrentPosition(FloatPoint(m_scrollOffset.width
(), m_scrollOffset.height())); |
| 103 element->setSavedLayerScrollOffset(IntSize()); | 103 element->setSavedLayerScrollOffset(IntSize()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 updateResizerAreaSet(); | 106 updateResizerAreaSet(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 RenderLayerScrollableArea::~RenderLayerScrollableArea() | 109 LayerScrollableArea::~LayerScrollableArea() |
| 110 { | 110 { |
| 111 if (inResizeMode() && !box().documentBeingDestroyed()) { | 111 if (inResizeMode() && !box().documentBeingDestroyed()) { |
| 112 if (LocalFrame* frame = box().frame()) | 112 if (LocalFrame* frame = box().frame()) |
| 113 frame->eventHandler().resizeScrollableAreaDestroyed(); | 113 frame->eventHandler().resizeScrollableAreaDestroyed(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (LocalFrame* frame = box().frame()) { | 116 if (LocalFrame* frame = box().frame()) { |
| 117 if (FrameView* frameView = frame->view()) { | 117 if (FrameView* frameView = frame->view()) { |
| 118 frameView->removeScrollableArea(this); | 118 frameView->removeScrollableArea(this); |
| 119 frameView->removeAnimatingScrollableArea(this); | 119 frameView->removeAnimatingScrollableArea(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 | 139 |
| 140 destroyScrollbar(HorizontalScrollbar); | 140 destroyScrollbar(HorizontalScrollbar); |
| 141 destroyScrollbar(VerticalScrollbar); | 141 destroyScrollbar(VerticalScrollbar); |
| 142 | 142 |
| 143 if (m_scrollCorner) | 143 if (m_scrollCorner) |
| 144 m_scrollCorner->destroy(); | 144 m_scrollCorner->destroy(); |
| 145 if (m_resizer) | 145 if (m_resizer) |
| 146 m_resizer->destroy(); | 146 m_resizer->destroy(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 HostWindow* RenderLayerScrollableArea::hostWindow() const | 149 HostWindow* LayerScrollableArea::hostWindow() const |
| 150 { | 150 { |
| 151 if (Page* page = box().frame()->page()) | 151 if (Page* page = box().frame()->page()) |
| 152 return &page->chrome(); | 152 return &page->chrome(); |
| 153 return nullptr; | 153 return nullptr; |
| 154 } | 154 } |
| 155 | 155 |
| 156 GraphicsLayer* RenderLayerScrollableArea::layerForScrolling() const | 156 GraphicsLayer* LayerScrollableArea::layerForScrolling() const |
| 157 { | 157 { |
| 158 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->scrollingContentsLayer() : 0; | 158 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->scrollingContentsLayer() : 0; |
| 159 } | 159 } |
| 160 | 160 |
| 161 GraphicsLayer* RenderLayerScrollableArea::layerForHorizontalScrollbar() const | 161 GraphicsLayer* LayerScrollableArea::layerForHorizontalScrollbar() const |
| 162 { | 162 { |
| 163 // See crbug.com/343132. | 163 // See crbug.com/343132. |
| 164 DisableCompositingQueryAsserts disabler; | 164 DisableCompositingQueryAsserts disabler; |
| 165 | 165 |
| 166 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForHorizontalScrollbar() : 0; | 166 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForHorizontalScrollbar() : 0; |
| 167 } | 167 } |
| 168 | 168 |
| 169 GraphicsLayer* RenderLayerScrollableArea::layerForVerticalScrollbar() const | 169 GraphicsLayer* LayerScrollableArea::layerForVerticalScrollbar() const |
| 170 { | 170 { |
| 171 // See crbug.com/343132. | 171 // See crbug.com/343132. |
| 172 DisableCompositingQueryAsserts disabler; | 172 DisableCompositingQueryAsserts disabler; |
| 173 | 173 |
| 174 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForVerticalScrollbar() : 0; | 174 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForVerticalScrollbar() : 0; |
| 175 } | 175 } |
| 176 | 176 |
| 177 GraphicsLayer* RenderLayerScrollableArea::layerForScrollCorner() const | 177 GraphicsLayer* LayerScrollableArea::layerForScrollCorner() const |
| 178 { | 178 { |
| 179 // See crbug.com/343132. | 179 // See crbug.com/343132. |
| 180 DisableCompositingQueryAsserts disabler; | 180 DisableCompositingQueryAsserts disabler; |
| 181 | 181 |
| 182 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForScrollCorner() : 0; | 182 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForScrollCorner() : 0; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, co
nst IntRect& rect) | 185 void LayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, const In
tRect& rect) |
| 186 { | 186 { |
| 187 // See crbug.com/343132. | 187 // See crbug.com/343132. |
| 188 DisableCompositingQueryAsserts disabler; | 188 DisableCompositingQueryAsserts disabler; |
| 189 | 189 |
| 190 if (scrollbar == m_vBar.get()) { | 190 if (scrollbar == m_vBar.get()) { |
| 191 if (GraphicsLayer* layer = layerForVerticalScrollbar()) { | 191 if (GraphicsLayer* layer = layerForVerticalScrollbar()) { |
| 192 layer->setNeedsDisplayInRect(rect, PaintInvalidationScroll); | 192 layer->setNeedsDisplayInRect(rect, PaintInvalidationScroll); |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 } else { | 195 } else { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 216 box().flipForWritingMode(paintInvalidationRect); | 216 box().flipForWritingMode(paintInvalidationRect); |
| 217 | 217 |
| 218 IntRect intRect = pixelSnappedIntRect(paintInvalidationRect); | 218 IntRect intRect = pixelSnappedIntRect(paintInvalidationRect); |
| 219 | 219 |
| 220 if (box().frameView()->isInPerformLayout()) | 220 if (box().frameView()->isInPerformLayout()) |
| 221 addScrollbarDamage(scrollbar, intRect); | 221 addScrollbarDamage(scrollbar, intRect); |
| 222 else | 222 else |
| 223 box().invalidatePaintRectangle(intRect); | 223 box().invalidatePaintRectangle(intRect); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void RenderLayerScrollableArea::invalidateScrollCornerRect(const IntRect& rect) | 226 void LayerScrollableArea::invalidateScrollCornerRect(const IntRect& rect) |
| 227 { | 227 { |
| 228 if (GraphicsLayer* layer = layerForScrollCorner()) { | 228 if (GraphicsLayer* layer = layerForScrollCorner()) { |
| 229 layer->setNeedsDisplayInRect(rect, PaintInvalidationScroll); | 229 layer->setNeedsDisplayInRect(rect, PaintInvalidationScroll); |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 | 232 |
| 233 if (m_scrollCorner) | 233 if (m_scrollCorner) |
| 234 m_scrollCorner->invalidatePaintRectangle(rect); | 234 m_scrollCorner->invalidatePaintRectangle(rect); |
| 235 if (m_resizer) | 235 if (m_resizer) |
| 236 m_resizer->invalidatePaintRectangle(rect); | 236 m_resizer->invalidatePaintRectangle(rect); |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool RenderLayerScrollableArea::shouldUseIntegerScrollOffset() const | 239 bool LayerScrollableArea::shouldUseIntegerScrollOffset() const |
| 240 { | 240 { |
| 241 Frame* frame = box().frame(); | 241 Frame* frame = box().frame(); |
| 242 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) | 242 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) |
| 243 return true; | 243 return true; |
| 244 return false; | 244 return false; |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool RenderLayerScrollableArea::isActive() const | 247 bool LayerScrollableArea::isActive() const |
| 248 { | 248 { |
| 249 Page* page = box().frame()->page(); | 249 Page* page = box().frame()->page(); |
| 250 return page && page->focusController().isActive(); | 250 return page && page->focusController().isActive(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 bool RenderLayerScrollableArea::isScrollCornerVisible() const | 253 bool LayerScrollableArea::isScrollCornerVisible() const |
| 254 { | 254 { |
| 255 return !scrollCornerRect().isEmpty(); | 255 return !scrollCornerRect().isEmpty(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 static int cornerStart(const RenderStyle* style, int minX, int maxX, int thickne
ss) | 258 static int cornerStart(const RenderStyle* style, int minX, int maxX, int thickne
ss) |
| 259 { | 259 { |
| 260 if (style->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 260 if (style->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 261 return minX + style->borderLeftWidth(); | 261 return minX + style->borderLeftWidth(); |
| 262 return maxX - thickness - style->borderRightWidth(); | 262 return maxX - thickness - style->borderRightWidth(); |
| 263 } | 263 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 280 } else { | 280 } else { |
| 281 horizontalThickness = verticalScrollbar->width(); | 281 horizontalThickness = verticalScrollbar->width(); |
| 282 verticalThickness = horizontalScrollbar->height(); | 282 verticalThickness = horizontalScrollbar->height(); |
| 283 } | 283 } |
| 284 return IntRect(cornerStart(style, bounds.x(), bounds.maxX(), horizontalThick
ness), | 284 return IntRect(cornerStart(style, bounds.x(), bounds.maxX(), horizontalThick
ness), |
| 285 bounds.maxY() - verticalThickness - style->borderBottomWidth(), | 285 bounds.maxY() - verticalThickness - style->borderBottomWidth(), |
| 286 horizontalThickness, verticalThickness); | 286 horizontalThickness, verticalThickness); |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 IntRect RenderLayerScrollableArea::scrollCornerRect() const | 290 IntRect LayerScrollableArea::scrollCornerRect() const |
| 291 { | 291 { |
| 292 // We have a scrollbar corner when a scrollbar is visible and not filling th
e entire length of the box. | 292 // We have a scrollbar corner when a scrollbar is visible and not filling th
e entire length of the box. |
| 293 // This happens when: | 293 // This happens when: |
| 294 // (a) A resizer is present and at least one scrollbar is present | 294 // (a) A resizer is present and at least one scrollbar is present |
| 295 // (b) Both scrollbars are present. | 295 // (b) Both scrollbars are present. |
| 296 bool hasHorizontalBar = horizontalScrollbar(); | 296 bool hasHorizontalBar = horizontalScrollbar(); |
| 297 bool hasVerticalBar = verticalScrollbar(); | 297 bool hasVerticalBar = verticalScrollbar(); |
| 298 bool hasResizer = box().style()->resize() != RESIZE_NONE; | 298 bool hasResizer = box().style()->resize() != RESIZE_NONE; |
| 299 if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar
|| hasVerticalBar))) | 299 if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar
|| hasVerticalBar))) |
| 300 return cornerRect(box().style(), horizontalScrollbar(), verticalScrollba
r(), box().pixelSnappedBorderBoxRect()); | 300 return cornerRect(box().style(), horizontalScrollbar(), verticalScrollba
r(), box().pixelSnappedBorderBoxRect()); |
| 301 return IntRect(); | 301 return IntRect(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 IntRect RenderLayerScrollableArea::convertFromScrollbarToContainingView(const Sc
rollbar* scrollbar, const IntRect& scrollbarRect) const | 304 IntRect LayerScrollableArea::convertFromScrollbarToContainingView(const Scrollba
r* scrollbar, const IntRect& scrollbarRect) const |
| 305 { | 305 { |
| 306 RenderView* view = box().view(); | 306 RenderView* view = box().view(); |
| 307 if (!view) | 307 if (!view) |
| 308 return scrollbarRect; | 308 return scrollbarRect; |
| 309 | 309 |
| 310 IntRect rect = scrollbarRect; | 310 IntRect rect = scrollbarRect; |
| 311 rect.move(scrollbarOffset(scrollbar)); | 311 rect.move(scrollbarOffset(scrollbar)); |
| 312 | 312 |
| 313 return view->frameView()->convertFromRenderer(box(), rect); | 313 return view->frameView()->convertFromRenderer(box(), rect); |
| 314 } | 314 } |
| 315 | 315 |
| 316 IntRect RenderLayerScrollableArea::convertFromContainingViewToScrollbar(const Sc
rollbar* scrollbar, const IntRect& parentRect) const | 316 IntRect LayerScrollableArea::convertFromContainingViewToScrollbar(const Scrollba
r* scrollbar, const IntRect& parentRect) const |
| 317 { | 317 { |
| 318 RenderView* view = box().view(); | 318 RenderView* view = box().view(); |
| 319 if (!view) | 319 if (!view) |
| 320 return parentRect; | 320 return parentRect; |
| 321 | 321 |
| 322 IntRect rect = view->frameView()->convertToRenderer(box(), parentRect); | 322 IntRect rect = view->frameView()->convertToRenderer(box(), parentRect); |
| 323 rect.move(-scrollbarOffset(scrollbar)); | 323 rect.move(-scrollbarOffset(scrollbar)); |
| 324 return rect; | 324 return rect; |
| 325 } | 325 } |
| 326 | 326 |
| 327 IntPoint RenderLayerScrollableArea::convertFromScrollbarToContainingView(const S
crollbar* scrollbar, const IntPoint& scrollbarPoint) const | 327 IntPoint LayerScrollableArea::convertFromScrollbarToContainingView(const Scrollb
ar* scrollbar, const IntPoint& scrollbarPoint) const |
| 328 { | 328 { |
| 329 RenderView* view = box().view(); | 329 RenderView* view = box().view(); |
| 330 if (!view) | 330 if (!view) |
| 331 return scrollbarPoint; | 331 return scrollbarPoint; |
| 332 | 332 |
| 333 IntPoint point = scrollbarPoint; | 333 IntPoint point = scrollbarPoint; |
| 334 point.move(scrollbarOffset(scrollbar)); | 334 point.move(scrollbarOffset(scrollbar)); |
| 335 return view->frameView()->convertFromRenderer(box(), point); | 335 return view->frameView()->convertFromRenderer(box(), point); |
| 336 } | 336 } |
| 337 | 337 |
| 338 IntPoint RenderLayerScrollableArea::convertFromContainingViewToScrollbar(const S
crollbar* scrollbar, const IntPoint& parentPoint) const | 338 IntPoint LayerScrollableArea::convertFromContainingViewToScrollbar(const Scrollb
ar* scrollbar, const IntPoint& parentPoint) const |
| 339 { | 339 { |
| 340 RenderView* view = box().view(); | 340 RenderView* view = box().view(); |
| 341 if (!view) | 341 if (!view) |
| 342 return parentPoint; | 342 return parentPoint; |
| 343 | 343 |
| 344 IntPoint point = view->frameView()->convertToRenderer(box(), parentPoint); | 344 IntPoint point = view->frameView()->convertToRenderer(box(), parentPoint); |
| 345 | 345 |
| 346 point.move(-scrollbarOffset(scrollbar)); | 346 point.move(-scrollbarOffset(scrollbar)); |
| 347 return point; | 347 return point; |
| 348 } | 348 } |
| 349 | 349 |
| 350 int RenderLayerScrollableArea::scrollSize(ScrollbarOrientation orientation) cons
t | 350 int LayerScrollableArea::scrollSize(ScrollbarOrientation orientation) const |
| 351 { | 351 { |
| 352 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; | 352 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition()
; |
| 353 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); | 353 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr
ollDimensions.height(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void RenderLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset) | 356 void LayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset) |
| 357 { | 357 { |
| 358 setScrollOffset(DoublePoint(newScrollOffset)); | 358 setScrollOffset(DoublePoint(newScrollOffset)); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void RenderLayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffs
et) | 361 void LayerScrollableArea::setScrollOffset(const DoublePoint& newScrollOffset) |
| 362 { | 362 { |
| 363 // Ensure that the dimensions will be computed if they need to be (for overf
low:hidden blocks). | 363 // Ensure that the dimensions will be computed if they need to be (for overf
low:hidden blocks). |
| 364 if (m_scrollDimensionsDirty) | 364 if (m_scrollDimensionsDirty) |
| 365 computeScrollDimensions(); | 365 computeScrollDimensions(); |
| 366 | 366 |
| 367 if (scrollOffset() == toDoubleSize(newScrollOffset)) | 367 if (scrollOffset() == toDoubleSize(newScrollOffset)) |
| 368 return; | 368 return; |
| 369 | 369 |
| 370 m_scrollOffset = toDoubleSize(newScrollOffset); | 370 m_scrollOffset = toDoubleSize(newScrollOffset); |
| 371 | 371 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 382 // We don't update compositing layers, because we need to do a deep update f
rom the compositing ancestor. | 382 // We don't update compositing layers, because we need to do a deep update f
rom the compositing ancestor. |
| 383 if (!frameView->isInPerformLayout()) { | 383 if (!frameView->isInPerformLayout()) { |
| 384 // If we're in the middle of layout, we'll just update layers once layou
t has finished. | 384 // If we're in the middle of layout, we'll just update layers once layou
t has finished. |
| 385 layer()->updateLayerPositionsAfterOverflowScroll(); | 385 layer()->updateLayerPositionsAfterOverflowScroll(); |
| 386 // Update regions, scrolling may change the clip of a particular region. | 386 // Update regions, scrolling may change the clip of a particular region. |
| 387 frameView->updateAnnotatedRegions(); | 387 frameView->updateAnnotatedRegions(); |
| 388 frameView->setNeedsUpdateWidgetPositions(); | 388 frameView->setNeedsUpdateWidgetPositions(); |
| 389 updateCompositingLayersAfterScroll(); | 389 updateCompositingLayersAfterScroll(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 const RenderLayerModelObject* paintInvalidationContainer = box().containerFo
rPaintInvalidation(); | 392 const LayoutLayerModelObject* paintInvalidationContainer = box().containerFo
rPaintInvalidation(); |
| 393 // The caret rect needs to be invalidated after scrolling | 393 // The caret rect needs to be invalidated after scrolling |
| 394 frame->selection().setCaretRectNeedsUpdate(); | 394 frame->selection().setCaretRectNeedsUpdate(); |
| 395 | 395 |
| 396 FloatQuad quadForFakeMouseMoveEvent = FloatQuad(layer()->renderer()->previou
sPaintInvalidationRect()); | 396 FloatQuad quadForFakeMouseMoveEvent = FloatQuad(layer()->renderer()->previou
sPaintInvalidationRect()); |
| 397 | 397 |
| 398 quadForFakeMouseMoveEvent = paintInvalidationContainer->localToAbsoluteQuad(
quadForFakeMouseMoveEvent); | 398 quadForFakeMouseMoveEvent = paintInvalidationContainer->localToAbsoluteQuad(
quadForFakeMouseMoveEvent); |
| 399 frame->eventHandler().dispatchFakeMouseMoveEventSoonInQuad(quadForFakeMouseM
oveEvent); | 399 frame->eventHandler().dispatchFakeMouseMoveEventSoonInQuad(quadForFakeMouseM
oveEvent); |
| 400 | 400 |
| 401 bool requiresPaintInvalidation = true; | 401 bool requiresPaintInvalidation = true; |
| 402 | 402 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 423 // Schedule the scroll DOM event. | 423 // Schedule the scroll DOM event. |
| 424 if (box().node()) | 424 if (box().node()) |
| 425 box().node()->document().enqueueScrollEventForNode(box().node()); | 425 box().node()->document().enqueueScrollEventForNode(box().node()); |
| 426 | 426 |
| 427 if (AXObjectCache* cache = box().document().existingAXObjectCache()) | 427 if (AXObjectCache* cache = box().document().existingAXObjectCache()) |
| 428 cache->handleScrollPositionChanged(&box()); | 428 cache->handleScrollPositionChanged(&box()); |
| 429 | 429 |
| 430 InspectorInstrumentation::didScrollLayer(&box()); | 430 InspectorInstrumentation::didScrollLayer(&box()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 IntPoint RenderLayerScrollableArea::scrollPosition() const | 433 IntPoint LayerScrollableArea::scrollPosition() const |
| 434 { | 434 { |
| 435 return IntPoint(flooredIntSize(m_scrollOffset)); | 435 return IntPoint(flooredIntSize(m_scrollOffset)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 DoublePoint RenderLayerScrollableArea::scrollPositionDouble() const | 438 DoublePoint LayerScrollableArea::scrollPositionDouble() const |
| 439 { | 439 { |
| 440 return DoublePoint(m_scrollOffset); | 440 return DoublePoint(m_scrollOffset); |
| 441 } | 441 } |
| 442 | 442 |
| 443 IntPoint RenderLayerScrollableArea::minimumScrollPosition() const | 443 IntPoint LayerScrollableArea::minimumScrollPosition() const |
| 444 { | 444 { |
| 445 return -scrollOrigin(); | 445 return -scrollOrigin(); |
| 446 } | 446 } |
| 447 | 447 |
| 448 IntPoint RenderLayerScrollableArea::maximumScrollPosition() const | 448 IntPoint LayerScrollableArea::maximumScrollPosition() const |
| 449 { | 449 { |
| 450 if (!box().hasOverflowClip()) | 450 if (!box().hasOverflowClip()) |
| 451 return -scrollOrigin(); | 451 return -scrollOrigin(); |
| 452 return -scrollOrigin() + IntPoint(pixelSnappedScrollWidth(), pixelSnappedScr
ollHeight()) - enclosingIntRect(box().clientBoxRect()).size(); | 452 return -scrollOrigin() + IntPoint(pixelSnappedScrollWidth(), pixelSnappedScr
ollHeight()) - enclosingIntRect(box().clientBoxRect()).size(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 IntRect RenderLayerScrollableArea::visibleContentRect(IncludeScrollbarsInRect sc
rollbarInclusion) const | 455 IntRect LayerScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollba
rInclusion) const |
| 456 { | 456 { |
| 457 int verticalScrollbarWidth = 0; | 457 int verticalScrollbarWidth = 0; |
| 458 int horizontalScrollbarHeight = 0; | 458 int horizontalScrollbarHeight = 0; |
| 459 if (scrollbarInclusion == IncludeScrollbars) { | 459 if (scrollbarInclusion == IncludeScrollbars) { |
| 460 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; | 460 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) ? verticalScrollbar()->width() : 0; |
| 461 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; | 461 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; |
| 462 } | 462 } |
| 463 | 463 |
| 464 return IntRect(IntPoint(scrollXOffset(), scrollYOffset()), | 464 return IntRect(IntPoint(scrollXOffset(), scrollYOffset()), |
| 465 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), max(0,
layer()->size().height() - horizontalScrollbarHeight))); | 465 IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), max(0,
layer()->size().height() - horizontalScrollbarHeight))); |
| 466 } | 466 } |
| 467 | 467 |
| 468 int RenderLayerScrollableArea::visibleHeight() const | 468 int LayerScrollableArea::visibleHeight() const |
| 469 { | 469 { |
| 470 return layer()->size().height(); | 470 return layer()->size().height(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 int RenderLayerScrollableArea::visibleWidth() const | 473 int LayerScrollableArea::visibleWidth() const |
| 474 { | 474 { |
| 475 return layer()->size().width(); | 475 return layer()->size().width(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 IntSize RenderLayerScrollableArea::contentsSize() const | 478 IntSize LayerScrollableArea::contentsSize() const |
| 479 { | 479 { |
| 480 return IntSize(scrollWidth(), scrollHeight()); | 480 return IntSize(scrollWidth(), scrollHeight()); |
| 481 } | 481 } |
| 482 | 482 |
| 483 IntSize RenderLayerScrollableArea::overhangAmount() const | 483 IntSize LayerScrollableArea::overhangAmount() const |
| 484 { | 484 { |
| 485 return IntSize(); | 485 return IntSize(); |
| 486 } | 486 } |
| 487 | 487 |
| 488 IntPoint RenderLayerScrollableArea::lastKnownMousePosition() const | 488 IntPoint LayerScrollableArea::lastKnownMousePosition() const |
| 489 { | 489 { |
| 490 return box().frame() ? box().frame()->eventHandler().lastKnownMousePosition(
) : IntPoint(); | 490 return box().frame() ? box().frame()->eventHandler().lastKnownMousePosition(
) : IntPoint(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 bool RenderLayerScrollableArea::shouldSuspendScrollAnimations() const | 493 bool LayerScrollableArea::shouldSuspendScrollAnimations() const |
| 494 { | 494 { |
| 495 RenderView* view = box().view(); | 495 RenderView* view = box().view(); |
| 496 if (!view) | 496 if (!view) |
| 497 return true; | 497 return true; |
| 498 return view->frameView()->shouldSuspendScrollAnimations(); | 498 return view->frameView()->shouldSuspendScrollAnimations(); |
| 499 } | 499 } |
| 500 | 500 |
| 501 bool RenderLayerScrollableArea::scrollbarsCanBeActive() const | 501 bool LayerScrollableArea::scrollbarsCanBeActive() const |
| 502 { | 502 { |
| 503 RenderView* view = box().view(); | 503 RenderView* view = box().view(); |
| 504 if (!view) | 504 if (!view) |
| 505 return false; | 505 return false; |
| 506 return view->frameView()->scrollbarsCanBeActive(); | 506 return view->frameView()->scrollbarsCanBeActive(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 IntRect RenderLayerScrollableArea::scrollableAreaBoundingBox() const | 509 IntRect LayerScrollableArea::scrollableAreaBoundingBox() const |
| 510 { | 510 { |
| 511 return box().absoluteBoundingBoxRect(); | 511 return box().absoluteBoundingBoxRect(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void RenderLayerScrollableArea::registerForAnimation() | 514 void LayerScrollableArea::registerForAnimation() |
| 515 { | 515 { |
| 516 if (LocalFrame* frame = box().frame()) { | 516 if (LocalFrame* frame = box().frame()) { |
| 517 if (FrameView* frameView = frame->view()) | 517 if (FrameView* frameView = frame->view()) |
| 518 frameView->addAnimatingScrollableArea(this); | 518 frameView->addAnimatingScrollableArea(this); |
| 519 } | 519 } |
| 520 } | 520 } |
| 521 | 521 |
| 522 void RenderLayerScrollableArea::deregisterForAnimation() | 522 void LayerScrollableArea::deregisterForAnimation() |
| 523 { | 523 { |
| 524 if (LocalFrame* frame = box().frame()) { | 524 if (LocalFrame* frame = box().frame()) { |
| 525 if (FrameView* frameView = frame->view()) | 525 if (FrameView* frameView = frame->view()) |
| 526 frameView->removeAnimatingScrollableArea(this); | 526 frameView->removeAnimatingScrollableArea(this); |
| 527 } | 527 } |
| 528 } | 528 } |
| 529 | 529 |
| 530 bool RenderLayerScrollableArea::userInputScrollable(ScrollbarOrientation orienta
tion) const | 530 bool LayerScrollableArea::userInputScrollable(ScrollbarOrientation orientation)
const |
| 531 { | 531 { |
| 532 if (box().isIntristicallyScrollable(orientation)) | 532 if (box().isIntristicallyScrollable(orientation)) |
| 533 return true; | 533 return true; |
| 534 | 534 |
| 535 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? | 535 EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? |
| 536 box().style()->overflowX() : box().style()->overflowY(); | 536 box().style()->overflowX() : box().style()->overflowY(); |
| 537 return (overflowStyle == OSCROLL || overflowStyle == OAUTO || overflowStyle
== OOVERLAY); | 537 return (overflowStyle == OSCROLL || overflowStyle == OAUTO || overflowStyle
== OOVERLAY); |
| 538 } | 538 } |
| 539 | 539 |
| 540 bool RenderLayerScrollableArea::shouldPlaceVerticalScrollbarOnLeft() const | 540 bool LayerScrollableArea::shouldPlaceVerticalScrollbarOnLeft() const |
| 541 { | 541 { |
| 542 return box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft(); | 542 return box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 int RenderLayerScrollableArea::pageStep(ScrollbarOrientation orientation) const | 545 int LayerScrollableArea::pageStep(ScrollbarOrientation orientation) const |
| 546 { | 546 { |
| 547 int length = (orientation == HorizontalScrollbar) ? | 547 int length = (orientation == HorizontalScrollbar) ? |
| 548 box().pixelSnappedClientWidth() : box().pixelSnappedClientHeight(); | 548 box().pixelSnappedClientWidth() : box().pixelSnappedClientHeight(); |
| 549 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo
StepWhenPaging(); | 549 int minPageStep = static_cast<float>(length) * ScrollableArea::minFractionTo
StepWhenPaging(); |
| 550 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa
ges()); | 550 int pageStep = max(minPageStep, length - ScrollableArea::maxOverlapBetweenPa
ges()); |
| 551 | 551 |
| 552 return max(pageStep, 1); | 552 return max(pageStep, 1); |
| 553 } | 553 } |
| 554 | 554 |
| 555 RenderBox& RenderLayerScrollableArea::box() const | 555 RenderBox& LayerScrollableArea::box() const |
| 556 { | 556 { |
| 557 return *m_layer.renderBox(); | 557 return *m_layer.renderBox(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 RenderLayer* RenderLayerScrollableArea::layer() const | 560 Layer* LayerScrollableArea::layer() const |
| 561 { | 561 { |
| 562 return &m_layer; | 562 return &m_layer; |
| 563 } | 563 } |
| 564 | 564 |
| 565 LayoutUnit RenderLayerScrollableArea::scrollWidth() const | 565 LayoutUnit LayerScrollableArea::scrollWidth() const |
| 566 { | 566 { |
| 567 if (m_scrollDimensionsDirty) | 567 if (m_scrollDimensionsDirty) |
| 568 const_cast<RenderLayerScrollableArea*>(this)->computeScrollDimensions(); | 568 const_cast<LayerScrollableArea*>(this)->computeScrollDimensions(); |
| 569 return m_overflowRect.width(); | 569 return m_overflowRect.width(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 LayoutUnit RenderLayerScrollableArea::scrollHeight() const | 572 LayoutUnit LayerScrollableArea::scrollHeight() const |
| 573 { | 573 { |
| 574 if (m_scrollDimensionsDirty) | 574 if (m_scrollDimensionsDirty) |
| 575 const_cast<RenderLayerScrollableArea*>(this)->computeScrollDimensions(); | 575 const_cast<LayerScrollableArea*>(this)->computeScrollDimensions(); |
| 576 return m_overflowRect.height(); | 576 return m_overflowRect.height(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 int RenderLayerScrollableArea::pixelSnappedScrollWidth() const | 579 int LayerScrollableArea::pixelSnappedScrollWidth() const |
| 580 { | 580 { |
| 581 return snapSizeToPixel(scrollWidth(), box().clientLeft() + box().location().
x()); | 581 return snapSizeToPixel(scrollWidth(), box().clientLeft() + box().location().
x()); |
| 582 } | 582 } |
| 583 | 583 |
| 584 int RenderLayerScrollableArea::pixelSnappedScrollHeight() const | 584 int LayerScrollableArea::pixelSnappedScrollHeight() const |
| 585 { | 585 { |
| 586 return snapSizeToPixel(scrollHeight(), box().clientTop() + box().location().
y()); | 586 return snapSizeToPixel(scrollHeight(), box().clientTop() + box().location().
y()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 void RenderLayerScrollableArea::computeScrollDimensions() | 589 void LayerScrollableArea::computeScrollDimensions() |
| 590 { | 590 { |
| 591 m_scrollDimensionsDirty = false; | 591 m_scrollDimensionsDirty = false; |
| 592 | 592 |
| 593 m_overflowRect = box().layoutOverflowRect(); | 593 m_overflowRect = box().layoutOverflowRect(); |
| 594 box().flipForWritingMode(m_overflowRect); | 594 box().flipForWritingMode(m_overflowRect); |
| 595 | 595 |
| 596 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); | 596 int scrollableLeftOverflow = m_overflowRect.x() - box().borderLeft() - (box(
).style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? box().verticalScr
ollbarWidth() : 0); |
| 597 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); | 597 int scrollableTopOverflow = m_overflowRect.y() - box().borderTop(); |
| 598 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); | 598 setScrollOrigin(IntPoint(-scrollableLeftOverflow, -scrollableTopOverflow)); |
| 599 } | 599 } |
| 600 | 600 |
| 601 void RenderLayerScrollableArea::scrollToOffset(const DoubleSize& scrollOffset, S
crollOffsetClamping clamp, ScrollBehavior scrollBehavior) | 601 void LayerScrollableArea::scrollToOffset(const DoubleSize& scrollOffset, ScrollO
ffsetClamping clamp, ScrollBehavior scrollBehavior) |
| 602 { | 602 { |
| 603 cancelProgrammaticScrollAnimation(); | 603 cancelProgrammaticScrollAnimation(); |
| 604 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; | 604 DoubleSize newScrollOffset = clamp == ScrollOffsetClamped ? clampScrollOffse
t(scrollOffset) : scrollOffset; |
| 605 if (newScrollOffset != adjustedScrollOffset()) { | 605 if (newScrollOffset != adjustedScrollOffset()) { |
| 606 if (scrollBehavior == ScrollBehaviorAuto) | 606 if (scrollBehavior == ScrollBehaviorAuto) |
| 607 scrollBehavior = box().style()->scrollBehavior(); | 607 scrollBehavior = box().style()->scrollBehavior(); |
| 608 DoublePoint origin(scrollOrigin()); | 608 DoublePoint origin(scrollOrigin()); |
| 609 if (scrollBehavior == ScrollBehaviorSmooth) { | 609 if (scrollBehavior == ScrollBehaviorSmooth) { |
| 610 // FIXME: Make programmaticallyScrollSmoothlyToOffset take DoublePoi
nt. crbug.com/243871. | 610 // FIXME: Make programmaticallyScrollSmoothlyToOffset take DoublePoi
nt. crbug.com/243871. |
| 611 programmaticallyScrollSmoothlyToOffset(toFloatPoint(-origin + newScr
ollOffset)); | 611 programmaticallyScrollSmoothlyToOffset(toFloatPoint(-origin + newScr
ollOffset)); |
| 612 } else { | 612 } else { |
| 613 // FIXME: Make scrollToOffsetWithoutAnimation take DoublePoint. crbu
g.com/414283. | 613 // FIXME: Make scrollToOffsetWithoutAnimation take DoublePoint. crbu
g.com/414283. |
| 614 scrollToOffsetWithoutAnimation(toFloatPoint(-origin + newScrollOffse
t)); | 614 scrollToOffsetWithoutAnimation(toFloatPoint(-origin + newScrollOffse
t)); |
| 615 } | 615 } |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 void RenderLayerScrollableArea::updateAfterLayout() | 619 void LayerScrollableArea::updateAfterLayout() |
| 620 { | 620 { |
| 621 m_scrollDimensionsDirty = true; | 621 m_scrollDimensionsDirty = true; |
| 622 DoubleSize originalScrollOffset = adjustedScrollOffset(); | 622 DoubleSize originalScrollOffset = adjustedScrollOffset(); |
| 623 | 623 |
| 624 computeScrollDimensions(); | 624 computeScrollDimensions(); |
| 625 | 625 |
| 626 // Layout may cause us to be at an invalid scroll position. In this case we
need | 626 // Layout may cause us to be at an invalid scroll position. In this case we
need |
| 627 // to pull our scroll offsets back to the max (or push them up to the min). | 627 // to pull our scroll offsets back to the max (or push them up to the min). |
| 628 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); | 628 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); |
| 629 if (clampedScrollOffset != adjustedScrollOffset()) | 629 if (clampedScrollOffset != adjustedScrollOffset()) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 707 |
| 708 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); | 708 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica
lOverflow(); |
| 709 updateScrollableAreaSet(hasOverflow); | 709 updateScrollableAreaSet(hasOverflow); |
| 710 | 710 |
| 711 if (hasOverflow) { | 711 if (hasOverflow) { |
| 712 DisableCompositingQueryAsserts disabler; | 712 DisableCompositingQueryAsserts disabler; |
| 713 positionOverflowControls(IntSize()); | 713 positionOverflowControls(IntSize()); |
| 714 } | 714 } |
| 715 } | 715 } |
| 716 | 716 |
| 717 bool RenderLayerScrollableArea::hasHorizontalOverflow() const | 717 bool LayerScrollableArea::hasHorizontalOverflow() const |
| 718 { | 718 { |
| 719 ASSERT(!m_scrollDimensionsDirty); | 719 ASSERT(!m_scrollDimensionsDirty); |
| 720 | 720 |
| 721 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth(); | 721 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth(); |
| 722 } | 722 } |
| 723 | 723 |
| 724 bool RenderLayerScrollableArea::hasVerticalOverflow() const | 724 bool LayerScrollableArea::hasVerticalOverflow() const |
| 725 { | 725 { |
| 726 ASSERT(!m_scrollDimensionsDirty); | 726 ASSERT(!m_scrollDimensionsDirty); |
| 727 | 727 |
| 728 return pixelSnappedScrollHeight() > box().pixelSnappedClientHeight(); | 728 return pixelSnappedScrollHeight() > box().pixelSnappedClientHeight(); |
| 729 } | 729 } |
| 730 | 730 |
| 731 bool RenderLayerScrollableArea::hasScrollableHorizontalOverflow() const | 731 bool LayerScrollableArea::hasScrollableHorizontalOverflow() const |
| 732 { | 732 { |
| 733 return hasHorizontalOverflow() && box().scrollsOverflowX(); | 733 return hasHorizontalOverflow() && box().scrollsOverflowX(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 bool RenderLayerScrollableArea::hasScrollableVerticalOverflow() const | 736 bool LayerScrollableArea::hasScrollableVerticalOverflow() const |
| 737 { | 737 { |
| 738 return hasVerticalOverflow() && box().scrollsOverflowY(); | 738 return hasVerticalOverflow() && box().scrollsOverflowY(); |
| 739 } | 739 } |
| 740 | 740 |
| 741 static bool overflowRequiresScrollbar(EOverflow overflow) | 741 static bool overflowRequiresScrollbar(EOverflow overflow) |
| 742 { | 742 { |
| 743 return overflow == OSCROLL; | 743 return overflow == OSCROLL; |
| 744 } | 744 } |
| 745 | 745 |
| 746 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) | 746 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) |
| 747 { | 747 { |
| 748 return overflow == OAUTO || overflow == OOVERLAY; | 748 return overflow == OAUTO || overflow == OOVERLAY; |
| 749 } | 749 } |
| 750 | 750 |
| 751 // This function returns true if the given box requires overflow scrollbars (as | 751 // This function returns true if the given box requires overflow scrollbars (as |
| 752 // opposed to the 'viewport' scrollbars managed by the RenderLayerCompositor). | 752 // opposed to the 'viewport' scrollbars managed by the LayerCompositor). |
| 753 // FIXME: we should use the same scrolling machinery for both the viewport and | 753 // FIXME: we should use the same scrolling machinery for both the viewport and |
| 754 // overflow. Currently, we need to avoid producing scrollbars here if they'll be | 754 // overflow. Currently, we need to avoid producing scrollbars here if they'll be |
| 755 // handled externally in the RLC. | 755 // handled externally in the RLC. |
| 756 static bool canHaveOverflowScrollbars(const RenderBox& box) | 756 static bool canHaveOverflowScrollbars(const RenderBox& box) |
| 757 { | 757 { |
| 758 bool rootLayerScrolls = box.document().settings() && box.document().settings
()->rootLayerScrolls(); | 758 bool rootLayerScrolls = box.document().settings() && box.document().settings
()->rootLayerScrolls(); |
| 759 return (rootLayerScrolls || !box.isRenderView()) && box.document().viewportD
efiningElement() != box.node(); | 759 return (rootLayerScrolls || !box.isRenderView()) && box.document().viewportD
efiningElement() != box.node(); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void RenderLayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldSty
le) | 762 void LayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldStyle) |
| 763 { | 763 { |
| 764 if (!m_scrollDimensionsDirty) | 764 if (!m_scrollDimensionsDirty) |
| 765 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollab
leVerticalOverflow()); | 765 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollab
leVerticalOverflow()); |
| 766 | 766 |
| 767 if (!canHaveOverflowScrollbars(box())) | 767 if (!canHaveOverflowScrollbars(box())) |
| 768 return; | 768 return; |
| 769 | 769 |
| 770 EOverflow overflowX = box().style()->overflowX(); | 770 EOverflow overflowX = box().style()->overflowX(); |
| 771 EOverflow overflowY = box().style()->overflowY(); | 771 EOverflow overflowY = box().style()->overflowY(); |
| 772 | 772 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 792 if (m_hBar) | 792 if (m_hBar) |
| 793 m_hBar->styleChanged(); | 793 m_hBar->styleChanged(); |
| 794 if (m_vBar) | 794 if (m_vBar) |
| 795 m_vBar->styleChanged(); | 795 m_vBar->styleChanged(); |
| 796 | 796 |
| 797 updateScrollCornerStyle(); | 797 updateScrollCornerStyle(); |
| 798 updateResizerAreaSet(); | 798 updateResizerAreaSet(); |
| 799 updateResizerStyle(); | 799 updateResizerStyle(); |
| 800 } | 800 } |
| 801 | 801 |
| 802 bool RenderLayerScrollableArea::updateAfterCompositingChange() | 802 bool LayerScrollableArea::updateAfterCompositingChange() |
| 803 { | 803 { |
| 804 layer()->updateScrollingStateAfterCompositingChange(); | 804 layer()->updateScrollingStateAfterCompositingChange(); |
| 805 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; | 805 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; |
| 806 m_topmostScrollChild = m_nextTopmostScrollChild; | 806 m_topmostScrollChild = m_nextTopmostScrollChild; |
| 807 m_nextTopmostScrollChild = nullptr; | 807 m_nextTopmostScrollChild = nullptr; |
| 808 return layersChanged; | 808 return layersChanged; |
| 809 } | 809 } |
| 810 | 810 |
| 811 void RenderLayerScrollableArea::updateAfterOverflowRecalc() | 811 void LayerScrollableArea::updateAfterOverflowRecalc() |
| 812 { | 812 { |
| 813 computeScrollDimensions(); | 813 computeScrollDimensions(); |
| 814 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 814 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
| 815 int clientWidth = box().pixelSnappedClientWidth(); | 815 int clientWidth = box().pixelSnappedClientWidth(); |
| 816 horizontalScrollbar->setProportion(clientWidth, overflowRect().width()); | 816 horizontalScrollbar->setProportion(clientWidth, overflowRect().width()); |
| 817 } | 817 } |
| 818 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | 818 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { |
| 819 int clientHeight = box().pixelSnappedClientHeight(); | 819 int clientHeight = box().pixelSnappedClientHeight(); |
| 820 verticalScrollbar->setProportion(clientHeight, overflowRect().height()); | 820 verticalScrollbar->setProportion(clientHeight, overflowRect().height()); |
| 821 } | 821 } |
| 822 | 822 |
| 823 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 823 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
| 824 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 824 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
| 825 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); | 825 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() &&
(hasHorizontalScrollbar() != hasHorizontalOverflow); |
| 826 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); | 826 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has
VerticalScrollbar() != hasVerticalOverflow); |
| 827 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) | 827 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) |
| 828 box().setNeedsLayoutAndFullPaintInvalidation(); | 828 box().setNeedsLayoutAndFullPaintInvalidation(); |
| 829 } | 829 } |
| 830 | 830 |
| 831 DoubleSize RenderLayerScrollableArea::clampScrollOffset(const DoubleSize& scroll
Offset) const | 831 DoubleSize LayerScrollableArea::clampScrollOffset(const DoubleSize& scrollOffset
) const |
| 832 { | 832 { |
| 833 int maxX = scrollWidth() - box().pixelSnappedClientWidth(); | 833 int maxX = scrollWidth() - box().pixelSnappedClientWidth(); |
| 834 int maxY = scrollHeight() - box().pixelSnappedClientHeight(); | 834 int maxY = scrollHeight() - box().pixelSnappedClientHeight(); |
| 835 | 835 |
| 836 double x = std::max(std::min(scrollOffset.width(), static_cast<double>(maxX)
), 0.0); | 836 double x = std::max(std::min(scrollOffset.width(), static_cast<double>(maxX)
), 0.0); |
| 837 double y = std::max(std::min(scrollOffset.height(), static_cast<double>(maxY
)), 0.0); | 837 double y = std::max(std::min(scrollOffset.height(), static_cast<double>(maxY
)), 0.0); |
| 838 return DoubleSize(x, y); | 838 return DoubleSize(x, y); |
| 839 } | 839 } |
| 840 | 840 |
| 841 IntRect RenderLayerScrollableArea::rectForHorizontalScrollbar(const IntRect& bor
derBoxRect) const | 841 IntRect LayerScrollableArea::rectForHorizontalScrollbar(const IntRect& borderBox
Rect) const |
| 842 { | 842 { |
| 843 if (!m_hBar) | 843 if (!m_hBar) |
| 844 return IntRect(); | 844 return IntRect(); |
| 845 | 845 |
| 846 const IntRect& scrollCorner = scrollCornerRect(); | 846 const IntRect& scrollCorner = scrollCornerRect(); |
| 847 | 847 |
| 848 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), | 848 return IntRect(horizontalScrollbarStart(borderBoxRect.x()), |
| 849 borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), | 849 borderBoxRect.maxY() - box().borderBottom() - m_hBar->height(), |
| 850 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr
ollCorner.width(), | 850 borderBoxRect.width() - (box().borderLeft() + box().borderRight()) - scr
ollCorner.width(), |
| 851 m_hBar->height()); | 851 m_hBar->height()); |
| 852 } | 852 } |
| 853 | 853 |
| 854 IntRect RenderLayerScrollableArea::rectForVerticalScrollbar(const IntRect& borde
rBoxRect) const | 854 IntRect LayerScrollableArea::rectForVerticalScrollbar(const IntRect& borderBoxRe
ct) const |
| 855 { | 855 { |
| 856 if (!m_vBar) | 856 if (!m_vBar) |
| 857 return IntRect(); | 857 return IntRect(); |
| 858 | 858 |
| 859 const IntRect& scrollCorner = scrollCornerRect(); | 859 const IntRect& scrollCorner = scrollCornerRect(); |
| 860 | 860 |
| 861 return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX(
)), | 861 return IntRect(verticalScrollbarStart(borderBoxRect.x(), borderBoxRect.maxX(
)), |
| 862 borderBoxRect.y() + box().borderTop(), | 862 borderBoxRect.y() + box().borderTop(), |
| 863 m_vBar->width(), | 863 m_vBar->width(), |
| 864 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - sc
rollCorner.height()); | 864 borderBoxRect.height() - (box().borderTop() + box().borderBottom()) - sc
rollCorner.height()); |
| 865 } | 865 } |
| 866 | 866 |
| 867 LayoutUnit RenderLayerScrollableArea::verticalScrollbarStart(int minX, int maxX)
const | 867 LayoutUnit LayerScrollableArea::verticalScrollbarStart(int minX, int maxX) const |
| 868 { | 868 { |
| 869 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 869 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 870 return minX + box().borderLeft(); | 870 return minX + box().borderLeft(); |
| 871 return maxX - box().borderRight() - m_vBar->width(); | 871 return maxX - box().borderRight() - m_vBar->width(); |
| 872 } | 872 } |
| 873 | 873 |
| 874 LayoutUnit RenderLayerScrollableArea::horizontalScrollbarStart(int minX) const | 874 LayoutUnit LayerScrollableArea::horizontalScrollbarStart(int minX) const |
| 875 { | 875 { |
| 876 int x = minX + box().borderLeft(); | 876 int x = minX + box().borderLeft(); |
| 877 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 877 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 878 x += m_vBar ? m_vBar->width() : resizerCornerRect(box().pixelSnappedBord
erBoxRect(), ResizerForPointer).width(); | 878 x += m_vBar ? m_vBar->width() : resizerCornerRect(box().pixelSnappedBord
erBoxRect(), ResizerForPointer).width(); |
| 879 return x; | 879 return x; |
| 880 } | 880 } |
| 881 | 881 |
| 882 IntSize RenderLayerScrollableArea::scrollbarOffset(const Scrollbar* scrollbar) c
onst | 882 IntSize LayerScrollableArea::scrollbarOffset(const Scrollbar* scrollbar) const |
| 883 { | 883 { |
| 884 if (scrollbar == m_vBar.get()) | 884 if (scrollbar == m_vBar.get()) |
| 885 return IntSize(verticalScrollbarStart(0, box().size().width()), box().bo
rderTop()); | 885 return IntSize(verticalScrollbarStart(0, box().size().width()), box().bo
rderTop()); |
| 886 | 886 |
| 887 if (scrollbar == m_hBar.get()) | 887 if (scrollbar == m_hBar.get()) |
| 888 return IntSize(horizontalScrollbarStart(0), box().size().height() - box(
).borderBottom() - scrollbar->height()); | 888 return IntSize(horizontalScrollbarStart(0), box().size().height() - box(
).borderBottom() - scrollbar->height()); |
| 889 | 889 |
| 890 ASSERT_NOT_REACHED(); | 890 ASSERT_NOT_REACHED(); |
| 891 return IntSize(); | 891 return IntSize(); |
| 892 } | 892 } |
| 893 | 893 |
| 894 static inline RenderObject* rendererForScrollbar(RenderObject& renderer) | 894 static inline RenderObject* rendererForScrollbar(RenderObject& renderer) |
| 895 { | 895 { |
| 896 if (Node* node = renderer.node()) { | 896 if (Node* node = renderer.node()) { |
| 897 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 897 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 898 if (shadowRoot->type() == ShadowRoot::UserAgentShadowRoot) | 898 if (shadowRoot->type() == ShadowRoot::UserAgentShadowRoot) |
| 899 return shadowRoot->host()->renderer(); | 899 return shadowRoot->host()->renderer(); |
| 900 } | 900 } |
| 901 } | 901 } |
| 902 | 902 |
| 903 return &renderer; | 903 return &renderer; |
| 904 } | 904 } |
| 905 | 905 |
| 906 PassRefPtrWillBeRawPtr<Scrollbar> RenderLayerScrollableArea::createScrollbar(Scr
ollbarOrientation orientation) | 906 PassRefPtrWillBeRawPtr<Scrollbar> LayerScrollableArea::createScrollbar(Scrollbar
Orientation orientation) |
| 907 { | 907 { |
| 908 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; | 908 RefPtrWillBeRawPtr<Scrollbar> widget = nullptr; |
| 909 RenderObject* actualRenderer = rendererForScrollbar(box()); | 909 RenderObject* actualRenderer = rendererForScrollbar(box()); |
| 910 bool hasCustomScrollbarStyle = actualRenderer->isBox() && actualRenderer->st
yle()->hasPseudoStyle(SCROLLBAR); | 910 bool hasCustomScrollbarStyle = actualRenderer->isBox() && actualRenderer->st
yle()->hasPseudoStyle(SCROLLBAR); |
| 911 if (hasCustomScrollbarStyle) { | 911 if (hasCustomScrollbarStyle) { |
| 912 widget = RenderScrollbar::createCustomScrollbar(this, orientation, actua
lRenderer->node()); | 912 widget = RenderScrollbar::createCustomScrollbar(this, orientation, actua
lRenderer->node()); |
| 913 } else { | 913 } else { |
| 914 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 914 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 915 if (actualRenderer->style()->hasAppearance()) | 915 if (actualRenderer->style()->hasAppearance()) |
| 916 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualRenderer->style()->appearance()); | 916 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualRenderer->style()->appearance()); |
| 917 widget = Scrollbar::create(this, orientation, scrollbarSize); | 917 widget = Scrollbar::create(this, orientation, scrollbarSize); |
| 918 if (orientation == HorizontalScrollbar) | 918 if (orientation == HorizontalScrollbar) |
| 919 didAddScrollbar(widget.get(), HorizontalScrollbar); | 919 didAddScrollbar(widget.get(), HorizontalScrollbar); |
| 920 else | 920 else |
| 921 didAddScrollbar(widget.get(), VerticalScrollbar); | 921 didAddScrollbar(widget.get(), VerticalScrollbar); |
| 922 } | 922 } |
| 923 box().document().view()->addChild(widget.get()); | 923 box().document().view()->addChild(widget.get()); |
| 924 return widget.release(); | 924 return widget.release(); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void RenderLayerScrollableArea::destroyScrollbar(ScrollbarOrientation orientatio
n) | 927 void LayerScrollableArea::destroyScrollbar(ScrollbarOrientation orientation) |
| 928 { | 928 { |
| 929 RefPtrWillBePersistent<Scrollbar>& scrollbar = orientation == HorizontalScro
llbar ? m_hBar : m_vBar; | 929 RefPtrWillBePersistent<Scrollbar>& scrollbar = orientation == HorizontalScro
llbar ? m_hBar : m_vBar; |
| 930 if (!scrollbar) | 930 if (!scrollbar) |
| 931 return; | 931 return; |
| 932 | 932 |
| 933 if (!scrollbar->isCustomScrollbar()) | 933 if (!scrollbar->isCustomScrollbar()) |
| 934 willRemoveScrollbar(scrollbar.get(), orientation); | 934 willRemoveScrollbar(scrollbar.get(), orientation); |
| 935 | 935 |
| 936 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); | 936 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); |
| 937 scrollbar->disconnectFromScrollableArea(); | 937 scrollbar->disconnectFromScrollableArea(); |
| 938 scrollbar = nullptr; | 938 scrollbar = nullptr; |
| 939 } | 939 } |
| 940 | 940 |
| 941 void RenderLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) | 941 void LayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) |
| 942 { | 942 { |
| 943 if (hasScrollbar == hasHorizontalScrollbar()) | 943 if (hasScrollbar == hasHorizontalScrollbar()) |
| 944 return; | 944 return; |
| 945 | 945 |
| 946 if (hasScrollbar) { | 946 if (hasScrollbar) { |
| 947 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar | 947 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar |
| 948 // does, presumably this code does as well. | 948 // does, presumably this code does as well. |
| 949 DisableCompositingQueryAsserts disabler; | 949 DisableCompositingQueryAsserts disabler; |
| 950 m_hBar = createScrollbar(HorizontalScrollbar); | 950 m_hBar = createScrollbar(HorizontalScrollbar); |
| 951 } else { | 951 } else { |
| 952 if (!layerForHorizontalScrollbar()) | 952 if (!layerForHorizontalScrollbar()) |
| 953 m_hBar->invalidate(); | 953 m_hBar->invalidate(); |
| 954 // Otherwise we will remove the layer and just need recompositing. | 954 // Otherwise we will remove the layer and just need recompositing. |
| 955 | 955 |
| 956 destroyScrollbar(HorizontalScrollbar); | 956 destroyScrollbar(HorizontalScrollbar); |
| 957 } | 957 } |
| 958 | 958 |
| 959 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 959 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
| 960 if (m_hBar) | 960 if (m_hBar) |
| 961 m_hBar->styleChanged(); | 961 m_hBar->styleChanged(); |
| 962 if (m_vBar) | 962 if (m_vBar) |
| 963 m_vBar->styleChanged(); | 963 m_vBar->styleChanged(); |
| 964 | 964 |
| 965 // Force an update since we know the scrollbars have changed things. | 965 // Force an update since we know the scrollbars have changed things. |
| 966 if (box().document().hasAnnotatedRegions()) | 966 if (box().document().hasAnnotatedRegions()) |
| 967 box().document().setAnnotatedRegionsDirty(true); | 967 box().document().setAnnotatedRegionsDirty(true); |
| 968 } | 968 } |
| 969 | 969 |
| 970 void RenderLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) | 970 void LayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) |
| 971 { | 971 { |
| 972 if (hasScrollbar == hasVerticalScrollbar()) | 972 if (hasScrollbar == hasVerticalScrollbar()) |
| 973 return; | 973 return; |
| 974 | 974 |
| 975 if (hasScrollbar) { | 975 if (hasScrollbar) { |
| 976 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html | 976 // Hits in compositing/overflow/automatically-opt-into-composited-scroll
ing-after-style-change.html |
| 977 DisableCompositingQueryAsserts disabler; | 977 DisableCompositingQueryAsserts disabler; |
| 978 m_vBar = createScrollbar(VerticalScrollbar); | 978 m_vBar = createScrollbar(VerticalScrollbar); |
| 979 } else { | 979 } else { |
| 980 if (!layerForVerticalScrollbar()) | 980 if (!layerForVerticalScrollbar()) |
| 981 m_vBar->invalidate(); | 981 m_vBar->invalidate(); |
| 982 // Otherwise we will remove the layer and just need recompositing. | 982 // Otherwise we will remove the layer and just need recompositing. |
| 983 | 983 |
| 984 destroyScrollbar(VerticalScrollbar); | 984 destroyScrollbar(VerticalScrollbar); |
| 985 } | 985 } |
| 986 | 986 |
| 987 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 987 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
| 988 if (m_hBar) | 988 if (m_hBar) |
| 989 m_hBar->styleChanged(); | 989 m_hBar->styleChanged(); |
| 990 if (m_vBar) | 990 if (m_vBar) |
| 991 m_vBar->styleChanged(); | 991 m_vBar->styleChanged(); |
| 992 | 992 |
| 993 // Force an update since we know the scrollbars have changed things. | 993 // Force an update since we know the scrollbars have changed things. |
| 994 if (box().document().hasAnnotatedRegions()) | 994 if (box().document().hasAnnotatedRegions()) |
| 995 box().document().setAnnotatedRegionsDirty(true); | 995 box().document().setAnnotatedRegionsDirty(true); |
| 996 } | 996 } |
| 997 | 997 |
| 998 int RenderLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeReleva
ncy relevancy) const | 998 int LayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy re
levancy) const |
| 999 { | 999 { |
| 1000 if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS
crollbarSize || !m_vBar->shouldParticipateInHitTesting()))) | 1000 if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS
crollbarSize || !m_vBar->shouldParticipateInHitTesting()))) |
| 1001 return 0; | 1001 return 0; |
| 1002 return m_vBar->width(); | 1002 return m_vBar->width(); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 int RenderLayerScrollableArea::horizontalScrollbarHeight(OverlayScrollbarSizeRel
evancy relevancy) const | 1005 int LayerScrollableArea::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy
relevancy) const |
| 1006 { | 1006 { |
| 1007 if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS
crollbarSize || !m_hBar->shouldParticipateInHitTesting()))) | 1007 if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayS
crollbarSize || !m_hBar->shouldParticipateInHitTesting()))) |
| 1008 return 0; | 1008 return 0; |
| 1009 return m_hBar->height(); | 1009 return m_hBar->height(); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void RenderLayerScrollableArea::positionOverflowControls(const IntSize& offsetFr
omRoot) | 1012 void LayerScrollableArea::positionOverflowControls(const IntSize& offsetFromRoot
) |
| 1013 { | 1013 { |
| 1014 if (!hasScrollbar() && !box().canResize()) | 1014 if (!hasScrollbar() && !box().canResize()) |
| 1015 return; | 1015 return; |
| 1016 | 1016 |
| 1017 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); | 1017 const IntRect borderBox = box().pixelSnappedBorderBoxRect(); |
| 1018 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | 1018 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { |
| 1019 IntRect vBarRect = rectForVerticalScrollbar(borderBox); | 1019 IntRect vBarRect = rectForVerticalScrollbar(borderBox); |
| 1020 vBarRect.move(offsetFromRoot); | 1020 vBarRect.move(offsetFromRoot); |
| 1021 verticalScrollbar->setFrameRect(vBarRect); | 1021 verticalScrollbar->setFrameRect(vBarRect); |
| 1022 } | 1022 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1034 if (m_resizer) | 1034 if (m_resizer) |
| 1035 m_resizer->setFrameRect(resizerCornerRect(borderBox, ResizerForPointer))
; | 1035 m_resizer->setFrameRect(resizerCornerRect(borderBox, ResizerForPointer))
; |
| 1036 | 1036 |
| 1037 // FIXME, this should eventually be removed, once we are certain that compos
ited | 1037 // FIXME, this should eventually be removed, once we are certain that compos
ited |
| 1038 // controls get correctly positioned on a compositor update. For now, conser
vatively | 1038 // controls get correctly positioned on a compositor update. For now, conser
vatively |
| 1039 // leaving this unchanged. | 1039 // leaving this unchanged. |
| 1040 if (layer()->hasCompositedLayerMapping()) | 1040 if (layer()->hasCompositedLayerMapping()) |
| 1041 layer()->compositedLayerMapping()->positionOverflowControlsLayers(offset
FromRoot); | 1041 layer()->compositedLayerMapping()->positionOverflowControlsLayers(offset
FromRoot); |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 void RenderLayerScrollableArea::updateScrollCornerStyle() | 1044 void LayerScrollableArea::updateScrollCornerStyle() |
| 1045 { | 1045 { |
| 1046 if (!m_scrollCorner && !hasScrollbar()) | 1046 if (!m_scrollCorner && !hasScrollbar()) |
| 1047 return; | 1047 return; |
| 1048 if (!m_scrollCorner && hasOverlayScrollbars()) | 1048 if (!m_scrollCorner && hasOverlayScrollbars()) |
| 1049 return; | 1049 return; |
| 1050 | 1050 |
| 1051 RenderObject* actualRenderer = rendererForScrollbar(box()); | 1051 RenderObject* actualRenderer = rendererForScrollbar(box()); |
| 1052 RefPtr<RenderStyle> corner = box().hasOverflowClip() ? actualRenderer->getUn
cachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->style())
: PassRefPtr<RenderStyle>(nullptr); | 1052 RefPtr<RenderStyle> corner = box().hasOverflowClip() ? actualRenderer->getUn
cachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualRenderer->style())
: PassRefPtr<RenderStyle>(nullptr); |
| 1053 if (corner) { | 1053 if (corner) { |
| 1054 if (!m_scrollCorner) { | 1054 if (!m_scrollCorner) { |
| 1055 m_scrollCorner = RenderScrollbarPart::createAnonymous(&box().documen
t()); | 1055 m_scrollCorner = RenderScrollbarPart::createAnonymous(&box().documen
t()); |
| 1056 m_scrollCorner->setParent(&box()); | 1056 m_scrollCorner->setParent(&box()); |
| 1057 } | 1057 } |
| 1058 m_scrollCorner->setStyle(corner.release()); | 1058 m_scrollCorner->setStyle(corner.release()); |
| 1059 } else if (m_scrollCorner) { | 1059 } else if (m_scrollCorner) { |
| 1060 m_scrollCorner->destroy(); | 1060 m_scrollCorner->destroy(); |
| 1061 m_scrollCorner = nullptr; | 1061 m_scrollCorner = nullptr; |
| 1062 } | 1062 } |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 bool RenderLayerScrollableArea::hitTestOverflowControls(HitTestResult& result, c
onst IntPoint& localPoint) | 1065 bool LayerScrollableArea::hitTestOverflowControls(HitTestResult& result, const I
ntPoint& localPoint) |
| 1066 { | 1066 { |
| 1067 if (!hasScrollbar() && !box().canResize()) | 1067 if (!hasScrollbar() && !box().canResize()) |
| 1068 return false; | 1068 return false; |
| 1069 | 1069 |
| 1070 IntRect resizeControlRect; | 1070 IntRect resizeControlRect; |
| 1071 if (box().style()->resize() != RESIZE_NONE) { | 1071 if (box().style()->resize() != RESIZE_NONE) { |
| 1072 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(),
ResizerForPointer); | 1072 resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(),
ResizerForPointer); |
| 1073 if (resizeControlRect.contains(localPoint)) | 1073 if (resizeControlRect.contains(localPoint)) |
| 1074 return true; | 1074 return true; |
| 1075 } | 1075 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1096 result.setScrollbar(m_hBar.get()); | 1096 result.setScrollbar(m_hBar.get()); |
| 1097 return true; | 1097 return true; |
| 1098 } | 1098 } |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 // FIXME: We should hit test the m_scrollCorner and pass it back through the
result. | 1101 // FIXME: We should hit test the m_scrollCorner and pass it back through the
result. |
| 1102 | 1102 |
| 1103 return false; | 1103 return false; |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 IntRect RenderLayerScrollableArea::resizerCornerRect(const IntRect& bounds, Resi
zerHitTestType resizerHitTestType) const | 1106 IntRect LayerScrollableArea::resizerCornerRect(const IntRect& bounds, ResizerHit
TestType resizerHitTestType) const |
| 1107 { | 1107 { |
| 1108 if (box().style()->resize() == RESIZE_NONE) | 1108 if (box().style()->resize() == RESIZE_NONE) |
| 1109 return IntRect(); | 1109 return IntRect(); |
| 1110 IntRect corner = cornerRect(box().style(), horizontalScrollbar(), verticalSc
rollbar(), bounds); | 1110 IntRect corner = cornerRect(box().style(), horizontalScrollbar(), verticalSc
rollbar(), bounds); |
| 1111 | 1111 |
| 1112 if (resizerHitTestType == ResizerForTouch) { | 1112 if (resizerHitTestType == ResizerForTouch) { |
| 1113 // We make the resizer virtually larger for touch hit testing. With the | 1113 // We make the resizer virtually larger for touch hit testing. With the |
| 1114 // expanding ratio k = ResizerControlExpandRatioForTouch, we first move | 1114 // expanding ratio k = ResizerControlExpandRatioForTouch, we first move |
| 1115 // the resizer rect (of width w & height h), by (-w * (k-1), -h * (k-1))
, | 1115 // the resizer rect (of width w & height h), by (-w * (k-1), -h * (k-1))
, |
| 1116 // then expand the rect by new_w/h = w/h * k. | 1116 // then expand the rect by new_w/h = w/h * k. |
| 1117 int expandRatio = ResizerControlExpandRatioForTouch - 1; | 1117 int expandRatio = ResizerControlExpandRatioForTouch - 1; |
| 1118 corner.move(-corner.width() * expandRatio, -corner.height() * expandRati
o); | 1118 corner.move(-corner.width() * expandRatio, -corner.height() * expandRati
o); |
| 1119 corner.expand(corner.width() * expandRatio, corner.height() * expandRati
o); | 1119 corner.expand(corner.width() * expandRatio, corner.height() * expandRati
o); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 return corner; | 1122 return corner; |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 IntRect RenderLayerScrollableArea::scrollCornerAndResizerRect() const | 1125 IntRect LayerScrollableArea::scrollCornerAndResizerRect() const |
| 1126 { | 1126 { |
| 1127 IntRect scrollCornerAndResizer = scrollCornerRect(); | 1127 IntRect scrollCornerAndResizer = scrollCornerRect(); |
| 1128 if (scrollCornerAndResizer.isEmpty()) | 1128 if (scrollCornerAndResizer.isEmpty()) |
| 1129 scrollCornerAndResizer = resizerCornerRect(box().pixelSnappedBorderBoxRe
ct(), ResizerForPointer); | 1129 scrollCornerAndResizer = resizerCornerRect(box().pixelSnappedBorderBoxRe
ct(), ResizerForPointer); |
| 1130 return scrollCornerAndResizer; | 1130 return scrollCornerAndResizer; |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 bool RenderLayerScrollableArea::isPointInResizeControl(const IntPoint& absoluteP
oint, ResizerHitTestType resizerHitTestType) const | 1133 bool LayerScrollableArea::isPointInResizeControl(const IntPoint& absolutePoint,
ResizerHitTestType resizerHitTestType) const |
| 1134 { | 1134 { |
| 1135 if (!box().canResize()) | 1135 if (!box().canResize()) |
| 1136 return false; | 1136 return false; |
| 1137 | 1137 |
| 1138 IntPoint localPoint = roundedIntPoint(box().absoluteToLocal(absolutePoint, U
seTransforms)); | 1138 IntPoint localPoint = roundedIntPoint(box().absoluteToLocal(absolutePoint, U
seTransforms)); |
| 1139 IntRect localBounds(0, 0, box().pixelSnappedWidth(), box().pixelSnappedHeigh
t()); | 1139 IntRect localBounds(0, 0, box().pixelSnappedWidth(), box().pixelSnappedHeigh
t()); |
| 1140 return resizerCornerRect(localBounds, resizerHitTestType).contains(localPoin
t); | 1140 return resizerCornerRect(localBounds, resizerHitTestType).contains(localPoin
t); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 bool RenderLayerScrollableArea::hitTestResizerInFragments(const LayerFragments&
layerFragments, const HitTestLocation& hitTestLocation) const | 1143 bool LayerScrollableArea::hitTestResizerInFragments(const LayerFragments& layerF
ragments, const HitTestLocation& hitTestLocation) const |
| 1144 { | 1144 { |
| 1145 if (!box().canResize()) | 1145 if (!box().canResize()) |
| 1146 return false; | 1146 return false; |
| 1147 | 1147 |
| 1148 if (layerFragments.isEmpty()) | 1148 if (layerFragments.isEmpty()) |
| 1149 return false; | 1149 return false; |
| 1150 | 1150 |
| 1151 for (int i = layerFragments.size() - 1; i >= 0; --i) { | 1151 for (int i = layerFragments.size() - 1; i >= 0; --i) { |
| 1152 const LayerFragment& fragment = layerFragments.at(i); | 1152 const LayerFragment& fragment = layerFragments.at(i); |
| 1153 if (fragment.backgroundRect.intersects(hitTestLocation) && resizerCorner
Rect(pixelSnappedIntRect(fragment.layerBounds), ResizerForPointer).contains(hitT
estLocation.roundedPoint())) | 1153 if (fragment.backgroundRect.intersects(hitTestLocation) && resizerCorner
Rect(pixelSnappedIntRect(fragment.layerBounds), ResizerForPointer).contains(hitT
estLocation.roundedPoint())) |
| 1154 return true; | 1154 return true; |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 return false; | 1157 return false; |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 void RenderLayerScrollableArea::updateResizerAreaSet() | 1160 void LayerScrollableArea::updateResizerAreaSet() |
| 1161 { | 1161 { |
| 1162 LocalFrame* frame = box().frame(); | 1162 LocalFrame* frame = box().frame(); |
| 1163 if (!frame) | 1163 if (!frame) |
| 1164 return; | 1164 return; |
| 1165 FrameView* frameView = frame->view(); | 1165 FrameView* frameView = frame->view(); |
| 1166 if (!frameView) | 1166 if (!frameView) |
| 1167 return; | 1167 return; |
| 1168 if (box().canResize()) | 1168 if (box().canResize()) |
| 1169 frameView->addResizerArea(box()); | 1169 frameView->addResizerArea(box()); |
| 1170 else | 1170 else |
| 1171 frameView->removeResizerArea(box()); | 1171 frameView->removeResizerArea(box()); |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 void RenderLayerScrollableArea::updateResizerStyle() | 1174 void LayerScrollableArea::updateResizerStyle() |
| 1175 { | 1175 { |
| 1176 if (!m_resizer && !box().canResize()) | 1176 if (!m_resizer && !box().canResize()) |
| 1177 return; | 1177 return; |
| 1178 | 1178 |
| 1179 RenderObject* actualRenderer = rendererForScrollbar(box()); | 1179 RenderObject* actualRenderer = rendererForScrollbar(box()); |
| 1180 RefPtr<RenderStyle> resizer = box().hasOverflowClip() ? actualRenderer->getU
ncachedPseudoStyle(PseudoStyleRequest(RESIZER), actualRenderer->style()) : PassR
efPtr<RenderStyle>(nullptr); | 1180 RefPtr<RenderStyle> resizer = box().hasOverflowClip() ? actualRenderer->getU
ncachedPseudoStyle(PseudoStyleRequest(RESIZER), actualRenderer->style()) : PassR
efPtr<RenderStyle>(nullptr); |
| 1181 if (resizer) { | 1181 if (resizer) { |
| 1182 if (!m_resizer) { | 1182 if (!m_resizer) { |
| 1183 m_resizer = RenderScrollbarPart::createAnonymous(&box().document()); | 1183 m_resizer = RenderScrollbarPart::createAnonymous(&box().document()); |
| 1184 m_resizer->setParent(&box()); | 1184 m_resizer->setParent(&box()); |
| 1185 } | 1185 } |
| 1186 m_resizer->setStyle(resizer.release()); | 1186 m_resizer->setStyle(resizer.release()); |
| 1187 } else if (m_resizer) { | 1187 } else if (m_resizer) { |
| 1188 m_resizer->destroy(); | 1188 m_resizer->destroy(); |
| 1189 m_resizer = nullptr; | 1189 m_resizer = nullptr; |
| 1190 } | 1190 } |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 IntSize RenderLayerScrollableArea::offsetFromResizeCorner(const IntPoint& absolu
tePoint) const | 1193 IntSize LayerScrollableArea::offsetFromResizeCorner(const IntPoint& absolutePoin
t) const |
| 1194 { | 1194 { |
| 1195 // Currently the resize corner is either the bottom right corner or the bott
om left corner. | 1195 // Currently the resize corner is either the bottom right corner or the bott
om left corner. |
| 1196 // FIXME: This assumes the location is 0, 0. Is this guaranteed to always be
the case? | 1196 // FIXME: This assumes the location is 0, 0. Is this guaranteed to always be
the case? |
| 1197 IntSize elementSize = layer()->size(); | 1197 IntSize elementSize = layer()->size(); |
| 1198 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1198 if (box().style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 1199 elementSize.setWidth(0); | 1199 elementSize.setWidth(0); |
| 1200 IntPoint resizerPoint = IntPoint(elementSize); | 1200 IntPoint resizerPoint = IntPoint(elementSize); |
| 1201 IntPoint localPoint = roundedIntPoint(box().absoluteToLocal(absolutePoint, U
seTransforms)); | 1201 IntPoint localPoint = roundedIntPoint(box().absoluteToLocal(absolutePoint, U
seTransforms)); |
| 1202 return localPoint - resizerPoint; | 1202 return localPoint - resizerPoint; |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 void RenderLayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSiz
e& oldOffset) | 1205 void LayerScrollableArea::resize(const PlatformEvent& evt, const LayoutSize& old
Offset) |
| 1206 { | 1206 { |
| 1207 // FIXME: This should be possible on generated content but is not right now. | 1207 // FIXME: This should be possible on generated content but is not right now. |
| 1208 if (!inResizeMode() || !box().canResize() || !box().node()) | 1208 if (!inResizeMode() || !box().canResize() || !box().node()) |
| 1209 return; | 1209 return; |
| 1210 | 1210 |
| 1211 ASSERT(box().node()->isElementNode()); | 1211 ASSERT(box().node()->isElementNode()); |
| 1212 Element* element = toElement(box().node()); | 1212 Element* element = toElement(box().node()); |
| 1213 | 1213 |
| 1214 Document& document = element->document(); | 1214 Document& document = element->document(); |
| 1215 | 1215 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 LayoutUnit baseHeight = box().size().height() - (isBoxSizingBorder ? Lay
outUnit() : box().borderAndPaddingHeight()); | 1274 LayoutUnit baseHeight = box().size().height() - (isBoxSizingBorder ? Lay
outUnit() : box().borderAndPaddingHeight()); |
| 1275 baseHeight = baseHeight / zoomFactor; | 1275 baseHeight = baseHeight / zoomFactor; |
| 1276 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); | 1276 element->setInlineStyleProperty(CSSPropertyHeight, roundToInt(baseHeight
+ difference.height()), CSSPrimitiveValue::CSS_PX); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 document.updateLayout(); | 1279 document.updateLayout(); |
| 1280 | 1280 |
| 1281 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. | 1281 // FIXME (Radar 4118564): We should also autoscroll the window as necessary
to keep the point under the cursor in view. |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 LayoutRect RenderLayerScrollableArea::exposeRect(const LayoutRect& rect, const S
crollAlignment& alignX, const ScrollAlignment& alignY) | 1284 LayoutRect LayerScrollableArea::exposeRect(const LayoutRect& rect, const ScrollA
lignment& alignX, const ScrollAlignment& alignY) |
| 1285 { | 1285 { |
| 1286 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); | 1286 LayoutRect localExposeRect(box().absoluteToLocalQuad(FloatQuad(FloatRect(rec
t)), UseTransforms).boundingBox()); |
| 1287 localExposeRect.move(-box().borderLeft(), -box().borderTop()); | 1287 localExposeRect.move(-box().borderLeft(), -box().borderTop()); |
| 1288 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); | 1288 LayoutRect layerBounds(0, 0, box().clientWidth(), box().clientHeight()); |
| 1289 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); | 1289 LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect
, alignX, alignY); |
| 1290 | 1290 |
| 1291 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() +
roundedIntSize(r.location())); | 1291 DoubleSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset() +
roundedIntSize(r.location())); |
| 1292 if (clampedScrollOffset == adjustedScrollOffset()) | 1292 if (clampedScrollOffset == adjustedScrollOffset()) |
| 1293 return rect; | 1293 return rect; |
| 1294 | 1294 |
| 1295 DoubleSize oldScrollOffset = adjustedScrollOffset(); | 1295 DoubleSize oldScrollOffset = adjustedScrollOffset(); |
| 1296 scrollToOffset(clampedScrollOffset); | 1296 scrollToOffset(clampedScrollOffset); |
| 1297 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset
; | 1297 DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset
; |
| 1298 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); | 1298 localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
| 1299 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); | 1299 return LayoutRect(box().localToAbsoluteQuad(FloatQuad(FloatRect(localExposeR
ect)), UseTransforms).boundingBox()); |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 void RenderLayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) | 1302 void LayerScrollableArea::updateScrollableAreaSet(bool hasOverflow) |
| 1303 { | 1303 { |
| 1304 LocalFrame* frame = box().frame(); | 1304 LocalFrame* frame = box().frame(); |
| 1305 if (!frame) | 1305 if (!frame) |
| 1306 return; | 1306 return; |
| 1307 | 1307 |
| 1308 FrameView* frameView = frame->view(); | 1308 FrameView* frameView = frame->view(); |
| 1309 if (!frameView) | 1309 if (!frameView) |
| 1310 return; | 1310 return; |
| 1311 | 1311 |
| 1312 // FIXME: Does this need to be fixed later for OOPI? | 1312 // FIXME: Does this need to be fixed later for OOPI? |
| 1313 bool isVisibleToHitTest = box().visibleToHitTesting(); | 1313 bool isVisibleToHitTest = box().visibleToHitTesting(); |
| 1314 if (HTMLFrameOwnerElement* owner = frame->deprecatedLocalOwner()) | 1314 if (HTMLFrameOwnerElement* owner = frame->deprecatedLocalOwner()) |
| 1315 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH
itTesting(); | 1315 isVisibleToHitTest &= owner->renderer() && owner->renderer()->visibleToH
itTesting(); |
| 1316 | 1316 |
| 1317 bool didScrollOverflow = m_scrollsOverflow; | 1317 bool didScrollOverflow = m_scrollsOverflow; |
| 1318 | 1318 |
| 1319 m_scrollsOverflow = hasOverflow && isVisibleToHitTest; | 1319 m_scrollsOverflow = hasOverflow && isVisibleToHitTest; |
| 1320 if (didScrollOverflow == scrollsOverflow()) | 1320 if (didScrollOverflow == scrollsOverflow()) |
| 1321 return; | 1321 return; |
| 1322 | 1322 |
| 1323 if (m_scrollsOverflow) { | 1323 if (m_scrollsOverflow) { |
| 1324 ASSERT(canHaveOverflowScrollbars(box())); | 1324 ASSERT(canHaveOverflowScrollbars(box())); |
| 1325 frameView->addScrollableArea(this); | 1325 frameView->addScrollableArea(this); |
| 1326 } else | 1326 } else { |
| 1327 frameView->removeScrollableArea(this); | 1327 frameView->removeScrollableArea(this); |
| 1328 } |
| 1328 } | 1329 } |
| 1329 | 1330 |
| 1330 void RenderLayerScrollableArea::updateCompositingLayersAfterScroll() | 1331 void LayerScrollableArea::updateCompositingLayersAfterScroll() |
| 1331 { | 1332 { |
| 1332 DisableCompositingQueryAsserts disabler; | 1333 DisableCompositingQueryAsserts disabler; |
| 1333 RenderLayerCompositor* compositor = box().view()->compositor(); | 1334 LayerCompositor* compositor = box().view()->compositor(); |
| 1334 if (compositor->inCompositingMode()) { | 1335 if (compositor->inCompositingMode()) { |
| 1335 if (usesCompositedScrolling()) { | 1336 if (usesCompositedScrolling()) { |
| 1336 ASSERT(layer()->hasCompositedLayerMapping()); | 1337 ASSERT(layer()->hasCompositedLayerMapping()); |
| 1337 layer()->compositedLayerMapping()->setNeedsGraphicsLayerUpdate(Graph
icsLayerUpdateSubtree); | 1338 layer()->compositedLayerMapping()->setNeedsGraphicsLayerUpdate(Graph
icsLayerUpdateSubtree); |
| 1338 compositor->setNeedsCompositingUpdate(CompositingUpdateAfterGeometry
Change); | 1339 compositor->setNeedsCompositingUpdate(CompositingUpdateAfterGeometry
Change); |
| 1339 } else { | 1340 } else { |
| 1340 layer()->setNeedsCompositingInputsUpdate(); | 1341 layer()->setNeedsCompositingInputsUpdate(); |
| 1341 } | 1342 } |
| 1342 } | 1343 } |
| 1343 } | 1344 } |
| 1344 | 1345 |
| 1345 bool RenderLayerScrollableArea::usesCompositedScrolling() const | 1346 bool LayerScrollableArea::usesCompositedScrolling() const |
| 1346 { | 1347 { |
| 1347 // Scroll form controls on the main thread so they exhibit correct touch scr
oll event bubbling | 1348 // Scroll form controls on the main thread so they exhibit correct touch scr
oll event bubbling |
| 1348 if (box().isIntristicallyScrollable(VerticalScrollbar) || box().isIntristica
llyScrollable(HorizontalScrollbar)) | 1349 if (box().isIntristicallyScrollable(VerticalScrollbar) || box().isIntristica
llyScrollable(HorizontalScrollbar)) |
| 1349 return false; | 1350 return false; |
| 1350 | 1351 |
| 1351 // See https://codereview.chromium.org/176633003/ for the tests that fail wi
thout this disabler. | 1352 // See https://codereview.chromium.org/176633003/ for the tests that fail wi
thout this disabler. |
| 1352 DisableCompositingQueryAsserts disabler; | 1353 DisableCompositingQueryAsserts disabler; |
| 1353 return layer()->hasCompositedLayerMapping() && layer()->compositedLayerMappi
ng()->scrollingLayer(); | 1354 return layer()->hasCompositedLayerMapping() && layer()->compositedLayerMappi
ng()->scrollingLayer(); |
| 1354 } | 1355 } |
| 1355 | 1356 |
| 1356 static bool layerNeedsCompositedScrolling(RenderLayerScrollableArea::LCDTextMode
mode, const RenderLayer* layer) | 1357 static bool layerNeedsCompositedScrolling(LayerScrollableArea::LCDTextMode mode,
const Layer* layer) |
| 1357 { | 1358 { |
| 1358 if (mode == RenderLayerScrollableArea::ConsiderLCDText && !layer->compositor
()->preferCompositingToLCDTextEnabled()) | 1359 if (mode == LayerScrollableArea::ConsiderLCDText && !layer->compositor()->pr
eferCompositingToLCDTextEnabled()) |
| 1359 return false; | 1360 return false; |
| 1360 | 1361 |
| 1361 return layer->scrollsOverflow() | 1362 return layer->scrollsOverflow() |
| 1362 && !layer->hasDescendantWithClipPath() | 1363 && !layer->hasDescendantWithClipPath() |
| 1363 && !layer->hasAncestorWithClipPath() | 1364 && !layer->hasAncestorWithClipPath() |
| 1364 && !layer->renderer()->style()->hasBorderRadius(); | 1365 && !layer->renderer()->style()->hasBorderRadius(); |
| 1365 } | 1366 } |
| 1366 | 1367 |
| 1367 void RenderLayerScrollableArea::updateNeedsCompositedScrolling(LCDTextMode mode) | 1368 void LayerScrollableArea::updateNeedsCompositedScrolling(LCDTextMode mode) |
| 1368 { | 1369 { |
| 1369 const bool needsCompositedScrolling = layerNeedsCompositedScrolling(mode, la
yer()); | 1370 const bool needsCompositedScrolling = layerNeedsCompositedScrolling(mode, la
yer()); |
| 1370 if (static_cast<bool>(m_needsCompositedScrolling) != needsCompositedScrollin
g) { | 1371 if (static_cast<bool>(m_needsCompositedScrolling) != needsCompositedScrollin
g) { |
| 1371 m_needsCompositedScrolling = needsCompositedScrolling; | 1372 m_needsCompositedScrolling = needsCompositedScrolling; |
| 1372 layer()->didUpdateNeedsCompositedScrolling(); | 1373 layer()->didUpdateNeedsCompositedScrolling(); |
| 1373 } | 1374 } |
| 1374 } | 1375 } |
| 1375 | 1376 |
| 1376 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) | 1377 void LayerScrollableArea::setTopmostScrollChild(Layer* scrollChild) |
| 1377 { | 1378 { |
| 1378 // We only want to track the topmost scroll child for scrollable areas with | 1379 // We only want to track the topmost scroll child for scrollable areas with |
| 1379 // overlay scrollbars. | 1380 // overlay scrollbars. |
| 1380 if (!hasOverlayScrollbars()) | 1381 if (!hasOverlayScrollbars()) |
| 1381 return; | 1382 return; |
| 1382 m_nextTopmostScrollChild = scrollChild; | 1383 m_nextTopmostScrollChild = scrollChild; |
| 1383 } | 1384 } |
| 1384 | 1385 |
| 1385 } // namespace blink | 1386 } // namespace blink |
| OLD | NEW |