void ChromeClient::setToolTip(LocalFrame& frame, const HitTestResult& result) { // First priority is a tooltip for element with "title" attribute. TextDirection toolTipDirection; String toolTip = result.title(toolTipDirection); // Lastly, some elements provide default tooltip strings. e.g. <input // type="file" multiple> shows a tooltip for the selected filenames. if (toolTip.isEmpty()) { if (Node* node = result.innerNode()) { if (node->isElementNode()) { toolTip = toElement(node)->defaultToolTip(); // FIXME: We should obtain text direction of tooltip from // ChromeClient or platform. As of October 2011, all client // implementations don't use text direction information for // ChromeClient::setToolTip. We'll work on tooltip text // direction during bidi cleanup in form inputs. toolTipDirection = LTR; } } } if (m_lastToolTipPoint == result.hitTestLocation().point() && m_lastToolTipText == toolTip) return; m_lastToolTipPoint = result.hitTestLocation().point(); m_lastToolTipText = toolTip; setToolTip(frame, toolTip, toolTipDirection); }
void ChromeClient::setToolTip(const HitTestResult& result) { // First priority is a potential toolTip representing a spelling or grammar // error. TextDirection toolTipDirection; String toolTip = result.spellingToolTip(toolTipDirection); // Next we'll consider a tooltip for element with "title" attribute. if (toolTip.isEmpty()) toolTip = result.title(toolTipDirection); // Lastly, for <input type="file"> that allow multiple files, we'll consider // a tooltip for the selected filenames. if (toolTip.isEmpty()) { if (Node* node = result.innerNode()) { if (isHTMLInputElement(*node)) { HTMLInputElement* input = toHTMLInputElement(node); toolTip = input->defaultToolTip(); // FIXME: We should obtain text direction of tooltip from // ChromeClient or platform. As of October 2011, all client // implementations don't use text direction information for // ChromeClient::setToolTip. We'll work on tooltip text // direction during bidi cleanup in form inputs. toolTipDirection = LTR; } } } if (m_lastToolTipPoint == result.hitTestLocation().point() && m_lastToolTipText == toolTip) return; m_lastToolTipPoint = result.hitTestLocation().point(); m_lastToolTipText = toolTip; setToolTip(toolTip, toolTipDirection); }
void HitTestCache::addCachedResult(const HitTestResult& result, uint64_t domTreeVersion) { if (!result.isCacheable()) return; // If the result was a hit test on an LayoutPart and the request allowed // querying of the layout part; then the part hasn't been loaded yet. if (result.isOverWidget() && result.hitTestRequest().allowsChildFrameContent()) return; // For now don't support rect based or list based requests. if (result.hitTestLocation().isRectBasedTest() || result.hitTestRequest().listBased()) return; if (domTreeVersion != m_domTreeVersion) clear(); if (m_items.size() < HIT_TEST_CACHE_SIZE) m_items.resize(m_updateIndex + 1); m_items.at(m_updateIndex).cacheValues(result); m_domTreeVersion = domTreeVersion; m_updateIndex++; if (m_updateIndex >= HIT_TEST_CACHE_SIZE) m_updateIndex = 0; }
bool LayoutImage::nodeAtPoint(HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) { HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); bool inside = LayoutReplaced::nodeAtPoint(tempResult, locationInContainer, accumulatedOffset, hitTestAction); if (!inside && result.hitTestRequest().listBased()) result.append(tempResult); if (inside) result = tempResult; return inside; }
bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) { HitTestResult tempResult(result.hitTestLocation()); bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInContainer, accumulatedOffset); if (!inside && result.isRectBasedTest()) result.append(tempResult); if (inside) result = tempResult; return inside; }
bool HitTestCache::lookupCachedResult(HitTestResult& hitResult, uint64_t domTreeVersion) { bool result = false; HitHistogramMetric metric = HitHistogramMetric::MISS; if (hitResult.hitTestRequest().avoidCache()) { metric = HitHistogramMetric::MISS_EXPLICIT_AVOID; // For now we don't support rect based hit results. } else if (domTreeVersion == m_domTreeVersion && !hitResult.hitTestLocation().isRectBasedTest()) { for (const auto& cachedItem : m_items) { if (cachedItem.hitTestLocation().point() == hitResult.hitTestLocation().point()) { if (hitResult.hitTestRequest().equalForCacheability(cachedItem.hitTestRequest())) { metric = HitHistogramMetric::HIT_EXACT_MATCH; result = true; hitResult = cachedItem; break; } metric = HitHistogramMetric::MISS_VALIDITY_RECT_MATCHES; } } } Platform::current()->histogramEnumeration("Event.HitTest", static_cast<int>(metric), static_cast<int>(HitHistogramMetric::MAX_HIT_METRIC)); return result; }
bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) { HitTestResult tempResult(result.hitTestLocation()); bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInContainer, accumulatedOffset, hitTestAction); if (tempResult.innerNode() && node()) { if (HTMLMapElement* map = imageMap()) { LayoutRect contentBox = contentBoxRect(); float scaleFactor = 1 / style()->effectiveZoom(); LayoutPoint mapLocation = locationInContainer.point() - toLayoutSize(accumulatedOffset) - locationOffset() - toLayoutSize(contentBox.location()); mapLocation.scale(scaleFactor, scaleFactor); if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult)) tempResult.setInnerNonSharedNode(node()); } } if (!inside && result.isRectBasedTest()) result.append(tempResult); if (inside) result = tempResult; return inside; }
bool RenderView::hitTest(const HitTestRequest& request, HitTestResult& result) { return hitTest(request, result.hitTestLocation(), result); }