OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/frame/SmartClip.h" | 32 #include "core/frame/SmartClip.h" |
33 | 33 |
34 #include "core/dom/ContainerNode.h" | 34 #include "core/dom/ContainerNode.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/NodeTraversal.h" | 36 #include "core/dom/NodeTraversal.h" |
37 #include "core/frame/LocalDOMWindow.h" | 37 #include "core/frame/LocalDOMWindow.h" |
38 #include "core/frame/FrameView.h" | 38 #include "core/frame/FrameView.h" |
39 #include "core/html/HTMLFrameOwnerElement.h" | 39 #include "core/html/HTMLFrameOwnerElement.h" |
| 40 #include "core/layout/LayoutObject.h" |
40 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
41 #include "core/rendering/RenderObject.h" | |
42 #include "wtf/text/StringBuilder.h" | 42 #include "wtf/text/StringBuilder.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 static IntRect applyScaleWithoutCollapsingToZero(const IntRect& rect, float scal
e) | 46 static IntRect applyScaleWithoutCollapsingToZero(const IntRect& rect, float scal
e) |
47 { | 47 { |
48 IntRect result = rect; | 48 IntRect result = rect; |
49 result.scale(scale); | 49 result.scale(scale); |
50 if (rect.width() > 0 && !result.width()) | 50 if (rect.width() > 0 && !result.width()) |
51 result.setWidth(1); | 51 result.setWidth(1); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 Node* minNode = nullptr; | 170 Node* minNode = nullptr; |
171 | 171 |
172 while (node) { | 172 while (node) { |
173 IntRect nodeRect = node->pixelSnappedBoundingBox(); | 173 IntRect nodeRect = node->pixelSnappedBoundingBox(); |
174 | 174 |
175 if (node->isElementNode() && equalIgnoringCase(toElement(node)->fastGetA
ttribute(HTMLNames::aria_hiddenAttr), "true")) { | 175 if (node->isElementNode() && equalIgnoringCase(toElement(node)->fastGetA
ttribute(HTMLNames::aria_hiddenAttr), "true")) { |
176 node = NodeTraversal::nextSkippingChildren(*node, rootNode); | 176 node = NodeTraversal::nextSkippingChildren(*node, rootNode); |
177 continue; | 177 continue; |
178 } | 178 } |
179 | 179 |
180 RenderObject* renderer = node->renderer(); | 180 LayoutObject* renderer = node->renderer(); |
181 if (renderer && !nodeRect.isEmpty()) { | 181 if (renderer && !nodeRect.isEmpty()) { |
182 if (renderer->isText() | 182 if (renderer->isText() |
183 || renderer->isRenderImage() | 183 || renderer->isRenderImage() |
184 || node->isFrameOwnerElement() | 184 || node->isFrameOwnerElement() |
185 || (renderer->style()->hasBackgroundImage() && !shouldSkipBackgr
oundImage(node))) { | 185 || (renderer->style()->hasBackgroundImage() && !shouldSkipBackgr
oundImage(node))) { |
186 if (resizedCropRect.intersects(nodeRect)) { | 186 if (resizedCropRect.intersects(nodeRect)) { |
187 minNode = minNodeContainsNodes(minNode, node); | 187 minNode = minNodeContainsNodes(minNode, node); |
188 } else { | 188 } else { |
189 node = NodeTraversal::nextSkippingChildren(*node, rootNode); | 189 node = NodeTraversal::nextSkippingChildren(*node, rootNode); |
190 continue; | 190 continue; |
(...skipping 13 matching lines...) Expand all Loading... |
204 { | 204 { |
205 ASSERT(node); | 205 ASSERT(node); |
206 // Apparently we're only interested in background images on spans and divs. | 206 // Apparently we're only interested in background images on spans and divs. |
207 if (!isHTMLSpanElement(*node) && !isHTMLDivElement(*node)) | 207 if (!isHTMLSpanElement(*node) && !isHTMLDivElement(*node)) |
208 return true; | 208 return true; |
209 | 209 |
210 // This check actually makes a bit of sense. If you're going to sprite an | 210 // This check actually makes a bit of sense. If you're going to sprite an |
211 // image out of a CSS background, you're probably going to specify a height | 211 // image out of a CSS background, you're probably going to specify a height |
212 // or a width. On the other hand, if we've got a legit background image, | 212 // or a width. On the other hand, if we've got a legit background image, |
213 // it's very likely the height or the width will be set to auto. | 213 // it's very likely the height or the width will be set to auto. |
214 RenderObject* renderer = node->renderer(); | 214 LayoutObject* renderer = node->renderer(); |
215 if (renderer && (renderer->style()->logicalHeight().isAuto() || renderer->st
yle()->logicalWidth().isAuto())) | 215 if (renderer && (renderer->style()->logicalHeight().isAuto() || renderer->st
yle()->logicalWidth().isAuto())) |
216 return true; | 216 return true; |
217 | 217 |
218 return false; | 218 return false; |
219 } | 219 } |
220 | 220 |
221 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRect, WillBeHeapVector<RawPtrWillBeMember<Node>>& hitNodes) | 221 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRect, WillBeHeapVector<RawPtrWillBeMember<Node>>& hitNodes) |
222 { | 222 { |
223 if (!parentNode) | 223 if (!parentNode) |
224 return; | 224 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 result.append(nodeValue); | 269 result.append(nodeValue); |
270 } | 270 } |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 return result.toString(); | 274 return result.toString(); |
275 } | 275 } |
276 | 276 |
277 } // namespace blink | 277 } // namespace blink |
OLD | NEW |