| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NGUnits_h | 5 #ifndef NGUnits_h |
| 6 #define NGUnits_h | 6 #define NGUnits_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/ng_writing_mode.h" | 9 #include "core/layout/ng/ng_writing_mode.h" |
| 10 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 inline_start.toInt(), inline_end.toInt(), | 296 inline_start.toInt(), inline_end.toInt(), |
| 297 block_start.toInt(), block_end.toInt()); | 297 block_start.toInt(), block_end.toInt()); |
| 298 } | 298 } |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 inline std::ostream& operator<<(std::ostream& stream, const NGBoxStrut& value) { | 301 inline std::ostream& operator<<(std::ostream& stream, const NGBoxStrut& value) { |
| 302 return stream << value.ToString(); | 302 return stream << value.ToString(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 // This struct is used for the margin collapsing calculation. | 305 // This struct is used for the margin collapsing calculation. |
| 306 // TODO(glebl): Deprecated. It's being replaced by NGMarginStrut | |
| 307 struct CORE_EXPORT NGDeprecatedMarginStrut { | |
| 308 LayoutUnit margin_block_start; | |
| 309 LayoutUnit margin_block_end; | |
| 310 | |
| 311 LayoutUnit negative_margin_block_start; | |
| 312 LayoutUnit negative_margin_block_end; | |
| 313 | |
| 314 LayoutUnit BlockEndSum() const; | |
| 315 | |
| 316 void AppendMarginBlockStart(const LayoutUnit& value); | |
| 317 void AppendMarginBlockEnd(const LayoutUnit& value); | |
| 318 void SetMarginBlockStart(const LayoutUnit& value); | |
| 319 void SetMarginBlockEnd(const LayoutUnit& value); | |
| 320 | |
| 321 bool IsEmpty() const; | |
| 322 | |
| 323 String ToString() const; | |
| 324 | |
| 325 bool operator==(const NGDeprecatedMarginStrut& other) const; | |
| 326 }; | |
| 327 | |
| 328 // This struct is used for the margin collapsing calculation. | |
| 329 struct CORE_EXPORT NGMarginStrut { | 306 struct CORE_EXPORT NGMarginStrut { |
| 330 LayoutUnit margin; | 307 LayoutUnit margin; |
| 331 LayoutUnit negative_margin; | 308 LayoutUnit negative_margin; |
| 332 | 309 |
| 333 bool operator==(const NGMarginStrut& other) const; | 310 // Appends negative or positive value to the current margin strut. |
| 334 | |
| 335 void Append(const LayoutUnit& value); | 311 void Append(const LayoutUnit& value); |
| 336 | 312 |
| 337 LayoutUnit Collapse() const; | 313 // Sum up negative and positive margins of this strut. |
| 314 LayoutUnit Sum() const; |
| 315 |
| 316 bool operator==(const NGMarginStrut& other) const; |
| 338 | 317 |
| 339 String ToString() const; | 318 String ToString() const; |
| 340 }; | 319 }; |
| 341 | 320 |
| 342 inline std::ostream& operator<<(std::ostream& stream, | 321 inline std::ostream& operator<<(std::ostream& stream, |
| 343 const NGMarginStrut& value) { | 322 const NGMarginStrut& value) { |
| 344 return stream << value.ToString(); | 323 return stream << value.ToString(); |
| 345 } | 324 } |
| 346 | 325 |
| 347 // Struct to represent a simple edge that has start and end. | 326 // Struct to represent a simple edge that has start and end. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (position_matches) | 380 if (position_matches) |
| 402 return position; | 381 return position; |
| 403 else | 382 else |
| 404 return container_size - position - length - margin_start - margin_end; | 383 return container_size - position - length - margin_start - margin_end; |
| 405 } | 384 } |
| 406 }; | 385 }; |
| 407 | 386 |
| 408 } // namespace blink | 387 } // namespace blink |
| 409 | 388 |
| 410 #endif // NGUnits_h | 389 #endif // NGUnits_h |
| OLD | NEW |