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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: actually fix zoom handling Created 7 years 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) 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) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 2896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 if (!hasPercentHeightDescendant(box)) 2907 if (!hasPercentHeightDescendant(box))
2908 continue; 2908 continue;
2909 2909
2910 removePercentHeightDescendant(box); 2910 removePercentHeightDescendant(box);
2911 } 2911 }
2912 } 2912 }
2913 2913
2914 LayoutUnit RenderBlock::textIndentOffset() const 2914 LayoutUnit RenderBlock::textIndentOffset() const
2915 { 2915 {
2916 LayoutUnit cw = 0; 2916 LayoutUnit cw = 0;
2917 RenderView* renderView = 0;
2918 if (style()->textIndent().isPercent()) 2917 if (style()->textIndent().isPercent())
2919 cw = containingBlock()->availableLogicalWidth(); 2918 cw = containingBlock()->availableLogicalWidth();
2920 else if (style()->textIndent().isViewportPercentage()) 2919 return minimumValueForLength(style()->textIndent(), cw);
2921 renderView = view();
2922 return minimumValueForLength(style()->textIndent(), cw, renderView);
2923 } 2920 }
2924 2921
2925 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const 2922 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const
2926 { 2923 {
2927 LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLe ft() + paddingLeft() : borderTop() + paddingTop(); 2924 LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLe ft() + paddingLeft() : borderTop() + paddingTop();
2928 if (!region) 2925 if (!region)
2929 return logicalLeftOffset; 2926 return logicalLeftOffset;
2930 LayoutRect boxRect = borderBoxRectInRegion(region); 2927 LayoutRect boxRect = borderBoxRectInRegion(region);
2931 return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRec t.y()); 2928 return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRec t.y());
2932 } 2929 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 } else if (hitTestColumns(request, result, locationInContainer, toLayout Point(scrolledOffset), hitTestAction)) { 3112 } else if (hitTestColumns(request, result, locationInContainer, toLayout Point(scrolledOffset), hitTestAction)) {
3116 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset)); 3113 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset));
3117 return true; 3114 return true;
3118 } 3115 }
3119 } 3116 }
3120 3117
3121 // Check if the point is outside radii. 3118 // Check if the point is outside radii.
3122 if (!isRenderView() && style()->hasBorderRadius()) { 3119 if (!isRenderView() && style()->hasBorderRadius()) {
3123 LayoutRect borderRect = borderBoxRect(); 3120 LayoutRect borderRect = borderBoxRect();
3124 borderRect.moveBy(adjustedLocation); 3121 borderRect.moveBy(adjustedLocation);
3125 RoundedRect border = style()->getRoundedBorderFor(borderRect, view()); 3122 RoundedRect border = style()->getRoundedBorderFor(borderRect);
3126 if (!locationInContainer.intersects(border)) 3123 if (!locationInContainer.intersects(border))
3127 return false; 3124 return false;
3128 } 3125 }
3129 3126
3130 // Now hit test our background 3127 // Now hit test our background
3131 if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChild BlockBackground) { 3128 if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChild BlockBackground) {
3132 LayoutRect boundsRect(adjustedLocation, size()); 3129 LayoutRect boundsRect(adjustedLocation, size());
3133 if (visibleToHitTestRequest(request) && locationInContainer.intersects(b oundsRect)) { 3130 if (visibleToHitTestRequest(request) && locationInContainer.intersects(b oundsRect)) {
3134 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset)); 3131 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset));
3135 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect)) 3132 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, locationInContainer, boundsRect))
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4097 bool autoWrap, oldAutoWrap; 4094 bool autoWrap, oldAutoWrap;
4098 autoWrap = oldAutoWrap = styleToUse->autoWrap(); 4095 autoWrap = oldAutoWrap = styleToUse->autoWrap();
4099 4096
4100 InlineMinMaxIterator childIterator(this); 4097 InlineMinMaxIterator childIterator(this);
4101 4098
4102 // Only gets added to the max preffered width once. 4099 // Only gets added to the max preffered width once.
4103 bool addedTextIndent = false; 4100 bool addedTextIndent = false;
4104 // Signals the text indent was more negative than the min preferred width 4101 // Signals the text indent was more negative than the min preferred width
4105 bool hasRemainingNegativeTextIndent = false; 4102 bool hasRemainingNegativeTextIndent = false;
4106 4103
4107 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw, view()); 4104 LayoutUnit textIndent = minimumValueForLength(styleToUse->textIndent(), cw);
4108 RenderObject* prevFloat = 0; 4105 RenderObject* prevFloat = 0;
4109 bool isPrevChildInlineFlow = false; 4106 bool isPrevChildInlineFlow = false;
4110 bool shouldBreakLineAfterText = false; 4107 bool shouldBreakLineAfterText = false;
4111 while (RenderObject* child = childIterator.next()) { 4108 while (RenderObject* child = childIterator.next()) {
4112 autoWrap = child->isReplaced() ? child->parent()->style()->autoWrap() : 4109 autoWrap = child->isReplaced() ? child->parent()->style()->autoWrap() :
4113 child->style()->autoWrap(); 4110 child->style()->autoWrap();
4114 4111
4115 if (!child->isBR()) { 4112 if (!child->isBR()) {
4116 // Step One: determine whether or not we need to go ahead and 4113 // Step One: determine whether or not we need to go ahead and
4117 // terminate our current line. Each discrete chunk can become 4114 // terminate our current line. Each discrete chunk can become
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
4501 // Inline blocks are replaced elements. Otherwise, just pass off to 4498 // Inline blocks are replaced elements. Otherwise, just pass off to
4502 // the base class. If we're being queried as though we're the root line 4499 // the base class. If we're being queried as though we're the root line
4503 // box, then the fact that we're an inline-block is irrelevant, and we behav e 4500 // box, then the fact that we're an inline-block is irrelevant, and we behav e
4504 // just like a block. 4501 // just like a block.
4505 if (isReplaced() && linePositionMode == PositionOnContainingLine) 4502 if (isReplaced() && linePositionMode == PositionOnContainingLine)
4506 return RenderBox::lineHeight(firstLine, direction, linePositionMode); 4503 return RenderBox::lineHeight(firstLine, direction, linePositionMode);
4507 4504
4508 if (firstLine && document().styleEngine()->usesFirstLineRules()) { 4505 if (firstLine && document().styleEngine()->usesFirstLineRules()) {
4509 RenderStyle* s = style(firstLine); 4506 RenderStyle* s = style(firstLine);
4510 if (s != style()) 4507 if (s != style())
4511 return s->computedLineHeight(view()); 4508 return s->computedLineHeight();
4512 } 4509 }
4513 4510
4514 if (m_lineHeight == -1) 4511 if (m_lineHeight == -1)
4515 m_lineHeight = style()->computedLineHeight(view()); 4512 m_lineHeight = style()->computedLineHeight();
4516 4513
4517 return m_lineHeight; 4514 return m_lineHeight;
4518 } 4515 }
4519 4516
4520 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin eDirectionMode direction, LinePositionMode linePositionMode) const 4517 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin eDirectionMode direction, LinePositionMode linePositionMode) const
4521 { 4518 {
4522 // Inline blocks are replaced elements. Otherwise, just pass off to 4519 // Inline blocks are replaced elements. Otherwise, just pass off to
4523 // the base class. If we're being queried as though we're the root line 4520 // the base class. If we're being queried as though we're the root line
4524 // box, then the fact that we're an inline-block is irrelevant, and we behav e 4521 // box, then the fact that we're an inline-block is irrelevant, and we behav e
4525 // just like a block. 4522 // just like a block.
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
5816 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5813 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5817 { 5814 {
5818 showRenderObject(); 5815 showRenderObject();
5819 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5816 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5820 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5817 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5821 } 5818 }
5822 5819
5823 #endif 5820 #endif
5824 5821
5825 } // namespace WebCore 5822 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698