Changeset 106357 in webkit
- Timestamp:
- Jan 31, 2012 6:28:13 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r106346 r106357 1 2012-01-31 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Tap highlighting: Support better outlines for multiline inlines 4 https://bugs.webkit.org/show_bug.cgi?id=77428 5 6 Reviewed by Simon Hausmann. 7 8 Update the test to use a transform. 9 10 * ManualTests/qt/tap-highlighting-inlines.html: 11 1 12 2012-01-31 Nayan Kumar K <nayankk@motorola.com> 2 13 -
trunk/ManualTests/qt/tap-highlighting-inlines.html
r106241 r106357 1 1 <body> 2 <p style=" width: 10em; background-color: gray">2 <p style="position:absolute; left:100px; top:20px; width: 10em; -webkit-transform: rotate(30deg)"> 3 3 <a href="">some link</a><br><br> 4 4 <a href="">some link breaking lines</a><br><br> -
trunk/Source/WebCore/ChangeLog
r106354 r106357 1 2012-01-31 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Tap highlighting: Support better outlines for multiline inlines 4 https://bugs.webkit.org/show_bug.cgi?id=77428 5 6 Reviewed by Simon Hausmann. 7 8 Covered by manual tests. 9 10 Do not use the linesBoundingBox anymore but draw a custom path 11 with rounded corners. Inlines are drawn as max 3 rects, first 12 line rect, joined middle rect and the rect for the last line. 13 14 * page/GestureTapHighlighter.cpp: 15 * platform/graphics/Path.h: Make addBeziersForRoundedRect public. 16 1 17 2012-01-31 Alexei Filippov <alexeif@chromium.org> 2 18 -
trunk/Source/WebCore/page/GestureTapHighlighter.cpp
r105893 r106357 47 47 namespace { 48 48 49 inline Layout SizeownerFrameToMainFrameOffset(const RenderObject* o)49 inline LayoutPoint ownerFrameToMainFrameOffset(const RenderObject* o) 50 50 { 51 51 ASSERT(o->node()); 52 52 Frame* containingFrame = o->frame(); 53 53 if (!containingFrame) 54 return Layout Size();54 return LayoutPoint(); 55 55 56 56 Frame* mainFrame = containingFrame->page()->mainFrame(); 57 57 58 58 LayoutPoint mainFramePoint = mainFrame->view()->rootViewToContents(containingFrame->view()->contentsToRootView(LayoutPoint())); 59 return toLayoutSize(mainFramePoint);59 return mainFramePoint; 60 60 } 61 61 … … 85 85 { 86 86 ASSERT(o); 87 const int rounding = 4; 87 88 88 89 LayoutRect contentBox; … … 103 104 104 105 FloatRect rect(borderBox); 105 rect.inflate( 5);106 107 rect.move( ownerFrameToMainFrameOffset(o));106 rect.inflate(rounding); 107 108 rect.move(toLayoutSize(ownerFrameToMainFrameOffset(o))); 108 109 109 110 Path path; 110 path.addRoundedRect(rect, FloatSize(10, 10)); 111 FloatSize rounded(rounding * 1.8, rounding * 1.8); 112 path.addRoundedRect(rect, rounded); 111 113 112 114 return path; 113 115 } 114 116 117 void addRectWithRoundedCorners(Path& path, const LayoutRect& rect, bool topLeft, bool topRight, bool bottomLeft, bool bottomRight) 118 { 119 const int rounding = 4; 120 121 FloatRect copy(rect); 122 copy.inflateX(rounding); 123 copy.inflateY(rounding / 2); 124 125 FloatSize rounded(rounding * 1.8, rounding * 1.8); 126 FloatSize squared(0, 0); 127 128 path.addBeziersForRoundedRect(copy, 129 topLeft ? rounded : squared, topRight ? rounded : squared, 130 bottomLeft ? rounded : squared, bottomRight ? rounded : squared); 131 } 132 133 inline bool contains(LayoutRect rect, int x) 134 { 135 return !rect.isEmpty() && x >= rect.x() && x <= rect.maxX(); 136 } 137 115 138 Path pathForRenderInline(RenderInline* o) 116 139 { 117 // FIXME: Adapt this to not just use the bounding box. 118 LayoutRect borderBox = o->linesBoundingBox(); 119 120 FloatRect rect(borderBox); 121 rect.inflate(5); 122 123 rect.move(ownerFrameToMainFrameOffset(o)); 124 140 ASSERT(o); 125 141 Path path; 126 path.addRoundedRect(rect, FloatSize(10, 10)); 142 143 Vector<LayoutRect> rects; 144 o->absoluteRects(rects, /* acc. offset */ ownerFrameToMainFrameOffset(o)); 145 146 LayoutRect first = rects.size() ? rects.first() : LayoutRect(); 147 LayoutRect last = rects.size() > 1 ? rects.last() : LayoutRect(); 148 LayoutRect middle; 149 for (int i = 1; i < rects.size() - 1; ++i) 150 middle.uniteIfNonZero(rects.at(i)); 151 152 if (!middle.isEmpty()) { 153 int leftSide = middle.x(); 154 int rightSide = middle.maxX(); 155 156 if (!first.isEmpty()) { 157 leftSide = std::min(leftSide, first.x()); 158 rightSide = std::max(rightSide, first.maxX()); 159 } 160 if (!last.isEmpty()) { 161 leftSide = std::min(leftSide, last.x()); 162 rightSide = std::max(rightSide, last.maxX()); 163 } 164 165 middle.setX(leftSide); 166 middle.setWidth(rightSide - leftSide); 167 } 168 169 if (!first.isEmpty()) { 170 bool roundBottomLeft = !contains(middle, first.x()) && !contains(last, first.x()); 171 bool roundBottomRight = !contains(middle, first.maxX()) && !contains(last, first.maxX()); 172 addRectWithRoundedCorners(path, first, /* roundTopLeft */ true, /* roundTopRight */ true, roundBottomLeft, roundBottomRight); 173 } 174 175 if (!middle.isEmpty()) { 176 bool roundTopLeft = !contains(first, middle.x()); 177 bool roundBottomRight = !contains(last, middle.maxX()); 178 addRectWithRoundedCorners(path, middle, roundTopLeft, /* roundTopRight */ false, /* roundBottomLeft */ false, roundBottomRight); 179 } 180 181 if (!last.isEmpty()) { 182 bool roundTopLeft = !contains(middle, last.x()) && !contains(first, last.x()); 183 bool roundTopRight = !contains(middle, last.maxX()) && !contains(first, last.maxX()); 184 addRectWithRoundedCorners(path, last, roundTopLeft, roundTopRight, /* roundBottomLeft */ true, /* roundBottomRight */ true); 185 } 127 186 128 187 return path; -
trunk/Source/WebCore/platform/graphics/Path.h
r104585 r106357 147 147 void transform(const AffineTransform&); 148 148 149 private:150 149 void addBeziersForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius); 151 150 151 private: 152 152 PlatformPathPtr m_path; 153 153 };
Note: See TracChangeset
for help on using the changeset viewer.