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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 #include "platform/graphics/GraphicsContextStateSaver.h" | 67 #include "platform/graphics/GraphicsContextStateSaver.h" |
68 #include "platform/graphics/GraphicsLayer.h" | 68 #include "platform/graphics/GraphicsLayer.h" |
69 #include "platform/scroll/ScrollAnimator.h" | 69 #include "platform/scroll/ScrollAnimator.h" |
70 #include "platform/scroll/ScrollbarTheme.h" | 70 #include "platform/scroll/ScrollbarTheme.h" |
71 #include "public/platform/Platform.h" | 71 #include "public/platform/Platform.h" |
72 | 72 |
73 namespace WebCore { | 73 namespace WebCore { |
74 | 74 |
75 const int ResizerControlExpandRatioForTouch = 2; | 75 const int ResizerControlExpandRatioForTouch = 2; |
76 | 76 |
77 // Default value is set to 15 as the default | |
78 // minimum size used by firefox is 15x15. | |
79 static const LayoutUnit defaultMinimumValueForResizing(15); | |
80 static const LayoutSize defaultMinimumSizeForResizing(defaultMinimumValueForResi zing, defaultMinimumValueForResizing); | |
Julien - ping for review
2014/04/28 17:07:29
What I meant by 2 variables is minWidth and minHei
harpreet.sk
2014/04/29 08:57:43
Added the variables defaultMinimumWidthForResizing
| |
81 | |
77 RenderLayerScrollableArea::RenderLayerScrollableArea(RenderBox* box) | 82 RenderLayerScrollableArea::RenderLayerScrollableArea(RenderBox* box) |
78 : m_box(box) | 83 : m_box(box) |
79 , m_inResizeMode(false) | 84 , m_inResizeMode(false) |
80 , m_scrollsOverflow(false) | 85 , m_scrollsOverflow(false) |
81 , m_scrollDimensionsDirty(true) | 86 , m_scrollDimensionsDirty(true) |
82 , m_inOverflowRelayout(false) | 87 , m_inOverflowRelayout(false) |
83 , m_needsCompositedScrolling(false) | 88 , m_needsCompositedScrolling(false) |
84 , m_forceNeedsCompositedScrolling(DoNotForceCompositedScrolling) | 89 , m_forceNeedsCompositedScrolling(DoNotForceCompositedScrolling) |
90 , m_minimumSizeForResizing(defaultMinimumSizeForResizing) | |
85 , m_scrollCorner(0) | 91 , m_scrollCorner(0) |
86 , m_resizer(0) | 92 , m_resizer(0) |
87 { | 93 { |
88 ScrollableArea::setConstrainsScrollingToContentEdge(false); | 94 ScrollableArea::setConstrainsScrollingToContentEdge(false); |
89 | 95 |
90 Node* node = m_box->node(); | 96 Node* node = m_box->node(); |
91 if (node && node->isElementNode()) { | 97 if (node && node->isElementNode()) { |
92 // 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. |
93 Element* element = toElement(node); | 99 Element* element = toElement(node); |
94 m_scrollOffset = element->savedLayerScrollOffset(); | 100 m_scrollOffset = element->savedLayerScrollOffset(); |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 static bool overflowRequiresScrollbar(EOverflow overflow) | 714 static bool overflowRequiresScrollbar(EOverflow overflow) |
709 { | 715 { |
710 return overflow == OSCROLL; | 716 return overflow == OSCROLL; |
711 } | 717 } |
712 | 718 |
713 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) | 719 static bool overflowDefinesAutomaticScrollbar(EOverflow overflow) |
714 { | 720 { |
715 return overflow == OAUTO || overflow == OOVERLAY; | 721 return overflow == OAUTO || overflow == OOVERLAY; |
716 } | 722 } |
717 | 723 |
724 void RenderLayerScrollableArea::updateMinimumSizeForResizing() | |
725 { | |
726 LayoutUnit minimumWidth; | |
727 LayoutUnit minimumHeight; | |
728 | |
729 if (m_box->containingBlock()) { | |
730 minimumWidth = valueForLength(m_box->style()->logicalMinWidth(), m_box-> containingBlock()->logicalWidth()); | |
731 minimumHeight = valueForLength(m_box->style()->logicalMinHeight(), m_box ->containingBlock()->logicalHeight()); | |
Julien - ping for review
2014/04/28 17:07:29
This should be in physical coordinates as m_minimu
harpreet.sk
2014/04/29 08:57:43
Now using int for minimumWidth and minimumHeight a
| |
732 } | |
733 | |
734 minimumWidth = std::max(minimumWidth, defaultMinimumSizeForResizing.width()) ; | |
735 minimumHeight = std::max(minimumHeight, defaultMinimumSizeForResizing.height ()); | |
Julien - ping for review
2014/04/28 17:07:30
I think this code would be better if you initializ
harpreet.sk
2014/04/29 08:57:43
Actually i used containing block check earlier bec
| |
736 m_minimumSizeForResizing = LayoutSize(minimumWidth, minimumHeight); | |
737 } | |
738 | |
718 void RenderLayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldSty le) | 739 void RenderLayerScrollableArea::updateAfterStyleChange(const RenderStyle* oldSty le) |
719 { | 740 { |
720 // List box parts handle the scrollbars by themselves so we have nothing to do. | 741 // List box parts handle the scrollbars by themselves so we have nothing to do. |
721 if (m_box->style()->appearance() == ListboxPart) | 742 if (m_box->style()->appearance() == ListboxPart) |
722 return; | 743 return; |
723 | 744 |
724 // RenderView shouldn't provide scrollbars on its own. | 745 // RenderView shouldn't provide scrollbars on its own. |
725 if (m_box->isRenderView()) | 746 if (m_box->isRenderView()) |
726 return; | 747 return; |
727 | 748 |
728 if (!m_scrollDimensionsDirty) | 749 if (!m_scrollDimensionsDirty) |
729 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollab leVerticalOverflow()); | 750 updateScrollableAreaSet(hasScrollableHorizontalOverflow() || hasScrollab leVerticalOverflow()); |
730 | 751 |
731 EOverflow overflowX = m_box->style()->overflowX(); | 752 EOverflow overflowX = m_box->style()->overflowX(); |
732 EOverflow overflowY = m_box->style()->overflowY(); | 753 EOverflow overflowY = m_box->style()->overflowY(); |
733 | 754 |
755 updateMinimumSizeForResizing(); | |
756 | |
734 // To avoid doing a relayout in updateScrollbarsAfterLayout, we try to keep any automatic scrollbar that was already present. | 757 // To avoid doing a relayout in updateScrollbarsAfterLayout, we try to keep any automatic scrollbar that was already present. |
735 bool needsHorizontalScrollbar = (hasHorizontalScrollbar() && overflowDefines AutomaticScrollbar(overflowX)) || overflowRequiresScrollbar(overflowX); | 758 bool needsHorizontalScrollbar = (hasHorizontalScrollbar() && overflowDefines AutomaticScrollbar(overflowX)) || overflowRequiresScrollbar(overflowX); |
736 bool needsVerticalScrollbar = (hasVerticalScrollbar() && overflowDefinesAuto maticScrollbar(overflowY)) || overflowRequiresScrollbar(overflowY); | 759 bool needsVerticalScrollbar = (hasVerticalScrollbar() && overflowDefinesAuto maticScrollbar(overflowY)) || overflowRequiresScrollbar(overflowY); |
737 setHasHorizontalScrollbar(needsHorizontalScrollbar); | 760 setHasHorizontalScrollbar(needsHorizontalScrollbar); |
738 setHasVerticalScrollbar(needsVerticalScrollbar); | 761 setHasVerticalScrollbar(needsVerticalScrollbar); |
739 | 762 |
740 // With overflow: scroll, scrollbars are always visible but may be disabled. | 763 // With overflow: scroll, scrollbars are always visible but may be disabled. |
741 // When switching to another value, we need to re-enable them (see bug 11985 ). | 764 // When switching to another value, we need to re-enable them (see bug 11985 ). |
742 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) { | 765 if (needsHorizontalScrollbar && oldStyle && oldStyle->overflowX() == OSCROLL && overflowX != OSCROLL) { |
743 ASSERT(hasHorizontalScrollbar()); | 766 ASSERT(hasHorizontalScrollbar()); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 ASSERT_NOT_REACHED(); | 1369 ASSERT_NOT_REACHED(); |
1347 } | 1370 } |
1348 | 1371 |
1349 float zoomFactor = m_box->style()->effectiveZoom(); | 1372 float zoomFactor = m_box->style()->effectiveZoom(); |
1350 | 1373 |
1351 LayoutSize newOffset = offsetFromResizeCorner(document.view()->windowToConte nts(pos)); | 1374 LayoutSize newOffset = offsetFromResizeCorner(document.view()->windowToConte nts(pos)); |
1352 newOffset.setWidth(newOffset.width() / zoomFactor); | 1375 newOffset.setWidth(newOffset.width() / zoomFactor); |
1353 newOffset.setHeight(newOffset.height() / zoomFactor); | 1376 newOffset.setHeight(newOffset.height() / zoomFactor); |
1354 | 1377 |
1355 LayoutSize currentSize = LayoutSize(m_box->width() / zoomFactor, m_box->heig ht() / zoomFactor); | 1378 LayoutSize currentSize = LayoutSize(m_box->width() / zoomFactor, m_box->heig ht() / zoomFactor); |
1356 LayoutSize minimumSize = element->minimumSizeForResizing().shrunkTo(currentS ize); | |
1357 element->setMinimumSizeForResizing(minimumSize); | |
1358 | 1379 |
1359 LayoutSize adjustedOldOffset = LayoutSize(oldOffset.width() / zoomFactor, ol dOffset.height() / zoomFactor); | 1380 LayoutSize adjustedOldOffset = LayoutSize(oldOffset.width() / zoomFactor, ol dOffset.height() / zoomFactor); |
1360 if (m_box->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { | 1381 if (m_box->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { |
1361 newOffset.setWidth(-newOffset.width()); | 1382 newOffset.setWidth(-newOffset.width()); |
1362 adjustedOldOffset.setWidth(-adjustedOldOffset.width()); | 1383 adjustedOldOffset.setWidth(-adjustedOldOffset.width()); |
1363 } | 1384 } |
1364 | 1385 |
1365 LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expand edTo(minimumSize) - currentSize; | 1386 LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expand edTo(m_minimumSizeForResizing) - currentSize; |
Julien - ping for review
2014/04/28 17:07:30
We should probably not cache the value as resize()
harpreet.sk
2014/04/29 08:57:43
The api is changed to minimumSizeForResizing() and
| |
1366 | 1387 |
1367 bool isBoxSizingBorder = m_box->style()->boxSizing() == BORDER_BOX; | 1388 bool isBoxSizingBorder = m_box->style()->boxSizing() == BORDER_BOX; |
1368 | 1389 |
1369 EResize resize = m_box->style()->resize(); | 1390 EResize resize = m_box->style()->resize(); |
1370 if (resize != RESIZE_VERTICAL && difference.width()) { | 1391 if (resize != RESIZE_VERTICAL && difference.width()) { |
1371 if (element->isFormControlElement()) { | 1392 if (element->isFormControlElement()) { |
1372 // Make implicit margins from the theme explicit (see <http://bugs.w ebkit.org/show_bug.cgi?id=9547>). | 1393 // Make implicit margins from the theme explicit (see <http://bugs.w ebkit.org/show_bug.cgi?id=9547>). |
1373 element->setInlineStyleProperty(CSSPropertyMarginLeft, m_box->margin Left() / zoomFactor, CSSPrimitiveValue::CSS_PX); | 1394 element->setInlineStyleProperty(CSSPropertyMarginLeft, m_box->margin Left() / zoomFactor, CSSPrimitiveValue::CSS_PX); |
1374 element->setInlineStyleProperty(CSSPropertyMarginRight, m_box->margi nRight() / zoomFactor, CSSPrimitiveValue::CSS_PX); | 1395 element->setInlineStyleProperty(CSSPropertyMarginRight, m_box->margi nRight() / zoomFactor, CSSPrimitiveValue::CSS_PX); |
1375 } | 1396 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 void RenderLayerScrollableArea::setForceNeedsCompositedScrolling(ForceNeedsCompo sitedScrollingMode mode) | 1544 void RenderLayerScrollableArea::setForceNeedsCompositedScrolling(ForceNeedsCompo sitedScrollingMode mode) |
1524 { | 1545 { |
1525 if (m_forceNeedsCompositedScrolling == mode) | 1546 if (m_forceNeedsCompositedScrolling == mode) |
1526 return; | 1547 return; |
1527 | 1548 |
1528 m_forceNeedsCompositedScrolling = mode; | 1549 m_forceNeedsCompositedScrolling = mode; |
1529 layer()->didUpdateNeedsCompositedScrolling(); | 1550 layer()->didUpdateNeedsCompositedScrolling(); |
1530 } | 1551 } |
1531 | 1552 |
1532 } // Namespace WebCore | 1553 } // Namespace WebCore |
OLD | NEW |