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

Unified Diff: Source/web/LinkHighlight.cpp

Issue 129643002: Fix link highlights on links that contain images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/LinkHighlight.cpp
diff --git a/Source/web/LinkHighlight.cpp b/Source/web/LinkHighlight.cpp
index 34aa09d71558e9a25fb4d87b3d5c4cd6e0b13d6d..e17e9f01244b76ba6f0f315aa2b09534ed7764df 100644
--- a/Source/web/LinkHighlight.cpp
+++ b/Source/web/LinkHighlight.cpp
@@ -49,6 +49,7 @@
#include "public/platform/WebRect.h"
#include "public/platform/WebSize.h"
#include "wtf/CurrentTime.h"
+#include "wtf/Vector.h"
using namespace WebCore;
@@ -184,6 +185,27 @@ static void addQuadToPath(const FloatQuad& quad, Path& path)
path.closeSubpath();
}
+void LinkHighlight::computeQuads(Node* node, Vector<FloatQuad>& outQuads) const
+{
+ if (!node || !node->renderer())
+ return;
+
+ RenderObject* renderer = node->renderer();
+
+ // For inline elements, absoluteQuads will return a line box based on the line-height
+ // and font metrics, which is technically incorrect as replaced elements like images
+ // should use their intristic height and expand the linebox as needed. To get an
+ // appropriately sized highlight we descend into the children and have them add their
+ // boxes.
+ if (renderer->isRenderInline()) {
+ for (Node* child = node->firstChild(); child; child = child->nextSibling())
+ computeQuads(child, outQuads);
+ } else {
+ renderer->absoluteQuads(outQuads);
+ }
+
+}
+
bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositingLayer)
{
if (!m_node || !m_node->renderer() || !m_currentGraphicsLayer)
@@ -193,14 +215,14 @@ bool LinkHighlight::computeHighlightLayerPathAndPosition(RenderLayer* compositin
// Get quads for node in absolute coordinates.
Vector<FloatQuad> quads;
- m_node->renderer()->absoluteQuads(quads);
+ computeQuads(m_node.get(), quads);
ASSERT(quads.size());
// Adjust for offset between target graphics layer and the node's renderer.
FloatPoint positionAdjust = IntPoint(m_currentGraphicsLayer->offsetFromRenderer());
Path newPath;
- for (unsigned quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
+ for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
FloatQuad absoluteQuad = quads[quadIndex];
absoluteQuad.move(-positionAdjust.x(), -positionAdjust.y());
« no previous file with comments | « Source/web/LinkHighlight.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698