Auto merge of #12442 - shinglyu:stylo-page-break, r=emilio

Implemented page-break-before/after for Stylo

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12442)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-07-14 22:47:31 -07:00 committed by GitHub
commit 6bb5d0e846

View file

@ -432,8 +432,6 @@ impl Debug for ${style_struct.gecko_struct_name} {
force_stub += ["font-kerning", "font-stretch", "font-variant"] force_stub += ["font-kerning", "font-stretch", "font-variant"]
# These have unusual representations in gecko. # These have unusual representations in gecko.
force_stub += ["list-style-type", "text-overflow"] force_stub += ["list-style-type", "text-overflow"]
# These are booleans.
force_stub += ["page-break-after", "page-break-before"]
# In a nsTArray, have to be done manually, but probably not too much work # In a nsTArray, have to be done manually, but probably not too much work
# (the "filling them", not the "making them work") # (the "filling them", not the "making them work")
force_stub += ["animation-name", "animation-duration", force_stub += ["animation-name", "animation-duration",
@ -755,7 +753,9 @@ fn static_assert() {
</%self:impl_trait> </%self:impl_trait>
<%self:impl_trait style_struct_name="Box" skip_longhands="display overflow-y vertical-align -moz-binding"> <% skip_box_longhands= """display overflow-y vertical-align
-moz-binding page-break-before page-break-after""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
// We manually-implement the |display| property until we get general // We manually-implement the |display| property until we get general
// infrastructure for preffing certain values. // infrastructure for preffing certain values.
@ -844,6 +844,43 @@ fn static_assert() {
fn copy__moz_binding_from(&mut self, other: &Self) { fn copy__moz_binding_from(&mut self, other: &Self) {
unsafe { Gecko_CopyMozBindingFrom(&mut self.gecko, &other.gecko); } unsafe { Gecko_CopyMozBindingFrom(&mut self.gecko, &other.gecko); }
} }
// Temp fix for Bugzilla bug 24000.
// Map 'auto' and 'avoid' to false, and 'always', 'left', and 'right' to true.
// "A conforming user agent may interpret the values 'left' and 'right'
// as 'always'." - CSS2.1, section 13.3.1
fn set_page_break_before(&mut self, v: longhands::page_break_before::computed_value::T) {
use style::computed_values::page_break_before::T;
let result = match v {
T::auto => false,
T::always => true,
T::avoid => false,
T::left => true,
T::right => true
};
// TODO(shinglyu): Rename Gecko's struct to mPageBreakBefore
self.gecko.mBreakBefore = result;
}
${impl_simple_copy('page_break_before', 'mBreakBefore')}
// Temp fix for Bugzilla bug 24000.
// See set_page_break_before for detail.
fn set_page_break_after(&mut self, v: longhands::page_break_after::computed_value::T) {
use style::computed_values::page_break_after::T;
let result = match v {
T::auto => false,
T::always => true,
T::avoid => false,
T::left => true,
T::right => true
};
// TODO(shinglyu): Rename Gecko's struct to mPageBreakBefore
self.gecko.mBreakBefore = result;
}
${impl_simple_copy('page_break_after', 'mBreakAfter')}
</%self:impl_trait> </%self:impl_trait>
// TODO: Gecko accepts lists in most background-related properties. We just use // TODO: Gecko accepts lists in most background-related properties. We just use