OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
990 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 990 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
991 return viewWidth(IncludeScrollbars) / scale; | 991 return viewWidth(IncludeScrollbars) / scale; |
992 } | 992 } |
993 | 993 |
994 double RenderView::layoutViewportHeight() const | 994 double RenderView::layoutViewportHeight() const |
995 { | 995 { |
996 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; | 996 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; |
997 return viewHeight(IncludeScrollbars) / scale; | 997 return viewHeight(IncludeScrollbars) / scale; |
998 } | 998 } |
999 | 999 |
1000 bool RenderView::trySimplifiedLayoutOnHeightChange() | |
1001 { | |
1002 // FIXME: Move logics that are generic to RenderBox or RenderBlock into thes e classes | |
1003 // so that this function can be also used to optimize layout of them. | |
1004 | |
1005 // The style must be up-to-date. | |
1006 ASSERT(!document().needsStyleRecalc() && !document().childNeedsStyleRecalc() ); | |
1007 | |
1008 // Don't need to check viewport media queries or viewport sizes here, becaus e they are | |
1009 // handled before and during style recalc which should happen before this fu nction is called. | |
1010 | |
1011 // Quicks mode has different layout rules on view size change, e.g. the heig ht of <body> and | |
1012 // percent height descendants etc. To avoid simplified layout from being too complex, fallback | |
1013 // to full layout. | |
1014 if (document().inQuirksMode()) | |
1015 return false; | |
1016 | |
1017 if (document().paginated() || shouldUsePrintingLayout()) | |
1018 return false; | |
1019 | |
1020 // If the height is decreasing and the view isn't vertically scrollable, fal lback to | |
1021 // full layout to calculate the new layout overflow rect. | |
1022 LayoutRect layoutOverflow = layoutOverflowRect(); | |
1023 if (layoutOverflow.maxY() <= noOverflowRect().maxY() && viewHeight() < heigh t()) | |
1024 return false; | |
1025 | |
1026 // Update style to ensure the following checks to access up-to-date styles. | |
1027 document().updateStyleIfNeeded(); | |
Julien - ping for review
2014/03/11 01:23:37
Isn't this line contrary with the ASSERT above abo
Xianzhu
2014/03/11 19:05:13
Sorry. I added the code and later meant to move th
| |
1028 if (needsLayout()) | |
1029 return false; | |
1030 | |
1031 // Optimize layout in horizontal writing mode only to simplify the logic. | |
1032 if (!style()->isHorizontalWritingMode()) | |
1033 return false; | |
1034 | |
1035 if (hasPercentHeightDescendants()) | |
1036 return false; | |
1037 | |
1038 // Needs full layout if there is no body element (e.g. there is frameset who se layout is almost always | |
1039 // affected by the view size. | |
1040 Element* body = document().body(); | |
1041 if (!body || !body->hasTagName(HTMLNames::bodyTag)) | |
1042 return false; | |
1043 | |
1044 // Root background image may be stretched related to the viewport size. | |
1045 Element* documentElement = document().documentElement(); | |
1046 if (!documentElement || !documentElement->renderer() | |
1047 || documentElement->renderer()->rendererForRootBackground()->style()->ha sBackgroundImage()) | |
1048 return false; | |
1049 | |
1050 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) { | |
1051 TrackedRendererListHashSet::iterator end = positionedObjects->end(); | |
1052 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) { | |
1053 if ((*it)->node() && (*it)->node()->hasTagName(HTMLNames::dialogTag) ) | |
1054 return false; | |
1055 | |
1056 RenderStyle* childStyle = (*it)->style(); | |
1057 // Fixed position element may change compositing state when viewport height changes. | |
1058 if (childStyle->position() == FixedPosition) | |
1059 return false; | |
Xianzhu
2014/03/11 19:05:13
Removed the above because fixed position layout ha
| |
1060 if (childStyle->top().isPercent() || childStyle->height().isPercent( ) || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto()) | |
1061 return false; | |
1062 } | |
1063 } | |
1064 | |
1065 // Do a simplified layout on height change. | |
1066 setHeight(viewHeight()); | |
1067 | |
1068 // During a normal layout, change of height may cause creating or destroying the overflow. | |
1069 // The following code mimics the normal layout for overflow. | |
1070 m_overflow.clear(); | |
1071 addLayoutOverflow(layoutOverflow); | |
Julien - ping for review
2014/03/11 01:23:37
It's weird that you don't also add visual overflow
Xianzhu
2014/03/11 19:05:13
Actually I didn't notice it, so for cases needing
| |
1072 | |
1073 // FIXME: There may be a more efficient way to adjust the size of the root l ayer. | |
1074 layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags) ; | |
Julien - ping for review
2014/03/11 01:23:37
updateLayerPositions will recurse into all the lay
Xianzhu
2014/03/11 19:05:13
The repaints caused by layer resizing and exposing
| |
1075 | |
1076 return true; | |
1077 } | |
1078 | |
1000 } // namespace WebCore | 1079 } // namespace WebCore |
OLD | NEW |