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

Side by Side Diff: third_party/WebKit/Source/core/paint/ImagePainter.cpp

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "core/paint/ImagePainter.h" 5 #include "core/paint/ImagePainter.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 28 matching lines...) Expand all
39 return; 39 return;
40 40
41 Element* focusedElement = document.focusedElement(); 41 Element* focusedElement = document.focusedElement();
42 if (!isHTMLAreaElement(focusedElement)) 42 if (!isHTMLAreaElement(focusedElement))
43 return; 43 return;
44 44
45 HTMLAreaElement& areaElement = toHTMLAreaElement(*focusedElement); 45 HTMLAreaElement& areaElement = toHTMLAreaElement(*focusedElement);
46 if (areaElement.imageElement() != m_layoutImage.node()) 46 if (areaElement.imageElement() != m_layoutImage.node())
47 return; 47 return;
48 48
49 // Even if the theme handles focus ring drawing for entire elements, it won't do it for 49 // Even if the theme handles focus ring drawing for entire elements, it won't
50 // an area within an image, so we don't call LayoutTheme::themeDrawsFocusRing here. 50 // do it for an area within an image, so we don't call
51 // LayoutTheme::themeDrawsFocusRing here.
51 52
52 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle(); 53 const ComputedStyle& areaElementStyle = *areaElement.ensureComputedStyle();
53 int outlineWidth = areaElementStyle.outlineWidth(); 54 int outlineWidth = areaElementStyle.outlineWidth();
54 if (!outlineWidth) 55 if (!outlineWidth)
55 return; 56 return;
56 57
57 Path path = areaElement.getPath(&m_layoutImage); 58 Path path = areaElement.getPath(&m_layoutImage);
58 if (path.isEmpty()) 59 if (path.isEmpty())
59 return; 60 return;
60 61
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 paintInfo.phase, contentRect); 126 paintInfo.phase, contentRect);
126 paintIntoRect(context, paintRect, contentRect); 127 paintIntoRect(context, paintRect, contentRect);
127 } 128 }
128 } 129 }
129 130
130 void ImagePainter::paintIntoRect(GraphicsContext& context, 131 void ImagePainter::paintIntoRect(GraphicsContext& context,
131 const LayoutRect& destRect, 132 const LayoutRect& destRect,
132 const LayoutRect& contentRect) { 133 const LayoutRect& contentRect) {
133 if (!m_layoutImage.imageResource()->hasImage() || 134 if (!m_layoutImage.imageResource()->hasImage() ||
134 m_layoutImage.imageResource()->errorOccurred()) 135 m_layoutImage.imageResource()->errorOccurred())
135 return; // FIXME: should we just ASSERT these conditions? (audit all caller s). 136 return; // FIXME: should we just ASSERT these conditions? (audit all
137 // callers).
136 138
137 IntRect pixelSnappedDestRect = pixelSnappedIntRect(destRect); 139 IntRect pixelSnappedDestRect = pixelSnappedIntRect(destRect);
138 if (pixelSnappedDestRect.isEmpty()) 140 if (pixelSnappedDestRect.isEmpty())
139 return; 141 return;
140 142
141 RefPtr<Image> image = m_layoutImage.imageResource()->image( 143 RefPtr<Image> image = m_layoutImage.imageResource()->image(
142 pixelSnappedDestRect.size(), m_layoutImage.style()->effectiveZoom()); 144 pixelSnappedDestRect.size(), m_layoutImage.style()->effectiveZoom());
143 if (!image || image->isNull()) 145 if (!image || image->isNull())
144 return; 146 return;
145 147
146 // FIXME: why is interpolation quality selection not included in the Instrumen tation reported cost of drawing an image? 148 // FIXME: why is interpolation quality selection not included in the
149 // Instrumentation reported cost of drawing an image?
147 InterpolationQuality interpolationQuality = 150 InterpolationQuality interpolationQuality =
148 BoxPainter::chooseInterpolationQuality( 151 BoxPainter::chooseInterpolationQuality(
149 m_layoutImage, image.get(), image.get(), 152 m_layoutImage, image.get(), image.get(),
150 LayoutSize(pixelSnappedDestRect.size())); 153 LayoutSize(pixelSnappedDestRect.size()));
151 154
152 FloatRect srcRect = image->rect(); 155 FloatRect srcRect = image->rect();
153 // If the content rect requires clipping, adjust |srcRect| and |pixelSnappedDe stRect| over using a clip. 156 // If the content rect requires clipping, adjust |srcRect| and
157 // |pixelSnappedDestRect| over using a clip.
154 if (!contentRect.contains(destRect)) { 158 if (!contentRect.contains(destRect)) {
155 IntRect pixelSnappedContentRect = pixelSnappedIntRect(contentRect); 159 IntRect pixelSnappedContentRect = pixelSnappedIntRect(contentRect);
156 pixelSnappedContentRect.intersect(pixelSnappedDestRect); 160 pixelSnappedContentRect.intersect(pixelSnappedDestRect);
157 if (pixelSnappedContentRect.isEmpty()) 161 if (pixelSnappedContentRect.isEmpty())
158 return; 162 return;
159 srcRect = mapRect(pixelSnappedContentRect, pixelSnappedDestRect, srcRect); 163 srcRect = mapRect(pixelSnappedContentRect, pixelSnappedDestRect, srcRect);
160 pixelSnappedDestRect = pixelSnappedContentRect; 164 pixelSnappedDestRect = pixelSnappedContentRect;
161 } 165 }
162 166
163 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage", 167 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage",
164 "data", InspectorPaintImageEvent::data(m_layoutImage)); 168 "data", InspectorPaintImageEvent::data(m_layoutImage));
165 169
166 InterpolationQuality previousInterpolationQuality = 170 InterpolationQuality previousInterpolationQuality =
167 context.imageInterpolationQuality(); 171 context.imageInterpolationQuality();
168 context.setImageInterpolationQuality(interpolationQuality); 172 context.setImageInterpolationQuality(interpolationQuality);
169 context.drawImage( 173 context.drawImage(
170 image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode, 174 image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode,
171 LayoutObject::shouldRespectImageOrientation(&m_layoutImage)); 175 LayoutObject::shouldRespectImageOrientation(&m_layoutImage));
172 context.setImageInterpolationQuality(previousInterpolationQuality); 176 context.setImageInterpolationQuality(previousInterpolationQuality);
173 } 177 }
174 178
175 } // namespace blink 179 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ImagePainter.h ('k') | third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698