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 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/layout/TextAutosizer.h" | 32 #include "core/layout/TextAutosizer.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/dom/PseudoElement.h" | |
35 #include "core/frame/FrameHost.h" | 36 #include "core/frame/FrameHost.h" |
36 #include "core/frame/FrameView.h" | 37 #include "core/frame/FrameView.h" |
37 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
38 #include "core/frame/PinchViewport.h" | 39 #include "core/frame/PinchViewport.h" |
39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
40 #include "core/html/HTMLTextAreaElement.h" | 41 #include "core/html/HTMLTextAreaElement.h" |
41 #include "core/layout/LayoutBlock.h" | 42 #include "core/layout/LayoutBlock.h" |
42 #include "core/layout/LayoutListItem.h" | 43 #include "core/layout/LayoutListItem.h" |
43 #include "core/layout/LayoutListMarker.h" | 44 #include "core/layout/LayoutListMarker.h" |
44 #include "core/layout/LayoutTableCell.h" | 45 #include "core/layout/LayoutTableCell.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 if (child->isText()) { | 453 if (child->isText()) { |
453 hasTextChild = true; | 454 hasTextChild = true; |
454 // We only calculate this multiplier on-demand to ensure the parent block of this text | 455 // We only calculate this multiplier on-demand to ensure the parent block of this text |
455 // has entered layout. | 456 // has entered layout. |
456 if (!multiplier) | 457 if (!multiplier) |
457 multiplier = cluster->m_flags & SUPPRESSING ? 1.0f : clusterMult iplier(cluster); | 458 multiplier = cluster->m_flags & SUPPRESSING ? 1.0f : clusterMult iplier(cluster); |
458 applyMultiplier(child, multiplier); | 459 applyMultiplier(child, multiplier); |
459 // FIXME: Investigate why MarkOnlyThis is sufficient. | 460 // FIXME: Investigate why MarkOnlyThis is sufficient. |
460 if (parent->isLayoutInline()) | 461 if (parent->isLayoutInline()) |
461 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 462 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
463 | |
462 } else if (child->isLayoutInline()) { | 464 } else if (child->isLayoutInline()) { |
463 multiplier = inflate(child, behavior, multiplier); | 465 multiplier = inflate(child, behavior, multiplier); |
466 | |
464 } else if (child->isLayoutBlock() && behavior == DescendToInnerBlocks | 467 } else if (child->isLayoutBlock() && behavior == DescendToInnerBlocks |
465 && !classifyBlock(child, INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING) ) { | 468 && !classifyBlock(child, INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING) ) { |
466 multiplier = inflate(child, behavior, multiplier); | 469 multiplier = inflate(child, behavior, multiplier); |
467 } | 470 } |
468 child = child->nextSibling(); | 471 child = child->nextSibling(); |
469 } | 472 } |
470 | 473 |
471 if (hasTextChild) { | 474 if (hasTextChild) { |
472 applyMultiplier(parent, multiplier); // Parent handles line spacing. | 475 applyMultiplier(parent, multiplier); // Parent handles line spacing. |
476 | |
473 } else if (!parent->isListItem()) { | 477 } else if (!parent->isListItem()) { |
474 // For consistency, a block with no immediate text child should always h ave a | 478 // For consistency, a block with no immediate text child should always h ave a |
475 // multiplier of 1 (except for list items which are handled in inflateLi stItem). | 479 // multiplier of 1 (except for list items which are handled in inflateLi stItem). |
476 applyMultiplier(parent, 1); | 480 applyMultiplier(parent, 1); |
477 } | 481 } |
482 | |
483 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled() && parent->isLi stItem()) { | |
484 if (PseudoElement* element = toElement(parent->node())->pseudoElement(MA RKER)) { | |
esprehn
2015/04/22 07:45:46
remove, leave m_marker instead. The attachListMark
dsinclair
2015/04/22 20:00:39
Done.
| |
485 inflateListItem(toLayoutListItem(parent), toLayoutListMarker(element ->layoutObject())); | |
486 element->layoutObject()->setPreferredLogicalWidthsDirty(MarkOnlyThis ); | |
487 } | |
488 } | |
489 | |
478 return multiplier; | 490 return multiplier; |
479 } | 491 } |
480 | 492 |
481 bool TextAutosizer::shouldHandleLayout() const | 493 bool TextAutosizer::shouldHandleLayout() const |
482 { | 494 { |
483 return m_pageInfo.m_settingEnabled && m_pageInfo.m_pageNeedsAutosizing && !m _updatePageInfoDeferred; | 495 return m_pageInfo.m_settingEnabled && m_pageInfo.m_pageNeedsAutosizing && !m _updatePageInfoDeferred; |
484 } | 496 } |
485 | 497 |
486 void TextAutosizer::updatePageInfoInAllFrames() | 498 void TextAutosizer::updatePageInfoInAllFrames() |
487 { | 499 { |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 } | 1183 } |
1172 return computedSize; | 1184 return computedSize; |
1173 } | 1185 } |
1174 | 1186 |
1175 DEFINE_TRACE(TextAutosizer) | 1187 DEFINE_TRACE(TextAutosizer) |
1176 { | 1188 { |
1177 visitor->trace(m_document); | 1189 visitor->trace(m_document); |
1178 } | 1190 } |
1179 | 1191 |
1180 } // namespace blink | 1192 } // namespace blink |
OLD | NEW |