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

Side by Side Diff: Source/core/platform/graphics/GraphicsLayer.cpp

Issue 15663005: Expand tap highlight to allow multiple highlights for touch disambiguation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 , m_contentsVisible(true) 117 , m_contentsVisible(true)
118 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) 118 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
119 , m_contentsOrientation(CompositingCoordinatesTopDown) 119 , m_contentsOrientation(CompositingCoordinatesTopDown)
120 , m_parent(0) 120 , m_parent(0)
121 , m_maskLayer(0) 121 , m_maskLayer(0)
122 , m_replicaLayer(0) 122 , m_replicaLayer(0)
123 , m_replicatedLayer(0) 123 , m_replicatedLayer(0)
124 , m_paintCount(0) 124 , m_paintCount(0)
125 , m_contentsLayer(0) 125 , m_contentsLayer(0)
126 , m_contentsLayerId(0) 126 , m_contentsLayerId(0)
127 , m_linkHighlight(0)
128 , m_contentsLayerPurpose(NoContentsLayer) 127 , m_contentsLayerPurpose(NoContentsLayer)
129 , m_scrollableArea(0) 128 , m_scrollableArea(0)
130 , m_compositingReasons(WebKit::CompositingReasonUnknown) 129 , m_compositingReasons(WebKit::CompositingReasonUnknown)
131 { 130 {
132 #ifndef NDEBUG 131 #ifndef NDEBUG
133 if (m_client) 132 if (m_client)
134 m_client->verifyNotPainting(); 133 m_client->verifyNotPainting();
135 #endif 134 #endif
136 135
137 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this)); 136 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this));
138 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get())); 137 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get()));
139 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 138 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
140 m_layer->layer()->setWebLayerClient(this); 139 m_layer->layer()->setWebLayerClient(this);
141 m_layer->setAutomaticallyComputeRasterScale(true); 140 m_layer->setAutomaticallyComputeRasterScale(true);
142 } 141 }
143 142
144 GraphicsLayer::~GraphicsLayer() 143 GraphicsLayer::~GraphicsLayer()
145 { 144 {
146 if (m_linkHighlight) { 145 for (size_t i = 0; i < m_linkHighlights.size(); i++)
147 m_linkHighlight->clearCurrentGraphicsLayer(); 146 m_linkHighlights[i]->clearCurrentGraphicsLayer();
148 m_linkHighlight = 0; 147 m_linkHighlights.clear();
149 }
150 148
151 #ifndef NDEBUG 149 #ifndef NDEBUG
152 if (m_client) 150 if (m_client)
153 m_client->verifyNotPainting(); 151 m_client->verifyNotPainting();
154 #endif 152 #endif
155 153
156 if (m_replicaLayer) 154 if (m_replicaLayer)
157 m_replicaLayer->setReplicatedLayer(0); 155 m_replicaLayer->setReplicatedLayer(0);
158 156
159 if (m_replicatedLayer) 157 if (m_replicatedLayer)
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 528 }
531 529
532 const Vector<GraphicsLayer*>& childLayers = children(); 530 const Vector<GraphicsLayer*>& childLayers = children();
533 size_t numChildren = childLayers.size(); 531 size_t numChildren = childLayers.size();
534 for (size_t i = 0; i < numChildren; ++i) { 532 for (size_t i = 0; i < numChildren; ++i) {
535 GraphicsLayer* curChild = childLayers[i]; 533 GraphicsLayer* curChild = childLayers[i];
536 534
537 childHost->addChild(curChild->platformLayer()); 535 childHost->addChild(curChild->platformLayer());
538 } 536 }
539 537
540 if (m_linkHighlight) 538 for (size_t i = 0; i < m_linkHighlights.size(); i++)
541 childHost->addChild(m_linkHighlight->layer()); 539 childHost->addChild(m_linkHighlights[i]->layer());
542 } 540 }
543 541
544 void GraphicsLayer::updateLayerIsDrawable() 542 void GraphicsLayer::updateLayerIsDrawable()
545 { 543 {
546 // For the rest of the accelerated compositor code, there is no reason to ma ke a 544 // For the rest of the accelerated compositor code, there is no reason to ma ke a
547 // distinction between drawsContent and contentsVisible. So, for m_layer->la yer(), these two 545 // distinction between drawsContent and contentsVisible. So, for m_layer->la yer(), these two
548 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte nt flag 546 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte nt flag
549 // so it is only given contentsVisible. 547 // so it is only given contentsVisible.
550 548
551 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 549 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
552 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) 550 if (WebLayer* contentsLayer = contentsLayerIfRegistered())
553 contentsLayer->setDrawsContent(m_contentsVisible); 551 contentsLayer->setDrawsContent(m_contentsVisible);
554 552
555 if (m_drawsContent) { 553 if (m_drawsContent) {
556 m_layer->layer()->invalidate(); 554 m_layer->layer()->invalidate();
557 if (m_linkHighlight) 555 for (size_t i = 0; i < m_linkHighlights.size(); i++)
558 m_linkHighlight->invalidate(); 556 m_linkHighlights[i]->invalidate();
559 } 557 }
560 } 558 }
561 559
562 void GraphicsLayer::updateContentsRect() 560 void GraphicsLayer::updateContentsRect()
563 { 561 {
564 WebLayer* contentsLayer = contentsLayerIfRegistered(); 562 WebLayer* contentsLayer = contentsLayerIfRegistered();
565 if (!contentsLayer) 563 if (!contentsLayer)
566 return; 564 return;
567 565
568 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y() )); 566 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y() ));
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 dumpLayer(ts, 0, flags); 871 dumpLayer(ts, 0, flags);
874 return ts.release(); 872 return ts.release();
875 } 873 }
876 874
877 WebKit::WebString GraphicsLayer::debugName(WebKit::WebLayer* webLayer) 875 WebKit::WebString GraphicsLayer::debugName(WebKit::WebLayer* webLayer)
878 { 876 {
879 String name; 877 String name;
880 if (!m_client) 878 if (!m_client)
881 return name; 879 return name;
882 880
881 String highlightDebugName;
882 for (size_t i = 0; i < m_linkHighlights.size(); i++) {
883 if (webLayer == m_linkHighlights[i]->layer()) {
884 highlightDebugName = "LinkHighlight[" + String::number(i) + "] for " + m_client->debugName(this);
885 break;
886 }
887 }
888
883 if (webLayer == m_contentsLayer) { 889 if (webLayer == m_contentsLayer) {
884 name = "ContentsLayer for " + m_client->debugName(this); 890 name = "ContentsLayer for " + m_client->debugName(this);
885 } else if (m_linkHighlight && webLayer == m_linkHighlight->layer()) { 891 } else if (!highlightDebugName.isEmpty()) {
886 name = "LinkHighlight for " + m_client->debugName(this); 892 name = highlightDebugName;
887 } else if (webLayer == m_layer->layer()) { 893 } else if (webLayer == m_layer->layer()) {
888 name = m_client->debugName(this); 894 name = m_client->debugName(this);
889 } else { 895 } else {
890 ASSERT_NOT_REACHED(); 896 ASSERT_NOT_REACHED();
891 } 897 }
892 return name; 898 return name;
893 } 899 }
894 900
895 void GraphicsLayer::setCompositingReasons(WebKit::WebCompositingReasons reasons) 901 void GraphicsLayer::setCompositingReasons(WebKit::WebCompositingReasons reasons)
896 { 902 {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 contentsLayer->invalidate(); 1029 contentsLayer->invalidate();
1024 addRepaintRect(contentsRect()); 1030 addRepaintRect(contentsRect());
1025 } 1031 }
1026 } 1032 }
1027 1033
1028 void GraphicsLayer::setNeedsDisplay() 1034 void GraphicsLayer::setNeedsDisplay()
1029 { 1035 {
1030 if (drawsContent()) { 1036 if (drawsContent()) {
1031 m_layer->layer()->invalidate(); 1037 m_layer->layer()->invalidate();
1032 addRepaintRect(FloatRect(FloatPoint(), m_size)); 1038 addRepaintRect(FloatRect(FloatPoint(), m_size));
1033 if (m_linkHighlight) 1039 for (size_t i = 0; i < m_linkHighlights.size(); i++)
1034 m_linkHighlight->invalidate(); 1040 m_linkHighlights[i]->invalidate();
1035 } 1041 }
1036 } 1042 }
1037 1043
1038 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect) 1044 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
1039 { 1045 {
1040 if (drawsContent()) { 1046 if (drawsContent()) {
1041 m_layer->layer()->invalidateRect(rect); 1047 m_layer->layer()->invalidateRect(rect);
1042 addRepaintRect(rect); 1048 addRepaintRect(rect);
1043 if (m_linkHighlight) 1049 for (size_t i = 0; i < m_linkHighlights.size(); i++)
1044 m_linkHighlight->invalidate(); 1050 m_linkHighlights[i]->invalidate();
1045 } 1051 }
1046 } 1052 }
1047 1053
1048 void GraphicsLayer::setContentsRect(const IntRect& rect) 1054 void GraphicsLayer::setContentsRect(const IntRect& rect)
1049 { 1055 {
1050 if (rect == m_contentsRect) 1056 if (rect == m_contentsRect)
1051 return; 1057 return;
1052 1058
1053 m_contentsRect = rect; 1059 m_contentsRect = rect;
1054 updateContentsRect(); 1060 updateContentsRect();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1281 }
1276 1282
1277 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters) 1283 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters)
1278 { 1284 {
1279 OwnPtr<WebFilterOperations> webFilters = adoptPtr(Platform::current()->compo sitorSupport()->createFilterOperations()); 1285 OwnPtr<WebFilterOperations> webFilters = adoptPtr(Platform::current()->compo sitorSupport()->createFilterOperations());
1280 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, *webFilters)) 1286 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, *webFilters))
1281 return; 1287 return;
1282 m_layer->layer()->setBackgroundFilters(*webFilters); 1288 m_layer->layer()->setBackgroundFilters(*webFilters);
1283 } 1289 }
1284 1290
1285 void GraphicsLayer::setLinkHighlight(LinkHighlightClient* linkHighlight) 1291 void GraphicsLayer::addLinkHighlight(LinkHighlightClient* linkHighlight)
1286 { 1292 {
1287 m_linkHighlight = linkHighlight; 1293 ASSERT(linkHighlight);
1288 if (m_linkHighlight) 1294 m_linkHighlights.append(linkHighlight);
1289 m_linkHighlight->layer()->setWebLayerClient(this); 1295 linkHighlight->layer()->setWebLayerClient(this);
1290 updateChildList(); 1296 updateChildList();
1291 } 1297 }
1292 1298
1299 void GraphicsLayer::removeLinkHighlight(LinkHighlightClient* linkHighlight)
1300 {
1301 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight));
1302 ASSERT(!m_linkHighlights.contains(linkHighlight));
1303 updateChildList();
1304 }
1305
1293 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isMai nFrame) 1306 void GraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea, bool isMai nFrame)
1294 { 1307 {
1295 if (m_scrollableArea == scrollableArea) 1308 if (m_scrollableArea == scrollableArea)
1296 return; 1309 return;
1297 1310
1298 m_scrollableArea = scrollableArea; 1311 m_scrollableArea = scrollableArea;
1299 1312
1300 // Main frame scrolling may involve pinch zoom and gets routed through 1313 // Main frame scrolling may involve pinch zoom and gets routed through
1301 // WebViewImpl explicitly rather than via GraphicsLayer::didScroll. 1314 // WebViewImpl explicitly rather than via GraphicsLayer::didScroll.
1302 if (isMainFrame) 1315 if (isMainFrame)
(...skipping 30 matching lines...) Expand all
1333 #ifndef NDEBUG 1346 #ifndef NDEBUG
1334 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1347 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1335 { 1348 {
1336 if (!layer) 1349 if (!layer)
1337 return; 1350 return;
1338 1351
1339 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); 1352 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo);
1340 fprintf(stderr, "%s\n", output.utf8().data()); 1353 fprintf(stderr, "%s\n", output.utf8().data());
1341 } 1354 }
1342 #endif 1355 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698