| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 , m_superclusters() | 253 , m_superclusters() |
| 254 , m_clusterStack() | 254 , m_clusterStack() |
| 255 , m_fingerprintMapper() | 255 , m_fingerprintMapper() |
| 256 , m_pageInfo() | 256 , m_pageInfo() |
| 257 , m_updatePageInfoDeferred(false) | 257 , m_updatePageInfoDeferred(false) |
| 258 { | 258 { |
| 259 } | 259 } |
| 260 | 260 |
| 261 void FastTextAutosizer::record(const RenderBlock* block) | 261 void FastTextAutosizer::record(const RenderBlock* block) |
| 262 { | 262 { |
| 263 if (!enabled()) | 263 if (!m_pageInfo.m_settingEnabled) |
| 264 return; | 264 return; |
| 265 | 265 |
| 266 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); | 266 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); |
| 267 | 267 |
| 268 if (!classifyBlock(block, INDEPENDENT | EXPLICIT_WIDTH)) | 268 if (!classifyBlock(block, INDEPENDENT | EXPLICIT_WIDTH)) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 if (Fingerprint fingerprint = computeFingerprint(block)) | 271 if (Fingerprint fingerprint = computeFingerprint(block)) |
| 272 m_fingerprintMapper.addTentativeClusterRoot(block, fingerprint); | 272 m_fingerprintMapper.addTentativeClusterRoot(block, fingerprint); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void FastTextAutosizer::destroy(const RenderBlock* block) | 275 void FastTextAutosizer::destroy(const RenderBlock* block) |
| 276 { | 276 { |
| 277 if (!enabled()) | 277 if (!m_pageInfo.m_settingEnabled) |
| 278 return; | 278 return; |
| 279 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); | 279 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); |
| 280 | 280 |
| 281 m_fingerprintMapper.remove(block); | 281 m_fingerprintMapper.remove(block); |
| 282 } | 282 } |
| 283 | 283 |
| 284 FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const
RenderBlock* block) | 284 FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const
RenderBlock* block) |
| 285 { | 285 { |
| 286 #ifndef NDEBUG | 286 #ifndef NDEBUG |
| 287 m_blocksThatHaveBegunLayout.add(block); | 287 m_blocksThatHaveBegunLayout.add(block); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 applyMultiplier(descendant, multiplier); | 453 applyMultiplier(descendant, multiplier); |
| 454 applyMultiplier(descendant->parent(), multiplier); // Parent handles
line spacing. | 454 applyMultiplier(descendant->parent(), multiplier); // Parent handles
line spacing. |
| 455 // FIXME: Investigate why MarkOnlyThis is sufficient. | 455 // FIXME: Investigate why MarkOnlyThis is sufficient. |
| 456 if (descendant->parent()->isRenderInline()) | 456 if (descendant->parent()->isRenderInline()) |
| 457 descendant->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 457 descendant->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
| 458 } | 458 } |
| 459 descendant = descendant->nextInPreOrder(block); | 459 descendant = descendant->nextInPreOrder(block); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 // FIXME(crbug.com/367864): Unify this with m_pageInfo.m_settingEnabled. | |
| 464 bool FastTextAutosizer::enabled() const | |
| 465 { | |
| 466 return m_document->settings() && m_document->settings()->textAutosizingEnabl
ed(); | |
| 467 } | |
| 468 | |
| 469 bool FastTextAutosizer::shouldHandleLayout() const | 463 bool FastTextAutosizer::shouldHandleLayout() const |
| 470 { | 464 { |
| 471 return enabled() && m_pageInfo.m_pageNeedsAutosizing && !m_updatePageInfoDef
erred; | 465 return m_pageInfo.m_settingEnabled && m_pageInfo.m_pageNeedsAutosizing && !m
_updatePageInfoDeferred; |
| 472 } | 466 } |
| 473 | 467 |
| 474 void FastTextAutosizer::updatePageInfoInAllFrames() | 468 void FastTextAutosizer::updatePageInfoInAllFrames() |
| 475 { | 469 { |
| 476 ASSERT(!enabled() || m_document->frame()->isMainFrame()); | 470 ASSERT(!m_document->frame() || m_document->frame()->isMainFrame()); |
| 477 | 471 |
| 478 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().t
raverseNext()) { | 472 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().t
raverseNext()) { |
| 479 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi
zer()) | 473 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi
zer()) |
| 480 textAutosizer->updatePageInfo(); | 474 textAutosizer->updatePageInfo(); |
| 481 } | 475 } |
| 482 } | 476 } |
| 483 | 477 |
| 484 void FastTextAutosizer::updatePageInfo() | 478 void FastTextAutosizer::updatePageInfo() |
| 485 { | 479 { |
| 486 if (m_updatePageInfoDeferred || !m_document->page()) | 480 if (m_updatePageInfoDeferred || !m_document->page() || !m_document->settings
()) |
| 487 return; | 481 return; |
| 488 | 482 |
| 489 PageInfo previousPageInfo(m_pageInfo); | 483 PageInfo previousPageInfo(m_pageInfo); |
| 490 m_pageInfo.m_settingEnabled = enabled(); | 484 m_pageInfo.m_settingEnabled = m_document->settings()->textAutosizingEnabled(
); |
| 491 | 485 |
| 492 if (!enabled() || m_document->printing()) { | 486 if (!m_pageInfo.m_settingEnabled || m_document->printing()) { |
| 493 m_pageInfo.m_pageNeedsAutosizing = false; | 487 m_pageInfo.m_pageNeedsAutosizing = false; |
| 494 } else { | 488 } else { |
| 495 RenderView* renderView = toRenderView(m_document->renderer()); | 489 RenderView* renderView = toRenderView(m_document->renderer()); |
| 496 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()
->writingMode()); | 490 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()
->writingMode()); |
| 497 | 491 |
| 498 LocalFrame* mainFrame = m_document->page()->mainFrame(); | 492 LocalFrame* mainFrame = m_document->page()->mainFrame(); |
| 499 IntSize frameSize = m_document->settings()->textAutosizingWindowSizeOver
ride(); | 493 IntSize frameSize = m_document->settings()->textAutosizingWindowSizeOver
ride(); |
| 500 if (frameSize.isEmpty()) | 494 if (frameSize.isEmpty()) |
| 501 frameSize = mainFrame->view()->unscaledVisibleContentSize(IncludeScr
ollbars); | 495 frameSize = mainFrame->view()->unscaledVisibleContentSize(IncludeScr
ollbars); |
| 502 m_pageInfo.m_frameWidth = horizontalWritingMode ? frameSize.width() : fr
ameSize.height(); | 496 m_pageInfo.m_frameWidth = horizontalWritingMode ? frameSize.width() : fr
ameSize.height(); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() | 1084 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() |
| 1091 { | 1085 { |
| 1092 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto
sizer()) { | 1086 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto
sizer()) { |
| 1093 ASSERT(textAutosizer->m_updatePageInfoDeferred); | 1087 ASSERT(textAutosizer->m_updatePageInfoDeferred); |
| 1094 textAutosizer->m_updatePageInfoDeferred = false; | 1088 textAutosizer->m_updatePageInfoDeferred = false; |
| 1095 textAutosizer->updatePageInfoInAllFrames(); | 1089 textAutosizer->updatePageInfoInAllFrames(); |
| 1096 } | 1090 } |
| 1097 } | 1091 } |
| 1098 | 1092 |
| 1099 } // namespace WebCore | 1093 } // namespace WebCore |
| OLD | NEW |