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

Side by Side Diff: Source/core/rendering/RenderBlockFlow.h

Issue 399423006: Move widow-avoiding code from RenderBlock down to RenderBlockFlow. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * Copyright (C) 2013 Google Inc. All rights reserved. 7 * Copyright (C) 2013 Google Inc. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are 10 * modification, are permitted provided that the following conditions are
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 FlowThreadType flowThreadType(const RenderStyle*); 307 FlowThreadType flowThreadType(const RenderStyle*);
308 308
309 RenderMultiColumnFlowThread* createMultiColumnFlowThread(FlowThreadType); 309 RenderMultiColumnFlowThread* createMultiColumnFlowThread(FlowThreadType);
310 void createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderStyle* oldStyl e); 310 void createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderStyle* oldStyl e);
311 311
312 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionOpportunityCount); 312 void updateLogicalWidthForAlignment(const ETextAlign&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, unsigned expansionOpportunityCount);
313 void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bo ol& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight); 313 void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bo ol& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight);
314 bool shouldRelayoutForPagination(LayoutUnit& pageLogicalHeight, LayoutUnit l ayoutOverflowLogicalBottom) const; 314 bool shouldRelayoutForPagination(LayoutUnit& pageLogicalHeight, LayoutUnit l ayoutOverflowLogicalBottom) const;
315 void setColumnCountAndHeight(unsigned count, LayoutUnit pageLogicalHeight); 315 void setColumnCountAndHeight(unsigned count, LayoutUnit pageLogicalHeight);
316 316
317 bool shouldBreakAtLineToAvoidWidow() const { return m_rareData && m_rareData ->m_lineBreakToAvoidWidow >= 0; }
318 void clearShouldBreakAtLineToAvoidWidow() const;
319 int lineBreakToAvoidWidow() const { return m_rareData ? m_rareData->m_lineBr eakToAvoidWidow : -1; }
320 void setBreakAtLineToAvoidWidow(int);
321 void clearDidBreakAtLineToAvoidWidow();
322 void setDidBreakAtLineToAvoidWidow();
323 bool didBreakAtLineToAvoidWidow() const { return m_rareData && m_rareData->m _didBreakAtLineToAvoidWidow; }
324
317 public: 325 public:
318 struct FloatWithRect { 326 struct FloatWithRect {
319 FloatWithRect(RenderBox* f) 327 FloatWithRect(RenderBox* f)
320 : object(f) 328 : object(f)
321 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight())) 329 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight()))
322 , everHadLayout(f->everHadLayout()) 330 , everHadLayout(f->everHadLayout())
323 { 331 {
324 } 332 }
325 333
326 RenderBox* object; 334 RenderBox* object;
(...skipping 29 matching lines...) Expand all
356 MarginValues marginValuesForChild(RenderBox* child) const; 364 MarginValues marginValuesForChild(RenderBox* child) const;
357 365
358 // Allocated only when some of these fields have non-default values 366 // Allocated only when some of these fields have non-default values
359 struct RenderBlockFlowRareData { 367 struct RenderBlockFlowRareData {
360 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED; 368 WTF_MAKE_NONCOPYABLE(RenderBlockFlowRareData); WTF_MAKE_FAST_ALLOCATED;
361 public: 369 public:
362 RenderBlockFlowRareData(const RenderBlockFlow* block) 370 RenderBlockFlowRareData(const RenderBlockFlow* block)
363 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock)) 371 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBefore Default(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(bl ock))
364 , m_paginationStrut(0) 372 , m_paginationStrut(0)
365 , m_multiColumnFlowThread(0) 373 , m_multiColumnFlowThread(0)
374 , m_lineBreakToAvoidWidow(-1)
375 , m_didBreakAtLineToAvoidWidow(false)
366 , m_discardMarginBefore(false) 376 , m_discardMarginBefore(false)
367 , m_discardMarginAfter(false) 377 , m_discardMarginAfter(false)
368 { 378 {
369 } 379 }
370 380
371 static LayoutUnit positiveMarginBeforeDefault(const RenderBlockFlow* blo ck) 381 static LayoutUnit positiveMarginBeforeDefault(const RenderBlockFlow* blo ck)
372 { 382 {
373 return std::max<LayoutUnit>(block->marginBefore(), 0); 383 return std::max<LayoutUnit>(block->marginBefore(), 0);
374 } 384 }
375 static LayoutUnit negativeMarginBeforeDefault(const RenderBlockFlow* blo ck) 385 static LayoutUnit negativeMarginBeforeDefault(const RenderBlockFlow* blo ck)
376 { 386 {
377 return std::max<LayoutUnit>(-block->marginBefore(), 0); 387 return std::max<LayoutUnit>(-block->marginBefore(), 0);
378 } 388 }
379 static LayoutUnit positiveMarginAfterDefault(const RenderBlockFlow* bloc k) 389 static LayoutUnit positiveMarginAfterDefault(const RenderBlockFlow* bloc k)
380 { 390 {
381 return std::max<LayoutUnit>(block->marginAfter(), 0); 391 return std::max<LayoutUnit>(block->marginAfter(), 0);
382 } 392 }
383 static LayoutUnit negativeMarginAfterDefault(const RenderBlockFlow* bloc k) 393 static LayoutUnit negativeMarginAfterDefault(const RenderBlockFlow* bloc k)
384 { 394 {
385 return std::max<LayoutUnit>(-block->marginAfter(), 0); 395 return std::max<LayoutUnit>(-block->marginAfter(), 0);
386 } 396 }
387 397
388 MarginValues m_margins; 398 MarginValues m_margins;
389 LayoutUnit m_paginationStrut; 399 LayoutUnit m_paginationStrut;
390 400
391 RenderMultiColumnFlowThread* m_multiColumnFlowThread; 401 RenderMultiColumnFlowThread* m_multiColumnFlowThread;
392 402
403 int m_lineBreakToAvoidWidow;
404 bool m_didBreakAtLineToAvoidWidow : 1;
393 bool m_discardMarginBefore : 1; 405 bool m_discardMarginBefore : 1;
394 bool m_discardMarginAfter : 1; 406 bool m_discardMarginAfter : 1;
395 }; 407 };
396 LayoutUnit marginOffsetForSelfCollapsingBlock(); 408 LayoutUnit marginOffsetForSelfCollapsingBlock();
397 409
398 protected: 410 protected:
399 LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData- >m_margins.positiveMarginBefore() : RenderBlockFlowRareData::positiveMarginBefor eDefault(this); } 411 LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData- >m_margins.positiveMarginBefore() : RenderBlockFlowRareData::positiveMarginBefor eDefault(this); }
400 LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData- >m_margins.negativeMarginBefore() : RenderBlockFlowRareData::negativeMarginBefor eDefault(this); } 412 LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData- >m_margins.negativeMarginBefore() : RenderBlockFlowRareData::negativeMarginBefor eDefault(this); }
401 LayoutUnit maxPositiveMarginAfter() const { return m_rareData ? m_rareData-> m_margins.positiveMarginAfter() : RenderBlockFlowRareData::positiveMarginAfterDe fault(this); } 413 LayoutUnit maxPositiveMarginAfter() const { return m_rareData ? m_rareData-> m_margins.positiveMarginAfter() : RenderBlockFlowRareData::positiveMarginAfterDe fault(this); }
402 LayoutUnit maxNegativeMarginAfter() const { return m_rareData ? m_rareData-> m_margins.negativeMarginAfter() : RenderBlockFlowRareData::negativeMarginAfterDe fault(this); } 414 LayoutUnit maxNegativeMarginAfter() const { return m_rareData ? m_rareData-> m_margins.negativeMarginAfter() : RenderBlockFlowRareData::negativeMarginAfterDe fault(this); }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 510
499 // END METHODS DEFINED IN RenderBlockLineLayout 511 // END METHODS DEFINED IN RenderBlockLineLayout
500 512
501 }; 513 };
502 514
503 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow()); 515 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow());
504 516
505 } // namespace WebCore 517 } // namespace WebCore
506 518
507 #endif // RenderBlockFlow_h 519 #endif // RenderBlockFlow_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.cpp ('k') | Source/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698