OLD | NEW |
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 Loading... |
215 | 215 |
216 return (linkCount >= 3); | 216 return (linkCount >= 3); |
217 } | 217 } |
218 | 218 |
219 static bool blockHeightConstrained(const LayoutBlock* block) | 219 static bool blockHeightConstrained(const LayoutBlock* 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 const LayoutStyle& style = block->styleRef(); | 225 const ComputedStyle& style = block->styleRef(); |
226 if (style.overflowY() >= OSCROLL) | 226 if (style.overflowY() >= OSCROLL) |
227 return false; | 227 return false; |
228 if (style.height().isSpecified() || style.maxHeight().isSpecified() || b
lock->isOutOfFlowPositioned()) { | 228 if (style.height().isSpecified() || style.maxHeight().isSpecified() || b
lock->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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 { | 562 { |
563 Page * page = m_document->page(); | 563 Page * page = m_document->page(); |
564 ASSERT(page); | 564 ASSERT(page); |
565 return page->frameHost().pinchViewport().size(); | 565 return page->frameHost().pinchViewport().size(); |
566 } | 566 } |
567 | 567 |
568 void TextAutosizer::resetMultipliers() | 568 void TextAutosizer::resetMultipliers() |
569 { | 569 { |
570 LayoutObject* renderer = m_document->layoutView(); | 570 LayoutObject* renderer = m_document->layoutView(); |
571 while (renderer) { | 571 while (renderer) { |
572 if (const LayoutStyle* style = renderer->style()) { | 572 if (const ComputedStyle* style = renderer->style()) { |
573 if (style->textAutosizingMultiplier() != 1) | 573 if (style->textAutosizingMultiplier() != 1) |
574 applyMultiplier(renderer, 1, LayoutNeeded); | 574 applyMultiplier(renderer, 1, LayoutNeeded); |
575 } | 575 } |
576 renderer = renderer->nextInPreOrder(); | 576 renderer = renderer->nextInPreOrder(); |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 void TextAutosizer::setAllTextNeedsLayout() | 580 void TextAutosizer::setAllTextNeedsLayout() |
581 { | 581 { |
582 LayoutObject* renderer = m_document->layoutView(); | 582 LayoutObject* renderer = m_document->layoutView(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 Node* node = renderer->generatingNode(); | 681 Node* node = renderer->generatingNode(); |
682 if (!node || !node->isElementNode()) | 682 if (!node || !node->isElementNode()) |
683 return 0; | 683 return 0; |
684 | 684 |
685 FingerprintSourceData data; | 685 FingerprintSourceData data; |
686 if (const LayoutObject* parent = parentElementRenderer(renderer)) | 686 if (const LayoutObject* parent = parentElementRenderer(renderer)) |
687 data.m_parentHash = getFingerprint(parent); | 687 data.m_parentHash = getFingerprint(parent); |
688 | 688 |
689 data.m_qualifiedNameHash = QualifiedNameHash::hash(toElement(node)->tagQName
()); | 689 data.m_qualifiedNameHash = QualifiedNameHash::hash(toElement(node)->tagQName
()); |
690 | 690 |
691 if (const LayoutStyle* style = renderer->style()) { | 691 if (const ComputedStyle* style = renderer->style()) { |
692 data.m_packedStyleProperties = style->direction(); | 692 data.m_packedStyleProperties = style->direction(); |
693 data.m_packedStyleProperties |= (style->position() << 1); | 693 data.m_packedStyleProperties |= (style->position() << 1); |
694 data.m_packedStyleProperties |= (style->floating() << 4); | 694 data.m_packedStyleProperties |= (style->floating() << 4); |
695 data.m_packedStyleProperties |= (style->display() << 6); | 695 data.m_packedStyleProperties |= (style->display() << 6); |
696 data.m_packedStyleProperties |= (style->width().type() << 11); | 696 data.m_packedStyleProperties |= (style->width().type() << 11); |
697 // packedStyleProperties effectively using 15 bits now. | 697 // packedStyleProperties effectively using 15 bits now. |
698 | 698 |
699 // consider for adding: writing mode, padding. | 699 // consider for adding: writing mode, padding. |
700 | 700 |
701 data.m_width = style->width().getFloatValue(); | 701 data.m_width = style->width().getFloatValue(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 child = (firstOrLast == First) ? child->nextSibling() : child->previousS
ibling(); | 960 child = (firstOrLast == First) ? child->nextSibling() : child->previousS
ibling(); |
961 } | 961 } |
962 --depth; | 962 --depth; |
963 | 963 |
964 return 0; | 964 return 0; |
965 } | 965 } |
966 | 966 |
967 void TextAutosizer::applyMultiplier(LayoutObject* renderer, float multiplier, Re
layoutBehavior relayoutBehavior) | 967 void TextAutosizer::applyMultiplier(LayoutObject* renderer, float multiplier, Re
layoutBehavior relayoutBehavior) |
968 { | 968 { |
969 ASSERT(renderer); | 969 ASSERT(renderer); |
970 LayoutStyle& currentStyle = renderer->mutableStyleRef(); | 970 ComputedStyle& currentStyle = renderer->mutableStyleRef(); |
971 if (currentStyle.textAutosizingMultiplier() == multiplier) | 971 if (currentStyle.textAutosizingMultiplier() == multiplier) |
972 return; | 972 return; |
973 | 973 |
974 // We need to clone the render style to avoid breaking style sharing. | 974 // We need to clone the render style to avoid breaking style sharing. |
975 RefPtr<LayoutStyle> style = LayoutStyle::clone(currentStyle); | 975 RefPtr<ComputedStyle> style = ComputedStyle::clone(currentStyle); |
976 style->setTextAutosizingMultiplier(multiplier); | 976 style->setTextAutosizingMultiplier(multiplier); |
977 style->setUnique(); | 977 style->setUnique(); |
978 | 978 |
979 switch (relayoutBehavior) { | 979 switch (relayoutBehavior) { |
980 case AlreadyInLayout: | 980 case AlreadyInLayout: |
981 // Don't free currentStyle until the end of the layout pass. This allows
other parts of the system | 981 // Don't free currentStyle until the end of the layout pass. This allows
other parts of the system |
982 // to safely hold raw LayoutStyle* pointers during layout, e.g. Breaking
Context::m_currentStyle. | 982 // to safely hold raw ComputedStyle* pointers during layout, e.g. Breaki
ngContext::m_currentStyle. |
983 m_stylesRetainedDuringLayout.append(¤tStyle); | 983 m_stylesRetainedDuringLayout.append(¤tStyle); |
984 | 984 |
985 renderer->setStyleInternal(style.release()); | 985 renderer->setStyleInternal(style.release()); |
986 renderer->setNeedsLayoutAndFullPaintInvalidation(); | 986 renderer->setNeedsLayoutAndFullPaintInvalidation(); |
987 break; | 987 break; |
988 | 988 |
989 case LayoutNeeded: | 989 case LayoutNeeded: |
990 renderer->setStyle(style.release()); | 990 renderer->setStyle(style.release()); |
991 break; | 991 break; |
992 } | 992 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 } | 1172 } |
1173 return computedSize; | 1173 return computedSize; |
1174 } | 1174 } |
1175 | 1175 |
1176 DEFINE_TRACE(TextAutosizer) | 1176 DEFINE_TRACE(TextAutosizer) |
1177 { | 1177 { |
1178 visitor->trace(m_document); | 1178 visitor->trace(m_document); |
1179 } | 1179 } |
1180 | 1180 |
1181 } // namespace blink | 1181 } // namespace blink |
OLD | NEW |