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

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

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix a crashers (everything is building!) Created 5 years, 10 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 return (linkCount >= 3); 216 return (linkCount >= 3);
217 } 217 }
218 218
219 static bool blockHeightConstrained(const RenderBlock* block) 219 static bool blockHeightConstrained(const RenderBlock* block)
220 { 220 {
221 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently wa lking back up from each box. 221 // FIXME: Propagate constrainedness down the tree, to avoid inefficiently wa lking back up from each box.
222 // FIXME: This code needs to take into account vertical writing modes. 222 // FIXME: This code needs to take into account vertical writing modes.
223 // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in. 223 // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
224 for (; block; block = block->containingBlock()) { 224 for (; block; block = block->containingBlock()) {
225 RenderStyle* style = block->style(); 225 const RenderStyle* style = block->style();
226 if (style->overflowY() >= OSCROLL) 226 if (style->overflowY() >= OSCROLL)
227 return false; 227 return false;
228 if (style->height().isSpecified() || style->maxHeight().isSpecified() || block->isOutOfFlowPositioned()) { 228 if (style->height().isSpecified() || style->maxHeight().isSpecified() || block->isOutOfFlowPositioned()) {
229 // Some sites (e.g. wikipedia) set their html and/or body elements t o height:100%, 229 // Some sites (e.g. wikipedia) set their html and/or body elements t o height:100%,
230 // without intending to constrain the height of the content within t hem. 230 // without intending to constrain the height of the content within t hem.
231 return !block->isDocumentElement() && !block->isBody(); 231 return !block->isDocumentElement() && !block->isBody();
232 } 232 }
233 if (block->isFloating()) 233 if (block->isFloating())
234 return false; 234 return false;
235 } 235 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ASSERT(page); 559 ASSERT(page);
560 return page->settings().pinchVirtualViewportEnabled() ? 560 return page->settings().pinchVirtualViewportEnabled() ?
561 page->frameHost().pinchViewport().size() : 561 page->frameHost().pinchViewport().size() :
562 page->deprecatedLocalMainFrame()->view()->unscaledVisibleContentSize(Inc ludeScrollbars); 562 page->deprecatedLocalMainFrame()->view()->unscaledVisibleContentSize(Inc ludeScrollbars);
563 } 563 }
564 564
565 void TextAutosizer::resetMultipliers() 565 void TextAutosizer::resetMultipliers()
566 { 566 {
567 RenderObject* renderer = m_document->renderView(); 567 RenderObject* renderer = m_document->renderView();
568 while (renderer) { 568 while (renderer) {
569 if (RenderStyle* style = renderer->style()) { 569 if (const RenderStyle* style = renderer->style()) {
570 if (style->textAutosizingMultiplier() != 1) 570 if (style->textAutosizingMultiplier() != 1)
571 applyMultiplier(renderer, 1, LayoutNeeded); 571 applyMultiplier(renderer, 1, LayoutNeeded);
572 } 572 }
573 renderer = renderer->nextInPreOrder(); 573 renderer = renderer->nextInPreOrder();
574 } 574 }
575 } 575 }
576 576
577 void TextAutosizer::setAllTextNeedsLayout() 577 void TextAutosizer::setAllTextNeedsLayout()
578 { 578 {
579 RenderObject* renderer = m_document->renderView(); 579 RenderObject* renderer = m_document->renderView();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 Node* node = renderer->generatingNode(); 678 Node* node = renderer->generatingNode();
679 if (!node || !node->isElementNode()) 679 if (!node || !node->isElementNode())
680 return 0; 680 return 0;
681 681
682 FingerprintSourceData data; 682 FingerprintSourceData data;
683 if (const RenderObject* parent = parentElementRenderer(renderer)) 683 if (const RenderObject* parent = parentElementRenderer(renderer))
684 data.m_parentHash = getFingerprint(parent); 684 data.m_parentHash = getFingerprint(parent);
685 685
686 data.m_qualifiedNameHash = QualifiedNameHash::hash(toElement(node)->tagQName ()); 686 data.m_qualifiedNameHash = QualifiedNameHash::hash(toElement(node)->tagQName ());
687 687
688 if (RenderStyle* style = renderer->style()) { 688 if (const RenderStyle* style = renderer->style()) {
689 data.m_packedStyleProperties = style->direction(); 689 data.m_packedStyleProperties = style->direction();
690 data.m_packedStyleProperties |= (style->position() << 1); 690 data.m_packedStyleProperties |= (style->position() << 1);
691 data.m_packedStyleProperties |= (style->floating() << 4); 691 data.m_packedStyleProperties |= (style->floating() << 4);
692 data.m_packedStyleProperties |= (style->display() << 6); 692 data.m_packedStyleProperties |= (style->display() << 6);
693 data.m_packedStyleProperties |= (style->width().type() << 11); 693 data.m_packedStyleProperties |= (style->width().type() << 11);
694 // packedStyleProperties effectively using 15 bits now. 694 // packedStyleProperties effectively using 15 bits now.
695 695
696 // consider for adding: writing mode, padding. 696 // consider for adding: writing mode, padding.
697 697
698 data.m_width = style->width().getFloatValue(); 698 data.m_width = style->width().getFloatValue();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 child = (firstOrLast == First) ? child->nextSibling() : child->previousS ibling(); 957 child = (firstOrLast == First) ? child->nextSibling() : child->previousS ibling();
958 } 958 }
959 --depth; 959 --depth;
960 960
961 return 0; 961 return 0;
962 } 962 }
963 963
964 void TextAutosizer::applyMultiplier(RenderObject* renderer, float multiplier, Re layoutBehavior relayoutBehavior) 964 void TextAutosizer::applyMultiplier(RenderObject* renderer, float multiplier, Re layoutBehavior relayoutBehavior)
965 { 965 {
966 ASSERT(renderer && renderer->style()); 966 ASSERT(renderer && renderer->style());
967 RenderStyle* currentStyle = renderer->style(); 967 RenderStyle* currentStyle = renderer->deprecatedMutableStyle();
rune 2015/01/29 23:16:32 You need a mutable style here for storing a RefPtr
Julien - ping for review 2015/02/10 07:33:19 Indeed.
968 if (currentStyle->textAutosizingMultiplier() == multiplier) 968 if (currentStyle->textAutosizingMultiplier() == multiplier)
969 return; 969 return;
970 970
971 // We need to clone the render style to avoid breaking style sharing. 971 // We need to clone the render style to avoid breaking style sharing.
972 RefPtr<RenderStyle> style = RenderStyle::clone(currentStyle); 972 RefPtr<RenderStyle> style = RenderStyle::clone(currentStyle);
973 style->setTextAutosizingMultiplier(multiplier); 973 style->setTextAutosizingMultiplier(multiplier);
974 style->setUnique(); 974 style->setUnique();
975 975
976 switch (relayoutBehavior) { 976 switch (relayoutBehavior) {
977 case AlreadyInLayout: 977 case AlreadyInLayout:
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 } 1169 }
1170 return computedSize; 1170 return computedSize;
1171 } 1171 }
1172 1172
1173 void TextAutosizer::trace(Visitor* visitor) 1173 void TextAutosizer::trace(Visitor* visitor)
1174 { 1174 {
1175 visitor->trace(m_document); 1175 visitor->trace(m_document);
1176 } 1176 }
1177 1177
1178 } // namespace blink 1178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698