OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #include "core/html/shadow/TextControlInnerElements.h" | 95 #include "core/html/shadow/TextControlInnerElements.h" |
96 #include "core/inspector/ConsoleMessageStorage.h" | 96 #include "core/inspector/ConsoleMessageStorage.h" |
97 #include "core/inspector/InspectorClient.h" | 97 #include "core/inspector/InspectorClient.h" |
98 #include "core/inspector/InspectorConsoleAgent.h" | 98 #include "core/inspector/InspectorConsoleAgent.h" |
99 #include "core/inspector/InspectorController.h" | 99 #include "core/inspector/InspectorController.h" |
100 #include "core/inspector/InspectorCounters.h" | 100 #include "core/inspector/InspectorCounters.h" |
101 #include "core/inspector/InspectorFrontendChannel.h" | 101 #include "core/inspector/InspectorFrontendChannel.h" |
102 #include "core/inspector/InspectorInstrumentation.h" | 102 #include "core/inspector/InspectorInstrumentation.h" |
103 #include "core/inspector/InspectorOverlay.h" | 103 #include "core/inspector/InspectorOverlay.h" |
104 #include "core/inspector/InstrumentingAgents.h" | 104 #include "core/inspector/InstrumentingAgents.h" |
| 105 #include "core/layout/Layer.h" |
105 #include "core/layout/LayoutTreeAsText.h" | 106 #include "core/layout/LayoutTreeAsText.h" |
106 #include "core/layout/compositing/CompositedLayerMapping.h" | 107 #include "core/layout/compositing/CompositedLayerMapping.h" |
107 #include "core/layout/compositing/RenderLayerCompositor.h" | 108 #include "core/layout/compositing/LayerCompositor.h" |
108 #include "core/loader/FrameLoader.h" | 109 #include "core/loader/FrameLoader.h" |
109 #include "core/loader/HistoryItem.h" | 110 #include "core/loader/HistoryItem.h" |
110 #include "core/page/Chrome.h" | 111 #include "core/page/Chrome.h" |
111 #include "core/page/ChromeClient.h" | 112 #include "core/page/ChromeClient.h" |
112 #include "core/page/EventHandler.h" | 113 #include "core/page/EventHandler.h" |
113 #include "core/page/FocusController.h" | 114 #include "core/page/FocusController.h" |
114 #include "core/page/NetworkStateNotifier.h" | 115 #include "core/page/NetworkStateNotifier.h" |
115 #include "core/page/Page.h" | 116 #include "core/page/Page.h" |
116 #include "core/page/PrintContext.h" | 117 #include "core/page/PrintContext.h" |
117 #include "core/plugins/testing/DictionaryPluginPlaceholder.h" | 118 #include "core/plugins/testing/DictionaryPluginPlaceholder.h" |
118 #include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h" | 119 #include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h" |
119 #include "core/rendering/RenderLayer.h" | |
120 #include "core/rendering/RenderMenuList.h" | 120 #include "core/rendering/RenderMenuList.h" |
121 #include "core/rendering/RenderObject.h" | 121 #include "core/rendering/RenderObject.h" |
122 #include "core/rendering/RenderView.h" | 122 #include "core/rendering/RenderView.h" |
123 #include "core/testing/DictionaryTest.h" | 123 #include "core/testing/DictionaryTest.h" |
124 #include "core/testing/GCObservation.h" | 124 #include "core/testing/GCObservation.h" |
125 #include "core/testing/InternalSettings.h" | 125 #include "core/testing/InternalSettings.h" |
126 #include "core/testing/LayerRect.h" | 126 #include "core/testing/LayerRect.h" |
127 #include "core/testing/LayerRectList.h" | 127 #include "core/testing/LayerRectList.h" |
128 #include "core/testing/PluginPlaceholderOptions.h" | 128 #include "core/testing/PluginPlaceholderOptions.h" |
129 #include "core/testing/PrivateScriptTest.h" | 129 #include "core/testing/PrivateScriptTest.h" |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 ASSERT(document); | 1158 ASSERT(document); |
1159 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); | 1159 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent); |
1160 } | 1160 } |
1161 | 1161 |
1162 unsigned Internals::touchEventHandlerCount(Document* document) | 1162 unsigned Internals::touchEventHandlerCount(Document* document) |
1163 { | 1163 { |
1164 ASSERT(document); | 1164 ASSERT(document); |
1165 return eventHandlerCount(*document, EventHandlerRegistry::TouchEvent); | 1165 return eventHandlerCount(*document, EventHandlerRegistry::TouchEvent); |
1166 } | 1166 } |
1167 | 1167 |
1168 static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, Gra
phicsLayer* graphicsLayer, IntSize* layerOffset, String* layerType) | 1168 static Layer* findLayerForGraphicsLayer(Layer* searchRoot, GraphicsLayer* graphi
csLayer, IntSize* layerOffset, String* layerType) |
1169 { | 1169 { |
1170 *layerOffset = IntSize(); | 1170 *layerOffset = IntSize(); |
1171 if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot->
compositedLayerMapping()->mainGraphicsLayer()) { | 1171 if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot->
compositedLayerMapping()->mainGraphicsLayer()) { |
1172 LayoutRect rect; | 1172 LayoutRect rect; |
1173 RenderLayer::mapRectToPaintBackingCoordinates(searchRoot->renderer(), re
ct); | 1173 Layer::mapRectToPaintBackingCoordinates(searchRoot->renderer(), rect); |
1174 *layerOffset = IntSize(rect.x(), rect.y()); | 1174 *layerOffset = IntSize(rect.x(), rect.y()); |
1175 return searchRoot; | 1175 return searchRoot; |
1176 } | 1176 } |
1177 | 1177 |
1178 GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot
->scrollableArea()->layerForScrolling() : 0; | 1178 GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot
->scrollableArea()->layerForScrolling() : 0; |
1179 if (graphicsLayer == layerForScrolling) { | 1179 if (graphicsLayer == layerForScrolling) { |
1180 *layerType = "scrolling"; | 1180 *layerType = "scrolling"; |
1181 return searchRoot; | 1181 return searchRoot; |
1182 } | 1182 } |
1183 | 1183 |
1184 if (searchRoot->compositingState() == PaintsIntoGroupedBacking) { | 1184 if (searchRoot->compositingState() == PaintsIntoGroupedBacking) { |
1185 GraphicsLayer* squashingLayer = searchRoot->groupedMapping()->squashingL
ayer(); | 1185 GraphicsLayer* squashingLayer = searchRoot->groupedMapping()->squashingL
ayer(); |
1186 if (graphicsLayer == squashingLayer) { | 1186 if (graphicsLayer == squashingLayer) { |
1187 *layerType ="squashing"; | 1187 *layerType ="squashing"; |
1188 LayoutRect rect; | 1188 LayoutRect rect; |
1189 RenderLayer::mapRectToPaintBackingCoordinates(searchRoot->renderer()
, rect); | 1189 Layer::mapRectToPaintBackingCoordinates(searchRoot->renderer(), rect
); |
1190 *layerOffset = IntSize(rect.x(), rect.y()); | 1190 *layerOffset = IntSize(rect.x(), rect.y()); |
1191 return searchRoot; | 1191 return searchRoot; |
1192 } | 1192 } |
1193 } | 1193 } |
1194 | 1194 |
1195 GraphicsLayer* layerForHorizontalScrollbar = searchRoot->scrollableArea() ?
searchRoot->scrollableArea()->layerForHorizontalScrollbar() : 0; | 1195 GraphicsLayer* layerForHorizontalScrollbar = searchRoot->scrollableArea() ?
searchRoot->scrollableArea()->layerForHorizontalScrollbar() : 0; |
1196 if (graphicsLayer == layerForHorizontalScrollbar) { | 1196 if (graphicsLayer == layerForHorizontalScrollbar) { |
1197 *layerType = "horizontalScrollbar"; | 1197 *layerType = "horizontalScrollbar"; |
1198 return searchRoot; | 1198 return searchRoot; |
1199 } | 1199 } |
1200 | 1200 |
1201 GraphicsLayer* layerForVerticalScrollbar = searchRoot->scrollableArea() ? se
archRoot->scrollableArea()->layerForVerticalScrollbar() : 0; | 1201 GraphicsLayer* layerForVerticalScrollbar = searchRoot->scrollableArea() ? se
archRoot->scrollableArea()->layerForVerticalScrollbar() : 0; |
1202 if (graphicsLayer == layerForVerticalScrollbar) { | 1202 if (graphicsLayer == layerForVerticalScrollbar) { |
1203 *layerType = "verticalScrollbar"; | 1203 *layerType = "verticalScrollbar"; |
1204 return searchRoot; | 1204 return searchRoot; |
1205 } | 1205 } |
1206 | 1206 |
1207 GraphicsLayer* layerForScrollCorner = searchRoot->scrollableArea() ? searchR
oot->scrollableArea()->layerForScrollCorner() : 0; | 1207 GraphicsLayer* layerForScrollCorner = searchRoot->scrollableArea() ? searchR
oot->scrollableArea()->layerForScrollCorner() : 0; |
1208 if (graphicsLayer == layerForScrollCorner) { | 1208 if (graphicsLayer == layerForScrollCorner) { |
1209 *layerType = "scrollCorner"; | 1209 *layerType = "scrollCorner"; |
1210 return searchRoot; | 1210 return searchRoot; |
1211 } | 1211 } |
1212 | 1212 |
1213 // Search right to left to increase the chances that we'll choose the top-mo
st layers in a | 1213 // Search right to left to increase the chances that we'll choose the top-mo
st layers in a |
1214 // grouped mapping for squashing. | 1214 // grouped mapping for squashing. |
1215 for (RenderLayer* child = searchRoot->lastChild(); child; child = child->pre
viousSibling()) { | 1215 for (Layer* child = searchRoot->lastChild(); child; child = child->previousS
ibling()) { |
1216 RenderLayer* foundLayer = findRenderLayerForGraphicsLayer(child, graphic
sLayer, layerOffset, layerType); | 1216 Layer* foundLayer = findLayerForGraphicsLayer(child, graphicsLayer, laye
rOffset, layerType); |
1217 if (foundLayer) | 1217 if (foundLayer) |
1218 return foundLayer; | 1218 return foundLayer; |
1219 } | 1219 } |
1220 | 1220 |
1221 return 0; | 1221 return 0; |
1222 } | 1222 } |
1223 | 1223 |
1224 // Given a vector of rects, merge those that are adjacent, leaving empty rects | 1224 // Given a vector of rects, merge those that are adjacent, leaving empty rects |
1225 // in the place of no longer used slots. This is intended to simplify the list | 1225 // in the place of no longer used slots. This is intended to simplify the list |
1226 // of rects returned by an SkRegion (which have been split apart for sorting | 1226 // of rects returned by an SkRegion (which have been split apart for sorting |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 rects[i].height += rects[j].height; | 1259 rects[i].height += rects[j].height; |
1260 rects[j] = blink::WebRect(); | 1260 rects[j] = blink::WebRect(); |
1261 updated = true; | 1261 updated = true; |
1262 } | 1262 } |
1263 } | 1263 } |
1264 } | 1264 } |
1265 } while (updated); | 1265 } while (updated); |
1266 } | 1266 } |
1267 } | 1267 } |
1268 | 1268 |
1269 static void accumulateLayerRectList(RenderLayerCompositor* compositor, GraphicsL
ayer* graphicsLayer, LayerRectList* rects) | 1269 static void accumulateLayerRectList(LayerCompositor* compositor, GraphicsLayer*
graphicsLayer, LayerRectList* rects) |
1270 { | 1270 { |
1271 blink::WebVector<blink::WebRect> layerRects = graphicsLayer->platformLayer()
->touchEventHandlerRegion(); | 1271 blink::WebVector<blink::WebRect> layerRects = graphicsLayer->platformLayer()
->touchEventHandlerRegion(); |
1272 if (!layerRects.isEmpty()) { | 1272 if (!layerRects.isEmpty()) { |
1273 mergeRects(layerRects); | 1273 mergeRects(layerRects); |
1274 String layerType; | 1274 String layerType; |
1275 IntSize layerOffset; | 1275 IntSize layerOffset; |
1276 RenderLayer* renderLayer = findRenderLayerForGraphicsLayer(compositor->r
ootRenderLayer(), graphicsLayer, &layerOffset, &layerType); | 1276 Layer* renderLayer = findLayerForGraphicsLayer(compositor->rootLayer(),
graphicsLayer, &layerOffset, &layerType); |
1277 Node* node = renderLayer ? renderLayer->renderer()->node() : 0; | 1277 Node* node = renderLayer ? renderLayer->renderer()->node() : 0; |
1278 for (size_t i = 0; i < layerRects.size(); ++i) { | 1278 for (size_t i = 0; i < layerRects.size(); ++i) { |
1279 if (!layerRects[i].isEmpty()) { | 1279 if (!layerRects[i].isEmpty()) { |
1280 rects->append(node, layerType, layerOffset.width(), layerOffset.
height(), ClientRect::create(layerRects[i])); | 1280 rects->append(node, layerType, layerOffset.width(), layerOffset.
height(), ClientRect::create(layerRects[i])); |
1281 } | 1281 } |
1282 } | 1282 } |
1283 } | 1283 } |
1284 | 1284 |
1285 size_t numChildren = graphicsLayer->children().size(); | 1285 size_t numChildren = graphicsLayer->children().size(); |
1286 for (size_t i = 0; i < numChildren; ++i) | 1286 for (size_t i = 0; i < numChildren; ++i) |
1287 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects)
; | 1287 accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects)
; |
1288 } | 1288 } |
1289 | 1289 |
1290 LayerRectList* Internals::touchEventTargetLayerRects(Document* document, Excepti
onState& exceptionState) | 1290 LayerRectList* Internals::touchEventTargetLayerRects(Document* document, Excepti
onState& exceptionState) |
1291 { | 1291 { |
1292 ASSERT(document); | 1292 ASSERT(document); |
1293 if (!document->view() || !document->page() || document != contextDocument())
{ | 1293 if (!document->view() || !document->page() || document != contextDocument())
{ |
1294 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); | 1294 exceptionState.throwDOMException(InvalidAccessError, "The document provi
ded is invalid."); |
1295 return nullptr; | 1295 return nullptr; |
1296 } | 1296 } |
1297 | 1297 |
1298 // Do any pending layout and compositing update (which may call touchEventTa
rgetRectsChange) to ensure this | 1298 // Do any pending layout and compositing update (which may call touchEventTa
rgetRectsChange) to ensure this |
1299 // really takes any previous changes into account. | 1299 // really takes any previous changes into account. |
1300 forceCompositingUpdate(document, exceptionState); | 1300 forceCompositingUpdate(document, exceptionState); |
1301 if (exceptionState.hadException()) | 1301 if (exceptionState.hadException()) |
1302 return nullptr; | 1302 return nullptr; |
1303 | 1303 |
1304 if (RenderView* view = document->renderView()) { | 1304 if (RenderView* view = document->renderView()) { |
1305 if (RenderLayerCompositor* compositor = view->compositor()) { | 1305 if (LayerCompositor* compositor = view->compositor()) { |
1306 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { | 1306 if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) { |
1307 LayerRectList* rects = LayerRectList::create(); | 1307 LayerRectList* rects = LayerRectList::create(); |
1308 accumulateLayerRectList(compositor, rootLayer, rects); | 1308 accumulateLayerRectList(compositor, rootLayer, rects); |
1309 return rects; | 1309 return rects; |
1310 } | 1310 } |
1311 } | 1311 } |
1312 } | 1312 } |
1313 | 1313 |
1314 return nullptr; | 1314 return nullptr; |
1315 } | 1315 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 RenderObject* renderer2 = element2->renderer(); | 1547 RenderObject* renderer2 = element2->renderer(); |
1548 if (!renderer1 || !renderer1->isBox()) { | 1548 if (!renderer1 || !renderer1->isBox()) { |
1549 exceptionState.throwDOMException(InvalidAccessError, renderer1 ? "The fi
rst provided element's renderer is not a box." : "The first provided element has
no renderer."); | 1549 exceptionState.throwDOMException(InvalidAccessError, renderer1 ? "The fi
rst provided element's renderer is not a box." : "The first provided element has
no renderer."); |
1550 return 0; | 1550 return 0; |
1551 } | 1551 } |
1552 if (!renderer2 || !renderer2->isBox()) { | 1552 if (!renderer2 || !renderer2->isBox()) { |
1553 exceptionState.throwDOMException(InvalidAccessError, renderer2 ? "The se
cond provided element's renderer is not a box." : "The second provided element h
as no renderer."); | 1553 exceptionState.throwDOMException(InvalidAccessError, renderer2 ? "The se
cond provided element's renderer is not a box." : "The second provided element h
as no renderer."); |
1554 return 0; | 1554 return 0; |
1555 } | 1555 } |
1556 | 1556 |
1557 RenderLayer* layer1 = toRenderBox(renderer1)->layer(); | 1557 Layer* layer1 = toRenderBox(renderer1)->layer(); |
1558 RenderLayer* layer2 = toRenderBox(renderer2)->layer(); | 1558 Layer* layer2 = toRenderBox(renderer2)->layer(); |
1559 if (!layer1 || !layer2) { | 1559 if (!layer1 || !layer2) { |
1560 exceptionState.throwDOMException(InvalidAccessError, String::format("No
render layer can be obtained from the %s provided element.", layer1 ? "second" :
"first")); | 1560 exceptionState.throwDOMException(InvalidAccessError, String::format("No
render layer can be obtained from the %s provided element.", layer1 ? "second" :
"first")); |
1561 return 0; | 1561 return 0; |
1562 } | 1562 } |
1563 | 1563 |
1564 return layer1->scrollsWithRespectTo(layer2); | 1564 return layer1->scrollsWithRespectTo(layer2); |
1565 } | 1565 } |
1566 | 1566 |
1567 String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionS
tate& exceptionState) const | 1567 String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionS
tate& exceptionState) const |
1568 { | 1568 { |
(...skipping 12 matching lines...) Expand all Loading... |
1581 { | 1581 { |
1582 ASSERT(element); | 1582 ASSERT(element); |
1583 element->document().updateLayout(); | 1583 element->document().updateLayout(); |
1584 | 1584 |
1585 RenderObject* renderer = element->renderer(); | 1585 RenderObject* renderer = element->renderer(); |
1586 if (!renderer || !renderer->isBox()) { | 1586 if (!renderer || !renderer->isBox()) { |
1587 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); | 1587 exceptionState.throwDOMException(InvalidAccessError, renderer ? "The pro
vided element's renderer is not a box." : "The provided element has no renderer.
"); |
1588 return String(); | 1588 return String(); |
1589 } | 1589 } |
1590 | 1590 |
1591 RenderLayer* layer = toRenderBox(renderer)->layer(); | 1591 Layer* layer = toRenderBox(renderer)->layer(); |
1592 if (!layer | 1592 if (!layer |
1593 || !layer->hasCompositedLayerMapping() | 1593 || !layer->hasCompositedLayerMapping() |
1594 || !layer->compositedLayerMapping()->mainGraphicsLayer()) { | 1594 || !layer->compositedLayerMapping()->mainGraphicsLayer()) { |
1595 // Don't raise exception in these cases which may be normally used in te
sts. | 1595 // Don't raise exception in these cases which may be normally used in te
sts. |
1596 return String(); | 1596 return String(); |
1597 } | 1597 } |
1598 | 1598 |
1599 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText
(flags); | 1599 return layer->compositedLayerMapping()->mainGraphicsLayer()->layerTreeAsText
(flags); |
1600 } | 1600 } |
1601 | 1601 |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 { | 2357 { |
2358 ThreadState::current()->scheduleGC(); | 2358 ThreadState::current()->scheduleGC(); |
2359 } | 2359 } |
2360 | 2360 |
2361 ValueIterable<int>::IterationSource* Internals::startIteration(ScriptState*, Exc
eptionState&) | 2361 ValueIterable<int>::IterationSource* Internals::startIteration(ScriptState*, Exc
eptionState&) |
2362 { | 2362 { |
2363 return new InternalsIterationSource(); | 2363 return new InternalsIterationSource(); |
2364 } | 2364 } |
2365 | 2365 |
2366 } // namespace blink | 2366 } // namespace blink |
OLD | NEW |