bool snapTo(const SubtargetGeometry& geom, const IntPoint& touchPoint, const IntRect& touchArea, IntPoint& adjustedPoint) { FrameView* view = geom.node()->document()->view(); FloatQuad quad = geom.quad(); if (quad.isRectilinear()) { IntRect contentBounds = geom.boundingBox(); // Convert from frame coordinates to window coordinates. IntRect bounds = view->contentsToWindow(contentBounds); if (bounds.contains(touchPoint)) { adjustedPoint = touchPoint; return true; } if (bounds.intersects(touchArea)) { bounds.intersect(touchArea); adjustedPoint = bounds.center(); return true; } return false; } // The following code tries to adjust the point to place inside a both the touchArea and the non-rectilinear quad. // FIXME: This will return the point inside the touch area that is the closest to the quad center, but does not // guarantee that the point will be inside the quad. Corner-cases exist where the quad will intersect but this // will fail to adjust the point to somewhere in the intersection. // Convert quad from content to window coordinates. FloatPoint p1 = contentsToWindow(view, quad.p1()); FloatPoint p2 = contentsToWindow(view, quad.p2()); FloatPoint p3 = contentsToWindow(view, quad.p3()); FloatPoint p4 = contentsToWindow(view, quad.p4()); quad = FloatQuad(p1, p2, p3, p4); if (quad.containsPoint(touchPoint)) { adjustedPoint = touchPoint; return true; } // Pull point towards the center of the element. FloatPoint center = quad.center(); adjustPointToRect(center, touchArea); adjustedPoint = roundedIntPoint(center); return quad.containsPoint(adjustedPoint); }
IntRect FrameView::windowClipRect() const { ASSERT(m_frame->view() == this); if (paintsEntireContents()) return IntRect(IntPoint(), size()); // Set our clip rect to be our contents. IntRect clipRect = contentsToWindow(visibleContentRect()); return clipRect; }
IntRect ScrollView::contentsToScreen(const IntRect& rect) const { IntRect result(contentsToWindow(rect)); POINT topLeft = {0, 0}; // Find the top left corner of the Widget's containing window in screen coords, // and adjust the result rect's position by this amount. ::ClientToScreen(containingWindow(), &topLeft); result.move(topLeft.x, topLeft.y); return result; }
void ScrollView::updateContents(const IntRect& rect, bool now) { if (rect.isEmpty()) return; IntPoint windowPoint = contentsToWindow(rect.location()); IntRect containingWindowRect = rect; containingWindowRect.setLocation(windowPoint); RECT containingWindowRectWin = containingWindowRect; HWND containingWindowHandle = containingWindow(); ::InvalidateRect(containingWindowHandle, &containingWindowRectWin, false); // Cache the dirty spot. addToDirtyRegion(containingWindowRect); if (now) ::UpdateWindow(containingWindowHandle); }
IntRect FramelessScrollView::windowClipRect(bool clipToContents) const { return contentsToWindow(visibleContentRect(clipToContents ? ExcludeScrollbars : IncludeScrollbars)); }
IntRect FramelessScrollView::windowClipRect(bool clipToContents) const { return contentsToWindow(visibleContentRect(!clipToContents)); }