Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "platform/geometry/LayoutRect.h" | 35 #include "platform/geometry/LayoutRect.h" |
| 36 #include "platform/geometry/RoundedRect.h" | 36 #include "platform/geometry/RoundedRect.h" |
| 37 #include "platform/graphics/Path.h" | 37 #include "platform/graphics/Path.h" |
| 38 #include "platform/text/WritingMode.h" | 38 #include "platform/text/WritingMode.h" |
| 39 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
| 40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 struct LineSegment { | 44 struct LineSegment { |
| 45 LineSegment() | |
| 46 : logicalLeft(0) | |
| 47 , logicalRight(0) | |
| 48 , isValid(false) | |
| 49 { | |
| 50 } | |
| 51 | |
| 45 LineSegment(float logicalLeft, float logicalRight) | 52 LineSegment(float logicalLeft, float logicalRight) |
| 46 : logicalLeft(logicalLeft) | 53 : logicalLeft(logicalLeft) |
| 47 , logicalRight(logicalRight) | 54 , logicalRight(logicalRight) |
| 55 , isValid(true) | |
| 48 { | 56 { |
| 49 } | 57 } |
| 50 | 58 |
| 51 float logicalLeft; | 59 float logicalLeft; |
| 52 float logicalRight; | 60 float logicalRight; |
| 61 bool isValid; | |
|
leviw_travelin_and_unemployed
2014/08/08 21:46:59
This makes me wish this were a class instead of a
| |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 typedef Vector<LineSegment> SegmentList; | |
| 56 | |
| 57 | |
| 58 // A representation of a BasicShape that enables layout code to determine how to break a line up into segments | 64 // A representation of a BasicShape that enables layout code to determine how to break a line up into segments |
| 59 // that will fit within or around a shape. The line is defined by a pair of logi cal Y coordinates and the | 65 // that will fit within or around a shape. The line is defined by a pair of logi cal Y coordinates and the |
| 60 // computed segments are returned as pairs of logical X coordinates. The BasicSh ape itself is defined in | 66 // computed segments are returned as pairs of logical X coordinates. The BasicSh ape itself is defined in |
| 61 // physical coordinates. | 67 // physical coordinates. |
| 62 | 68 |
| 63 class Shape { | 69 class Shape { |
| 64 public: | 70 public: |
| 65 struct DisplayPaths { | 71 struct DisplayPaths { |
| 66 Path shape; | 72 Path shape; |
| 67 Path marginShape; | 73 Path marginShape; |
| 68 }; | 74 }; |
| 69 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo gicalBoxSize, WritingMode, float margin); | 75 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo gicalBoxSize, WritingMode, float margin); |
| 70 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La youtRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin); | 76 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La youtRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin); |
| 71 static PassOwnPtr<Shape> createEmptyRasterShape(WritingMode, float margin); | 77 static PassOwnPtr<Shape> createEmptyRasterShape(WritingMode, float margin); |
| 72 static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMod e, float margin); | 78 static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMod e, float margin); |
| 73 | 79 |
| 74 virtual ~Shape() { } | 80 virtual ~Shape() { } |
| 75 | 81 |
| 76 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; | 82 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; |
| 77 virtual bool isEmpty() const = 0; | 83 virtual bool isEmpty() const = 0; |
| 78 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH eight, SegmentList&) const = 0; | 84 virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit lo gicalHeight) const = 0; |
| 79 | 85 |
| 80 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight ) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical BoundingBox()); } | 86 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight ) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical BoundingBox()); } |
| 81 virtual void buildDisplayPaths(DisplayPaths&) const = 0; | 87 virtual void buildDisplayPaths(DisplayPaths&) const = 0; |
| 82 | 88 |
| 83 protected: | 89 protected: |
| 84 float shapeMargin() const { return m_margin; } | 90 float shapeMargin() const { return m_margin; } |
| 85 | 91 |
| 86 private: | 92 private: |
| 87 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons t LayoutRect& rect) const | 93 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons t LayoutRect& rect) const |
| 88 { | 94 { |
| 89 if (rect.isEmpty()) | 95 if (rect.isEmpty()) |
| 90 return false; | 96 return false; |
| 91 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l ineHeight && lineTop == rect.y()); | 97 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l ineHeight && lineTop == rect.y()); |
| 92 } | 98 } |
| 93 | 99 |
| 94 WritingMode m_writingMode; | 100 WritingMode m_writingMode; |
| 95 float m_margin; | 101 float m_margin; |
| 96 }; | 102 }; |
| 97 | 103 |
| 98 } // namespace blink | 104 } // namespace blink |
| 99 | 105 |
| 100 #endif // Shape_h | 106 #endif // Shape_h |
| OLD | NEW |