OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 LayoutPoint center = rect.center(); | 137 LayoutPoint center = rect.center(); |
138 unsigned leftPadding, rightPadding, topPadding, bottomPadding; | 138 unsigned leftPadding, rightPadding, topPadding, bottomPadding; |
139 leftPadding = rightPadding = rect.width() / 2; | 139 leftPadding = rightPadding = rect.width() / 2; |
140 topPadding = bottomPadding = rect.height() / 2; | 140 topPadding = bottomPadding = rect.height() / 2; |
141 HitTestResult result(request, center, topPadding, rightPadding, bottomPaddin
g, leftPadding); | 141 HitTestResult result(request, center, topPadding, rightPadding, bottomPaddin
g, leftPadding); |
142 document.frame()->contentLayoutItem().hitTest(result); | 142 document.frame()->contentLayoutItem().hitTest(result); |
143 return document.elementsFromHitTestResult(result); | 143 return document.elementsFromHitTestResult(result); |
144 } | 144 } |
145 | 145 |
146 // Blends the colors from the given gradient with the existing colors. | 146 // Blends the colors from the given gradient with the existing colors. |
147 void blendWithColorsFromGradient(CSSGradientValue* gradient, HeapVector<Color>&
colors, bool& foundNonTransparentColor, bool& foundOpaqueColor, const LayoutObje
ct& layoutObject) | 147 void blendWithColorsFromGradient(CSSGradientValue* gradient, Vector<Color>& colo
rs, bool& foundNonTransparentColor, bool& foundOpaqueColor, const LayoutObject&
layoutObject) |
148 { | 148 { |
149 HeapVector<Color> stopColors; | 149 Vector<Color> stopColors; |
150 gradient->getStopColors(stopColors, layoutObject); | 150 gradient->getStopColors(stopColors, layoutObject); |
151 | 151 |
152 if (colors.isEmpty()) { | 152 if (colors.isEmpty()) { |
153 colors.appendRange(stopColors.begin(), stopColors.end()); | 153 colors.appendRange(stopColors.begin(), stopColors.end()); |
154 } else { | 154 } else { |
155 if (colors.size() > 1) { | 155 if (colors.size() > 1) { |
156 // Gradient on gradient is too complicated, bail out | 156 // Gradient on gradient is too complicated, bail out |
157 colors.clear(); | 157 colors.clear(); |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 Color existingColor = colors.first(); | 161 Color existingColor = colors.first(); |
162 colors.clear(); | 162 colors.clear(); |
163 for (auto stopColor : stopColors) { | 163 for (auto stopColor : stopColors) { |
164 foundNonTransparentColor = foundNonTransparentColor || (stopColor.al
pha() != 0); | 164 foundNonTransparentColor = foundNonTransparentColor || (stopColor.al
pha() != 0); |
165 colors.append(existingColor.blend(stopColor)); | 165 colors.append(existingColor.blend(stopColor)); |
166 } | 166 } |
167 } | 167 } |
168 foundOpaqueColor = foundOpaqueColor || gradient->knownToBeOpaque(layoutObjec
t); | 168 foundOpaqueColor = foundOpaqueColor || gradient->knownToBeOpaque(layoutObjec
t); |
169 } | 169 } |
170 | 170 |
171 // Gets the colors from an image style, if one exists and it is a gradient. | 171 // Gets the colors from an image style, if one exists and it is a gradient. |
172 void addColorsFromImageStyle(const ComputedStyle& style, HeapVector<Color>& colo
rs, bool& foundOpaqueColor, bool& foundNonTransparentColor, const LayoutObject&
layoutObject) | 172 void addColorsFromImageStyle(const ComputedStyle& style, Vector<Color>& colors,
bool& foundOpaqueColor, bool& foundNonTransparentColor, const LayoutObject& layo
utObject) |
173 { | 173 { |
174 const FillLayer& backgroundLayers = style.backgroundLayers(); | 174 const FillLayer& backgroundLayers = style.backgroundLayers(); |
175 if (!backgroundLayers.hasImage()) | 175 if (!backgroundLayers.hasImage()) |
176 return; | 176 return; |
177 | 177 |
178 StyleImage* styleImage = backgroundLayers.image(); | 178 StyleImage* styleImage = backgroundLayers.image(); |
179 // hasImage() does not always indicate that this is non-null | 179 // hasImage() does not always indicate that this is non-null |
180 if (!styleImage) | 180 if (!styleImage) |
181 return; | 181 return; |
182 | 182 |
(...skipping 10 matching lines...) Expand all Loading... |
193 CSSGradientValue* gradient = toCSSGradientValue(imageCSS); | 193 CSSGradientValue* gradient = toCSSGradientValue(imageCSS); |
194 blendWithColorsFromGradient(gradient, colors, foundNonTransparentColor,
foundOpaqueColor, layoutObject); | 194 blendWithColorsFromGradient(gradient, colors, foundNonTransparentColor,
foundOpaqueColor, layoutObject); |
195 } | 195 } |
196 return; | 196 return; |
197 } | 197 } |
198 | 198 |
199 // Get the background colors behind the given rect in the given document, by | 199 // Get the background colors behind the given rect in the given document, by |
200 // walking up all the elements returned by a hit test (but not going beyond | 200 // walking up all the elements returned by a hit test (but not going beyond |
201 // |topElement|) covering the area of the rect, and blending their background | 201 // |topElement|) covering the area of the rect, and blending their background |
202 // colors. | 202 // colors. |
203 bool getColorsFromRect(LayoutRect rect, Document& document, Element* topElement,
HeapVector<Color>& colors) | 203 bool getColorsFromRect(LayoutRect rect, Document& document, Element* topElement,
Vector<Color>& colors) |
204 { | 204 { |
205 HeapVector<Member<Element>> elementsUnderRect = elementsFromRect(rect, docum
ent); | 205 HeapVector<Member<Element>> elementsUnderRect = elementsFromRect(rect, docum
ent); |
206 | 206 |
207 bool foundOpaqueColor = false; | 207 bool foundOpaqueColor = false; |
208 bool foundTopElement = false; | 208 bool foundTopElement = false; |
209 | 209 |
210 for (auto e = elementsUnderRect.rbegin(); !foundTopElement && e != elementsU
nderRect.rend(); ++e) { | 210 for (auto e = elementsUnderRect.rbegin(); !foundTopElement && e != elementsU
nderRect.rend(); ++e) { |
211 const Element* element = *e; | 211 const Element* element = *e; |
212 if (element == topElement) | 212 if (element == topElement) |
213 foundTopElement = true; | 213 foundTopElement = true; |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 return; | 2023 return; |
2024 | 2024 |
2025 for (const LayoutObject* child = elementLayout->slowFirstChild(); child; chi
ld = child->nextSibling()) { | 2025 for (const LayoutObject* child = elementLayout->slowFirstChild(); child; chi
ld = child->nextSibling()) { |
2026 if (!child->isText()) | 2026 if (!child->isText()) |
2027 continue; | 2027 continue; |
2028 textBounds.unite(LayoutRect(child->absoluteBoundingBoxRect())); | 2028 textBounds.unite(LayoutRect(child->absoluteBoundingBoxRect())); |
2029 } | 2029 } |
2030 if (textBounds.size().isEmpty()) | 2030 if (textBounds.size().isEmpty()) |
2031 return; | 2031 return; |
2032 | 2032 |
2033 HeapVector<Color> colors; | 2033 Vector<Color> colors; |
2034 FrameView* view = element->document().view(); | 2034 FrameView* view = element->document().view(); |
2035 if (!view) { | 2035 if (!view) { |
2036 *errorString = "No view."; | 2036 *errorString = "No view."; |
2037 return; | 2037 return; |
2038 } | 2038 } |
2039 Document& document = element->document(); | 2039 Document& document = element->document(); |
2040 bool isMainFrame = !document.ownerElement(); | 2040 bool isMainFrame = !document.ownerElement(); |
2041 bool foundOpaqueColor = false; | 2041 bool foundOpaqueColor = false; |
2042 if (isMainFrame && !view->isTransparent()) { | 2042 if (isMainFrame && !view->isTransparent()) { |
2043 // Start with the "default" page color (typically white). | 2043 // Start with the "default" page color (typically white). |
(...skipping 29 matching lines...) Expand all Loading... |
2073 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); | 2073 visitor->trace(m_cssStyleSheetToInspectorStyleSheet); |
2074 visitor->trace(m_documentToCSSStyleSheets); | 2074 visitor->trace(m_documentToCSSStyleSheets); |
2075 visitor->trace(m_invalidatedDocuments); | 2075 visitor->trace(m_invalidatedDocuments); |
2076 visitor->trace(m_nodeToInspectorStyleSheet); | 2076 visitor->trace(m_nodeToInspectorStyleSheet); |
2077 visitor->trace(m_documentToViaInspectorStyleSheet); | 2077 visitor->trace(m_documentToViaInspectorStyleSheet); |
2078 visitor->trace(m_inspectorUserAgentStyleSheet); | 2078 visitor->trace(m_inspectorUserAgentStyleSheet); |
2079 InspectorBaseAgent::trace(visitor); | 2079 InspectorBaseAgent::trace(visitor); |
2080 } | 2080 } |
2081 | 2081 |
2082 } // namespace blink | 2082 } // namespace blink |
OLD | NEW |