OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 5046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5057 | 5057 |
5058 DISABLE_CFI_PERF | 5058 DISABLE_CFI_PERF |
5059 void LayoutBox::AddOverflowFromChild(const LayoutBox& child, | 5059 void LayoutBox::AddOverflowFromChild(const LayoutBox& child, |
5060 const LayoutSize& delta) { | 5060 const LayoutSize& delta) { |
5061 // Never allow flow threads to propagate overflow up to a parent. | 5061 // Never allow flow threads to propagate overflow up to a parent. |
5062 if (child.IsLayoutFlowThread()) | 5062 if (child.IsLayoutFlowThread()) |
5063 return; | 5063 return; |
5064 | 5064 |
5065 // Only propagate layout overflow from the child if the child isn't clipping | 5065 // Only propagate layout overflow from the child if the child isn't clipping |
5066 // its overflow. If it is, then its overflow is internal to it, and we don't | 5066 // its overflow. If it is, then its overflow is internal to it, and we don't |
5067 // care about it. layoutOverflowRectForPropagation takes care of this and just | 5067 // care about it. LayoutOverflowRectForPropagation takes care of this and just |
5068 // propagates the border box rect instead. | 5068 // propagates the border box rect instead. |
5069 LayoutRect child_layout_overflow_rect = | 5069 LayoutRect child_layout_overflow_rect = |
5070 child.LayoutOverflowRectForPropagation(StyleRef()); | 5070 child.LayoutOverflowRectForPropagation(); |
5071 child_layout_overflow_rect.Move(delta); | 5071 child_layout_overflow_rect.Move(delta); |
5072 AddLayoutOverflow(child_layout_overflow_rect); | 5072 AddLayoutOverflow(child_layout_overflow_rect); |
5073 | 5073 |
5074 // Add in visual overflow from the child. Even if the child clips its | 5074 // Add in visual overflow from the child. Even if the child clips its |
5075 // overflow, it may still have visual overflow of its own set from box shadows | 5075 // overflow, it may still have visual overflow of its own set from box shadows |
5076 // or reflections. It is unnecessary to propagate this overflow if we are | 5076 // or reflections. It is unnecessary to propagate this overflow if we are |
5077 // clipping our own overflow. | 5077 // clipping our own overflow. |
5078 if (child.HasSelfPaintingLayer()) | 5078 if (child.HasSelfPaintingLayer()) |
5079 return; | 5079 return; |
5080 LayoutRect child_visual_overflow_rect = | 5080 LayoutRect child_visual_overflow_rect = |
5081 child.VisualOverflowRectForPropagation(StyleRef()); | 5081 child.VisualOverflowRectForPropagation(); |
5082 child_visual_overflow_rect.Move(delta); | 5082 child_visual_overflow_rect.Move(delta); |
5083 AddContentsVisualOverflow(child_visual_overflow_rect); | 5083 AddContentsVisualOverflow(child_visual_overflow_rect); |
5084 } | 5084 } |
5085 | 5085 |
5086 bool LayoutBox::HasTopOverflow() const { | 5086 bool LayoutBox::HasTopOverflow() const { |
5087 return !Style()->IsLeftToRightDirection() && !IsHorizontalWritingMode(); | 5087 return !Style()->IsLeftToRightDirection() && !IsHorizontalWritingMode(); |
5088 } | 5088 } |
5089 | 5089 |
5090 bool LayoutBox::HasLeftOverflow() const { | 5090 bool LayoutBox::HasLeftOverflow() const { |
5091 return !Style()->IsLeftToRightDirection() && IsHorizontalWritingMode(); | 5091 return !Style()->IsLeftToRightDirection() && IsHorizontalWritingMode(); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5269 while (curr) { | 5269 while (curr) { |
5270 PaintLayer* layer = | 5270 PaintLayer* layer = |
5271 curr->HasLayer() && curr->IsBox() ? ToLayoutBox(curr)->Layer() : 0; | 5271 curr->HasLayer() && curr->IsBox() ? ToLayoutBox(curr)->Layer() : 0; |
5272 if (layer && layer->IsSelfPaintingLayer()) | 5272 if (layer && layer->IsSelfPaintingLayer()) |
5273 return layer; | 5273 return layer; |
5274 curr = curr->Parent(); | 5274 curr = curr->Parent(); |
5275 } | 5275 } |
5276 return nullptr; | 5276 return nullptr; |
5277 } | 5277 } |
5278 | 5278 |
5279 LayoutRect LayoutBox::LogicalVisualOverflowRectForPropagation( | 5279 LayoutRect LayoutBox::LogicalVisualOverflowRectForPropagation() const { |
5280 const ComputedStyle& parent_style) const { | 5280 LayoutRect rect = VisualOverflowRectForPropagation(); |
5281 LayoutRect rect = VisualOverflowRectForPropagation(parent_style); | 5281 if (!Parent()->StyleRef().IsHorizontalWritingMode()) |
5282 if (!parent_style.IsHorizontalWritingMode()) | |
5283 return rect.TransposedRect(); | 5282 return rect.TransposedRect(); |
5284 return rect; | 5283 return rect; |
5285 } | 5284 } |
5286 | 5285 |
5287 DISABLE_CFI_PERF | 5286 DISABLE_CFI_PERF |
5288 LayoutRect LayoutBox::VisualOverflowRectForPropagation( | 5287 LayoutRect LayoutBox::RectForOverflowPropagation(const LayoutRect& rect) const { |
5289 const ComputedStyle& parent_style) const { | 5288 // If the child and parent are in the same blocks direction, then we don't |
5290 // If the writing modes of the child and parent match, then we don't have to | 5289 // have to do anything fancy. Just return the rect. |
5291 // do anything fancy. Just return the result. | 5290 if (Parent()->StyleRef().IsFlippedBlocksWritingMode() == |
5292 LayoutRect rect = VisualOverflowRect(); | 5291 StyleRef().IsFlippedBlocksWritingMode()) |
5293 if (parent_style.GetWritingMode() == Style()->GetWritingMode()) | |
5294 return rect; | 5292 return rect; |
5295 | 5293 |
5296 // We are putting ourselves into our parent's coordinate space. If there is a | 5294 // Convert the rect into parent's blocks direction by flipping along the y |
5297 // flipped block mismatch in a particular axis, then we have to flip the rect | 5295 // axis. |
5298 // along that axis. | 5296 LayoutRect result = rect; |
5299 if (IsFlippedBlocksWritingMode(Style()->GetWritingMode()) || | 5297 result.SetX(Size().Width() - rect.MaxX()); |
5300 IsFlippedBlocksWritingMode(parent_style.GetWritingMode())) | 5298 return result; |
5301 rect.SetX(Size().Width() - rect.MaxX()); | |
5302 | |
5303 return rect; | |
5304 } | 5299 } |
5305 | 5300 |
5306 DISABLE_CFI_PERF | 5301 DISABLE_CFI_PERF |
5307 LayoutRect LayoutBox::LogicalLayoutOverflowRectForPropagation( | 5302 LayoutRect LayoutBox::LogicalLayoutOverflowRectForPropagation() const { |
5308 const ComputedStyle& parent_style) const { | 5303 LayoutRect rect = LayoutOverflowRectForPropagation(); |
5309 LayoutRect rect = LayoutOverflowRectForPropagation(parent_style); | 5304 if (!Parent()->StyleRef().IsHorizontalWritingMode()) |
5310 if (!parent_style.IsHorizontalWritingMode()) | |
5311 return rect.TransposedRect(); | 5305 return rect.TransposedRect(); |
5312 return rect; | 5306 return rect; |
5313 } | 5307 } |
5314 | 5308 |
5315 DISABLE_CFI_PERF | 5309 DISABLE_CFI_PERF |
5316 LayoutRect LayoutBox::LayoutOverflowRectForPropagation( | 5310 LayoutRect LayoutBox::LayoutOverflowRectForPropagation() const { |
5317 const ComputedStyle& parent_style) const { | |
5318 // Only propagate interior layout overflow if we don't clip it. | 5311 // Only propagate interior layout overflow if we don't clip it. |
5319 LayoutRect rect = BorderBoxRect(); | 5312 LayoutRect rect = BorderBoxRect(); |
5320 // We want to include the margin, but only when it adds height. Quirky margins | 5313 // We want to include the margin, but only when it adds height. Quirky margins |
5321 // don't contribute height nor do the margins of self-collapsing blocks. | 5314 // don't contribute height nor do the margins of self-collapsing blocks. |
5322 if (!StyleRef().HasMarginAfterQuirk() && !IsSelfCollapsingBlock()) | 5315 if (!StyleRef().HasMarginAfterQuirk() && !IsSelfCollapsingBlock()) |
5323 rect.Expand(IsHorizontalWritingMode() | 5316 rect.Expand(IsHorizontalWritingMode() |
5324 ? LayoutSize(LayoutUnit(), MarginAfter()) | 5317 ? LayoutSize(LayoutUnit(), MarginAfter()) |
5325 : LayoutSize(MarginAfter(), LayoutUnit())); | 5318 : LayoutSize(MarginAfter(), LayoutUnit())); |
5326 | 5319 |
5327 if (!HasOverflowClip()) | 5320 if (!HasOverflowClip()) |
5328 rect.Unite(LayoutOverflowRect()); | 5321 rect.Unite(LayoutOverflowRect()); |
5329 | 5322 |
5330 bool has_transform = HasLayer() && Layer()->Transform(); | 5323 bool has_transform = HasLayer() && Layer()->Transform(); |
5331 if (IsInFlowPositioned() || has_transform) { | 5324 if (IsInFlowPositioned() || has_transform) { |
5332 // If we are relatively positioned or if we have a transform, then we have | 5325 // If we are relatively positioned or if we have a transform, then we have |
5333 // to convert this rectangle into physical coordinates, apply relative | 5326 // to convert this rectangle into physical coordinates, apply relative |
5334 // positioning and transforms to it, and then convert it back. | 5327 // positioning and transforms to it, and then convert it back. |
5335 FlipForWritingMode(rect); | 5328 FlipForWritingMode(rect); |
5336 | 5329 |
5337 if (has_transform) | 5330 if (has_transform) |
5338 rect = Layer()->CurrentTransform().MapRect(rect); | 5331 rect = Layer()->CurrentTransform().MapRect(rect); |
5339 | 5332 |
5340 if (IsInFlowPositioned()) | 5333 if (IsInFlowPositioned()) |
5341 rect.Move(OffsetForInFlowPosition()); | 5334 rect.Move(OffsetForInFlowPosition()); |
5342 | 5335 |
5343 // Now we need to flip back. | 5336 // Now we need to flip back. |
5344 FlipForWritingMode(rect); | 5337 FlipForWritingMode(rect); |
5345 } | 5338 } |
5346 | 5339 |
5347 // If the writing modes of the child and parent match, then we don't have to | 5340 return RectForOverflowPropagation(rect); |
5348 // do anything fancy. Just return the result. | |
5349 if (parent_style.GetWritingMode() == Style()->GetWritingMode()) | |
5350 return rect; | |
5351 | |
5352 // We are putting ourselves into our parent's coordinate space. If there is a | |
5353 // flipped block mismatch in a particular axis, then we have to flip the rect | |
5354 // along that axis. | |
5355 if (IsFlippedBlocksWritingMode(Style()->GetWritingMode()) || | |
5356 IsFlippedBlocksWritingMode(parent_style.GetWritingMode())) | |
5357 rect.SetX(Size().Width() - rect.MaxX()); | |
5358 | |
5359 return rect; | |
5360 } | 5341 } |
5361 | 5342 |
5362 DISABLE_CFI_PERF | 5343 DISABLE_CFI_PERF |
5363 LayoutRect LayoutBox::NoOverflowRect() const { | 5344 LayoutRect LayoutBox::NoOverflowRect() const { |
5364 // Because of the special coordinate system used for overflow rectangles and | 5345 // Because of the special coordinate system used for overflow rectangles and |
5365 // many other rectangles (not quite logical, not quite physical), we need to | 5346 // many other rectangles (not quite logical, not quite physical), we need to |
5366 // flip the block progression coordinate in vertical-rl writing mode. In other | 5347 // flip the block progression coordinate in vertical-rl writing mode. In other |
5367 // words, the rectangle returned is physical, except for the block direction | 5348 // words, the rectangle returned is physical, except for the block direction |
5368 // progression coordinate (x in vertical writing mode), which is always | 5349 // progression coordinate (x in vertical writing mode), which is always |
5369 // "logical top". Apart from the flipping, this method does the same thing as | 5350 // "logical top". Apart from the flipping, this method does the same thing as |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5904 void LayoutBox::MutableForPainting:: | 5885 void LayoutBox::MutableForPainting:: |
5905 SavePreviousContentBoxSizeAndLayoutOverflowRect() { | 5886 SavePreviousContentBoxSizeAndLayoutOverflowRect() { |
5906 auto& rare_data = GetLayoutBox().EnsureRareData(); | 5887 auto& rare_data = GetLayoutBox().EnsureRareData(); |
5907 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; | 5888 rare_data.has_previous_content_box_size_and_layout_overflow_rect_ = true; |
5908 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); | 5889 rare_data.previous_content_box_size_ = GetLayoutBox().ContentBoxRect().Size(); |
5909 rare_data.previous_layout_overflow_rect_ = | 5890 rare_data.previous_layout_overflow_rect_ = |
5910 GetLayoutBox().LayoutOverflowRect(); | 5891 GetLayoutBox().LayoutOverflowRect(); |
5911 } | 5892 } |
5912 | 5893 |
5913 } // namespace blink | 5894 } // namespace blink |
OLD | NEW |