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

Side by Side Diff: Source/core/rendering/TextAutosizer.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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 return (ancestor && ancestor->isListItem()) ? toRenderListItem(ancestor) : 0 ; 99 return (ancestor && ancestor->isListItem()) ? toRenderListItem(ancestor) : 0 ;
100 } 100 }
101 101
102 static RenderObject* getAncestorList(const RenderObject* renderer) 102 static RenderObject* getAncestorList(const RenderObject* renderer)
103 { 103 {
104 // FIXME: Add support for <menu> elements as a possible ancestor of an <li> element, 104 // FIXME: Add support for <menu> elements as a possible ancestor of an <li> element,
105 // see http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping- content.html#the-li-element 105 // see http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping- content.html#the-li-element
106 for (RenderObject* ancestor = renderer->parent(); ancestor; ancestor = ances tor->parent()) { 106 for (RenderObject* ancestor = renderer->parent(); ancestor; ancestor = ances tor->parent()) {
107 Node* parentNode = ancestor->generatingNode(); 107 Node* parentNode = ancestor->generatingNode();
108 if (parentNode && (parentNode->hasTagName(olTag) || parentNode->hasTagNa me(ulTag))) 108 if (parentNode && (isHTMLOListElement(*parentNode) || isHTMLUListElement (*parentNode)))
109 return ancestor; 109 return ancestor;
110 } 110 }
111 return 0; 111 return 0;
112 } 112 }
113 113
114 static Node* getGeneratingElementNode(const RenderObject* renderer) 114 static Node* getGeneratingElementNode(const RenderObject* renderer)
115 { 115 {
116 Node* node = renderer->generatingNode(); 116 Node* node = renderer->generatingNode();
117 return (node && node->isElementNode()) ? node : 0; 117 return (node && node->isElementNode()) ? node : 0;
118 } 118 }
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 newStyle->setTextAutosizingMultiplier(multiplier); 441 newStyle->setTextAutosizingMultiplier(multiplier);
442 newStyle->setUnique(); 442 newStyle->setUnique();
443 renderer->setStyle(newStyle.release()); 443 renderer->setStyle(newStyle.release());
444 } 444 }
445 445
446 void TextAutosizer::setMultiplierForList(RenderObject* renderer, float multiplie r) 446 void TextAutosizer::setMultiplierForList(RenderObject* renderer, float multiplie r)
447 { 447 {
448 #ifndef NDEBUG 448 #ifndef NDEBUG
449 Node* parentNode = renderer->generatingNode(); 449 Node* parentNode = renderer->generatingNode();
450 ASSERT(parentNode); 450 ASSERT(parentNode);
451 ASSERT(parentNode->hasTagName(olTag) || parentNode->hasTagName(ulTag)); 451 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode));
452 #endif 452 #endif
453 setMultiplier(renderer, multiplier); 453 setMultiplier(renderer, multiplier);
454 454
455 // Make sure all list items are autosized consistently. 455 // Make sure all list items are autosized consistently.
456 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) { 456 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) {
457 if (child->isListItem() && child->style()->textAutosizingMultiplier() == 1) 457 if (child->isListItem() && child->style()->textAutosizingMultiplier() == 1)
458 setMultiplier(child, multiplier); 458 setMultiplier(child, multiplier);
459 } 459 }
460 } 460 }
461 461
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (i + 1 < clusterInfos.size()) { 839 if (i + 1 < clusterInfos.size()) {
840 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( ); 840 LayoutUnit currentWidth = clusterInfos[i].root->contentLogicalWidth( );
841 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth (); 841 LayoutUnit nextWidth = clusterInfos[i + 1].root->contentLogicalWidth ();
842 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) 842 if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
843 groups.grow(groups.size() + 1); 843 groups.grow(groups.size() + 1);
844 } 844 }
845 } 845 }
846 } 846 }
847 847
848 } // namespace WebCore 848 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderView.cpp ('k') | Source/core/rendering/compositing/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698