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() ); | |
esprehn
2014/03/15 02:19:42
This is not correct, you need to check !document()
| |
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 // Optimize layout in horizontal writing mode only to simplify the logic. | |
1021 if (!style()->isHorizontalWritingMode()) | |
1022 return false; | |
1023 | |
1024 if (hasPercentHeightDescendants()) | |
1025 return false; | |
1026 | |
1027 // Needs full layout if there is no body element (e.g. there is frameset who se layout is almost always | |
1028 // affected by the view size. | |
1029 Element* body = document().body(); | |
1030 if (!body || !body->hasTagName(HTMLNames::bodyTag)) | |
1031 return false; | |
1032 | |
1033 // Root background image may be stretched related to the viewport size. | |
1034 Element* documentElement = document().documentElement(); | |
1035 if (!documentElement || !documentElement->renderer() | |
1036 || documentElement->renderer()->rendererForRootBackground()->style()->ha sBackgroundImage()) | |
1037 return false; | |
1038 | |
1039 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) { | |
1040 TrackedRendererListHashSet::iterator end = positionedObjects->end(); | |
1041 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) { | |
1042 if ((*it)->node() && (*it)->node()->hasTagName(HTMLNames::dialogTag) ) | |
esprehn
2014/03/15 02:19:42
Special casing dialog is wrong, why are you doing
| |
1043 return false; | |
1044 | |
1045 RenderStyle* childStyle = (*it)->style(); | |
1046 if (childStyle->top().isPercent() || childStyle->height().isPercent( ) || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto()) | |
esprehn
2014/03/15 02:19:42
This should be a method, the check is really hard
| |
1047 return false; | |
1048 } | |
1049 } | |
1050 | |
1051 // Do a simplified layout on height change. | |
1052 | |
1053 // If the height is decreasing and the view isn't vertically scrollable, we need to recompute the overflow. | |
1054 LayoutRect layoutOverflow = layoutOverflowRect(); | |
1055 bool needsRecomputeOverflow = layoutOverflow.maxY() <= noOverflowRect().maxY () && viewHeight() < height(); | |
1056 | |
1057 setHeight(viewHeight()); | |
1058 | |
1059 if (needsRecomputeOverflow) { | |
1060 LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layout ClientAfterEdge() : clientLogicalBottom(); | |
1061 computeOverflow(oldClientAfterEdge, false); | |
1062 } else { | |
1063 // Size of layout overflow is unchanged. However change of height may ca use creating or destroying m_overflow. | |
1064 // following code mimics the normal layout for overflow. | |
1065 // Visual overflow will be automatically updated when m_overflow is recr eated when needed in addLayoutOverflow(). | |
1066 m_overflow.clear(); | |
1067 addLayoutOverflow(layoutOverflow); | |
1068 } | |
1069 | |
1070 // FIXME: There may be a more efficient way to resize the root layer and rep aint the exposed area. | |
1071 layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags) ; | |
1072 | |
1073 return true; | |
1074 } | |
1075 | |
1000 } // namespace WebCore | 1076 } // namespace WebCore |
OLD | NEW |