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

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

Issue 197283025: Use new is*Element() helper functions more in rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 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. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 RenderBlock::removePositionedObject(this); 137 RenderBlock::removePositionedObject(this);
138 } 138 }
139 139
140 void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl e) 140 void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl e)
141 { 141 {
142 RenderStyle* oldStyle = style(); 142 RenderStyle* oldStyle = style();
143 if (oldStyle) { 143 if (oldStyle) {
144 // The background of the root element or the body element could propagat e up to 144 // The background of the root element or the body element could propagat e up to
145 // the canvas. Just dirty the entire canvas when our style changes subs tantially. 145 // the canvas. Just dirty the entire canvas when our style changes subs tantially.
146 if (diff >= StyleDifferenceRepaint && node() && 146 if (diff >= StyleDifferenceRepaint && node() &&
147 (node()->hasTagName(htmlTag) || node()->hasTagName(bodyTag))) { 147 (isHTMLHtmlElement(*node()) || isHTMLBodyElement(*node()))) {
148 view()->repaint(); 148 view()->repaint();
149 149
150 if (oldStyle->hasEntirelyFixedBackground() != newStyle->hasEntirelyF ixedBackground()) 150 if (oldStyle->hasEntirelyFixedBackground() != newStyle->hasEntirelyF ixedBackground())
151 view()->compositor()->rootFixedBackgroundsChanged(); 151 view()->compositor()->rootFixedBackgroundsChanged();
152 } 152 }
153 153
154 // When a layout hint happens and an object's position style changes, we have to do a layout 154 // When a layout hint happens and an object's position style changes, we have to do a layout
155 // to dirty the render tree using the old position value now. 155 // to dirty the render tree using the old position value now.
156 if (diff == StyleDifferenceLayout && parent() && oldStyle->position() != newStyle->position()) { 156 if (diff == StyleDifferenceLayout && parent() && oldStyle->position() != newStyle->position()) {
157 markContainingBlocksForLayout(); 157 markContainingBlocksForLayout();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 490 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
491 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 491 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
492 newRect = layer()->scrollableArea()->exposeRect(rect, alignX, alignY); 492 newRect = layer()->scrollableArea()->exposeRect(rect, alignX, alignY);
493 } else if (!parentBox && canBeProgramaticallyScrolled()) { 493 } else if (!parentBox && canBeProgramaticallyScrolled()) {
494 if (FrameView* frameView = this->frameView()) { 494 if (FrameView* frameView = this->frameView()) {
495 Element* ownerElement = document().ownerElement(); 495 Element* ownerElement = document().ownerElement();
496 496
497 if (ownerElement && ownerElement->renderer()) { 497 if (ownerElement && ownerElement->renderer()) {
498 HTMLFrameElementBase* frameElementBase = 0; 498 HTMLFrameElementBase* frameElementBase = 0;
499 499
500 if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagNa me(iframeTag)) 500 if (isHTMLFrameElement(*ownerElement) || isHTMLIFrameElement(*ow nerElement))
501 frameElementBase = toHTMLFrameElementBase(ownerElement); 501 frameElementBase = toHTMLFrameElementBase(ownerElement);
502 502
503 if (frameElementAndViewPermitScroll(frameElementBase, frameView) ) { 503 if (frameElementAndViewPermitScroll(frameElementBase, frameView) ) {
504 LayoutRect viewRect = frameView->visibleContentRect(); 504 LayoutRect viewRect = frameView->visibleContentRect();
505 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie wRect, rect, alignX, alignY); 505 LayoutRect exposeRect = ScrollAlignment::getRectToExpose(vie wRect, rect, alignX, alignY);
506 506
507 int xOffset = roundToInt(exposeRect.x()); 507 int xOffset = roundToInt(exposeRect.x());
508 int yOffset = roundToInt(exposeRect.y()); 508 int yOffset = roundToInt(exposeRect.y());
509 // Adjust offsets if they're outside of the allowable range. 509 // Adjust offsets if they're outside of the allowable range.
510 xOffset = max(0, min(frameView->contentsWidth(), xOffset)); 510 xOffset = max(0, min(frameView->contentsWidth(), xOffset));
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 setMarginStart(computedValues.m_margins.m_start); 2152 setMarginStart(computedValues.m_margins.m_start);
2153 setMarginEnd(computedValues.m_margins.m_end); 2153 setMarginEnd(computedValues.m_margins.m_end);
2154 } 2154 }
2155 2155
2156 static float getMaxWidthListMarker(const RenderBox* renderer) 2156 static float getMaxWidthListMarker(const RenderBox* renderer)
2157 { 2157 {
2158 #ifndef NDEBUG 2158 #ifndef NDEBUG
2159 ASSERT(renderer); 2159 ASSERT(renderer);
2160 Node* parentNode = renderer->generatingNode(); 2160 Node* parentNode = renderer->generatingNode();
2161 ASSERT(parentNode); 2161 ASSERT(parentNode);
2162 ASSERT(parentNode->hasTagName(olTag) || parentNode->hasTagName(ulTag)); 2162 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode));
2163 ASSERT(renderer->style()->textAutosizingMultiplier() != 1); 2163 ASSERT(renderer->style()->textAutosizingMultiplier() != 1);
2164 #endif 2164 #endif
2165 float maxWidth = 0; 2165 float maxWidth = 0;
2166 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) { 2166 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) {
2167 if (!child->isListItem()) 2167 if (!child->isListItem())
2168 continue; 2168 continue;
2169 2169
2170 RenderBox* listItem = toRenderBox(child); 2170 RenderBox* listItem = toRenderBox(child);
2171 for (RenderObject* itemChild = listItem->firstChild(); itemChild; itemCh ild = itemChild->nextSibling()) { 2171 for (RenderObject* itemChild = listItem->firstChild(); itemChild; itemCh ild = itemChild->nextSibling()) {
2172 if (!itemChild->isListMarker()) 2172 if (!itemChild->isListMarker())
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent - cb->marginStartForChild(this); 2261 LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent - cb->marginStartForChild(this);
2262 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty le()->isLeftToRightDirection(); 2262 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != sty le()->isLeftToRightDirection();
2263 if (hasInvertedDirection) 2263 if (hasInvertedDirection)
2264 computedValues.m_margins.m_start = newMargin; 2264 computedValues.m_margins.m_start = newMargin;
2265 else 2265 else
2266 computedValues.m_margins.m_end = newMargin; 2266 computedValues.m_margins.m_end = newMargin;
2267 } 2267 }
2268 2268
2269 if (styleToUse->textAutosizingMultiplier() != 1 && styleToUse->marginStart() .type() == Fixed) { 2269 if (styleToUse->textAutosizingMultiplier() != 1 && styleToUse->marginStart() .type() == Fixed) {
2270 Node* parentNode = generatingNode(); 2270 Node* parentNode = generatingNode();
2271 if (parentNode && (parentNode->hasTagName(olTag) || parentNode->hasTagNa me(ulTag))) { 2271 if (parentNode && (isHTMLOListElement(*parentNode) || isHTMLUListElement (*parentNode))) {
2272 // Make sure the markers in a list are properly positioned (i.e. not chopped off) when autosized. 2272 // Make sure the markers in a list are properly positioned (i.e. not chopped off) when autosized.
2273 const float adjustedMargin = (1 - 1.0 / styleToUse->textAutosizingMu ltiplier()) * getMaxWidthListMarker(this); 2273 const float adjustedMargin = (1 - 1.0 / styleToUse->textAutosizingMu ltiplier()) * getMaxWidthListMarker(this);
2274 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection(); 2274 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection();
2275 if (hasInvertedDirection) 2275 if (hasInvertedDirection)
2276 computedValues.m_margins.m_end += adjustedMargin; 2276 computedValues.m_margins.m_end += adjustedMargin;
2277 else 2277 else
2278 computedValues.m_margins.m_start += adjustedMargin; 2278 computedValues.m_margins.m_start += adjustedMargin;
2279 } 2279 }
2280 } 2280 }
2281 } 2281 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 return true; 2414 return true;
2415 2415
2416 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode( )) 2416 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode( ))
2417 return true; 2417 return true;
2418 2418
2419 return false; 2419 return false;
2420 } 2420 }
2421 2421
2422 bool RenderBox::autoWidthShouldFitContent() const 2422 bool RenderBox::autoWidthShouldFitContent() const
2423 { 2423 {
2424 return node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectT ag) || node()->hasTagName(buttonTag) 2424 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node() ) || isHTMLButtonElement(*node())
2425 || node()->hasTagName(textareaTag) || (node()->hasTagName(legendTag) && !style()->hasOutOfFlowPosition())); 2425 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s tyle()->hasOutOfFlowPosition()));
2426 } 2426 }
2427 2427
2428 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni t& marginEnd) const 2428 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni t& marginEnd) const
2429 { 2429 {
2430 const RenderStyle* containingBlockStyle = containingBlock->style(); 2430 const RenderStyle* containingBlockStyle = containingBlock->style();
2431 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); 2431 Length marginStartLength = style()->marginStartUsing(containingBlockStyle);
2432 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); 2432 Length marginEndLength = style()->marginEndUsing(containingBlockStyle);
2433 2433
2434 if (isFloating() || isInline()) { 2434 if (isFloating() || isInline()) {
2435 // Inline blocks/tables and floats don't have their margins increased. 2435 // Inline blocks/tables and floats don't have their margins increased.
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
4705 return 0; 4705 return 0;
4706 4706
4707 if (!layoutState && !flowThreadContainingBlock()) 4707 if (!layoutState && !flowThreadContainingBlock())
4708 return 0; 4708 return 0;
4709 4709
4710 RenderBlock* containerBlock = containingBlock(); 4710 RenderBlock* containerBlock = containingBlock();
4711 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); 4711 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
4712 } 4712 }
4713 4713
4714 } // namespace WebCore 4714 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698