static void updateRenderedRectsForMarker(RenderedDocumentMarker& marker, Node& node) { ASSERT(!node.document().view() || !node.document().view()->needsLayout()); // FIXME: We should refactor this so that we don't use Range (because we only have one Node), but still share code with absoluteTextQuads(). RefPtr<Range> markerRange = Range::create(node.document(), &node, marker.startOffset(), &node, marker.endOffset()); if (!markerRange) return; Vector<FloatQuad> absoluteMarkerQuads; markerRange->absoluteTextQuads(absoluteMarkerQuads, true); Vector<FloatRect> absoluteMarkerRects; absoluteMarkerRects.reserveInitialCapacity(absoluteMarkerQuads.size()); for (const auto& quad : absoluteMarkerQuads) absoluteMarkerRects.append(quad.boundingBox()); marker.setUnclippedAbsoluteRects(absoluteMarkerRects); }
unsigned TouchEventHandler::spellCheck(Platform::TouchPoint& touchPoint) { Element* elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable(); if (!m_lastFatFingersResult.isTextInput() || !elementUnderFatFinger) return 0; LayoutPoint contentPos(m_webPage->mapFromViewportToContents(touchPoint.m_pos)); contentPos = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), m_webPage->focusedOrMainFrame(), contentPos); Document* document = elementUnderFatFinger->document(); ASSERT(document); RenderedDocumentMarker* marker = document->markers()->renderedMarkerContainingPoint(contentPos, DocumentMarker::Spelling); if (!marker) return 0; IntRect rect = marker->renderedRect(); LayoutPoint newContentPos = LayoutPoint(rect.x() + rect.width(), rect.y() + rect.height() / 2); Frame* frame = m_webPage->focusedOrMainFrame(); if (frame != m_webPage->mainFrame()) newContentPos = m_webPage->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(newContentPos)); m_lastFatFingersResult.m_adjustedPosition = newContentPos; m_lastFatFingersResult.m_positionWasAdjusted = true; return marker->endOffset() - marker->startOffset(); }