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

Side by Side Diff: Source/core/rendering/shapes/Shape.h

Issue 237313003: CSS shapes support in Web Inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review comments Created 6 years, 7 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
OLDNEW
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 16 matching lines...) Expand all
27 * OF THE POSSIBILITY OF SUCH DAMAGE. 27 * OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #ifndef Shape_h 30 #ifndef Shape_h
31 #define Shape_h 31 #define Shape_h
32 32
33 #include "core/rendering/style/BasicShapes.h" 33 #include "core/rendering/style/BasicShapes.h"
34 #include "core/rendering/style/StyleImage.h" 34 #include "core/rendering/style/StyleImage.h"
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/text/WritingMode.h" 38 #include "platform/text/WritingMode.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
39 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 struct LineSegment { 44 struct LineSegment {
44 LineSegment(float logicalLeft, float logicalRight) 45 LineSegment(float logicalLeft, float logicalRight)
45 : logicalLeft(logicalLeft) 46 : logicalLeft(logicalLeft)
46 , logicalRight(logicalRight) 47 , logicalRight(logicalRight)
47 { 48 {
48 } 49 }
49 50
50 float logicalLeft; 51 float logicalLeft;
51 float logicalRight; 52 float logicalRight;
52 }; 53 };
53 54
54 typedef Vector<LineSegment> SegmentList; 55 typedef Vector<LineSegment> SegmentList;
55 56
56 57
57 // A representation of a BasicShape that enables layout code to determine how to break a line up into segments 58 // A representation of a BasicShape that enables layout code to determine how to break a line up into segments
58 // that will fit within or around a shape. The line is defined by a pair of logi cal Y coordinates and the 59 // that will fit within or around a shape. The line is defined by a pair of logi cal Y coordinates and the
59 // computed segments are returned as pairs of logical X coordinates. The BasicSh ape itself is defined in 60 // computed segments are returned as pairs of logical X coordinates. The BasicSh ape itself is defined in
60 // physical coordinates. 61 // physical coordinates.
61 62
62 class Shape { 63 class Shape {
63 public: 64 public:
65 struct DisplayPaths {
66 Path shape;
67 Path marginShape;
68 };
64 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo gicalBoxSize, WritingMode, float margin); 69 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo gicalBoxSize, WritingMode, float margin);
65 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La youtRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin); 70 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La youtRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin);
66 static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMod e, float margin); 71 static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMod e, float margin);
67 72
68 virtual ~Shape() { } 73 virtual ~Shape() { }
69 74
70 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; 75 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0;
71 virtual bool isEmpty() const = 0; 76 virtual bool isEmpty() const = 0;
72 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH eight, SegmentList&) const = 0; 77 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH eight, SegmentList&) const = 0;
73 78
74 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight ) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical BoundingBox()); } 79 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight ) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical BoundingBox()); }
80 virtual void buildDisplayPaths(DisplayPaths&) const = 0;
75 81
76 protected: 82 protected:
77 float shapeMargin() const { return m_margin; } 83 float shapeMargin() const { return m_margin; }
78 84
79 private: 85 private:
80 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons t LayoutRect& rect) const 86 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons t LayoutRect& rect) const
81 { 87 {
82 if (rect.isEmpty()) 88 if (rect.isEmpty())
83 return false; 89 return false;
84 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l ineHeight && lineTop == rect.y()); 90 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l ineHeight && lineTop == rect.y());
85 } 91 }
86 92
87 WritingMode m_writingMode; 93 WritingMode m_writingMode;
88 float m_margin; 94 float m_margin;
89 }; 95 };
90 96
91 } // namespace WebCore 97 } // namespace WebCore
92 98
93 #endif // Shape_h 99 #endif // Shape_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698