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 |
| 3 * reserved. |
3 * | 4 * |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
5 * | 6 * |
6 * Other contributors: | 7 * Other contributors: |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
8 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
9 * Christian Biesinger <cbiesinger@gmail.com> | 10 * Christian Biesinger <cbiesinger@gmail.com> |
10 * Randall Jesup <rjesup@wgate.com> | 11 * Randall Jesup <rjesup@wgate.com> |
11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> | 12 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> |
12 * Josh Soref <timeless@mac.com> | 13 * Josh Soref <timeless@mac.com> |
13 * Boris Zbarsky <bzbarsky@mit.edu> | 14 * Boris Zbarsky <bzbarsky@mit.edu> |
14 * | 15 * |
15 * This library is free software; you can redistribute it and/or | 16 * This library is free software; you can redistribute it and/or |
16 * modify it under the terms of the GNU Lesser General Public | 17 * modify it under the terms of the GNU Lesser General Public |
17 * License as published by the Free Software Foundation; either | 18 * License as published by the Free Software Foundation; either |
18 * version 2.1 of the License, or (at your option) any later version. | 19 * version 2.1 of the License, or (at your option) any later version. |
19 * | 20 * |
20 * This library is distributed in the hope that it will be useful, | 21 * This library is distributed in the hope that it will be useful, |
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
23 * Lesser General Public License for more details. | 24 * Lesser General Public License for more details. |
24 * | 25 * |
25 * You should have received a copy of the GNU Lesser General Public | 26 * You should have received a copy of the GNU Lesser General Public |
26 * License along with this library; if not, write to the Free Software | 27 * License along with this library; if not, write to the Free Software |
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
A | 28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
28 * | 29 * |
29 * Alternatively, the contents of this file may be used under the terms | 30 * Alternatively, the contents of this file may be used under the terms |
30 * of either the Mozilla Public License Version 1.1, found at | 31 * of either the Mozilla Public License Version 1.1, found at |
31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public | 32 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public |
32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html | 33 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html |
33 * (the "GPL"), in which case the provisions of the MPL or the GPL are | 34 * (the "GPL"), in which case the provisions of the MPL or the GPL are |
34 * applicable instead of those above. If you wish to allow use of your | 35 * applicable instead of those above. If you wish to allow use of your |
35 * version of this file only under the terms of one of those two | 36 * 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 | 37 * 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 | 38 * version of this file under the LGPL, indicate your decision by |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 m_scrollCorner(nullptr), | 105 m_scrollCorner(nullptr), |
105 m_resizer(nullptr), | 106 m_resizer(nullptr), |
106 m_scrollAnchor(this) | 107 m_scrollAnchor(this) |
107 #if ENABLE(ASSERT) | 108 #if ENABLE(ASSERT) |
108 , | 109 , |
109 m_hasBeenDisposed(false) | 110 m_hasBeenDisposed(false) |
110 #endif | 111 #endif |
111 { | 112 { |
112 Node* node = box().node(); | 113 Node* node = box().node(); |
113 if (node && node->isElementNode()) { | 114 if (node && node->isElementNode()) { |
114 // We save and restore only the scrollOffset as the other scroll values are
recalculated. | 115 // We save and restore only the scrollOffset as the other scroll values are |
| 116 // recalculated. |
115 Element* element = toElement(node); | 117 Element* element = toElement(node); |
116 m_scrollOffset = element->savedLayerScrollOffset(); | 118 m_scrollOffset = element->savedLayerScrollOffset(); |
117 if (!m_scrollOffset.isZero()) { | 119 if (!m_scrollOffset.isZero()) { |
118 scrollAnimator().setCurrentPosition( | 120 scrollAnimator().setCurrentPosition( |
119 FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); | 121 FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); |
120 } | 122 } |
121 element->setSavedLayerScrollOffset(IntSize()); | 123 element->setSavedLayerScrollOffset(IntSize()); |
122 } | 124 } |
123 updateResizerAreaSet(); | 125 updateResizerAreaSet(); |
124 } | 126 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 168 |
167 m_scrollbarManager.dispose(); | 169 m_scrollbarManager.dispose(); |
168 | 170 |
169 if (m_scrollCorner) | 171 if (m_scrollCorner) |
170 m_scrollCorner->destroy(); | 172 m_scrollCorner->destroy(); |
171 if (m_resizer) | 173 if (m_resizer) |
172 m_resizer->destroy(); | 174 m_resizer->destroy(); |
173 | 175 |
174 clearScrollAnimators(); | 176 clearScrollAnimators(); |
175 | 177 |
176 // Note: it is not safe to call ScrollAnchor::clear if the document is being d
estroyed, | 178 // Note: it is not safe to call ScrollAnchor::clear if the document is being |
177 // because LayoutObjectChildList::removeChildNode skips the call to willBeRemo
vedFromTree, | 179 // destroyed, because LayoutObjectChildList::removeChildNode skips the call to |
| 180 // willBeRemovedFromTree, |
178 // leaving the ScrollAnchor with a stale LayoutObject pointer. | 181 // leaving the ScrollAnchor with a stale LayoutObject pointer. |
179 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 182 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
180 !box().documentBeingDestroyed()) | 183 !box().documentBeingDestroyed()) |
181 m_scrollAnchor.clear(); | 184 m_scrollAnchor.clear(); |
182 | 185 |
183 #if ENABLE(ASSERT) | 186 #if ENABLE(ASSERT) |
184 m_hasBeenDisposed = true; | 187 m_hasBeenDisposed = true; |
185 #endif | 188 #endif |
186 } | 189 } |
187 | 190 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 return maxX - thickness - box.styleRef().borderRightWidth(); | 260 return maxX - thickness - box.styleRef().borderRightWidth(); |
258 } | 261 } |
259 | 262 |
260 static IntRect cornerRect(const LayoutBox& box, | 263 static IntRect cornerRect(const LayoutBox& box, |
261 const Scrollbar* horizontalScrollbar, | 264 const Scrollbar* horizontalScrollbar, |
262 const Scrollbar* verticalScrollbar, | 265 const Scrollbar* verticalScrollbar, |
263 const IntRect& bounds) { | 266 const IntRect& bounds) { |
264 int horizontalThickness; | 267 int horizontalThickness; |
265 int verticalThickness; | 268 int verticalThickness; |
266 if (!verticalScrollbar && !horizontalScrollbar) { | 269 if (!verticalScrollbar && !horizontalScrollbar) { |
267 // FIXME: This isn't right. We need to know the thickness of custom scrollba
rs | 270 // FIXME: This isn't right. We need to know the thickness of custom |
268 // even when they don't exist in order to set the resizer square size proper
ly. | 271 // scrollbars even when they don't exist in order to set the resizer square |
| 272 // size properly. |
269 horizontalThickness = ScrollbarTheme::theme().scrollbarThickness(); | 273 horizontalThickness = ScrollbarTheme::theme().scrollbarThickness(); |
270 verticalThickness = horizontalThickness; | 274 verticalThickness = horizontalThickness; |
271 } else if (verticalScrollbar && !horizontalScrollbar) { | 275 } else if (verticalScrollbar && !horizontalScrollbar) { |
272 horizontalThickness = verticalScrollbar->scrollbarThickness(); | 276 horizontalThickness = verticalScrollbar->scrollbarThickness(); |
273 verticalThickness = horizontalThickness; | 277 verticalThickness = horizontalThickness; |
274 } else if (horizontalScrollbar && !verticalScrollbar) { | 278 } else if (horizontalScrollbar && !verticalScrollbar) { |
275 verticalThickness = horizontalScrollbar->scrollbarThickness(); | 279 verticalThickness = horizontalScrollbar->scrollbarThickness(); |
276 horizontalThickness = verticalThickness; | 280 horizontalThickness = verticalThickness; |
277 } else { | 281 } else { |
278 horizontalThickness = verticalScrollbar->scrollbarThickness(); | 282 horizontalThickness = verticalScrollbar->scrollbarThickness(); |
279 verticalThickness = horizontalScrollbar->scrollbarThickness(); | 283 verticalThickness = horizontalScrollbar->scrollbarThickness(); |
280 } | 284 } |
281 return IntRect( | 285 return IntRect( |
282 cornerStart(box, bounds.x(), bounds.maxX(), horizontalThickness), | 286 cornerStart(box, bounds.x(), bounds.maxX(), horizontalThickness), |
283 bounds.maxY() - verticalThickness - box.styleRef().borderBottomWidth(), | 287 bounds.maxY() - verticalThickness - box.styleRef().borderBottomWidth(), |
284 horizontalThickness, verticalThickness); | 288 horizontalThickness, verticalThickness); |
285 } | 289 } |
286 | 290 |
287 IntRect PaintLayerScrollableArea::scrollCornerRect() const { | 291 IntRect PaintLayerScrollableArea::scrollCornerRect() const { |
288 // We have a scrollbar corner when a scrollbar is visible and not filling the
entire length of the box. | 292 // We have a scrollbar corner when a scrollbar is visible and not filling the |
| 293 // entire length of the box. |
289 // This happens when: | 294 // This happens when: |
290 // (a) A resizer is present and at least one scrollbar is present | 295 // (a) A resizer is present and at least one scrollbar is present |
291 // (b) Both scrollbars are present. | 296 // (b) Both scrollbars are present. |
292 bool hasHorizontalBar = horizontalScrollbar(); | 297 bool hasHorizontalBar = horizontalScrollbar(); |
293 bool hasVerticalBar = verticalScrollbar(); | 298 bool hasVerticalBar = verticalScrollbar(); |
294 bool hasResizer = box().style()->resize() != RESIZE_NONE; | 299 bool hasResizer = box().style()->resize() != RESIZE_NONE; |
295 if ((hasHorizontalBar && hasVerticalBar) || | 300 if ((hasHorizontalBar && hasVerticalBar) || |
296 (hasResizer && (hasHorizontalBar || hasVerticalBar))) | 301 (hasResizer && (hasHorizontalBar || hasVerticalBar))) |
297 return cornerRect(box(), horizontalScrollbar(), verticalScrollbar(), | 302 return cornerRect(box(), horizontalScrollbar(), verticalScrollbar(), |
298 box().pixelSnappedBorderBoxRect()); | 303 box().pixelSnappedBorderBoxRect()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 375 |
371 FrameView* frameView = box().frameView(); | 376 FrameView* frameView = box().frameView(); |
372 | 377 |
373 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", | 378 TRACE_EVENT1("devtools.timeline", "ScrollLayer", "data", |
374 InspectorScrollLayerEvent::data(&box())); | 379 InspectorScrollLayerEvent::data(&box())); |
375 | 380 |
376 // FIXME(420741): Resolve circular dependency between scroll offset and | 381 // FIXME(420741): Resolve circular dependency between scroll offset and |
377 // compositing state, and remove this disabler. | 382 // compositing state, and remove this disabler. |
378 DisableCompositingQueryAsserts disabler; | 383 DisableCompositingQueryAsserts disabler; |
379 | 384 |
380 // Update the positions of our child layers (if needed as only fixed layers sh
ould be impacted by a scroll). | 385 // Update the positions of our child layers (if needed as only fixed layers |
381 // We don't update compositing layers, because we need to do a deep update fro
m the compositing ancestor. | 386 // should be impacted by a scroll). We don't update compositing layers, |
| 387 // because we need to do a deep update from the compositing ancestor. |
382 if (!frameView->isInPerformLayout()) { | 388 if (!frameView->isInPerformLayout()) { |
383 // If we're in the middle of layout, we'll just update layers once layout ha
s finished. | 389 // If we're in the middle of layout, we'll just update layers once layout |
| 390 // has finished. |
384 layer()->updateLayerPositionsAfterOverflowScroll(scrollDelta); | 391 layer()->updateLayerPositionsAfterOverflowScroll(scrollDelta); |
385 // Update regions, scrolling may change the clip of a particular region. | 392 // Update regions, scrolling may change the clip of a particular region. |
386 frameView->updateDocumentAnnotatedRegions(); | 393 frameView->updateDocumentAnnotatedRegions(); |
387 frameView->setNeedsUpdateWidgetGeometries(); | 394 frameView->setNeedsUpdateWidgetGeometries(); |
388 updateCompositingLayersAfterScroll(); | 395 updateCompositingLayersAfterScroll(); |
389 } | 396 } |
390 | 397 |
391 const LayoutBoxModelObject& paintInvalidationContainer = | 398 const LayoutBoxModelObject& paintInvalidationContainer = |
392 box().containerForPaintInvalidation(); | 399 box().containerForPaintInvalidation(); |
393 // The caret rect needs to be invalidated after scrolling | 400 // The caret rect needs to be invalidated after scrolling |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 441 } |
435 | 442 |
436 // Schedule the scroll DOM event. | 443 // Schedule the scroll DOM event. |
437 if (box().node()) | 444 if (box().node()) |
438 box().node()->document().enqueueScrollEventForNode(box().node()); | 445 box().node()->document().enqueueScrollEventForNode(box().node()); |
439 | 446 |
440 if (AXObjectCache* cache = box().document().existingAXObjectCache()) | 447 if (AXObjectCache* cache = box().document().existingAXObjectCache()) |
441 cache->handleScrollPositionChanged(&box()); | 448 cache->handleScrollPositionChanged(&box()); |
442 box().view()->clearHitTestCache(); | 449 box().view()->clearHitTestCache(); |
443 | 450 |
444 // Inform the FrameLoader of the new scroll position, so it can be restored wh
en navigating back. | 451 // Inform the FrameLoader of the new scroll position, so it can be restored |
| 452 // when navigating back. |
445 if (layer()->isRootLayer()) { | 453 if (layer()->isRootLayer()) { |
446 frameView->frame().loader().saveScrollState(); | 454 frameView->frame().loader().saveScrollState(); |
447 frameView->didChangeScrollOffset(); | 455 frameView->didChangeScrollOffset(); |
448 } | 456 } |
449 | 457 |
450 // All scrolls clear the fragment anchor. | 458 // All scrolls clear the fragment anchor. |
451 frameView->clearFragmentAnchor(); | 459 frameView->clearFragmentAnchor(); |
452 | 460 |
453 // Clear the scroll anchor, unless it is the reason for this scroll. | 461 // Clear the scroll anchor, unless it is the reason for this scroll. |
454 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && | 462 if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 return snapSizeToPixel(scrollWidth(), | 623 return snapSizeToPixel(scrollWidth(), |
616 box().clientLeft() + box().location().x()); | 624 box().clientLeft() + box().location().x()); |
617 } | 625 } |
618 | 626 |
619 int PaintLayerScrollableArea::pixelSnappedScrollHeight() const { | 627 int PaintLayerScrollableArea::pixelSnappedScrollHeight() const { |
620 return snapSizeToPixel(scrollHeight(), | 628 return snapSizeToPixel(scrollHeight(), |
621 box().clientTop() + box().location().y()); | 629 box().clientTop() + box().location().y()); |
622 } | 630 } |
623 | 631 |
624 void PaintLayerScrollableArea::updateScrollOrigin() { | 632 void PaintLayerScrollableArea::updateScrollOrigin() { |
625 // This should do nothing prior to first layout; the if-clause will catch that
. | 633 // This should do nothing prior to first layout; the if-clause will catch |
| 634 // that. |
626 if (overflowRect().isEmpty()) | 635 if (overflowRect().isEmpty()) |
627 return; | 636 return; |
628 LayoutPoint scrollableOverflow = | 637 LayoutPoint scrollableOverflow = |
629 m_overflowRect.location() - | 638 m_overflowRect.location() - |
630 LayoutSize(box().borderLeft(), box().borderTop()); | 639 LayoutSize(box().borderLeft(), box().borderTop()); |
631 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + | 640 setScrollOrigin(flooredIntPoint(-scrollableOverflow) + |
632 box().originAdjustmentForScrollbars()); | 641 box().originAdjustmentForScrollbars()); |
633 } | 642 } |
634 | 643 |
635 void PaintLayerScrollableArea::updateScrollDimensions() { | 644 void PaintLayerScrollableArea::updateScrollDimensions() { |
(...skipping 26 matching lines...) Expand all Loading... |
662 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); | 671 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); |
663 bool hasVerticalOverflow = this->hasVerticalOverflow(); | 672 bool hasVerticalOverflow = this->hasVerticalOverflow(); |
664 | 673 |
665 // Don't add auto scrollbars if the box contents aren't visible. | 674 // Don't add auto scrollbars if the box contents aren't visible. |
666 bool shouldHaveAutoHorizontalScrollbar = | 675 bool shouldHaveAutoHorizontalScrollbar = |
667 hasHorizontalOverflow && box().pixelSnappedClientHeight(); | 676 hasHorizontalOverflow && box().pixelSnappedClientHeight(); |
668 bool shouldHaveAutoVerticalScrollbar = | 677 bool shouldHaveAutoVerticalScrollbar = |
669 hasVerticalOverflow && box().pixelSnappedClientWidth(); | 678 hasVerticalOverflow && box().pixelSnappedClientWidth(); |
670 | 679 |
671 { | 680 { |
672 // Hits in compositing/overflow/automatically-opt-into-composited-scrolling-
after-style-change.html. | 681 // Hits in |
| 682 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. |
673 DisableCompositingQueryAsserts disabler; | 683 DisableCompositingQueryAsserts disabler; |
674 | 684 |
675 // overflow:scroll should just enable/disable. | 685 // overflow:scroll should just enable/disable. |
676 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) | 686 if (box().style()->overflowX() == OverflowScroll && horizontalScrollbar()) |
677 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); | 687 horizontalScrollbar()->setEnabled(hasHorizontalOverflow); |
678 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) | 688 if (box().style()->overflowY() == OverflowScroll && verticalScrollbar()) |
679 verticalScrollbar()->setEnabled(hasVerticalOverflow); | 689 verticalScrollbar()->setEnabled(hasVerticalOverflow); |
680 } | 690 } |
681 | 691 |
682 // We need to layout again if scrollbars are added or removed by overflow:auto
, | 692 // We need to layout again if scrollbars are added or removed by |
683 // or by changing between native and custom. | 693 // overflow:auto, or by changing between native and custom. |
684 bool horizontalScrollbarShouldChange = | 694 bool horizontalScrollbarShouldChange = |
685 (box().hasAutoHorizontalScrollbar() && | 695 (box().hasAutoHorizontalScrollbar() && |
686 (hasHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar)) || | 696 (hasHorizontalScrollbar() != shouldHaveAutoHorizontalScrollbar)) || |
687 (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar()); | 697 (box().style()->overflowX() == OverflowScroll && !horizontalScrollbar()); |
688 bool verticalScrollbarShouldChange = | 698 bool verticalScrollbarShouldChange = |
689 (box().hasAutoVerticalScrollbar() && | 699 (box().hasAutoVerticalScrollbar() && |
690 (hasVerticalScrollbar() != shouldHaveAutoVerticalScrollbar)) || | 700 (hasVerticalScrollbar() != shouldHaveAutoVerticalScrollbar)) || |
691 (box().style()->overflowY() == OverflowScroll && !verticalScrollbar()); | 701 (box().style()->overflowY() == OverflowScroll && !verticalScrollbar()); |
692 bool scrollbarsWillChange = | 702 bool scrollbarsWillChange = |
693 !scrollbarsAreFrozen && !visualViewportSuppliesScrollbars() && | 703 !scrollbarsAreFrozen && !visualViewportSuppliesScrollbars() && |
(...skipping 25 matching lines...) Expand all Loading... |
719 box().style()->overflowX() != OverflowOverlay) || | 729 box().style()->overflowX() != OverflowOverlay) || |
720 (verticalScrollbarShouldChange && | 730 (verticalScrollbarShouldChange && |
721 box().style()->overflowY() != OverflowOverlay)) { | 731 box().style()->overflowY() != OverflowOverlay)) { |
722 if ((verticalScrollbarShouldChange && box().isHorizontalWritingMode()) || | 732 if ((verticalScrollbarShouldChange && box().isHorizontalWritingMode()) || |
723 (horizontalScrollbarShouldChange && | 733 (horizontalScrollbarShouldChange && |
724 !box().isHorizontalWritingMode())) { | 734 !box().isHorizontalWritingMode())) { |
725 box().setPreferredLogicalWidthsDirty(); | 735 box().setPreferredLogicalWidthsDirty(); |
726 } | 736 } |
727 if (relayoutIsPrevented) { | 737 if (relayoutIsPrevented) { |
728 // We're not doing re-layout right now, but we still want to | 738 // We're not doing re-layout right now, but we still want to |
729 // add the scrollbar to the logical width now, to facilitate parent layo
ut. | 739 // add the scrollbar to the logical width now, to facilitate parent |
| 740 // layout. |
730 box().updateLogicalWidth(); | 741 box().updateLogicalWidth(); |
731 PreventRelayoutScope::setBoxNeedsLayout(*this, hadHorizontalScrollbar, | 742 PreventRelayoutScope::setBoxNeedsLayout(*this, hadHorizontalScrollbar, |
732 hadVerticalScrollbar); | 743 hadVerticalScrollbar); |
733 } else { | 744 } else { |
734 m_inOverflowRelayout = true; | 745 m_inOverflowRelayout = true; |
735 SubtreeLayoutScope layoutScope(box()); | 746 SubtreeLayoutScope layoutScope(box()); |
736 layoutScope.setNeedsLayout(&box(), | 747 layoutScope.setNeedsLayout(&box(), |
737 LayoutInvalidationReason::ScrollbarChanged); | 748 LayoutInvalidationReason::ScrollbarChanged); |
738 if (box().isLayoutBlock()) { | 749 if (box().isLayoutBlock()) { |
739 LayoutBlock& block = toLayoutBlock(box()); | 750 LayoutBlock& block = toLayoutBlock(box()); |
740 block.scrollbarsChanged(horizontalScrollbarShouldChange, | 751 block.scrollbarsChanged(horizontalScrollbarShouldChange, |
741 verticalScrollbarShouldChange); | 752 verticalScrollbarShouldChange); |
742 block.layoutBlock(true); | 753 block.layoutBlock(true); |
743 } else { | 754 } else { |
744 box().layout(); | 755 box().layout(); |
745 } | 756 } |
746 m_inOverflowRelayout = false; | 757 m_inOverflowRelayout = false; |
747 m_scrollbarManager.destroyDetachedScrollbars(); | 758 m_scrollbarManager.destroyDetachedScrollbars(); |
748 } | 759 } |
749 LayoutObject* parent = box().parent(); | 760 LayoutObject* parent = box().parent(); |
750 if (parent && parent->isFlexibleBox()) | 761 if (parent && parent->isFlexibleBox()) |
751 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box()); | 762 toLayoutFlexibleBox(parent)->clearCachedMainSizeForChild(box()); |
752 } | 763 } |
753 } | 764 } |
754 | 765 |
755 { | 766 { |
756 // Hits in compositing/overflow/automatically-opt-into-composited-scrolling-
after-style-change.html. | 767 // Hits in |
| 768 // compositing/overflow/automatically-opt-into-composited-scrolling-after-st
yle-change.html. |
757 DisableCompositingQueryAsserts disabler; | 769 DisableCompositingQueryAsserts disabler; |
758 | 770 |
759 // Set up the range (and page step/line step). | 771 // Set up the range (and page step/line step). |
760 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | 772 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { |
761 int clientWidth = box().pixelSnappedClientWidth(); | 773 int clientWidth = box().pixelSnappedClientWidth(); |
762 horizontalScrollbar->setProportion(clientWidth, | 774 horizontalScrollbar->setProportion(clientWidth, |
763 overflowRect().width().toInt()); | 775 overflowRect().width().toInt()); |
764 } | 776 } |
765 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | 777 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { |
766 int clientHeight = box().pixelSnappedClientHeight(); | 778 int clientHeight = box().pixelSnappedClientHeight(); |
(...skipping 15 matching lines...) Expand all Loading... |
782 bool hasOverflow = | 794 bool hasOverflow = |
783 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow(); | 795 hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow(); |
784 updateScrollableAreaSet(hasOverflow); | 796 updateScrollableAreaSet(hasOverflow); |
785 } | 797 } |
786 | 798 |
787 DisableCompositingQueryAsserts disabler; | 799 DisableCompositingQueryAsserts disabler; |
788 positionOverflowControls(); | 800 positionOverflowControls(); |
789 } | 801 } |
790 | 802 |
791 void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() { | 803 void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() { |
792 // If a vertical scrollbar was removed, the min/max scroll positions may have
changed, | 804 // If a vertical scrollbar was removed, the min/max scroll positions may have |
793 // so the scroll positions needs to be clamped. If the scroll position did no
t change, | 805 // changed, so the scroll positions needs to be clamped. If the scroll |
794 // but the scroll origin *did* change, we still need to notify the scrollbars
to | 806 // position did not change, but the scroll origin *did* change, we still need |
795 // update their dimensions. | 807 // to notify the scrollbars to update their dimensions. |
796 | 808 |
797 if (DelayScrollPositionClampScope::clampingIsDelayed()) { | 809 if (DelayScrollPositionClampScope::clampingIsDelayed()) { |
798 DelayScrollPositionClampScope::setNeedsClamp(this); | 810 DelayScrollPositionClampScope::setNeedsClamp(this); |
799 return; | 811 return; |
800 } | 812 } |
801 | 813 |
802 // Restore before clamping because clamping clears the scroll anchor. | 814 // Restore before clamping because clamping clears the scroll anchor. |
803 if (shouldPerformScrollAnchoring()) | 815 if (shouldPerformScrollAnchoring()) |
804 m_scrollAnchor.restore(); | 816 m_scrollAnchor.restore(); |
805 | 817 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 void PaintLayerScrollableArea::updateAfterStyleChange( | 887 void PaintLayerScrollableArea::updateAfterStyleChange( |
876 const ComputedStyle* oldStyle) { | 888 const ComputedStyle* oldStyle) { |
877 // Don't do this on first style recalc, before layout has ever happened. | 889 // Don't do this on first style recalc, before layout has ever happened. |
878 if (!overflowRect().size().isZero()) | 890 if (!overflowRect().size().isZero()) |
879 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || | 891 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || |
880 hasScrollableVerticalOverflow()); | 892 hasScrollableVerticalOverflow()); |
881 | 893 |
882 if (!canHaveOverflowScrollbars(box())) | 894 if (!canHaveOverflowScrollbars(box())) |
883 return; | 895 return; |
884 | 896 |
885 // Avoid drawing two sets of scrollbars when one is provided by the visual vie
wport. | 897 // Avoid drawing two sets of scrollbars when one is provided by the visual |
| 898 // viewport. |
886 if (visualViewportSuppliesScrollbars()) { | 899 if (visualViewportSuppliesScrollbars()) { |
887 setHasHorizontalScrollbar(false); | 900 setHasHorizontalScrollbar(false); |
888 setHasVerticalScrollbar(false); | 901 setHasVerticalScrollbar(false); |
889 return; | 902 return; |
890 } | 903 } |
891 | 904 |
892 EOverflow overflowX = box().style()->overflowX(); | 905 EOverflow overflowX = box().style()->overflowX(); |
893 EOverflow overflowY = box().style()->overflowY(); | 906 EOverflow overflowY = box().style()->overflowY(); |
894 | 907 |
895 bool needsHorizontalScrollbar = | 908 bool needsHorizontalScrollbar = |
896 (hasHorizontalScrollbar() && | 909 (hasHorizontalScrollbar() && |
897 overflowDefinesAutomaticScrollbar(overflowX)) || | 910 overflowDefinesAutomaticScrollbar(overflowX)) || |
898 overflowRequiresScrollbar(overflowX); | 911 overflowRequiresScrollbar(overflowX); |
899 bool needsVerticalScrollbar = | 912 bool needsVerticalScrollbar = |
900 (hasVerticalScrollbar() && | 913 (hasVerticalScrollbar() && |
901 overflowDefinesAutomaticScrollbar(overflowY)) || | 914 overflowDefinesAutomaticScrollbar(overflowY)) || |
902 overflowRequiresScrollbar(overflowY); | 915 overflowRequiresScrollbar(overflowY); |
903 | 916 |
904 // Look for the scrollbarModes and reset the needs Horizontal & vertical Scrol
lbar values based on scrollbarModes, as during force style change | 917 // Look for the scrollbarModes and reset the needs Horizontal & vertical |
905 // StyleResolver::styleForDocument returns documentStyle with no overflow val
ues, due to which we are destorying the scrollbars that was | 918 // Scrollbar values based on scrollbarModes, as during force style change |
906 // already present. | 919 // StyleResolver::styleForDocument returns documentStyle with no overflow |
| 920 // values, due to which we are destorying the scrollbars that was already |
| 921 // present. |
907 if (box().isLayoutView()) { | 922 if (box().isLayoutView()) { |
908 if (LocalFrame* frame = box().frame()) { | 923 if (LocalFrame* frame = box().frame()) { |
909 if (FrameView* frameView = frame->view()) { | 924 if (FrameView* frameView = frame->view()) { |
910 ScrollbarMode hMode; | 925 ScrollbarMode hMode; |
911 ScrollbarMode vMode; | 926 ScrollbarMode vMode; |
912 frameView->calculateScrollbarModes(hMode, vMode); | 927 frameView->calculateScrollbarModes(hMode, vMode); |
913 if (hMode == ScrollbarAlwaysOn && !needsHorizontalScrollbar) | 928 if (hMode == ScrollbarAlwaysOn && !needsHorizontalScrollbar) |
914 needsHorizontalScrollbar = true; | 929 needsHorizontalScrollbar = true; |
915 if (vMode == ScrollbarAlwaysOn && !needsVerticalScrollbar) | 930 if (vMode == ScrollbarAlwaysOn && !needsVerticalScrollbar) |
916 needsVerticalScrollbar = true; | 931 needsVerticalScrollbar = true; |
(...skipping 11 matching lines...) Expand all Loading... |
928 ASSERT(hasHorizontalScrollbar()); | 943 ASSERT(hasHorizontalScrollbar()); |
929 horizontalScrollbar()->setEnabled(true); | 944 horizontalScrollbar()->setEnabled(true); |
930 } | 945 } |
931 | 946 |
932 if (needsVerticalScrollbar && oldStyle && | 947 if (needsVerticalScrollbar && oldStyle && |
933 oldStyle->overflowY() == OverflowScroll && overflowY != OverflowScroll) { | 948 oldStyle->overflowY() == OverflowScroll && overflowY != OverflowScroll) { |
934 ASSERT(hasVerticalScrollbar()); | 949 ASSERT(hasVerticalScrollbar()); |
935 verticalScrollbar()->setEnabled(true); | 950 verticalScrollbar()->setEnabled(true); |
936 } | 951 } |
937 | 952 |
938 // FIXME: Need to detect a swap from custom to native scrollbars (and vice ver
sa). | 953 // FIXME: Need to detect a swap from custom to native scrollbars (and vice |
| 954 // versa). |
939 if (horizontalScrollbar()) | 955 if (horizontalScrollbar()) |
940 horizontalScrollbar()->styleChanged(); | 956 horizontalScrollbar()->styleChanged(); |
941 if (verticalScrollbar()) | 957 if (verticalScrollbar()) |
942 verticalScrollbar()->styleChanged(); | 958 verticalScrollbar()->styleChanged(); |
943 | 959 |
944 updateScrollCornerStyle(); | 960 updateScrollCornerStyle(); |
945 updateResizerAreaSet(); | 961 updateResizerAreaSet(); |
946 updateResizerStyle(); | 962 updateResizerStyle(); |
947 | 963 |
948 // Whenever background changes on the scrollable element, the scroll bar | 964 // Whenever background changes on the scrollable element, the scroll bar |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1150 |
1135 if (hasScrollbar == hasHorizontalScrollbar()) | 1151 if (hasScrollbar == hasHorizontalScrollbar()) |
1136 return; | 1152 return; |
1137 | 1153 |
1138 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); | 1154 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
1139 | 1155 |
1140 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); | 1156 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
1141 | 1157 |
1142 updateScrollOrigin(); | 1158 updateScrollOrigin(); |
1143 | 1159 |
1144 // Destroying or creating one bar can cause our scrollbar corner to come and g
o. We need to update the opposite scrollbar's style. | 1160 // Destroying or creating one bar can cause our scrollbar corner to come and |
| 1161 // go. We need to update the opposite scrollbar's style. |
1145 if (hasHorizontalScrollbar()) | 1162 if (hasHorizontalScrollbar()) |
1146 horizontalScrollbar()->styleChanged(); | 1163 horizontalScrollbar()->styleChanged(); |
1147 if (hasVerticalScrollbar()) | 1164 if (hasVerticalScrollbar()) |
1148 verticalScrollbar()->styleChanged(); | 1165 verticalScrollbar()->styleChanged(); |
1149 | 1166 |
1150 setScrollCornerNeedsPaintInvalidation(); | 1167 setScrollCornerNeedsPaintInvalidation(); |
1151 | 1168 |
1152 // Force an update since we know the scrollbars have changed things. | 1169 // Force an update since we know the scrollbars have changed things. |
1153 if (box().document().hasAnnotatedRegions()) | 1170 if (box().document().hasAnnotatedRegions()) |
1154 box().document().setAnnotatedRegionsDirty(true); | 1171 box().document().setAnnotatedRegionsDirty(true); |
1155 } | 1172 } |
1156 | 1173 |
1157 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) { | 1174 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) { |
1158 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) | 1175 if (FreezeScrollbarsScope::scrollbarsAreFrozen()) |
1159 return; | 1176 return; |
1160 | 1177 |
1161 DCHECK(box().frame()->settings()); | 1178 DCHECK(box().frame()->settings()); |
1162 if (box().frame()->settings()->hideScrollbars()) | 1179 if (box().frame()->settings()->hideScrollbars()) |
1163 hasScrollbar = false; | 1180 hasScrollbar = false; |
1164 | 1181 |
1165 if (hasScrollbar == hasVerticalScrollbar()) | 1182 if (hasScrollbar == hasVerticalScrollbar()) |
1166 return; | 1183 return; |
1167 | 1184 |
1168 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); | 1185 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
1169 | 1186 |
1170 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); | 1187 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
1171 | 1188 |
1172 updateScrollOrigin(); | 1189 updateScrollOrigin(); |
1173 | 1190 |
1174 // Destroying or creating one bar can cause our scrollbar corner to come and g
o. We need to update the opposite scrollbar's style. | 1191 // Destroying or creating one bar can cause our scrollbar corner to come and |
| 1192 // go. We need to update the opposite scrollbar's style. |
1175 if (hasHorizontalScrollbar()) | 1193 if (hasHorizontalScrollbar()) |
1176 horizontalScrollbar()->styleChanged(); | 1194 horizontalScrollbar()->styleChanged(); |
1177 if (hasVerticalScrollbar()) | 1195 if (hasVerticalScrollbar()) |
1178 verticalScrollbar()->styleChanged(); | 1196 verticalScrollbar()->styleChanged(); |
1179 | 1197 |
1180 setScrollCornerNeedsPaintInvalidation(); | 1198 setScrollCornerNeedsPaintInvalidation(); |
1181 | 1199 |
1182 // Force an update since we know the scrollbars have changed things. | 1200 // Force an update since we know the scrollbars have changed things. |
1183 if (box().document().hasAnnotatedRegions()) | 1201 if (box().document().hasAnnotatedRegions()) |
1184 box().document().setAnnotatedRegionsDirty(true); | 1202 box().document().setAnnotatedRegionsDirty(true); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 horizontalScrollbar->setFrameRect(rectForHorizontalScrollbar(borderBox)); | 1236 horizontalScrollbar->setFrameRect(rectForHorizontalScrollbar(borderBox)); |
1219 | 1237 |
1220 const IntRect& scrollCorner = scrollCornerRect(); | 1238 const IntRect& scrollCorner = scrollCornerRect(); |
1221 if (m_scrollCorner) | 1239 if (m_scrollCorner) |
1222 m_scrollCorner->setFrameRect(LayoutRect(scrollCorner)); | 1240 m_scrollCorner->setFrameRect(LayoutRect(scrollCorner)); |
1223 | 1241 |
1224 if (m_resizer) | 1242 if (m_resizer) |
1225 m_resizer->setFrameRect( | 1243 m_resizer->setFrameRect( |
1226 LayoutRect(resizerCornerRect(borderBox, ResizerForPointer))); | 1244 LayoutRect(resizerCornerRect(borderBox, ResizerForPointer))); |
1227 | 1245 |
1228 // FIXME, this should eventually be removed, once we are certain that composit
ed | 1246 // FIXME, this should eventually be removed, once we are certain that |
1229 // controls get correctly positioned on a compositor update. For now, conserva
tively | 1247 // composited controls get correctly positioned on a compositor update. For |
1230 // leaving this unchanged. | 1248 // now, conservatively leaving this unchanged. |
1231 if (layer()->hasCompositedLayerMapping()) | 1249 if (layer()->hasCompositedLayerMapping()) |
1232 layer()->compositedLayerMapping()->positionOverflowControlsLayers(); | 1250 layer()->compositedLayerMapping()->positionOverflowControlsLayers(); |
1233 } | 1251 } |
1234 | 1252 |
1235 void PaintLayerScrollableArea::updateScrollCornerStyle() { | 1253 void PaintLayerScrollableArea::updateScrollCornerStyle() { |
1236 if (!m_scrollCorner && !hasScrollbar()) | 1254 if (!m_scrollCorner && !hasScrollbar()) |
1237 return; | 1255 return; |
1238 if (!m_scrollCorner && hasOverlayScrollbars()) | 1256 if (!m_scrollCorner && hasOverlayScrollbars()) |
1239 return; | 1257 return; |
1240 | 1258 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 (hasVerticalScrollbar() ? verticalScrollbar()->scrollbarThickness() | 1320 (hasVerticalScrollbar() ? verticalScrollbar()->scrollbarThickness() |
1303 : resizeControlSize)) | 1321 : resizeControlSize)) |
1304 .toInt(), | 1322 .toInt(), |
1305 horizontalScrollbar()->scrollbarThickness()); | 1323 horizontalScrollbar()->scrollbarThickness()); |
1306 if (hBarRect.contains(localPoint)) { | 1324 if (hBarRect.contains(localPoint)) { |
1307 result.setScrollbar(horizontalScrollbar()); | 1325 result.setScrollbar(horizontalScrollbar()); |
1308 return true; | 1326 return true; |
1309 } | 1327 } |
1310 } | 1328 } |
1311 | 1329 |
1312 // FIXME: We should hit test the m_scrollCorner and pass it back through the r
esult. | 1330 // FIXME: We should hit test the m_scrollCorner and pass it back through the |
| 1331 // result. |
1313 | 1332 |
1314 return false; | 1333 return false; |
1315 } | 1334 } |
1316 | 1335 |
1317 IntRect PaintLayerScrollableArea::resizerCornerRect( | 1336 IntRect PaintLayerScrollableArea::resizerCornerRect( |
1318 const IntRect& bounds, | 1337 const IntRect& bounds, |
1319 ResizerHitTestType resizerHitTestType) const { | 1338 ResizerHitTestType resizerHitTestType) const { |
1320 if (box().style()->resize() == RESIZE_NONE) | 1339 if (box().style()->resize() == RESIZE_NONE) |
1321 return IntRect(); | 1340 return IntRect(); |
1322 IntRect corner = | 1341 IntRect corner = |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 if (PaintLayerScrollableAreaRareData* d = rareData()) { | 1448 if (PaintLayerScrollableAreaRareData* d = rareData()) { |
1430 d->m_stickyConstraintsMap.remove(layer); | 1449 d->m_stickyConstraintsMap.remove(layer); |
1431 if (needsCompositingUpdate && | 1450 if (needsCompositingUpdate && |
1432 layer->layoutObject()->style()->position() == StickyPosition) | 1451 layer->layoutObject()->style()->position() == StickyPosition) |
1433 layer->setNeedsCompositingInputsUpdate(); | 1452 layer->setNeedsCompositingInputsUpdate(); |
1434 } | 1453 } |
1435 } | 1454 } |
1436 | 1455 |
1437 IntSize PaintLayerScrollableArea::offsetFromResizeCorner( | 1456 IntSize PaintLayerScrollableArea::offsetFromResizeCorner( |
1438 const IntPoint& absolutePoint) const { | 1457 const IntPoint& absolutePoint) const { |
1439 // Currently the resize corner is either the bottom right corner or the bottom
left corner. | 1458 // Currently the resize corner is either the bottom right corner or the bottom |
1440 // FIXME: This assumes the location is 0, 0. Is this guaranteed to always be t
he case? | 1459 // left corner. |
| 1460 // FIXME: This assumes the location is 0, 0. Is this guaranteed to always be |
| 1461 // the case? |
1441 IntSize elementSize = layer()->size(); | 1462 IntSize elementSize = layer()->size(); |
1442 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1463 if (box().shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1443 elementSize.setWidth(0); | 1464 elementSize.setWidth(0); |
1444 IntPoint resizerPoint = IntPoint(elementSize); | 1465 IntPoint resizerPoint = IntPoint(elementSize); |
1445 IntPoint localPoint = | 1466 IntPoint localPoint = |
1446 roundedIntPoint(box().absoluteToLocal(absolutePoint, UseTransforms)); | 1467 roundedIntPoint(box().absoluteToLocal(absolutePoint, UseTransforms)); |
1447 return localPoint - resizerPoint; | 1468 return localPoint - resizerPoint; |
1448 } | 1469 } |
1449 | 1470 |
1450 void PaintLayerScrollableArea::resize(const PlatformEvent& evt, | 1471 void PaintLayerScrollableArea::resize(const PlatformEvent& evt, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 | 1520 |
1500 LayoutSize difference( | 1521 LayoutSize difference( |
1501 (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - | 1522 (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - |
1502 currentSize); | 1523 currentSize); |
1503 | 1524 |
1504 bool isBoxSizingBorder = box().style()->boxSizing() == BoxSizingBorderBox; | 1525 bool isBoxSizingBorder = box().style()->boxSizing() == BoxSizingBorderBox; |
1505 | 1526 |
1506 EResize resize = box().style()->resize(); | 1527 EResize resize = box().style()->resize(); |
1507 if (resize != RESIZE_VERTICAL && difference.width()) { | 1528 if (resize != RESIZE_VERTICAL && difference.width()) { |
1508 if (element->isFormControlElement()) { | 1529 if (element->isFormControlElement()) { |
1509 // Make implicit margins from the theme explicit (see <http://bugs.webkit.
org/show_bug.cgi?id=9547>). | 1530 // Make implicit margins from the theme explicit (see |
| 1531 // <http://bugs.webkit.org/show_bug.cgi?id=9547>). |
1510 element->setInlineStyleProperty(CSSPropertyMarginLeft, | 1532 element->setInlineStyleProperty(CSSPropertyMarginLeft, |
1511 box().marginLeft() / zoomFactor, | 1533 box().marginLeft() / zoomFactor, |
1512 CSSPrimitiveValue::UnitType::Pixels); | 1534 CSSPrimitiveValue::UnitType::Pixels); |
1513 element->setInlineStyleProperty(CSSPropertyMarginRight, | 1535 element->setInlineStyleProperty(CSSPropertyMarginRight, |
1514 box().marginRight() / zoomFactor, | 1536 box().marginRight() / zoomFactor, |
1515 CSSPrimitiveValue::UnitType::Pixels); | 1537 CSSPrimitiveValue::UnitType::Pixels); |
1516 } | 1538 } |
1517 LayoutUnit baseWidth = | 1539 LayoutUnit baseWidth = |
1518 box().size().width() - | 1540 box().size().width() - |
1519 (isBoxSizingBorder ? LayoutUnit() : box().borderAndPaddingWidth()); | 1541 (isBoxSizingBorder ? LayoutUnit() : box().borderAndPaddingWidth()); |
1520 baseWidth = LayoutUnit(baseWidth / zoomFactor); | 1542 baseWidth = LayoutUnit(baseWidth / zoomFactor); |
1521 element->setInlineStyleProperty(CSSPropertyWidth, | 1543 element->setInlineStyleProperty(CSSPropertyWidth, |
1522 roundToInt(baseWidth + difference.width()), | 1544 roundToInt(baseWidth + difference.width()), |
1523 CSSPrimitiveValue::UnitType::Pixels); | 1545 CSSPrimitiveValue::UnitType::Pixels); |
1524 } | 1546 } |
1525 | 1547 |
1526 if (resize != RESIZE_HORIZONTAL && difference.height()) { | 1548 if (resize != RESIZE_HORIZONTAL && difference.height()) { |
1527 if (element->isFormControlElement()) { | 1549 if (element->isFormControlElement()) { |
1528 // Make implicit margins from the theme explicit (see <http://bugs.webkit.
org/show_bug.cgi?id=9547>). | 1550 // Make implicit margins from the theme explicit (see |
| 1551 // <http://bugs.webkit.org/show_bug.cgi?id=9547>). |
1529 element->setInlineStyleProperty(CSSPropertyMarginTop, | 1552 element->setInlineStyleProperty(CSSPropertyMarginTop, |
1530 box().marginTop() / zoomFactor, | 1553 box().marginTop() / zoomFactor, |
1531 CSSPrimitiveValue::UnitType::Pixels); | 1554 CSSPrimitiveValue::UnitType::Pixels); |
1532 element->setInlineStyleProperty(CSSPropertyMarginBottom, | 1555 element->setInlineStyleProperty(CSSPropertyMarginBottom, |
1533 box().marginBottom() / zoomFactor, | 1556 box().marginBottom() / zoomFactor, |
1534 CSSPrimitiveValue::UnitType::Pixels); | 1557 CSSPrimitiveValue::UnitType::Pixels); |
1535 } | 1558 } |
1536 LayoutUnit baseHeight = | 1559 LayoutUnit baseHeight = |
1537 box().size().height() - | 1560 box().size().height() - |
1538 (isBoxSizingBorder ? LayoutUnit() : box().borderAndPaddingHeight()); | 1561 (isBoxSizingBorder ? LayoutUnit() : box().borderAndPaddingHeight()); |
1539 baseHeight = LayoutUnit(baseHeight / zoomFactor); | 1562 baseHeight = LayoutUnit(baseHeight / zoomFactor); |
1540 element->setInlineStyleProperty( | 1563 element->setInlineStyleProperty( |
1541 CSSPropertyHeight, roundToInt(baseHeight + difference.height()), | 1564 CSSPropertyHeight, roundToInt(baseHeight + difference.height()), |
1542 CSSPrimitiveValue::UnitType::Pixels); | 1565 CSSPrimitiveValue::UnitType::Pixels); |
1543 } | 1566 } |
1544 | 1567 |
1545 document.updateStyleAndLayout(); | 1568 document.updateStyleAndLayout(); |
1546 | 1569 |
1547 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to
keep the point under the cursor in view. | 1570 // FIXME (Radar 4118564): We should also autoscroll the window as necessary to |
| 1571 // keep the point under the cursor in view. |
1548 } | 1572 } |
1549 | 1573 |
1550 LayoutRect PaintLayerScrollableArea::scrollIntoView( | 1574 LayoutRect PaintLayerScrollableArea::scrollIntoView( |
1551 const LayoutRect& rect, | 1575 const LayoutRect& rect, |
1552 const ScrollAlignment& alignX, | 1576 const ScrollAlignment& alignX, |
1553 const ScrollAlignment& alignY, | 1577 const ScrollAlignment& alignY, |
1554 ScrollType scrollType) { | 1578 ScrollType scrollType) { |
1555 LayoutRect localExposeRect( | 1579 LayoutRect localExposeRect( |
1556 box() | 1580 box() |
1557 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) | 1581 .absoluteToLocalQuad(FloatQuad(FloatRect(rect)), UseTransforms) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 GraphicsLayerUpdateSubtree); | 1647 GraphicsLayerUpdateSubtree); |
1624 compositor->setNeedsCompositingUpdate( | 1648 compositor->setNeedsCompositingUpdate( |
1625 CompositingUpdateAfterGeometryChange); | 1649 CompositingUpdateAfterGeometryChange); |
1626 } else { | 1650 } else { |
1627 layer()->setNeedsCompositingInputsUpdate(); | 1651 layer()->setNeedsCompositingInputsUpdate(); |
1628 } | 1652 } |
1629 } | 1653 } |
1630 } | 1654 } |
1631 | 1655 |
1632 bool PaintLayerScrollableArea::usesCompositedScrolling() const { | 1656 bool PaintLayerScrollableArea::usesCompositedScrolling() const { |
1633 // See https://codereview.chromium.org/176633003/ for the tests that fail with
out this disabler. | 1657 // See https://codereview.chromium.org/176633003/ for the tests that fail |
| 1658 // without this disabler. |
1634 DisableCompositingQueryAsserts disabler; | 1659 DisableCompositingQueryAsserts disabler; |
1635 return layer()->hasCompositedLayerMapping() && | 1660 return layer()->hasCompositedLayerMapping() && |
1636 layer()->compositedLayerMapping()->scrollingLayer(); | 1661 layer()->compositedLayerMapping()->scrollingLayer(); |
1637 } | 1662 } |
1638 | 1663 |
1639 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { | 1664 bool PaintLayerScrollableArea::shouldScrollOnMainThread() const { |
1640 if (LocalFrame* frame = box().frame()) { | 1665 if (LocalFrame* frame = box().frame()) { |
1641 if (Page* page = frame->page()) { | 1666 if (Page* page = frame->page()) { |
1642 if (page->scrollingCoordinator() | 1667 if (page->scrollingCoordinator() |
1643 ->shouldUpdateScrollLayerPositionOnMainThread()) | 1668 ->shouldUpdateScrollLayerPositionOnMainThread()) |
1644 return true; | 1669 return true; |
1645 } | 1670 } |
1646 } | 1671 } |
1647 return ScrollableArea::shouldScrollOnMainThread(); | 1672 return ScrollableArea::shouldScrollOnMainThread(); |
1648 } | 1673 } |
1649 | 1674 |
1650 static bool layerNeedsCompositedScrolling( | 1675 static bool layerNeedsCompositedScrolling( |
1651 PaintLayerScrollableArea::LCDTextMode mode, | 1676 PaintLayerScrollableArea::LCDTextMode mode, |
1652 const PaintLayer* layer) { | 1677 const PaintLayer* layer) { |
1653 if (!layer->scrollsOverflow()) | 1678 if (!layer->scrollsOverflow()) |
1654 return false; | 1679 return false; |
1655 | 1680 |
1656 Node* node = layer->enclosingNode(); | 1681 Node* node = layer->enclosingNode(); |
1657 if (node && node->isElementNode() && | 1682 if (node && node->isElementNode() && |
1658 (toElement(node)->compositorMutableProperties() & | 1683 (toElement(node)->compositorMutableProperties() & |
1659 (CompositorMutableProperty::kScrollTop | | 1684 (CompositorMutableProperty::kScrollTop | |
1660 CompositorMutableProperty::kScrollLeft))) | 1685 CompositorMutableProperty::kScrollLeft))) |
1661 return true; | 1686 return true; |
1662 | 1687 |
1663 // TODO(schenney): LCD Text also requires integer scroll offsets for the layer
. While we | 1688 // TODO(schenney): LCD Text also requires integer scroll offsets for the |
1664 // use integer scroll offsets locally when !layer->compositor()->preferComposi
tingToLCDTextEnabled(), | 1689 // layer. While we use integer scroll offsets locally when |
1665 // we do not check offsets accumulated from the root (including translates). c
rbug.com/644833 | 1690 // !layer->compositor()->preferCompositingToLCDTextEnabled(), we do not check |
| 1691 // offsets accumulated from the root (including translates). crbug.com/644833 |
1666 bool backgroundSupportsLCDText = | 1692 bool backgroundSupportsLCDText = |
1667 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && | 1693 RuntimeEnabledFeatures::compositeOpaqueScrollersEnabled() && |
1668 layer->canPaintBackgroundOntoScrollingContentsLayer() && | 1694 layer->canPaintBackgroundOntoScrollingContentsLayer() && |
1669 layer->backgroundIsKnownToBeOpaqueInRect( | 1695 layer->backgroundIsKnownToBeOpaqueInRect( |
1670 toLayoutBox(layer->layoutObject())->paddingBoxRect()); | 1696 toLayoutBox(layer->layoutObject())->paddingBoxRect()); |
1671 if (mode == PaintLayerScrollableArea::ConsiderLCDText && | 1697 if (mode == PaintLayerScrollableArea::ConsiderLCDText && |
1672 !layer->compositor()->preferCompositingToLCDTextEnabled() && | 1698 !layer->compositor()->preferCompositingToLCDTextEnabled() && |
1673 !backgroundSupportsLCDText) | 1699 !backgroundSupportsLCDText) |
1674 return false; | 1700 return false; |
1675 | 1701 |
1676 // TODO(schenney) Tests fail if we do not also exclude layer->layoutObject()->
style()->hasBorderDecoration() | 1702 // TODO(schenney) Tests fail if we do not also exclude |
1677 // (missing background behind dashed borders). Resolve this case, or not, and
update this check with | 1703 // layer->layoutObject()->style()->hasBorderDecoration() (missing background |
1678 // the results. | 1704 // behind dashed borders). Resolve this case, or not, and update this check |
| 1705 // with the results. |
1679 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || | 1706 return !(layer->size().isEmpty() || layer->hasDescendantWithClipPath() || |
1680 layer->hasAncestorWithClipPath() || | 1707 layer->hasAncestorWithClipPath() || |
1681 layer->layoutObject()->style()->hasBorderRadius()); | 1708 layer->layoutObject()->style()->hasBorderRadius()); |
1682 } | 1709 } |
1683 | 1710 |
1684 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( | 1711 void PaintLayerScrollableArea::updateNeedsCompositedScrolling( |
1685 LCDTextMode mode) { | 1712 LCDTextMode mode) { |
1686 const bool needsCompositedScrolling = | 1713 const bool needsCompositedScrolling = |
1687 layerNeedsCompositedScrolling(mode, layer()); | 1714 layerNeedsCompositedScrolling(mode, layer()); |
1688 if (static_cast<bool>(m_needsCompositedScrolling) != | 1715 if (static_cast<bool>(m_needsCompositedScrolling) != |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 ASSERT(!m_vBarIsAttached || m_vBar); | 1775 ASSERT(!m_vBarIsAttached || m_vBar); |
1749 if (m_hBar && !m_hBarIsAttached) | 1776 if (m_hBar && !m_hBarIsAttached) |
1750 destroyScrollbar(HorizontalScrollbar); | 1777 destroyScrollbar(HorizontalScrollbar); |
1751 if (m_vBar && !m_vBarIsAttached) | 1778 if (m_vBar && !m_vBarIsAttached) |
1752 destroyScrollbar(VerticalScrollbar); | 1779 destroyScrollbar(VerticalScrollbar); |
1753 } | 1780 } |
1754 | 1781 |
1755 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar( | 1782 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar( |
1756 bool hasScrollbar) { | 1783 bool hasScrollbar) { |
1757 if (hasScrollbar) { | 1784 if (hasScrollbar) { |
1758 // This doesn't hit in any tests, but since the equivalent code in setHasVer
ticalScrollbar | 1785 // This doesn't hit in any tests, but since the equivalent code in |
1759 // does, presumably this code does as well. | 1786 // setHasVerticalScrollbar does, presumably this code does as well. |
1760 DisableCompositingQueryAsserts disabler; | 1787 DisableCompositingQueryAsserts disabler; |
1761 if (!m_hBar) { | 1788 if (!m_hBar) { |
1762 m_hBar = createScrollbar(HorizontalScrollbar); | 1789 m_hBar = createScrollbar(HorizontalScrollbar); |
1763 m_hBarIsAttached = 1; | 1790 m_hBarIsAttached = 1; |
1764 if (!m_hBar->isCustomScrollbar()) | 1791 if (!m_hBar->isCustomScrollbar()) |
1765 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); | 1792 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); |
1766 } else { | 1793 } else { |
1767 m_hBarIsAttached = 1; | 1794 m_hBarIsAttached = 1; |
1768 } | 1795 } |
1769 } else { | 1796 } else { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 | 1980 |
1954 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: | 1981 void PaintLayerScrollableArea::DelayScrollPositionClampScope:: |
1955 clampScrollableAreas() { | 1982 clampScrollableAreas() { |
1956 for (auto& scrollableArea : *s_needsClamp) | 1983 for (auto& scrollableArea : *s_needsClamp) |
1957 scrollableArea->clampScrollPositionsAfterLayout(); | 1984 scrollableArea->clampScrollPositionsAfterLayout(); |
1958 delete s_needsClamp; | 1985 delete s_needsClamp; |
1959 s_needsClamp = nullptr; | 1986 s_needsClamp = nullptr; |
1960 } | 1987 } |
1961 | 1988 |
1962 } // namespace blink | 1989 } // namespace blink |
OLD | NEW |