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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1856373002: Only allow forced fragmentainer breaks at class A break points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Woho! LayoutTests/printing/css2.1/page-break-after-003.html now passes. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 95d95708beb1699297998eb54c4eb55b97dd2459..81d9f77efa2d2fbc81b22864a9ea31b30382a8ea 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -1909,14 +1909,60 @@ EBreak LayoutBox::breakInside() const
return BreakAuto;
}
-bool LayoutBox::hasForcedBreakBefore() const
+// At a class A break point [1], the break value with the highest precedence wins. If the two values
+// have the same precedence (e.g. "left" and "right"), the value specified on a latter object wins.
+//
+// [1] https://drafts.csswg.org/css-break/#possible-breaks
+static inline int fragmentainerBreakPrecedence(EBreak breakValue)
+{
+ // "auto" has the lowest priority.
+ // "avoid*" values win over "auto".
+ // "avoid-page" wins over "avoid-column".
+ // "avoid" wins over "avoid-page".
+ // Forced break values win over "avoid".
+ // Any forced page break value wins over "column" forced break.
+ // More specific break values (left, right, recto, verso) wins over generic "page" values.
+
+ switch (breakValue) {
+ default:
+ ASSERT_NOT_REACHED();
+ // fall-through
+ case BreakAuto:
+ return 0;
+ case BreakAvoidColumn:
+ return 1;
+ case BreakAvoidPage:
+ return 2;
+ case BreakAvoid:
+ return 3;
+ case BreakColumn:
+ return 4;
+ case BreakPage:
+ return 5;
+ case BreakLeft:
+ case BreakRight:
+ case BreakRecto:
+ case BreakVerso:
+ return 6;
+ }
+}
+
+EBreak LayoutBox::joinFragmentainerBreakValues(EBreak firstValue, EBreak secondValue)
+{
+ if (fragmentainerBreakPrecedence(secondValue) >= fragmentainerBreakPrecedence(firstValue))
+ return secondValue;
+ return firstValue;
+}
+
+EBreak LayoutBox::classABreakPointValue(EBreak previousBreakAfterValue) const
{
- return isForcedFragmentainerBreakValue(breakBefore());
+ ASSERT(isBreakBetweenControllable(previousBreakAfterValue));
+ return joinFragmentainerBreakValues(previousBreakAfterValue, breakBefore());
}
-bool LayoutBox::hasForcedBreakAfter() const
+bool LayoutBox::needsForcedBreakBefore(EBreak previousBreakAfterValue) const
{
- return isForcedFragmentainerBreakValue(breakAfter());
+ return isForcedFragmentainerBreakValue(classABreakPointValue(previousBreakAfterValue));
}
LayoutRect LayoutBox::localOverflowRectForPaintInvalidation() const
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/PaginationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698