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: 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, 6 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 , m_showRepaintCounter(false) 124 , m_showRepaintCounter(false)
125 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) 125 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
126 , m_contentsOrientation(CompositingCoordinatesTopDown) 126 , m_contentsOrientation(CompositingCoordinatesTopDown)
127 , m_parent(0) 127 , m_parent(0)
128 , m_maskLayer(0) 128 , m_maskLayer(0)
129 , m_replicaLayer(0) 129 , m_replicaLayer(0)
130 , m_replicatedLayer(0) 130 , m_replicatedLayer(0)
131 , m_repaintCount(0) 131 , m_repaintCount(0)
132 , m_contentsLayer(0) 132 , m_contentsLayer(0)
133 , m_contentsLayerId(0) 133 , m_contentsLayerId(0)
134 , m_linkHighlight(0)
135 , m_contentsLayerPurpose(NoContentsLayer) 134 , m_contentsLayerPurpose(NoContentsLayer)
136 , m_scrollableArea(0) 135 , m_scrollableArea(0)
137 { 136 {
138 #ifndef NDEBUG 137 #ifndef NDEBUG
139 if (m_client) 138 if (m_client)
140 m_client->verifyNotPainting(); 139 m_client->verifyNotPainting();
141 #endif 140 #endif
142 141
143 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this)); 142 m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingCo ntentLayerDelegate(this));
144 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get())); 143 m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLa yer(m_opaqueRectTrackingContentLayerDelegate.get()));
145 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 144 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
146 m_layer->layer()->setScrollClient(this); 145 m_layer->layer()->setScrollClient(this);
147 m_layer->setAutomaticallyComputeRasterScale(true); 146 m_layer->setAutomaticallyComputeRasterScale(true);
148 } 147 }
149 148
150 GraphicsLayer::~GraphicsLayer() 149 GraphicsLayer::~GraphicsLayer()
151 { 150 {
152 if (m_linkHighlight) { 151 for (size_t i = 0; i < m_linkHighlights.size(); i++)
153 m_linkHighlight->clearCurrentGraphicsLayer(); 152 m_linkHighlights[i]->clearCurrentGraphicsLayer();
154 m_linkHighlight = 0; 153 m_linkHighlights.clear();
155 }
156 154
157 #ifndef NDEBUG 155 #ifndef NDEBUG
158 if (m_client) 156 if (m_client)
159 m_client->verifyNotPainting(); 157 m_client->verifyNotPainting();
160 #endif 158 #endif
161 159
162 if (m_replicaLayer) 160 if (m_replicaLayer)
163 m_replicaLayer->setReplicatedLayer(0); 161 m_replicaLayer->setReplicatedLayer(0);
164 162
165 if (m_replicatedLayer) 163 if (m_replicatedLayer)
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 555
558 void GraphicsLayer::updateNames() 556 void GraphicsLayer::updateNames()
559 { 557 {
560 String debugName = "Layer for " + m_nameBase; 558 String debugName = "Layer for " + m_nameBase;
561 m_layer->layer()->setDebugName(debugName); 559 m_layer->layer()->setDebugName(debugName);
562 560
563 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { 561 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) {
564 String debugName = "ContentsLayer for " + m_nameBase; 562 String debugName = "ContentsLayer for " + m_nameBase;
565 contentsLayer->setDebugName(debugName); 563 contentsLayer->setDebugName(debugName);
566 } 564 }
567 if (m_linkHighlight) { 565 for (size_t i = 0; i < m_linkHighlights.size(); i++) {
568 String debugName = "LinkHighlight for " + m_nameBase; 566 String debugName = "LinkHighlight for " + m_nameBase;
569 m_linkHighlight->layer()->setDebugName(debugName); 567 m_linkHighlights[i]->layer()->setDebugName(debugName);
wjmaclean 2013/06/12 15:09:06 It may be slightly confusing having multiple link
570 } 568 }
571 } 569 }
572 570
573 void GraphicsLayer::updateChildList() 571 void GraphicsLayer::updateChildList()
574 { 572 {
575 WebLayer* childHost = m_layer->layer(); 573 WebLayer* childHost = m_layer->layer();
576 childHost->removeAllChildren(); 574 childHost->removeAllChildren();
577 575
578 clearContentsLayerIfUnregistered(); 576 clearContentsLayerIfUnregistered();
579 577
580 if (m_contentsLayer) { 578 if (m_contentsLayer) {
581 // FIXME: add the contents layer in the correct order with negative z-or der children. 579 // FIXME: add the contents layer in the correct order with negative z-or der children.
582 // This does not cause visible rendering issues because currently conten ts layers are only used 580 // This does not cause visible rendering issues because currently conten ts layers are only used
583 // for replaced elements that don't have children. 581 // for replaced elements that don't have children.
584 childHost->addChild(m_contentsLayer); 582 childHost->addChild(m_contentsLayer);
585 } 583 }
586 584
587 const Vector<GraphicsLayer*>& childLayers = children(); 585 const Vector<GraphicsLayer*>& childLayers = children();
588 size_t numChildren = childLayers.size(); 586 size_t numChildren = childLayers.size();
589 for (size_t i = 0; i < numChildren; ++i) { 587 for (size_t i = 0; i < numChildren; ++i) {
590 GraphicsLayer* curChild = childLayers[i]; 588 GraphicsLayer* curChild = childLayers[i];
591 589
592 childHost->addChild(curChild->platformLayer()); 590 childHost->addChild(curChild->platformLayer());
593 } 591 }
594 592
595 if (m_linkHighlight) 593 for (size_t i = 0; i < m_linkHighlights.size(); i++)
596 childHost->addChild(m_linkHighlight->layer()); 594 childHost->addChild(m_linkHighlights[i]->layer());
597 } 595 }
598 596
599 void GraphicsLayer::updateLayerIsDrawable() 597 void GraphicsLayer::updateLayerIsDrawable()
600 { 598 {
601 // For the rest of the accelerated compositor code, there is no reason to ma ke a 599 // For the rest of the accelerated compositor code, there is no reason to ma ke a
602 // distinction between drawsContent and contentsVisible. So, for m_layer->la yer(), these two 600 // distinction between drawsContent and contentsVisible. So, for m_layer->la yer(), these two
603 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte nt flag 601 // flags are combined here. m_contentsLayer shouldn't receive the drawsConte nt flag
604 // so it is only given contentsVisible. 602 // so it is only given contentsVisible.
605 603
606 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 604 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
607 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) 605 if (WebLayer* contentsLayer = contentsLayerIfRegistered())
608 contentsLayer->setDrawsContent(m_contentsVisible); 606 contentsLayer->setDrawsContent(m_contentsVisible);
609 607
610 if (m_drawsContent) { 608 if (m_drawsContent) {
611 m_layer->layer()->invalidate(); 609 m_layer->layer()->invalidate();
612 if (m_linkHighlight) 610 for (size_t i = 0; i < m_linkHighlights.size(); i++)
613 m_linkHighlight->invalidate(); 611 m_linkHighlights[i]->invalidate();
614 } 612 }
615 } 613 }
616 614
617 void GraphicsLayer::updateContentsRect() 615 void GraphicsLayer::updateContentsRect()
618 { 616 {
619 WebLayer* contentsLayer = contentsLayerIfRegistered(); 617 WebLayer* contentsLayer = contentsLayerIfRegistered();
620 if (!contentsLayer) 618 if (!contentsLayer)
621 return; 619 return;
622 620
623 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y() )); 621 contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y() ));
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 info.addMember(m_parent, "parent"); 933 info.addMember(m_parent, "parent");
936 info.addMember(m_maskLayer, "maskLayer"); 934 info.addMember(m_maskLayer, "maskLayer");
937 info.addMember(m_replicaLayer, "replicaLayer"); 935 info.addMember(m_replicaLayer, "replicaLayer");
938 info.addMember(m_replicatedLayer, "replicatedLayer"); 936 info.addMember(m_replicatedLayer, "replicatedLayer");
939 info.ignoreMember(m_client); 937 info.ignoreMember(m_client);
940 info.addMember(m_name, "name"); 938 info.addMember(m_name, "name");
941 info.addMember(m_nameBase, "nameBase"); 939 info.addMember(m_nameBase, "nameBase");
942 info.addMember(m_layer, "layer"); 940 info.addMember(m_layer, "layer");
943 info.addMember(m_imageLayer, "imageLayer"); 941 info.addMember(m_imageLayer, "imageLayer");
944 info.addMember(m_contentsLayer, "contentsLayer"); 942 info.addMember(m_contentsLayer, "contentsLayer");
945 info.addMember(m_linkHighlight, "linkHighlight"); 943 for (size_t i = 0; i < m_linkHighlights.size(); i++) {
944 info.addMember(m_linkHighlights[i], "linkHighlights");
945 }
946 info.addMember(m_opaqueRectTrackingContentLayerDelegate, "opaqueRectTracking ContentLayerDelegate"); 946 info.addMember(m_opaqueRectTrackingContentLayerDelegate, "opaqueRectTracking ContentLayerDelegate");
947 info.addMember(m_animationIdMap, "animationIdMap"); 947 info.addMember(m_animationIdMap, "animationIdMap");
948 info.addMember(m_scrollableArea, "scrollableArea"); 948 info.addMember(m_scrollableArea, "scrollableArea");
949 } 949 }
950 950
951 void GraphicsLayer::setName(const String& name) 951 void GraphicsLayer::setName(const String& name)
952 { 952 {
953 m_nameBase = name; 953 m_nameBase = name;
954 m_name = String::format("GraphicsLayer(%p) ", this) + name; 954 m_name = String::format("GraphicsLayer(%p) ", this) + name;
955 updateNames(); 955 updateNames();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 contentsLayer->invalidate(); 1091 contentsLayer->invalidate();
1092 addRepaintRect(contentsRect()); 1092 addRepaintRect(contentsRect());
1093 } 1093 }
1094 } 1094 }
1095 1095
1096 void GraphicsLayer::setNeedsDisplay() 1096 void GraphicsLayer::setNeedsDisplay()
1097 { 1097 {
1098 if (drawsContent()) { 1098 if (drawsContent()) {
1099 m_layer->layer()->invalidate(); 1099 m_layer->layer()->invalidate();
1100 addRepaintRect(FloatRect(FloatPoint(), m_size)); 1100 addRepaintRect(FloatRect(FloatPoint(), m_size));
1101 if (m_linkHighlight) 1101 for (size_t i = 0; i < m_linkHighlights.size(); i++)
1102 m_linkHighlight->invalidate(); 1102 m_linkHighlights[i]->invalidate();
1103 } 1103 }
1104 } 1104 }
1105 1105
1106 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect) 1106 void GraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
1107 { 1107 {
1108 if (drawsContent()) { 1108 if (drawsContent()) {
1109 m_layer->layer()->invalidateRect(rect); 1109 m_layer->layer()->invalidateRect(rect);
1110 addRepaintRect(rect); 1110 addRepaintRect(rect);
1111 if (m_linkHighlight) 1111 for (size_t i = 0; i < m_linkHighlights.size(); i++)
1112 m_linkHighlight->invalidate(); 1112 m_linkHighlights[i]->invalidate();
1113 } 1113 }
1114 } 1114 }
1115 1115
1116 void GraphicsLayer::setContentsRect(const IntRect& rect) 1116 void GraphicsLayer::setContentsRect(const IntRect& rect)
1117 { 1117 {
1118 if (rect == m_contentsRect) 1118 if (rect == m_contentsRect)
1119 return; 1119 return;
1120 1120
1121 m_contentsRect = rect; 1121 m_contentsRect = rect;
1122 updateContentsRect(); 1122 updateContentsRect();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 } 1324 }
1325 1325
1326 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters) 1326 void GraphicsLayer::setBackgroundFilters(const FilterOperations& filters)
1327 { 1327 {
1328 WebFilterOperations webFilters; 1328 WebFilterOperations webFilters;
1329 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, webFilters)) 1329 if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, webFilters))
1330 return; 1330 return;
1331 m_layer->layer()->setBackgroundFilters(webFilters); 1331 m_layer->layer()->setBackgroundFilters(webFilters);
1332 } 1332 }
1333 1333
1334 void GraphicsLayer::setLinkHighlight(LinkHighlightClient* linkHighlight) 1334 void GraphicsLayer::addLinkHighlight(LinkHighlightClient* linkHighlight)
1335 { 1335 {
1336 m_linkHighlight = linkHighlight; 1336 ASSERT(linkHighlight);
1337 m_linkHighlights.append(linkHighlight);
1337 updateChildList(); 1338 updateChildList();
1338 } 1339 }
1339 1340
1341 void GraphicsLayer::removeLinkHighlight(
1342 LinkHighlightClient* linkHighlight)
1343 {
1344 m_linkHighlights.remove(m_linkHighlights.find(linkHighlight));
1345 ASSERT(!m_linkHighlights.contains(linkHighlight));
1346 updateChildList();
1347 }
1348
1340 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip) 1349 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip)
1341 { 1350 {
1342 paintGraphicsLayerContents(context, clip); 1351 paintGraphicsLayerContents(context, clip);
1343 } 1352 }
1344 1353
1345 1354
1346 void GraphicsLayer::notifyAnimationStarted(double startTime) 1355 void GraphicsLayer::notifyAnimationStarted(double startTime)
1347 { 1356 {
1348 if (m_client) 1357 if (m_client)
1349 m_client->notifyAnimationStarted(this, startTime); 1358 m_client->notifyAnimationStarted(this, startTime);
(...skipping 15 matching lines...) Expand all
1365 #ifndef NDEBUG 1374 #ifndef NDEBUG
1366 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1375 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1367 { 1376 {
1368 if (!layer) 1377 if (!layer)
1369 return; 1378 return;
1370 1379
1371 String output = layer->layerTreeAsText(LayerTreeAsTextDebug | LayerTreeAsTex tIncludeVisibleRects); 1380 String output = layer->layerTreeAsText(LayerTreeAsTextDebug | LayerTreeAsTex tIncludeVisibleRects);
1372 fprintf(stderr, "%s\n", output.utf8().data()); 1381 fprintf(stderr, "%s\n", output.utf8().data());
1373 } 1382 }
1374 #endif 1383 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698