Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 FrameView* FrameView::Create(LocalFrame& frame, const IntSize& initial_size) { 226 FrameView* FrameView::Create(LocalFrame& frame, const IntSize& initial_size) {
227 FrameView* view = new FrameView(frame, IntRect(IntPoint(), initial_size)); 227 FrameView* view = new FrameView(frame, IntRect(IntPoint(), initial_size));
228 view->SetLayoutSizeInternal(initial_size); 228 view->SetLayoutSizeInternal(initial_size);
229 229
230 view->Show(); 230 view->Show();
231 return view; 231 return view;
232 } 232 }
233 233
234 FrameView::~FrameView() { 234 FrameView::~FrameView() {
235 ASSERT(has_been_disposed_); 235 #if DCHECK_IS_ON()
236 DCHECK(has_been_disposed_);
237 #endif
236 } 238 }
237 239
238 DEFINE_TRACE(FrameView) { 240 DEFINE_TRACE(FrameView) {
239 visitor->Trace(frame_); 241 visitor->Trace(frame_);
240 visitor->Trace(parent_); 242 visitor->Trace(parent_);
241 visitor->Trace(fragment_anchor_); 243 visitor->Trace(fragment_anchor_);
242 visitor->Trace(scrollable_areas_); 244 visitor->Trace(scrollable_areas_);
243 visitor->Trace(animating_scrollable_areas_); 245 visitor->Trace(animating_scrollable_areas_);
244 visitor->Trace(auto_size_info_); 246 visitor->Trace(auto_size_info_);
245 visitor->Trace(children_); 247 visitor->Trace(children_);
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 // for the first time, or when the LayoutSVGRoot size has changed dynamically 985 // for the first time, or when the LayoutSVGRoot size has changed dynamically
984 // (eg. via <script>). 986 // (eg. via <script>).
985 FrameView* frame_view = owner_layout_item.GetFrame()->View(); 987 FrameView* frame_view = owner_layout_item.GetFrame()->View();
986 988
987 // Mark the owner layoutObject as needing layout. 989 // Mark the owner layoutObject as needing layout.
988 owner_layout_item.SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( 990 owner_layout_item.SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
989 LayoutInvalidationReason::kUnknown); 991 LayoutInvalidationReason::kUnknown);
990 992
991 // Synchronously enter layout, to layout the view containing the host 993 // Synchronously enter layout, to layout the view containing the host
992 // object/embed/iframe. 994 // object/embed/iframe.
993 ASSERT(frame_view); 995 DCHECK(frame_view);
994 frame_view->UpdateLayout(); 996 frame_view->UpdateLayout();
995 } 997 }
996 998
997 void FrameView::PerformPreLayoutTasks() { 999 void FrameView::PerformPreLayoutTasks() {
998 TRACE_EVENT0("blink,benchmark", "FrameView::performPreLayoutTasks"); 1000 TRACE_EVENT0("blink,benchmark", "FrameView::performPreLayoutTasks");
999 Lifecycle().AdvanceTo(DocumentLifecycle::kInPreLayout); 1001 Lifecycle().AdvanceTo(DocumentLifecycle::kInPreLayout);
1000 1002
1001 // Don't schedule more layouts, we're in one. 1003 // Don't schedule more layouts, we're in one.
1002 AutoReset<bool> change_scheduling_enabled(&layout_scheduling_enabled_, false); 1004 AutoReset<bool> change_scheduling_enabled(&layout_scheduling_enabled_, false);
1003 1005
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 if (in_subtree_layout && HasOrthogonalWritingModeRoots()) { 1103 if (in_subtree_layout && HasOrthogonalWritingModeRoots()) {
1102 // If we're going to lay out from each subtree root, rather than once from 1104 // If we're going to lay out from each subtree root, rather than once from
1103 // LayoutView, we need to merge the depth-ordered orthogonal writing mode 1105 // LayoutView, we need to merge the depth-ordered orthogonal writing mode
1104 // root list into the depth-ordered list of subtrees scheduled for 1106 // root list into the depth-ordered list of subtrees scheduled for
1105 // layout. Otherwise, during layout of one such subtree, we'd risk skipping 1107 // layout. Otherwise, during layout of one such subtree, we'd risk skipping
1106 // over a subtree of objects needing layout. 1108 // over a subtree of objects needing layout.
1107 DCHECK(!layout_subtree_root_list_.IsEmpty()); 1109 DCHECK(!layout_subtree_root_list_.IsEmpty());
1108 ScheduleOrthogonalWritingModeRootsForLayout(); 1110 ScheduleOrthogonalWritingModeRootsForLayout();
1109 } 1111 }
1110 1112
1111 ASSERT(!IsInPerformLayout()); 1113 DCHECK(!IsInPerformLayout());
1112 Lifecycle().AdvanceTo(DocumentLifecycle::kInPerformLayout); 1114 Lifecycle().AdvanceTo(DocumentLifecycle::kInPerformLayout);
1113 1115
1114 // performLayout is the actual guts of layout(). 1116 // performLayout is the actual guts of layout().
1115 // FIXME: The 300 other lines in layout() probably belong in other helper 1117 // FIXME: The 300 other lines in layout() probably belong in other helper
1116 // functions so that a single human could understand what layout() is actually 1118 // functions so that a single human could understand what layout() is actually
1117 // doing. 1119 // doing.
1118 1120
1119 ForceLayoutParentViewIfNeeded(); 1121 ForceLayoutParentViewIfNeeded();
1120 1122
1121 if (in_subtree_layout) { 1123 if (in_subtree_layout) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 // we can get stuck in a nasty cycle unless we call it through the timer 1174 // we can get stuck in a nasty cycle unless we call it through the timer
1173 // here. 1175 // here.
1174 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE); 1176 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE);
1175 if (NeedsLayout()) 1177 if (NeedsLayout())
1176 UpdateLayout(); 1178 UpdateLayout();
1177 } 1179 }
1178 } 1180 }
1179 1181
1180 void FrameView::UpdateLayout() { 1182 void FrameView::UpdateLayout() {
1181 // We should never layout a Document which is not in a LocalFrame. 1183 // We should never layout a Document which is not in a LocalFrame.
1182 ASSERT(frame_); 1184 DCHECK(frame_);
1183 ASSERT(frame_->View() == this); 1185 ASSERT(frame_->View() == this);
1184 ASSERT(frame_->GetPage()); 1186 DCHECK(frame_->GetPage());
1185 1187
1186 ScriptForbiddenScope forbid_script; 1188 ScriptForbiddenScope forbid_script;
1187 1189
1188 if (IsInPerformLayout() || ShouldThrottleRendering() || 1190 if (IsInPerformLayout() || ShouldThrottleRendering() ||
1189 !frame_->GetDocument()->IsActive()) 1191 !frame_->GetDocument()->IsActive())
1190 return; 1192 return;
1191 1193
1192 TRACE_EVENT0("blink,benchmark", "FrameView::layout"); 1194 TRACE_EVENT0("blink,benchmark", "FrameView::layout");
1193 1195
1194 if (auto_size_info_) 1196 if (auto_size_info_)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1308
1307 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 1309 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
1308 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree", 1310 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree",
1309 this, TracedLayoutObject::Create(*GetLayoutView(), false)); 1311 this, TracedLayoutObject::Create(*GetLayoutView(), false));
1310 1312
1311 PerformLayout(in_subtree_layout); 1313 PerformLayout(in_subtree_layout);
1312 1314
1313 if (!in_subtree_layout && !document->Printing()) 1315 if (!in_subtree_layout && !document->Printing())
1314 AdjustViewSizeAndLayout(); 1316 AdjustViewSizeAndLayout();
1315 1317
1316 ASSERT(layout_subtree_root_list_.IsEmpty()); 1318 DCHECK(layout_subtree_root_list_.IsEmpty());
1317 } // Reset m_layoutSchedulingEnabled to its previous value. 1319 } // Reset m_layoutSchedulingEnabled to its previous value.
1318 CheckDoesNotNeedLayout(); 1320 CheckDoesNotNeedLayout();
1319 1321
1320 frame_timing_requests_dirty_ = true; 1322 frame_timing_requests_dirty_ = true;
1321 1323
1322 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark 1324 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark
1323 // from there. crbug.com/462719 1325 // from there. crbug.com/462719
1324 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout(); 1326 GetLayoutViewItem().EnclosingLayer()->UpdateLayerPositionsAfterLayout();
1325 1327
1326 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 1328 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 const PaintInvalidationState& paint_invalidation_state) { 1368 const PaintInvalidationState& paint_invalidation_state) {
1367 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); 1369 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
1368 1370
1369 if (ShouldThrottleRendering()) 1371 if (ShouldThrottleRendering())
1370 return; 1372 return;
1371 1373
1372 Lifecycle().AdvanceTo(DocumentLifecycle::kInPaintInvalidation); 1374 Lifecycle().AdvanceTo(DocumentLifecycle::kInPaintInvalidation);
1373 1375
1374 RELEASE_ASSERT(!GetLayoutViewItem().IsNull()); 1376 RELEASE_ASSERT(!GetLayoutViewItem().IsNull());
1375 LayoutViewItem root_for_paint_invalidation = GetLayoutViewItem(); 1377 LayoutViewItem root_for_paint_invalidation = GetLayoutViewItem();
1376 ASSERT(!root_for_paint_invalidation.NeedsLayout()); 1378 DCHECK(!root_for_paint_invalidation.NeedsLayout());
1377 1379
1378 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", 1380 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root",
1379 root_for_paint_invalidation.DebugName().Ascii()); 1381 root_for_paint_invalidation.DebugName().Ascii());
1380 1382
1381 InvalidatePaint(paint_invalidation_state); 1383 InvalidatePaint(paint_invalidation_state);
1382 root_for_paint_invalidation.DeprecatedInvalidateTree( 1384 root_for_paint_invalidation.DeprecatedInvalidateTree(
1383 paint_invalidation_state); 1385 paint_invalidation_state);
1384 1386
1385 #if DCHECK_IS_ON() 1387 #if DCHECK_IS_ON()
1386 GetLayoutView()->AssertSubtreeClearedPaintInvalidationFlags(); 1388 GetLayoutView()->AssertSubtreeClearedPaintInvalidationFlags();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 if (!did_need_layout && !frame_view->ShouldThrottleRendering()) 1519 if (!did_need_layout && !frame_view->ShouldThrottleRendering())
1518 frame_view->CheckDoesNotNeedLayout(); 1520 frame_view->CheckDoesNotNeedLayout();
1519 } else { 1521 } else {
1520 part->UpdateGeometry(); 1522 part->UpdateGeometry();
1521 } 1523 }
1522 } 1524 }
1523 } 1525 }
1524 } 1526 }
1525 1527
1526 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) { 1528 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) {
1527 ASSERT(IsInPerformLayout()); 1529 DCHECK(IsInPerformLayout());
1528 // Tell the DOM element that it needs a FrameViewBase update. 1530 // Tell the DOM element that it needs a FrameViewBase update.
1529 Node* node = object.GetNode(); 1531 Node* node = object.GetNode();
1530 ASSERT(node); 1532 DCHECK(node);
1531 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) 1533 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node))
1532 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true); 1534 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true);
1533 1535
1534 part_update_set_.insert(&object); 1536 part_update_set_.insert(&object);
1535 } 1537 }
1536 1538
1537 void FrameView::SetDisplayMode(WebDisplayMode mode) { 1539 void FrameView::SetDisplayMode(WebDisplayMode mode) {
1538 if (mode == display_mode_) 1540 if (mode == display_mode_)
1539 return; 1541 return;
1540 1542
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 StyleChangeReason::kStyleSheetChange)); 1586 StyleChangeReason::kStyleSheetChange));
1585 } 1587 }
1586 1588
1587 bool FrameView::ContentsInCompositedLayer() const { 1589 bool FrameView::ContentsInCompositedLayer() const {
1588 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 1590 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
1589 return !layout_view_item.IsNull() && 1591 return !layout_view_item.IsNull() &&
1590 layout_view_item.GetCompositingState() == kPaintsIntoOwnBacking; 1592 layout_view_item.GetCompositingState() == kPaintsIntoOwnBacking;
1591 } 1593 }
1592 1594
1593 void FrameView::AddBackgroundAttachmentFixedObject(LayoutObject* object) { 1595 void FrameView::AddBackgroundAttachmentFixedObject(LayoutObject* object) {
1594 ASSERT(!background_attachment_fixed_objects_.Contains(object)); 1596 DCHECK(!background_attachment_fixed_objects_.Contains(object));
1595 1597
1596 background_attachment_fixed_objects_.insert(object); 1598 background_attachment_fixed_objects_.insert(object);
1597 if (ScrollingCoordinator* scrolling_coordinator = 1599 if (ScrollingCoordinator* scrolling_coordinator =
1598 this->GetScrollingCoordinator()) 1600 this->GetScrollingCoordinator())
1599 scrolling_coordinator 1601 scrolling_coordinator
1600 ->FrameViewHasBackgroundAttachmentFixedObjectsDidChange(this); 1602 ->FrameViewHasBackgroundAttachmentFixedObjectsDidChange(this);
1601 1603
1602 // Ensure main thread scrolling reasons are recomputed. 1604 // Ensure main thread scrolling reasons are recomputed.
1603 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { 1605 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) {
1604 SetNeedsPaintPropertyUpdate(); 1606 SetNeedsPaintPropertyUpdate();
1605 // The object's scroll properties are not affected by its own background. 1607 // The object's scroll properties are not affected by its own background.
1606 object->SetAncestorsNeedPaintPropertyUpdateForMainThreadScrolling(); 1608 object->SetAncestorsNeedPaintPropertyUpdateForMainThreadScrolling();
1607 } 1609 }
1608 } 1610 }
1609 1611
1610 void FrameView::RemoveBackgroundAttachmentFixedObject(LayoutObject* object) { 1612 void FrameView::RemoveBackgroundAttachmentFixedObject(LayoutObject* object) {
1611 ASSERT(background_attachment_fixed_objects_.Contains(object)); 1613 DCHECK(background_attachment_fixed_objects_.Contains(object));
1612 1614
1613 background_attachment_fixed_objects_.erase(object); 1615 background_attachment_fixed_objects_.erase(object);
1614 if (ScrollingCoordinator* scrolling_coordinator = 1616 if (ScrollingCoordinator* scrolling_coordinator =
1615 this->GetScrollingCoordinator()) 1617 this->GetScrollingCoordinator())
1616 scrolling_coordinator 1618 scrolling_coordinator
1617 ->FrameViewHasBackgroundAttachmentFixedObjectsDidChange(this); 1619 ->FrameViewHasBackgroundAttachmentFixedObjectsDidChange(this);
1618 1620
1619 // Ensure main thread scrolling reasons are recomputed. 1621 // Ensure main thread scrolling reasons are recomputed.
1620 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { 1622 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) {
1621 SetNeedsPaintPropertyUpdate(); 1623 SetNeedsPaintPropertyUpdate();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1778 }
1777 return false; 1779 return false;
1778 } 1780 }
1779 1781
1780 bool FrameView::InvalidateViewportConstrainedObjects() { 1782 bool FrameView::InvalidateViewportConstrainedObjects() {
1781 bool fast_path_allowed = true; 1783 bool fast_path_allowed = true;
1782 for (const auto& viewport_constrained_object : 1784 for (const auto& viewport_constrained_object :
1783 *viewport_constrained_objects_) { 1785 *viewport_constrained_objects_) {
1784 LayoutObject* layout_object = viewport_constrained_object; 1786 LayoutObject* layout_object = viewport_constrained_object;
1785 LayoutItem layout_item = LayoutItem(layout_object); 1787 LayoutItem layout_item = LayoutItem(layout_object);
1786 ASSERT(layout_item.Style()->HasViewportConstrainedPosition()); 1788 DCHECK(layout_item.Style()->HasViewportConstrainedPosition());
1787 ASSERT(layout_item.HasLayer()); 1789 DCHECK(layout_item.HasLayer());
1788 PaintLayer* layer = LayoutBoxModel(layout_item).Layer(); 1790 PaintLayer* layer = LayoutBoxModel(layout_item).Layer();
1789 1791
1790 if (layer->IsPaintInvalidationContainer()) 1792 if (layer->IsPaintInvalidationContainer())
1791 continue; 1793 continue;
1792 1794
1793 if (layer->SubtreeIsInvisible()) 1795 if (layer->SubtreeIsInvisible())
1794 continue; 1796 continue;
1795 1797
1796 // invalidate even if there is an ancestor with a filter that moves pixels. 1798 // invalidate even if there is an ancestor with a filter that moves pixels.
1797 layout_item 1799 layout_item
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 return true; 1832 return true;
1831 } 1833 }
1832 1834
1833 void FrameView::ScrollContentsSlowPath() { 1835 void FrameView::ScrollContentsSlowPath() {
1834 TRACE_EVENT0("blink", "FrameView::scrollContentsSlowPath"); 1836 TRACE_EVENT0("blink", "FrameView::scrollContentsSlowPath");
1835 // We need full invalidation during slow scrolling. For slimming paint, full 1837 // We need full invalidation during slow scrolling. For slimming paint, full
1836 // invalidation of the LayoutView is not enough. We also need to invalidate 1838 // invalidation of the LayoutView is not enough. We also need to invalidate
1837 // all of the objects. 1839 // all of the objects.
1838 // FIXME: Find out what are enough to invalidate in slow path scrolling. 1840 // FIXME: Find out what are enough to invalidate in slow path scrolling.
1839 // crbug.com/451090#9. 1841 // crbug.com/451090#9.
1840 ASSERT(!GetLayoutViewItem().IsNull()); 1842 DCHECK(!GetLayoutViewItem().IsNull());
1841 if (ContentsInCompositedLayer()) 1843 if (ContentsInCompositedLayer())
1842 GetLayoutViewItem() 1844 GetLayoutViewItem()
1843 .Layer() 1845 .Layer()
1844 ->GetCompositedLayerMapping() 1846 ->GetCompositedLayerMapping()
1845 ->SetContentsNeedDisplay(); 1847 ->SetContentsNeedDisplay();
1846 else 1848 else
1847 GetLayoutViewItem() 1849 GetLayoutViewItem()
1848 .SetShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 1850 .SetShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1849 1851
1850 if (ContentsInCompositedLayer()) { 1852 if (ContentsInCompositedLayer()) {
1851 IntRect update_rect = VisibleContentRect(); 1853 IntRect update_rect = VisibleContentRect();
1852 ASSERT(!GetLayoutViewItem().IsNull()); 1854 DCHECK(!GetLayoutViewItem().IsNull());
1853 // FIXME: We should not allow paint invalidation out of paint invalidation 1855 // FIXME: We should not allow paint invalidation out of paint invalidation
1854 // state. crbug.com/457415 1856 // state. crbug.com/457415
1855 DisablePaintInvalidationStateAsserts disabler; 1857 DisablePaintInvalidationStateAsserts disabler;
1856 GetLayoutViewItem().InvalidatePaintRectangle(LayoutRect(update_rect)); 1858 GetLayoutViewItem().InvalidatePaintRectangle(LayoutRect(update_rect));
1857 } 1859 }
1858 LayoutPartItem frame_layout_item = frame_->OwnerLayoutItem(); 1860 LayoutPartItem frame_layout_item = frame_->OwnerLayoutItem();
1859 if (!frame_layout_item.IsNull()) { 1861 if (!frame_layout_item.IsNull()) {
1860 if (IsEnclosedInCompositingLayer()) { 1862 if (IsEnclosedInCompositingLayer()) {
1861 LayoutRect rect( 1863 LayoutRect rect(
1862 frame_layout_item.BorderLeft() + frame_layout_item.PaddingLeft(), 1864 frame_layout_item.BorderLeft() + frame_layout_item.PaddingLeft(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 // Try again after decoding the ref, based on the document's encoding. 1896 // Try again after decoding the ref, based on the document's encoding.
1895 if (frame_->GetDocument()->Encoding().IsValid()) 1897 if (frame_->GetDocument()->Encoding().IsValid())
1896 ProcessUrlFragmentHelper( 1898 ProcessUrlFragmentHelper(
1897 DecodeURLEscapeSequences(fragment_identifier, 1899 DecodeURLEscapeSequences(fragment_identifier,
1898 frame_->GetDocument()->Encoding()), 1900 frame_->GetDocument()->Encoding()),
1899 behavior); 1901 behavior);
1900 } 1902 }
1901 1903
1902 bool FrameView::ProcessUrlFragmentHelper(const String& name, 1904 bool FrameView::ProcessUrlFragmentHelper(const String& name,
1903 UrlFragmentBehavior behavior) { 1905 UrlFragmentBehavior behavior) {
1904 ASSERT(frame_->GetDocument()); 1906 DCHECK(frame_->GetDocument());
1905 1907
1906 if (behavior == kUrlFragmentScroll && 1908 if (behavior == kUrlFragmentScroll &&
1907 !frame_->GetDocument()->IsRenderingReady()) { 1909 !frame_->GetDocument()->IsRenderingReady()) {
1908 frame_->GetDocument()->SetGotoAnchorNeededAfterStylesheetsLoad(true); 1910 frame_->GetDocument()->SetGotoAnchorNeededAfterStylesheetsLoad(true);
1909 return false; 1911 return false;
1910 } 1912 }
1911 1913
1912 frame_->GetDocument()->SetGotoAnchorNeededAfterStylesheetsLoad(false); 1914 frame_->GetDocument()->SetGotoAnchorNeededAfterStylesheetsLoad(false);
1913 1915
1914 Element* anchor_node = frame_->GetDocument()->FindAnchor(name); 1916 Element* anchor_node = frame_->GetDocument()->FindAnchor(name);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 if (behavior == kUrlFragmentScroll) 1949 if (behavior == kUrlFragmentScroll)
1948 frame_->GetDocument()->SetSequentialFocusNavigationStartingPoint( 1950 frame_->GetDocument()->SetSequentialFocusNavigationStartingPoint(
1949 anchor_node); 1951 anchor_node);
1950 frame_->GetDocument()->ClearFocusedElement(); 1952 frame_->GetDocument()->ClearFocusedElement();
1951 } 1953 }
1952 } 1954 }
1953 return true; 1955 return true;
1954 } 1956 }
1955 1957
1956 void FrameView::SetFragmentAnchor(Node* anchor_node) { 1958 void FrameView::SetFragmentAnchor(Node* anchor_node) {
1957 ASSERT(anchor_node); 1959 DCHECK(anchor_node);
1958 fragment_anchor_ = anchor_node; 1960 fragment_anchor_ = anchor_node;
1959 1961
1960 // We need to update the layout tree before scrolling. 1962 // We need to update the layout tree before scrolling.
1961 frame_->GetDocument()->UpdateStyleAndLayoutTree(); 1963 frame_->GetDocument()->UpdateStyleAndLayoutTree();
1962 1964
1963 // If layout is needed, we will scroll in performPostLayoutTasks. Otherwise, 1965 // If layout is needed, we will scroll in performPostLayoutTasks. Otherwise,
1964 // scroll immediately. 1966 // scroll immediately.
1965 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 1967 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
1966 if (!layout_view_item.IsNull() && layout_view_item.NeedsLayout()) 1968 if (!layout_view_item.IsNull() && layout_view_item.NeedsLayout())
1967 UpdateLayout(); 1969 UpdateLayout();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 } 2003 }
2002 2004
2003 IntSize FrameView::GetLayoutSize( 2005 IntSize FrameView::GetLayoutSize(
2004 IncludeScrollbarsInRect scrollbar_inclusion) const { 2006 IncludeScrollbarsInRect scrollbar_inclusion) const {
2005 return scrollbar_inclusion == kExcludeScrollbars 2007 return scrollbar_inclusion == kExcludeScrollbars
2006 ? ExcludeScrollbars(layout_size_) 2008 ? ExcludeScrollbars(layout_size_)
2007 : layout_size_; 2009 : layout_size_;
2008 } 2010 }
2009 2011
2010 void FrameView::SetLayoutSize(const IntSize& size) { 2012 void FrameView::SetLayoutSize(const IntSize& size) {
2011 ASSERT(!LayoutSizeFixedToFrameSize()); 2013 DCHECK(!LayoutSizeFixedToFrameSize());
2012 2014
2013 SetLayoutSizeInternal(size); 2015 SetLayoutSizeInternal(size);
2014 } 2016 }
2015 2017
2016 void FrameView::DidScrollTimerFired(TimerBase*) { 2018 void FrameView::DidScrollTimerFired(TimerBase*) {
2017 if (frame_->GetDocument() && 2019 if (frame_->GetDocument() &&
2018 !frame_->GetDocument()->GetLayoutViewItem().IsNull()) 2020 !frame_->GetDocument()->GetLayoutViewItem().IsNull())
2019 frame_->GetDocument()->Fetcher()->UpdateAllImageResourcePriorities(); 2021 frame_->GetDocument()->Fetcher()->UpdateAllImageResourcePriorities();
2020 } 2022 }
2021 2023
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 return true; 2105 return true;
2104 } 2106 }
2105 2107
2106 void FrameView::UpdateCompositedSelectionIfNeeded() { 2108 void FrameView::UpdateCompositedSelectionIfNeeded() {
2107 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) 2109 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled())
2108 return; 2110 return;
2109 2111
2110 TRACE_EVENT0("blink", "FrameView::updateCompositedSelectionIfNeeded"); 2112 TRACE_EVENT0("blink", "FrameView::updateCompositedSelectionIfNeeded");
2111 2113
2112 Page* page = GetFrame().GetPage(); 2114 Page* page = GetFrame().GetPage();
2113 ASSERT(page); 2115 DCHECK(page);
2114 2116
2115 CompositedSelection selection; 2117 CompositedSelection selection;
2116 LocalFrame* focused_frame = page->GetFocusController().FocusedFrame(); 2118 LocalFrame* focused_frame = page->GetFocusController().FocusedFrame();
2117 LocalFrame* local_frame = 2119 LocalFrame* local_frame =
2118 (focused_frame && 2120 (focused_frame &&
2119 (focused_frame->LocalFrameRoot() == frame_->LocalFrameRoot())) 2121 (focused_frame->LocalFrameRoot() == frame_->LocalFrameRoot()))
2120 ? focused_frame 2122 ? focused_frame
2121 : nullptr; 2123 : nullptr;
2122 2124
2123 if (local_frame && ComputeCompositedSelection(*local_frame, selection)) { 2125 if (local_frame && ComputeCompositedSelection(*local_frame, selection)) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 2518
2517 // Prevent plugins from causing infinite updates of themselves. 2519 // Prevent plugins from causing infinite updates of themselves.
2518 // FIXME: Do we really need to prevent this? 2520 // FIXME: Do we really need to prevent this?
2519 part_update_set_.erase(&object); 2521 part_update_set_.erase(&object);
2520 } 2522 }
2521 2523
2522 return part_update_set_.IsEmpty(); 2524 return part_update_set_.IsEmpty();
2523 } 2525 }
2524 2526
2525 void FrameView::UpdatePluginsTimerFired(TimerBase*) { 2527 void FrameView::UpdatePluginsTimerFired(TimerBase*) {
2526 ASSERT(!IsInPerformLayout()); 2528 DCHECK(!IsInPerformLayout());
2527 for (unsigned i = 0; i < kMaxUpdatePluginsIterations; ++i) { 2529 for (unsigned i = 0; i < kMaxUpdatePluginsIterations; ++i) {
2528 if (UpdatePlugins()) 2530 if (UpdatePlugins())
2529 return; 2531 return;
2530 } 2532 }
2531 } 2533 }
2532 2534
2533 void FrameView::FlushAnyPendingPostLayoutTasks() { 2535 void FrameView::FlushAnyPendingPostLayoutTasks() {
2534 ASSERT(!IsInPerformLayout()); 2536 DCHECK(!IsInPerformLayout());
2535 if (post_layout_tasks_timer_.IsActive()) 2537 if (post_layout_tasks_timer_.IsActive())
2536 PerformPostLayoutTasks(); 2538 PerformPostLayoutTasks();
2537 if (update_plugins_timer_.IsActive()) { 2539 if (update_plugins_timer_.IsActive()) {
2538 update_plugins_timer_.Stop(); 2540 update_plugins_timer_.Stop();
2539 UpdatePluginsTimerFired(nullptr); 2541 UpdatePluginsTimerFired(nullptr);
2540 } 2542 }
2541 } 2543 }
2542 2544
2543 void FrameView::ScheduleUpdatePluginsIfNecessary() { 2545 void FrameView::ScheduleUpdatePluginsIfNecessary() {
2544 ASSERT(!IsInPerformLayout()); 2546 DCHECK(!IsInPerformLayout());
2545 if (update_plugins_timer_.IsActive() || part_update_set_.IsEmpty()) 2547 if (update_plugins_timer_.IsActive() || part_update_set_.IsEmpty())
2546 return; 2548 return;
2547 update_plugins_timer_.StartOneShot(0, BLINK_FROM_HERE); 2549 update_plugins_timer_.StartOneShot(0, BLINK_FROM_HERE);
2548 } 2550 }
2549 2551
2550 void FrameView::PerformPostLayoutTasks() { 2552 void FrameView::PerformPostLayoutTasks() {
2551 // FIXME: We can reach here, even when the page is not active! 2553 // FIXME: We can reach here, even when the page is not active!
2552 // http/tests/inspector/elements/html-link-import.html and many other 2554 // http/tests/inspector/elements/html-link-import.html and many other
2553 // tests hit that case. 2555 // tests hit that case.
2554 // We should ASSERT(isActive()); or at least return early if we can! 2556 // We should DCHECK(isActive()); or at least return early if we can!
2555 2557
2556 // Always called before or after performLayout(), part of the highest-level 2558 // Always called before or after performLayout(), part of the highest-level
2557 // layout() call. 2559 // layout() call.
2558 ASSERT(!IsInPerformLayout()); 2560 DCHECK(!IsInPerformLayout());
2559 TRACE_EVENT0("blink,benchmark", "FrameView::performPostLayoutTasks"); 2561 TRACE_EVENT0("blink,benchmark", "FrameView::performPostLayoutTasks");
2560 2562
2561 post_layout_tasks_timer_.Stop(); 2563 post_layout_tasks_timer_.Stop();
2562 2564
2563 frame_->Selection().DidLayout(); 2565 frame_->Selection().DidLayout();
2564 2566
2565 ASSERT(frame_->GetDocument()); 2567 DCHECK(frame_->GetDocument());
2566 2568
2567 FontFaceSet::DidLayout(*frame_->GetDocument()); 2569 FontFaceSet::DidLayout(*frame_->GetDocument());
2568 // Cursor update scheduling is done by the local root, which is the main frame 2570 // Cursor update scheduling is done by the local root, which is the main frame
2569 // if there are no RemoteFrame ancestors in the frame tree. Use of 2571 // if there are no RemoteFrame ancestors in the frame tree. Use of
2570 // localFrameRoot() is discouraged but will change when cursor update 2572 // localFrameRoot() is discouraged but will change when cursor update
2571 // scheduling is moved from EventHandler to PageEventHandler. 2573 // scheduling is moved from EventHandler to PageEventHandler.
2572 GetFrame().LocalFrameRoot().GetEventHandler().ScheduleCursorUpdate(); 2574 GetFrame().LocalFrameRoot().GetEventHandler().ScheduleCursorUpdate();
2573 2575
2574 UpdateGeometries(); 2576 UpdateGeometries();
2575 2577
2576 // Plugins could have torn down the page inside updateGeometries(). 2578 // Plugins could have torn down the page inside updateGeometries().
2577 if (GetLayoutViewItem().IsNull()) 2579 if (GetLayoutViewItem().IsNull())
2578 return; 2580 return;
2579 2581
2580 ScheduleUpdatePluginsIfNecessary(); 2582 ScheduleUpdatePluginsIfNecessary();
2581 2583
2582 if (ScrollingCoordinator* scrolling_coordinator = 2584 if (ScrollingCoordinator* scrolling_coordinator =
2583 this->GetScrollingCoordinator()) 2585 this->GetScrollingCoordinator())
2584 scrolling_coordinator->NotifyGeometryChanged(); 2586 scrolling_coordinator->NotifyGeometryChanged();
2585 2587
2586 ScrollToFragmentAnchor(); 2588 ScrollToFragmentAnchor();
2587 SendResizeEventIfNeeded(); 2589 SendResizeEventIfNeeded();
2588 } 2590 }
2589 2591
2590 bool FrameView::WasViewportResized() { 2592 bool FrameView::WasViewportResized() {
2591 ASSERT(frame_); 2593 DCHECK(frame_);
2592 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 2594 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
2593 if (layout_view_item.IsNull()) 2595 if (layout_view_item.IsNull())
2594 return false; 2596 return false;
2595 ASSERT(layout_view_item.Style()); 2597 DCHECK(layout_view_item.Style());
2596 return (GetLayoutSize(kIncludeScrollbars) != last_viewport_size_ || 2598 return (GetLayoutSize(kIncludeScrollbars) != last_viewport_size_ ||
2597 layout_view_item.Style()->Zoom() != last_zoom_factor_); 2599 layout_view_item.Style()->Zoom() != last_zoom_factor_);
2598 } 2600 }
2599 2601
2600 void FrameView::SendResizeEventIfNeeded() { 2602 void FrameView::SendResizeEventIfNeeded() {
2601 ASSERT(frame_); 2603 DCHECK(frame_);
2602 2604
2603 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 2605 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
2604 if (layout_view_item.IsNull() || layout_view_item.GetDocument().Printing()) 2606 if (layout_view_item.IsNull() || layout_view_item.GetDocument().Printing())
2605 return; 2607 return;
2606 2608
2607 if (!WasViewportResized()) 2609 if (!WasViewportResized())
2608 return; 2610 return;
2609 2611
2610 last_viewport_size_ = GetLayoutSize(kIncludeScrollbars); 2612 last_viewport_size_ = GetLayoutSize(kIncludeScrollbars);
2611 last_zoom_factor_ = layout_view_item.Style()->Zoom(); 2613 last_zoom_factor_ = layout_view_item.Style()->Zoom();
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 } 3253 }
3252 3254
3253 void FrameView::PaintTree() { 3255 void FrameView::PaintTree() {
3254 TRACE_EVENT0("blink", "FrameView::paintTree"); 3256 TRACE_EVENT0("blink", "FrameView::paintTree");
3255 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Paint.UpdateTime"); 3257 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Paint.UpdateTime");
3256 3258
3257 ASSERT(GetFrame() == GetPage()->MainFrame() || 3259 ASSERT(GetFrame() == GetPage()->MainFrame() ||
3258 (!GetFrame().Tree().Parent()->IsLocalFrame())); 3260 (!GetFrame().Tree().Parent()->IsLocalFrame()));
3259 3261
3260 LayoutViewItem view = GetLayoutViewItem(); 3262 LayoutViewItem view = GetLayoutViewItem();
3261 ASSERT(!view.IsNull()); 3263 DCHECK(!view.IsNull());
3262 ForAllNonThrottledFrameViews([](FrameView& frame_view) { 3264 ForAllNonThrottledFrameViews([](FrameView& frame_view) {
3263 frame_view.Lifecycle().AdvanceTo(DocumentLifecycle::kInPaint); 3265 frame_view.Lifecycle().AdvanceTo(DocumentLifecycle::kInPaint);
3264 }); 3266 });
3265 3267
3266 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 3268 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
3267 if (GetLayoutView()->Layer()->NeedsRepaint()) { 3269 if (GetLayoutView()->Layer()->NeedsRepaint()) {
3268 GraphicsContext graphics_context(*paint_controller_); 3270 GraphicsContext graphics_context(*paint_controller_);
3269 if (RuntimeEnabledFeatures::printBrowserEnabled()) 3271 if (RuntimeEnabledFeatures::printBrowserEnabled())
3270 graphics_context.SetPrinting(true); 3272 graphics_context.SetPrinting(true);
3271 Paint(graphics_context, CullRect(LayoutRect::InfiniteIntRect())); 3273 Paint(graphics_context, CullRect(LayoutRect::InfiniteIntRect()));
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
3803 void FrameView::RemoveResizerArea(LayoutBox& resizer_box) { 3805 void FrameView::RemoveResizerArea(LayoutBox& resizer_box) {
3804 if (!resizer_areas_) 3806 if (!resizer_areas_)
3805 return; 3807 return;
3806 3808
3807 ResizerAreaSet::iterator it = resizer_areas_->find(&resizer_box); 3809 ResizerAreaSet::iterator it = resizer_areas_->find(&resizer_box);
3808 if (it != resizer_areas_->end()) 3810 if (it != resizer_areas_->end())
3809 resizer_areas_->erase(it); 3811 resizer_areas_->erase(it);
3810 } 3812 }
3811 3813
3812 void FrameView::AddScrollableArea(ScrollableArea* scrollable_area) { 3814 void FrameView::AddScrollableArea(ScrollableArea* scrollable_area) {
3813 ASSERT(scrollable_area); 3815 DCHECK(scrollable_area);
3814 if (!scrollable_areas_) 3816 if (!scrollable_areas_)
3815 scrollable_areas_ = new ScrollableAreaSet; 3817 scrollable_areas_ = new ScrollableAreaSet;
3816 scrollable_areas_->insert(scrollable_area); 3818 scrollable_areas_->insert(scrollable_area);
3817 3819
3818 if (ScrollingCoordinator* scrolling_coordinator = 3820 if (ScrollingCoordinator* scrolling_coordinator =
3819 this->GetScrollingCoordinator()) 3821 this->GetScrollingCoordinator())
3820 scrolling_coordinator->ScrollableAreasDidChange(); 3822 scrolling_coordinator->ScrollableAreasDidChange();
3821 } 3823 }
3822 3824
3823 void FrameView::RemoveScrollableArea(ScrollableArea* scrollable_area) { 3825 void FrameView::RemoveScrollableArea(ScrollableArea* scrollable_area) {
3824 if (!scrollable_areas_) 3826 if (!scrollable_areas_)
3825 return; 3827 return;
3826 scrollable_areas_->erase(scrollable_area); 3828 scrollable_areas_->erase(scrollable_area);
3827 3829
3828 if (ScrollingCoordinator* scrolling_coordinator = 3830 if (ScrollingCoordinator* scrolling_coordinator =
3829 this->GetScrollingCoordinator()) 3831 this->GetScrollingCoordinator())
3830 scrolling_coordinator->ScrollableAreasDidChange(); 3832 scrolling_coordinator->ScrollableAreasDidChange();
3831 } 3833 }
3832 3834
3833 void FrameView::AddAnimatingScrollableArea(ScrollableArea* scrollable_area) { 3835 void FrameView::AddAnimatingScrollableArea(ScrollableArea* scrollable_area) {
3834 ASSERT(scrollable_area); 3836 DCHECK(scrollable_area);
3835 if (!animating_scrollable_areas_) 3837 if (!animating_scrollable_areas_)
3836 animating_scrollable_areas_ = new ScrollableAreaSet; 3838 animating_scrollable_areas_ = new ScrollableAreaSet;
3837 animating_scrollable_areas_->insert(scrollable_area); 3839 animating_scrollable_areas_->insert(scrollable_area);
3838 } 3840 }
3839 3841
3840 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) { 3842 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) {
3841 if (!animating_scrollable_areas_) 3843 if (!animating_scrollable_areas_)
3842 return; 3844 return;
3843 animating_scrollable_areas_->erase(scrollable_area); 3845 animating_scrollable_areas_->erase(scrollable_area);
3844 } 3846 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
4275 if (old_rect != VerticalScrollbar()->FrameRect()) 4277 if (old_rect != VerticalScrollbar()->FrameRect())
4276 SetScrollbarNeedsPaintInvalidation(kVerticalScrollbar); 4278 SetScrollbarNeedsPaintInvalidation(kVerticalScrollbar);
4277 4279
4278 VerticalScrollbar()->SetProportion(VisibleHeight(), ContentsHeight()); 4280 VerticalScrollbar()->SetProportion(VisibleHeight(), ContentsHeight());
4279 VerticalScrollbar()->OffsetDidChange(); 4281 VerticalScrollbar()->OffsetDidChange();
4280 } 4282 }
4281 } 4283 }
4282 4284
4283 bool FrameView::AdjustScrollbarExistence( 4285 bool FrameView::AdjustScrollbarExistence(
4284 ComputeScrollbarExistenceOption option) { 4286 ComputeScrollbarExistenceOption option) {
4285 ASSERT(in_update_scrollbars_); 4287 DCHECK(in_update_scrollbars_);
4286 4288
4287 // If we came in here with the view already needing a layout, then go ahead 4289 // If we came in here with the view already needing a layout, then go ahead
4288 // and do that first. (This will be the common case, e.g., when the page 4290 // and do that first. (This will be the common case, e.g., when the page
4289 // changes due to window resizing for example). This layout will not re-enter 4291 // changes due to window resizing for example). This layout will not re-enter
4290 // updateScrollbars and does not count towards our max layout pass total. 4292 // updateScrollbars and does not count towards our max layout pass total.
4291 if (!scrollbars_suppressed_) 4293 if (!scrollbars_suppressed_)
4292 ScrollbarExistenceDidChange(); 4294 ScrollbarExistenceDidChange();
4293 4295
4294 bool has_horizontal_scrollbar = HorizontalScrollbar(); 4296 bool has_horizontal_scrollbar = HorizontalScrollbar();
4295 bool has_vertical_scrollbar = VerticalScrollbar(); 4297 bool has_vertical_scrollbar = VerticalScrollbar();
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 void FrameView::SetAnimationHost( 5388 void FrameView::SetAnimationHost(
5387 std::unique_ptr<CompositorAnimationHost> host) { 5389 std::unique_ptr<CompositorAnimationHost> host) {
5388 animation_host_ = std::move(host); 5390 animation_host_ = std::move(host);
5389 } 5391 }
5390 5392
5391 LayoutUnit FrameView::CaretWidth() const { 5393 LayoutUnit FrameView::CaretWidth() const {
5392 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5394 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5393 } 5395 }
5394 5396
5395 } // namespace blink 5397 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/frame/FrameViewAutoSizeInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698