| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 #endif | 981 #endif |
| 982 | 982 |
| 983 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const | 983 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const |
| 984 { | 984 { |
| 985 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); | 985 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); |
| 986 if (!viewportConstrainedObjects) | 986 if (!viewportConstrainedObjects) |
| 987 return false; | 987 return false; |
| 988 | 988 |
| 989 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { | 989 for (const LayoutObject* layoutObject : *viewportConstrainedObjects) { |
| 990 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); | 990 ASSERT(layoutObject->isBoxModelObject() && layoutObject->hasLayer()); |
| 991 ASSERT(layoutObject->style()->position() == FixedPosition); | 991 ASSERT(layoutObject->style()->position() == FixedPosition |
| 992 || layoutObject->style()->position() == StickyPosition); |
| 992 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); | 993 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); |
| 993 | 994 |
| 994 // Whether the Layer scrolls with the viewport is a tree-depenent | 995 // Whether the Layer scrolls with the viewport is a tree-depenent |
| 995 // property and our viewportConstrainedObjects collection is maintained | 996 // property and our viewportConstrainedObjects collection is maintained |
| 996 // with only LayoutObject-level information. | 997 // with only LayoutObject-level information. |
| 997 if (!layer->scrollsWithViewport()) | 998 if (!layer->scrollsWithViewport()) |
| 998 continue; | 999 continue; |
| 999 | 1000 |
| 1000 // If the whole subtree is invisible, there's no reason to scroll on | 1001 // If the whole subtree is invisible, there's no reason to scroll on |
| 1001 // the main thread because we don't need to generate invalidations | 1002 // the main thread because we don't need to generate invalidations |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1030 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver
seNext()) { | 1031 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver
seNext()) { |
| 1031 if (!frame->isLocalFrame()) | 1032 if (!frame->isLocalFrame()) |
| 1032 continue; | 1033 continue; |
| 1033 | 1034 |
| 1034 FrameView* frameView = toLocalFrame(frame)->view(); | 1035 FrameView* frameView = toLocalFrame(frame)->view(); |
| 1035 if (!frameView) | 1036 if (!frameView) |
| 1036 continue; | 1037 continue; |
| 1037 | 1038 |
| 1038 if (frameView->hasBackgroundAttachmentFixedObjects()) | 1039 if (frameView->hasBackgroundAttachmentFixedObjects()) |
| 1039 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO
bjects; | 1040 reasons |= MainThreadScrollingReason::kHasBackgroundAttachmentFixedO
bjects; |
| 1041 if (frameView->hasStickyPositionObjects()) |
| 1042 reasons |= MainThreadScrollingReason::kHasStickyPositionObjects; |
| 1040 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReaso
ns(); | 1043 FrameView::ScrollingReasons scrollingReasons = frameView->scrollingReaso
ns(); |
| 1041 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll
able); | 1044 const bool mayBeScrolledByInput = (scrollingReasons == FrameView::Scroll
able); |
| 1042 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea
sons == | 1045 const bool mayBeScrolledByScript = mayBeScrolledByInput || (scrollingRea
sons == |
| 1043 FrameView::NotScrollableExplicitlyDisabled); | 1046 FrameView::NotScrollableExplicitlyDisabled); |
| 1044 | 1047 |
| 1045 // TODO(awoloszyn) Currently crbug.com/304810 will let certain | 1048 // TODO(awoloszyn) Currently crbug.com/304810 will let certain |
| 1046 // overflow:hidden elements scroll on the compositor thread, so we shoul
d | 1049 // overflow:hidden elements scroll on the compositor thread, so we shoul
d |
| 1047 // not let this move there path as an optimization, when we have slow-re
paint | 1050 // not let this move there path as an optimization, when we have slow-re
paint |
| 1048 // elements. | 1051 // elements. |
| 1049 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj
ects(frameView)) { | 1052 if (mayBeScrolledByScript && hasVisibleSlowRepaintViewportConstrainedObj
ects(frameView)) { |
| 1050 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine
dObjects; | 1053 reasons |= MainThreadScrollingReason::kHasNonLayerViewportConstraine
dObjects; |
| 1051 } | 1054 } |
| 1052 } | 1055 } |
| 1053 | 1056 |
| 1054 return reasons; | 1057 return reasons; |
| 1055 } | 1058 } |
| 1056 | 1059 |
| 1057 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin
gReasons reasons) | 1060 String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin
gReasons reasons) |
| 1058 { | 1061 { |
| 1059 StringBuilder stringBuilder; | 1062 StringBuilder stringBuilder; |
| 1060 | 1063 |
| 1061 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject
s) | 1064 if (reasons & MainThreadScrollingReason::kHasBackgroundAttachmentFixedObject
s) |
| 1062 stringBuilder.appendLiteral("Has background-attachment:fixed, "); | 1065 stringBuilder.appendLiteral("Has background-attachment:fixed, "); |
| 1063 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje
cts) | 1066 if (reasons & MainThreadScrollingReason::kHasNonLayerViewportConstrainedObje
cts) |
| 1064 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects,
"); | 1067 stringBuilder.appendLiteral("Has non-layer viewport-constrained objects,
"); |
| 1068 if (reasons & MainThreadScrollingReason::kHasStickyPositionObjects) |
| 1069 stringBuilder.appendLiteral("Has sticky position objects, "); |
| 1065 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled) | 1070 if (reasons & MainThreadScrollingReason::kThreadedScrollingDisabled) |
| 1066 stringBuilder.appendLiteral("Threaded scrolling is disabled, "); | 1071 stringBuilder.appendLiteral("Threaded scrolling is disabled, "); |
| 1067 | 1072 |
| 1068 if (stringBuilder.length()) | 1073 if (stringBuilder.length()) |
| 1069 stringBuilder.resize(stringBuilder.length() - 2); | 1074 stringBuilder.resize(stringBuilder.length() - 2); |
| 1070 return stringBuilder.toString(); | 1075 return stringBuilder.toString(); |
| 1071 } | 1076 } |
| 1072 | 1077 |
| 1073 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 1078 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
| 1074 { | 1079 { |
| 1075 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() >
= DocumentLifecycle::CompositingClean); | 1080 ASSERT(m_page->deprecatedLocalMainFrame()->document()->lifecycle().state() >
= DocumentLifecycle::CompositingClean); |
| 1076 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); | 1081 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); |
| 1077 } | 1082 } |
| 1078 | 1083 |
| 1079 bool ScrollingCoordinator::frameViewIsDirty() const | 1084 bool ScrollingCoordinator::frameViewIsDirty() const |
| 1080 { | 1085 { |
| 1081 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca
tedLocalMainFrame()->view() : nullptr; | 1086 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? m_page->depreca
tedLocalMainFrame()->view() : nullptr; |
| 1082 bool frameIsScrollable = frameView && frameView->isScrollable(); | 1087 bool frameIsScrollable = frameView && frameView->isScrollable(); |
| 1083 if (frameIsScrollable != m_wasFrameScrollable) | 1088 if (frameIsScrollable != m_wasFrameScrollable) |
| 1084 return true; | 1089 return true; |
| 1085 | 1090 |
| 1086 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) | 1091 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) |
| 1087 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); | 1092 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); |
| 1088 return false; | 1093 return false; |
| 1089 } | 1094 } |
| 1090 | 1095 |
| 1091 } // namespace blink | 1096 } // namespace blink |
| OLD | NEW |