Title: [203294] trunk/Source/WebCore
- Revision
- 203294
- Author
- [email protected]
- Date
- 2016-07-15 13:19:29 -0700 (Fri, 15 Jul 2016)
Log Message
ScrollView::setHasHorizontalScrollbar / setHasVerticalScrollbar duplicate their logic
https://bugs.webkit.org/show_bug.cgi?id=159825
Patch introduces a (private) method to ScrollView
to share the code/logic of setHas{Horizontal,Vertical}Scrollbar.
Patch by Antonio Gomes <[email protected]> on 2016-07-15
Reviewed by Simon Fraser.
No new tests needed.
* platform/ScrollView.cpp:
(WebCore::ScrollView::setHasScrollbarInternal):
(WebCore::ScrollView::setHasHorizontalScrollbar):
(WebCore::ScrollView::setHasVerticalScrollbar):
* platform/ScrollView.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (203293 => 203294)
--- trunk/Source/WebCore/ChangeLog 2016-07-15 20:03:39 UTC (rev 203293)
+++ trunk/Source/WebCore/ChangeLog 2016-07-15 20:19:29 UTC (rev 203294)
@@ -1,3 +1,21 @@
+2016-07-15 Antonio Gomes <[email protected]>
+
+ ScrollView::setHasHorizontalScrollbar / setHasVerticalScrollbar duplicate their logic
+ https://bugs.webkit.org/show_bug.cgi?id=159825
+
+ Patch introduces a (private) method to ScrollView
+ to share the code/logic of setHas{Horizontal,Vertical}Scrollbar.
+
+ Reviewed by Simon Fraser.
+
+ No new tests needed.
+
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::setHasScrollbarInternal):
+ (WebCore::ScrollView::setHasHorizontalScrollbar):
+ (WebCore::ScrollView::setHasVerticalScrollbar):
+ * platform/ScrollView.h:
+
2016-07-15 Frederic Wang <[email protected]>
MathOperator: Improve alignment for vertical size variant
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (203293 => 203294)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2016-07-15 20:03:39 UTC (rev 203293)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2016-07-15 20:19:29 UTC (rev 203294)
@@ -83,48 +83,33 @@
bool ScrollView::setHasHorizontalScrollbar(bool hasBar, bool* contentSizeAffected)
{
- ASSERT(!hasBar || !avoidScrollbarCreation());
- if (hasBar && !m_horizontalScrollbar) {
- m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
- addChild(m_horizontalScrollbar.get());
- didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
- m_horizontalScrollbar->styleChanged();
- if (contentSizeAffected)
- *contentSizeAffected = !m_horizontalScrollbar->isOverlayScrollbar();
- return true;
- }
-
- if (!hasBar && m_horizontalScrollbar) {
- bool wasOverlayScrollbar = m_horizontalScrollbar->isOverlayScrollbar();
- willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
- removeChild(*m_horizontalScrollbar);
- m_horizontalScrollbar = nullptr;
- if (contentSizeAffected)
- *contentSizeAffected = !wasOverlayScrollbar;
- return true;
- }
-
- return false;
+ return setHasScrollbarInternal(m_horizontalScrollbar, HorizontalScrollbar, hasBar, contentSizeAffected);
}
bool ScrollView::setHasVerticalScrollbar(bool hasBar, bool* contentSizeAffected)
{
+ return setHasScrollbarInternal(m_verticalScrollbar, VerticalScrollbar, hasBar, contentSizeAffected);
+}
+
+bool ScrollView::setHasScrollbarInternal(RefPtr<Scrollbar>& scrollbar, ScrollbarOrientation orientation, bool hasBar, bool* contentSizeAffected)
+{
ASSERT(!hasBar || !avoidScrollbarCreation());
- if (hasBar && !m_verticalScrollbar) {
- m_verticalScrollbar = createScrollbar(VerticalScrollbar);
- addChild(m_verticalScrollbar.get());
- didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
- m_verticalScrollbar->styleChanged();
+
+ if (hasBar && !scrollbar) {
+ scrollbar = createScrollbar(orientation);
+ addChild(scrollbar.get());
+ didAddScrollbar(scrollbar.get(), orientation);
+ scrollbar->styleChanged();
if (contentSizeAffected)
- *contentSizeAffected = !m_verticalScrollbar->isOverlayScrollbar();
+ *contentSizeAffected = !scrollbar->isOverlayScrollbar();
return true;
}
- if (!hasBar && m_verticalScrollbar) {
- bool wasOverlayScrollbar = m_verticalScrollbar->isOverlayScrollbar();
- willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
- removeChild(*m_verticalScrollbar);
- m_verticalScrollbar = nullptr;
+ if (!hasBar && scrollbar) {
+ bool wasOverlayScrollbar = scrollbar->isOverlayScrollbar();
+ willRemoveScrollbar(scrollbar.get(), orientation);
+ removeChild(*scrollbar);
+ scrollbar = nullptr;
if (contentSizeAffected)
*contentSizeAffected = !wasOverlayScrollbar;
return true;
Modified: trunk/Source/WebCore/platform/ScrollView.h (203293 => 203294)
--- trunk/Source/WebCore/platform/ScrollView.h 2016-07-15 20:03:39 UTC (rev 203293)
+++ trunk/Source/WebCore/platform/ScrollView.h 2016-07-15 20:19:29 UTC (rev 203294)
@@ -431,6 +431,8 @@
void completeUpdatesAfterScrollTo(const IntSize& scrollDelta);
+ bool setHasScrollbarInternal(RefPtr<Scrollbar>&, ScrollbarOrientation, bool hasBar, bool* contentSizeAffected);
+
RefPtr<Scrollbar> m_horizontalScrollbar;
RefPtr<Scrollbar> m_verticalScrollbar;
ScrollbarMode m_horizontalScrollbarMode;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes