OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 , m_isTrackingRepaints(false) | 172 , m_isTrackingRepaints(false) |
173 , m_shouldUpdateWhileOffscreen(true) | 173 , m_shouldUpdateWhileOffscreen(true) |
174 , m_deferSetNeedsLayouts(0) | 174 , m_deferSetNeedsLayouts(0) |
175 , m_setNeedsLayoutWasDeferred(false) | 175 , m_setNeedsLayoutWasDeferred(false) |
176 , m_scrollCorner(0) | 176 , m_scrollCorner(0) |
177 , m_shouldAutoSize(false) | 177 , m_shouldAutoSize(false) |
178 , m_inAutoSize(false) | 178 , m_inAutoSize(false) |
179 , m_didRunAutosize(false) | 179 , m_didRunAutosize(false) |
180 , m_hasSoftwareFilters(false) | 180 , m_hasSoftwareFilters(false) |
181 , m_visibleContentScaleFactor(1) | 181 , m_visibleContentScaleFactor(1) |
182 , m_canStopPartialLayout(false) | |
183 , m_stopLayoutAtRenderer(0) | |
182 { | 184 { |
183 init(); | 185 init(); |
184 | 186 |
185 // FIXME: Can m_frame ever be null here? | 187 // FIXME: Can m_frame ever be null here? |
186 if (!m_frame) | 188 if (!m_frame) |
187 return; | 189 return; |
188 | 190 |
189 Page* page = m_frame->page(); | 191 Page* page = m_frame->page(); |
190 if (!page) | 192 if (!page) |
191 return; | 193 return; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
837 void FrameView::layout(bool allowSubtree) | 839 void FrameView::layout(bool allowSubtree) |
838 { | 840 { |
839 // We should never layout a Document which is not in a Frame. | 841 // We should never layout a Document which is not in a Frame. |
840 ASSERT(m_frame); | 842 ASSERT(m_frame); |
841 ASSERT(m_frame->view() == this); | 843 ASSERT(m_frame->view() == this); |
842 ASSERT(m_frame->page()); | 844 ASSERT(m_frame->page()); |
843 | 845 |
844 if (m_inLayout) | 846 if (m_inLayout) |
845 return; | 847 return; |
846 | 848 |
849 if (m_canStopPartialLayout) { | |
850 resetPartialLayoutState(); | |
851 return; | |
852 } | |
853 //ASSERT(!m_canStopPartialLayout); | |
854 | |
847 TRACE_EVENT0("webkit", "FrameView::layout"); | 855 TRACE_EVENT0("webkit", "FrameView::layout"); |
848 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout"); | 856 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout"); |
849 | 857 |
850 // Protect the view from being deleted during layout (in recalcStyle) | 858 // Protect the view from being deleted during layout (in recalcStyle) |
851 RefPtr<FrameView> protector(this); | 859 RefPtr<FrameView> protector(this); |
852 | 860 |
853 // Every scroll that happens during layout is programmatic. | 861 // Every scroll that happens during layout is programmatic. |
854 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru e); | 862 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru e); |
855 | 863 |
856 m_layoutTimer.stop(); | 864 m_layoutTimer.stop(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 | 1011 |
1004 endDeferredRepaints(); | 1012 endDeferredRepaints(); |
1005 m_inLayout = false; | 1013 m_inLayout = false; |
1006 | 1014 |
1007 if (inSubtreeLayout) | 1015 if (inSubtreeLayout) |
1008 rootForThisLayout->view()->popLayoutState(rootForThisLayout); | 1016 rootForThisLayout->view()->popLayoutState(rootForThisLayout); |
1009 } | 1017 } |
1010 m_layoutRoot = 0; | 1018 m_layoutRoot = 0; |
1011 } // Reset m_layoutSchedulingEnabled to its previous value. | 1019 } // Reset m_layoutSchedulingEnabled to its previous value. |
1012 | 1020 |
1021 if (m_canStopPartialLayout) { | |
1022 // Reset partial layout state post-layout. | |
1023 resetPartialLayoutState(); | |
1024 return; | |
1025 } | |
1026 | |
1013 bool neededFullRepaint = m_doFullRepaint; | 1027 bool neededFullRepaint = m_doFullRepaint; |
1014 | 1028 |
1015 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->printing()) | 1029 if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->printing()) |
1016 adjustViewSize(); | 1030 adjustViewSize(); |
1017 | 1031 |
1018 m_doFullRepaint = neededFullRepaint; | 1032 m_doFullRepaint = neededFullRepaint; |
1019 | 1033 |
1020 // Now update the positions of all layers. | 1034 // Now update the positions of all layers. |
1021 beginDeferredRepaints(); | 1035 beginDeferredRepaints(); |
1022 if (m_doFullRepaint) | 1036 if (m_doFullRepaint) |
1023 rootForThisLayout->view()->repaint(); // FIXME: This isn't really right, since the RenderView doesn't fully encompass the visibleContentRect(). It just happens | 1037 rootForThisLayout->view()->repaint(); // FIXME: This isn't really right, since the RenderView doesn't fully encompass the visibleContentRect(). It just happens |
1024 // to work out most of the time, since first la youts and printing don't have you scrolled anywhere. | 1038 // to work out most of the time, since first la youts and printing don't have you scrolled anywhere. |
1025 | 1039 |
1026 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPos itionFlags(layer, inSubtreeLayout, m_doFullRepaint)); | 1040 layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPos itionFlags(layer, inSubtreeLayout, m_doFullRepaint)); |
1027 | 1041 |
1028 endDeferredRepaints(); | 1042 endDeferredRepaints(); |
1029 | 1043 |
1030 updateCompositingLayersAfterLayout(); | 1044 updateCompositingLayersAfterLayout(); |
1031 | 1045 |
1032 m_layoutCount++; | 1046 m_layoutCount++; |
1033 | 1047 |
1034 if (AXObjectCache* cache = rootForThisLayout->document()->existingAXObjectCa che()) | 1048 if (AXObjectCache* cache = rootForThisLayout->document()->existingAXObjectCa che()) |
1035 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true); | 1049 cache->postNotification(rootForThisLayout, AXObjectCache::AXLayoutComple te, true); |
1036 updateAnnotatedRegions(); | 1050 updateAnnotatedRegions(); |
1037 | 1051 |
1052 if (m_canStopPartialLayout) { | |
1053 // Reset partial layout state post-layout. | |
1054 resetPartialLayoutState(); | |
1055 return; | |
1056 } | |
1057 | |
1038 layoutLazyBlocks(); | 1058 layoutLazyBlocks(); |
1039 | 1059 |
1040 ASSERT(!rootForThisLayout->needsLayout()); | 1060 if (m_canStopPartialLayout) { |
1061 // Reset partial layout state post-layout. | |
1062 resetPartialLayoutState(); | |
1063 return; | |
1064 } | |
1065 | |
1066 if (!m_canStopPartialLayout) | |
1067 ASSERT(!rootForThisLayout->needsLayout()); | |
1041 | 1068 |
1042 updateCanBlitOnScrollRecursively(); | 1069 updateCanBlitOnScrollRecursively(); |
1043 | 1070 |
1044 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) | 1071 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER)) |
1045 updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < c ontentsHeight()); | 1072 updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < c ontentsHeight()); |
1046 | 1073 |
1047 if (!m_postLayoutTasksTimer.isActive()) { | 1074 if (!m_postLayoutTasksTimer.isActive()) { |
1048 if (!m_inSynchronousPostLayout) { | 1075 if (!m_inSynchronousPostLayout) { |
1049 if (frame()->document()->shouldDisplaySeamlesslyWithParent()) { | 1076 if (frame()->document()->shouldDisplaySeamlesslyWithParent()) { |
1050 if (RenderView* renderView = this->renderView()) | 1077 if (RenderView* renderView = this->renderView()) |
1051 renderView->updateWidgetPositions(); | 1078 renderView->updateWidgetPositions(); |
1052 } else { | 1079 } else { |
1053 m_inSynchronousPostLayout = true; | 1080 m_inSynchronousPostLayout = true; |
1054 // Calls resumeScheduledEvents() | 1081 // Calls resumeScheduledEvents() |
1055 performPostLayoutTasks(); | 1082 performPostLayoutTasks(); |
achicu
2013/08/15 13:48:21
I think that the biggest performance improvement c
| |
1056 m_inSynchronousPostLayout = false; | 1083 m_inSynchronousPostLayout = false; |
1057 } | 1084 } |
1058 } | 1085 } |
1059 | 1086 |
1060 if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inSynchron ousPostLayout || frame()->document()->shouldDisplaySeamlesslyWithParent())) { | 1087 if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inSynchron ousPostLayout || frame()->document()->shouldDisplaySeamlesslyWithParent())) { |
1061 // If we need layout or are already in a synchronous call to postLay outTasks(), | 1088 // If we need layout or are already in a synchronous call to postLay outTasks(), |
1062 // defer widget updates and event dispatch until after we return. po stLayoutTasks() | 1089 // defer widget updates and event dispatch until after we return. po stLayoutTasks() |
1063 // can make us need to update again, and we can get stuck in a nasty cycle unless | 1090 // can make us need to update again, and we can get stuck in a nasty cycle unless |
1064 // we call it through the timer here. | 1091 // we call it through the timer here. |
1065 m_postLayoutTasksTimer.startOneShot(0); | 1092 m_postLayoutTasksTimer.startOneShot(0); |
1066 if (needsLayout()) { | 1093 if (needsLayout()) { |
1067 m_actionScheduler->pause(); | 1094 m_actionScheduler->pause(); |
1068 layout(); | 1095 layout(); |
1069 } | 1096 } |
1070 } | 1097 } |
1071 } else { | 1098 } else { |
1072 m_actionScheduler->resume(); | 1099 m_actionScheduler->resume(); |
1073 } | 1100 } |
1074 | 1101 |
1075 InspectorInstrumentation::didLayout(cookie, rootForThisLayout); | 1102 InspectorInstrumentation::didLayout(cookie, rootForThisLayout); |
1076 | 1103 |
1077 m_nestedLayoutCount--; | 1104 m_nestedLayoutCount--; |
1078 if (m_nestedLayoutCount) | 1105 if (m_nestedLayoutCount) |
1079 return; | 1106 return; |
1080 | 1107 |
1081 #ifndef NDEBUG | 1108 #ifndef NDEBUG |
1082 // Post-layout assert that nobody was re-marked as needing layout during lay out. | 1109 if (!m_canStopPartialLayout) { |
1083 for (RenderObject* renderer = document->renderer(); renderer; renderer = ren derer->nextInPreOrder()) | 1110 // Post-layout assert that nobody was re-marked as needing layout during layout. |
1084 ASSERT(!renderer->needsLayout()); | 1111 for (RenderObject* renderer = document->renderer(); renderer; renderer = renderer->nextInPreOrder()) |
1112 ASSERT(!renderer->needsLayout()); | |
1113 } | |
1085 #endif | 1114 #endif |
1086 | 1115 |
1116 // Reset partial layout state post-layout. | |
1117 resetPartialLayoutState(); | |
1118 | |
1087 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout | 1119 // FIXME: It should be not possible to remove the FrameView from the frame/p age during layout |
1088 // however m_inLayout is not set for most of this function, so none of our R ELEASE_ASSERTS | 1120 // however m_inLayout is not set for most of this function, so none of our R ELEASE_ASSERTS |
1089 // in Frame/Page will fire. One of the post-layout tasks is disconnecting th e Frame from | 1121 // in Frame/Page will fire. One of the post-layout tasks is disconnecting th e Frame from |
1090 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml | 1122 // the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.ht ml |
1091 // necessitating this check here. | 1123 // necessitating this check here. |
1092 ASSERT(frame()); | 1124 ASSERT(frame()); |
1093 // ASSERT(frame()->page()); | 1125 // ASSERT(frame()->page()); |
1094 if (frame() && frame()->page()) | 1126 if (frame() && frame()->page()) |
1095 frame()->page()->chrome().client()->layoutUpdated(frame()); | 1127 frame()->page()->chrome().client()->layoutUpdated(frame()); |
1096 } | 1128 } |
(...skipping 20 matching lines...) Expand all Loading... | |
1117 // Next walk all lazy blocks and find nested ones, these need another layout | 1149 // Next walk all lazy blocks and find nested ones, these need another layout |
1118 // since the first one would not have placed them correctly inside the viewp ort. | 1150 // since the first one would not have placed them correctly inside the viewp ort. |
1119 for (RenderLazyBlock* block = renderView()->firstLazyBlock(); block; block = block->next()) { | 1151 for (RenderLazyBlock* block = renderView()->firstLazyBlock(); block; block = block->next()) { |
1120 if (!block->isNested()) | 1152 if (!block->isNested()) |
1121 continue; | 1153 continue; |
1122 block->setNeedsLayout(); | 1154 block->setNeedsLayout(); |
1123 layout(); | 1155 layout(); |
1124 } | 1156 } |
1125 } | 1157 } |
1126 | 1158 |
1159 void FrameView::checkPartialLayoutComplete(RenderObject* renderer) | |
1160 { | |
1161 if (renderer == m_stopLayoutAtRenderer) { | |
1162 //fprintf(stderr, "stopping partial layout!\n"); | |
1163 //BACKTRACE(); | |
1164 m_canStopPartialLayout = true; | |
1165 } | |
1166 } | |
1167 | |
1127 RenderBox* FrameView::embeddedContentBox() const | 1168 RenderBox* FrameView::embeddedContentBox() const |
1128 { | 1169 { |
1129 RenderView* renderView = this->renderView(); | 1170 RenderView* renderView = this->renderView(); |
1130 if (!renderView) | 1171 if (!renderView) |
1131 return 0; | 1172 return 0; |
1132 | 1173 |
1133 RenderObject* firstChild = renderView->firstChild(); | 1174 RenderObject* firstChild = renderView->firstChild(); |
1134 if (!firstChild || !firstChild->isBox()) | 1175 if (!firstChild || !firstChild->isBox()) |
1135 return 0; | 1176 return 0; |
1136 | 1177 |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3356 } | 3397 } |
3357 | 3398 |
3358 AXObjectCache* FrameView::axObjectCache() const | 3399 AXObjectCache* FrameView::axObjectCache() const |
3359 { | 3400 { |
3360 if (frame() && frame()->document()) | 3401 if (frame() && frame()->document()) |
3361 return frame()->document()->existingAXObjectCache(); | 3402 return frame()->document()->existingAXObjectCache(); |
3362 return 0; | 3403 return 0; |
3363 } | 3404 } |
3364 | 3405 |
3365 } // namespace WebCore | 3406 } // namespace WebCore |
OLD | NEW |