Chromium Code Reviews| 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 void RenderView::viewResized() | |
| 1001 { | |
| 1002 if (needsLayout()) | |
| 1003 return; | |
| 1004 | |
| 1005 if (width() != viewWidth() || !trySimplifiedLayoutOnHeightChange()) | |
| 1006 setNeedsLayout(); | |
| 1007 } | |
| 1008 | |
| 1009 bool RenderView::trySimplifiedLayoutOnHeightChange() | |
| 1010 { | |
| 1011 // FIXME: Move logics that are generic to RenderBox or RenderBlock into thes e classes | |
| 1012 // so that this function can be also used to optimize layout of them. | |
| 1013 | |
| 1014 if (document().inQuirksMode() || document().paginated() || shouldUsePrinting Layout()) | |
|
esprehn
2014/03/10 21:32:30
Why not in quirks?
Xianzhu
2014/03/11 00:55:13
Added comments.
| |
| 1015 return false; | |
| 1016 | |
| 1017 // Optimize layout in horizontal writing mode only to simplify the logic. | |
| 1018 if (!style()->isHorizontalWritingMode()) | |
| 1019 return false; | |
| 1020 | |
| 1021 if (hasPercentHeightDescendants()) | |
| 1022 return false; | |
| 1023 | |
| 1024 // If the height is decreasing and the view isn't vertically scrollable, fal lback to | |
| 1025 // full layout to calculate the new layout overflow rect. | |
| 1026 LayoutRect layoutOverflow = layoutOverflowRect(); | |
| 1027 if (layoutOverflow.maxY() <= noOverflowRect().maxY() && viewHeight() < heigh t()) | |
| 1028 return false; | |
| 1029 | |
| 1030 if (document().ensureStyleResolver().mediaQueryAffectedByViewportChange() || document().hasViewportUnits()) | |
|
esprehn
2014/03/10 21:32:30
Doesn't this exclude all responsive websites?
Xianzhu
2014/03/11 00:55:13
Optimized viewport media query and viewport sizes
| |
| 1031 return false; | |
| 1032 | |
| 1033 // Needs layout if there is no body element (e.g. there is frameset). | |
| 1034 Element* body = document().body(); | |
| 1035 if (!body || !body->hasTagName(HTMLNames::bodyTag)) | |
|
esprehn
2014/03/10 21:32:30
Why is frameset special?
Xianzhu
2014/03/11 00:55:13
Added comment.
| |
| 1036 return false; | |
| 1037 | |
| 1038 // Root background image may be stretched related to the viewport size. | |
| 1039 Element* documentElement = document().documentElement(); | |
| 1040 if (!documentElement || !documentElement->renderer() | |
| 1041 || documentElement->renderer()->rendererForRootBackground()->style()->ha sBackgroundImage()) | |
|
esprehn
2014/03/10 21:32:30
You can't do this, the style might be dirty and yo
Xianzhu
2014/03/11 00:55:13
Now update style in FrameView::setLayoutSizeIntern
| |
| 1042 return false; | |
| 1043 | |
| 1044 if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects( )) { | |
| 1045 TrackedRendererListHashSet::iterator end = positionedObjects->end(); | |
| 1046 for (TrackedRendererListHashSet::iterator it = positionedObjects->begin( ); it != end; ++it) { | |
| 1047 if ((*it)->node() && (*it)->node()->hasTagName(HTMLNames::dialogTag) ) | |
| 1048 return false; | |
| 1049 | |
| 1050 RenderStyle* childStyle = (*it)->style(); | |
| 1051 // Fixed position element may change compositing state when viewport height changes. | |
| 1052 if (childStyle->position() == FixedPosition) | |
| 1053 return false; | |
| 1054 if (childStyle->top().isPercent() || childStyle->height().isPercent( ) || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto()) | |
|
esprehn
2014/03/10 21:32:30
Same, you never updated style so this is all stale
Xianzhu
2014/03/11 00:55:13
Ditto.
| |
| 1055 return false; | |
| 1056 } | |
| 1057 } | |
| 1058 | |
| 1059 // Do a simplified layout on height change. | |
| 1060 setHeight(viewHeight()); | |
| 1061 | |
| 1062 // During a normal layout, change of height may cause creating or destroying the overflow. | |
| 1063 // The following code mimics the normal layout for overflow. | |
| 1064 m_overflow.clear(); | |
| 1065 addLayoutOverflow(layoutOverflow); | |
| 1066 | |
| 1067 // FIXME: There may be an more efficient way to adjust the size of the root layer. | |
| 1068 layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags) ; | |
| 1069 | |
| 1070 return true; | |
| 1071 } | |
| 1072 | |
| 1000 } // namespace WebCore | 1073 } // namespace WebCore |
| OLD | NEW |