Example #1
0
bool CachedNode::Clip(const WebCore::IntRect& outer, WebCore::IntRect* inner,
    WTF::Vector<WebCore::IntRect>* rings)
{
    if (outer.contains(*inner))
        return true;
//    DBG_NAV_LOGD("outer:{%d,%d,%d,%d} does not contain inner:{%d,%d,%d,%d}",
//        outer.x(), outer.y(), outer.width(), outer.height(),
//        inner->x(), inner->y(), inner->width(), inner->height());
    bool intersects = outer.intersects(*inner);
    size_t size = intersects ? rings->size() : 0;
    *inner = WebCore::IntRect(0, 0, 0, 0);
    if (intersects) {
        WebCore::IntRect * const start = rings->begin();
        WebCore::IntRect* ring = start + size - 1;
        do {
            ring->intersect(outer);
            if (ring->isEmpty()) {
                if ((size_t) (ring - start) != --size)
                    *ring = start[size];
            } else
                inner->unite(*ring);
        } while (ring-- != start);
    }
    rings->shrink(size);
//    DBG_NAV_LOGD("size:%d", size);
    return size != 0;
}
void CachedHistory::setWorking(CachedFrame::Direction newMove, 
    const CachedNode* cursor, const WebCore::IntRect& viewBounds)
{
    CachedFrame::Direction lastAxis = (CachedFrame::Direction) (mLastMove & ~CachedFrame::RIGHT_DOWN); // up, left or uninitialized
    CachedFrame::Direction newAxis = (CachedFrame::Direction) (newMove & ~CachedFrame::RIGHT_DOWN); 
    bool change = newAxis != lastAxis;
    mDirectionChange = change && mLastMove != CachedFrame::UNINITIALIZED;
    if (cursor != NULL || mLastMove != CachedFrame::UNINITIALIZED) {
        mPriorMove = mLastMove;
        mLastMove = newMove;
    }
    const WebCore::IntRect* navBounds = &mNavBounds;
    if (cursor != NULL) {
        WebCore::IntRect cursorBounds;
        cursor->getBounds(&cursorBounds);
        if (cursorBounds.isEmpty() == false)
            mNavBounds = cursorBounds;
    }
    if (change) {   // uninitialized or change in direction
        if (lastAxis != CachedFrame::LEFT && navBounds->height() > 0) {
            mMinWorkingHorizontal = navBounds->y();
            mMaxWorkingHorizontal = navBounds->bottom();
        }
        if (lastAxis != CachedFrame::UP && navBounds->width() > 0) {
            mMinWorkingVertical = navBounds->x();
            mMaxWorkingVertical = navBounds->right();
        }
    }
    pinMaxMin(viewBounds);
}
Example #3
0
void NonCompositedContentHost::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
{
    context.translate(-m_layerAdjust);
    WebCore::IntRect adjustedClipRect = clipRect;
    adjustedClipRect.move(m_layerAdjust);
    m_webView->paintRootLayer(context, adjustedClipRect);
}
Example #4
0
static inline void _ewk_view_single_scroll_process_single(Ewk_View_Smart_Data* smartData, void* pixels, Evas_Coord width, Evas_Coord height, const WebCore::IntSize& scrollOffset, const WebCore::IntRect& rectToScroll)
{
    int scrollX = rectToScroll.x();
    int scrollY = rectToScroll.y();
    int scrollWidth = rectToScroll.width();
    int scrollHeight = rectToScroll.height();

    DBG("%d,%d + %d,%d %+03d,%+03d, store: %p %dx%d",
        scrollX, scrollY, scrollWidth, scrollHeight, scrollOffset.width(), scrollOffset.height(), pixels, width, height);

    if (abs(scrollOffset.width()) >= scrollWidth || abs(scrollOffset.height()) >= scrollHeight) {
        ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
        return;
    }

    if (scrollX < 0) {
        scrollWidth += scrollX;
        scrollX = 0;
    }
    if (scrollY < 0) {
        scrollHeight += scrollY;
        scrollY = 0;
    }

    if (scrollX + scrollWidth > width)
        scrollWidth = width - scrollX;
    if (scrollY + scrollHeight > height)
        scrollHeight = height - scrollY;

    if (scrollWidth <= 0 || scrollHeight <= 0)
        return;

    int sourceX = scrollOffset.width() < 0 ? abs(scrollOffset.width()) : 0;
    int sourceY = scrollOffset.height() < 0 ? abs(scrollOffset.height()) : 0;
    int destinationX = scrollOffset.width() < 0 ? 0 : scrollOffset.width();
    int destinationY = scrollOffset.height() < 0 ? 0 : scrollOffset.height();
    int copyWidth = scrollWidth - abs(scrollOffset.width());
    int copyHeight = scrollHeight - abs(scrollOffset.height());
    if (scrollOffset.width() || scrollOffset.height()) {
        _ewk_view_screen_move(static_cast<uint32_t*>(pixels), destinationX, destinationY, sourceX, sourceY, copyWidth, copyHeight, width);
        evas_object_image_data_update_add(smartData->backing_store, destinationX, destinationY, copyWidth, copyHeight);
    }

    Eina_Rectangle verticalUpdate;
    verticalUpdate.x = destinationX ? 0 : copyWidth - 1;
    verticalUpdate.y = 0;
    verticalUpdate.w = abs(scrollOffset.width());
    verticalUpdate.h = scrollHeight;
    if (verticalUpdate.w && verticalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, verticalUpdate.x, verticalUpdate.y, verticalUpdate.w, verticalUpdate.h);

    Eina_Rectangle horizontalUpdate;
    horizontalUpdate.x = destinationX;
    horizontalUpdate.y = destinationY ? 0 : copyHeight - 1;
    horizontalUpdate.w = copyWidth;
    horizontalUpdate.h = abs(scrollOffset.height());
    if (horizontalUpdate.w && horizontalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, horizontalUpdate.x, horizontalUpdate.y, horizontalUpdate.w, horizontalUpdate.h);
}
Example #5
0
IntRect TilingData::overlappedTileIndices(const WebCore::IntRect &srcRect) const
{
    int x = tileXIndexFromSrcCoord(srcRect.x());
    int y = tileYIndexFromSrcCoord(srcRect.y());
    int r = tileXIndexFromSrcCoord(srcRect.maxX());
    int b = tileYIndexFromSrcCoord(srcRect.maxY());
    return IntRect(x, y, r - x, b - y);
}
Example #6
0
WebCore::IntRect CachedNode::cursorRingBounds(const CachedFrame* frame) const
{
    int partMax = mNavableRects;
    ASSERT(partMax > 0);
    WebCore::IntRect bounds = mCursorRing[0];
    for (int partIndex = 1; partIndex < partMax; partIndex++)
        bounds.unite(mCursorRing[partIndex]);
    bounds.inflate(CURSOR_RING_HIT_TEST_RADIUS);
    return mIsInLayer ? frame->adjustBounds(this, bounds) : bounds;
}
Example #7
0
void CachedNode::move(int x, int y)
{
    mBounds.move(x, y);
    // mHitTestBounds will be moved by caller
    WebCore::IntRect* first = mFocusRing.begin();
    WebCore::IntRect* last = first + mFocusRing.size();
    --first;
    while (++first != last)
        first->move(x, y);
}
Example #8
0
WebCore::IntRect DOMHTMLInputElement::rectOnScreen()
{
    RenderObject* renderer = m_element->renderer();
    FrameView* view = m_element->document()->view();
    if (!renderer || !view)
        return WebCore::IntRect();

    WebCore::IntRect coreRect = renderer->absoluteBoundingBoxRect();
    coreRect.setLocation(view->contentsToWindow(coreRect.location()));
    return coreRect;
}
Example #9
0
WebCore::IntRect ChromeClient::windowToScreen(const WebCore::IntRect& windowPoint) const 
{
    HWND hwnd = m_webView ? m_webView->hostWindow() : NULL;
    if (!IsWindow(hwnd))
        return windowPoint;

    POINT tempPoint = { windowPoint.x(), windowPoint.y() };
    ClientToScreen(hwnd, &tempPoint);
    
    WebCore::IntRect screePoint(tempPoint.x, tempPoint.y, windowPoint.width(), windowPoint.height());
    return screePoint;
}
Example #10
0
void NonCompositedContentHost::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& context, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
{
    // On non-android platforms, we want to render text with subpixel antialiasing on the root layer
    // so long as the root is opaque. On android all text is grayscale.
#if !OS(ANDROID)
    if (m_opaque)
        context.platformContext()->setDrawingToImageBuffer(false);
#endif
    context.translate(-m_layerAdjust);
    WebCore::IntRect adjustedClipRect = clipRect;
    adjustedClipRect.move(m_layerAdjust);
    m_webView->paintRootLayer(context, adjustedClipRect);
}
		static bool WouldBeTrappedInElement(const WebCore::IntRect& rect, const WebCore::IntPoint& point, EA::WebKit::JumpDirection direction)
		{
			// If we're not inside, don't worry
			if (rect.contains(point))
			{
				typedef WebCore::IntPoint Vector2D;

				const WebCore::IntPoint centre = Average( rect.minXMaxYCorner(), rect.maxXMinYCorner() );

				Vector2D pointToCentre = Subtract(centre,point);
				Vector2D forward;

				switch (direction)
				{
				// note these are 'backward
				case EA::WebKit::JumpUp:		forward = Vector2D(0,-100); break;
				case EA::WebKit::JumpDown:		forward = Vector2D(0,100); break;
				case EA::WebKit::JumpLeft:		forward = Vector2D(-100,0); break;
				case EA::WebKit::JumpRight:		forward = Vector2D(100,0); break;
				}

				// Basically, if the centre is behind us, don't jump there
				if (DotProduct(forward,pointToCentre) < 0)
				{
					return false;
				}
				else
				{
					/*printf("(%d,%d) Trapped Inside Element (%d,%d)->(%d,%d): forward=(%d,%d) pointToCentre=(%d,%d) dot=%d\n",
						point.x(),
						point.y(),
						rect.bottomLeft().x(),
						rect.bottomLeft().y(),
						rect.topRight().x(),
						rect.topRight().y(),
						forward.x(),
						forward.y(),
						pointToCentre.x(),
						pointToCentre.y(),
						DotProduct(forward,pointToCentre)
						);*/
					return true;
				}
			}
			else
			{
				return false;
			}
		}
Example #12
0
void WebViewPrivate::repaint(const WebCore::IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly)
{
    if (windowRect.isEmpty())
        return;
    IntRect rect = windowRect;
    rect.intersect(m_rect);
    
    if (rect.isEmpty())
        return;

    if (contentChanged) {
        m_webView->addToDirtyRegion(rect);
        /*Frame* focusedFrame = m_webView->page()->focusController()->focusedFrame();
        if (focusedFrame) {
            Scrollbar* hBar = focusedFrame->view()->horizontalScrollbar();
            Scrollbar* vBar = focusedFrame->view()->verticalScrollbar();
            
            // TODO : caculate the scroll delta and test this.
            //if (dx && hBar)
            if (hBar)
                m_webView->addToDirtyRegion(IntRect(focusedFrame->view()->windowClipRect().x() + hBar->x(), focusedFrame->view()->windowClipRect().y() + hBar->y(), hBar->width(), hBar->height()));
            //if (dy && vBar)
            if (vBar)
                m_webView->addToDirtyRegion(IntRect(focusedFrame->view()->windowClipRect().x() + vBar->x(), focusedFrame->view()->windowClipRect().y() + vBar->y(), vBar->width(), vBar->height()));
        }*/
    }
    if (!repaintContentOnly)
        sendExposeEvent(rect);
    if (immediate) {
        if (repaintContentOnly)
            m_webView->updateBackingStore(core(m_webView->topLevelFrame())->view());
        else
            sendExposeEvent(rect);
    }
}
Example #13
0
void WebPageCompositorPrivate::findFixedElementRect(LayerCompositingThread* layer, WebCore::IntRect& fixedElementRect)
{
    if ((layer->hasFixedContainer() || layer->isFixedPosition() || layer->hasFixedAncestorInDOMTree()) && layer->layerRenderer()) {
        IntRect fixedRect = layer->layerRenderer()->toPixelViewportCoordinates(layer->boundingBox());
        // FIXME: It's possible that the rects don't intersect now, but will be connected by a fixed rect found later.
        // We need to handle it as well.
        if (fixedElementRect.isEmpty() || fixedElementRect.intersects(fixedRect)) // Unite rects if they intersect each other.
            fixedElementRect.unite(fixedRect);
        else if (fixedRect.y() < fixedElementRect.y()) // Replace the fixedElementRect with fixedRect if fixedRect is above it (closer to top).
            fixedElementRect = fixedRect;
    }

    const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->sublayers();
    for (size_t i = 0; i < sublayers.size(); i++)
        findFixedElementRect(sublayers[i].get(), fixedElementRect);
}
void SelectionHandler::setSelection(WebCore::IntPoint start, WebCore::IntPoint end)
{
    m_selectionActive = true;

    ASSERT(m_webPage && m_webPage->mainFrame() && m_webPage->mainFrame()->selection());
    Frame* frame = m_webPage->mainFrame();
    ASSERT(frame);

#if SHOWDEBUG_SELECTIONHANDLER
    Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::setSelection adjusted points %d, %d, %d, %d", start.x(), start.y(), end.x(), end.y());
#endif

    bool selectionIsValid = true;
    VisibleSelection newSelection(frame->visiblePositionForPoint(start), frame->visiblePositionForPoint(end));

    // Validate the new points to avoid crossing frame or editing boundaries.
    if (m_webPage->mainFrame() != m_webPage->focusedOrMainFrame() && m_webPage->focusedOrMainFrame()->ownerRenderer()) {
        // Current focus frame is not the main frame, it must be a subframe.
        WebCore::IntRect subframeRect = m_webPage->focusedOrMainFrame()->ownerRenderer()->absoluteContentBox();
        if (!subframeRect.contains(start) || !subframeRect.contains(end)) {
            // Requested selection points are outside of current frame.
            selectionIsValid = false;
        }
    }
    // Check whether selection is occurring inside of an input field.  Do not handle as
    // an else if, an input field may be active inside of a subframe.
    if (m_webPage->m_inputHandler->isInputMode() && !selectionIsContainedByAnchorNode(newSelection)) {
        // Requested selection points are not contained within the anchor node (input field).
        selectionIsValid = false;
    }

    if (selectionIsValid) {
        frame->selection()->setSelection(newSelection);

#if SHOWDEBUG_SELECTIONHANDLER
        Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::setSelection selection points valid, selection updated");
#endif
    }

    // Need to manually trigger notification as response to change.
    // This needs to be set even if no selection change occurs to ensure client has accurate
    // selection points.
    selectionPositionChanged();
}
// Note:  This is the only function in SelectionHandler in which the coordinate
// system is not entirely WebKit.
void SelectionHandler::selectionPositionChanged()
{
    if (!m_selectionActive)
        return;

    // Get the transformed coordinates from the WebPage.
    WebCore::IntRect startCaret = m_webPage->selectionStartCaretRect();
    WebCore::IntRect endCaret = m_webPage->selectionEndCaretRect();

#if SHOWDEBUG_SELECTIONHANDLER
    Olympia::Platform::log(Olympia::Platform::LogLevelInfo, "SelectionHandler::selectionPositionChanged Start Rect %d, %d, %dx%d End Rect%d, %d, %dx%d",
                                   startCaret.x(), startCaret.y(), startCaret.width(), startCaret.height(),
                                   endCaret.x(), endCaret.y(), endCaret.width(), endCaret.height());
#endif

    m_webPage->m_client->selectionBounds(startCaret, endCaret);
}
		static bool TryingToDoPerpendicularJump(const WebCore::IntRect& rect, const WebCore::IntRect& previousRect, EA::WebKit::JumpDirection direction)
		{
			if (direction == EA::WebKit::JumpLeft || direction == EA::WebKit::JumpRight)
			{
				if (rect.maxXMinYCorner().x() <= previousRect.maxXMinYCorner().x() && rect.minXMinYCorner().x() >= previousRect.minXMinYCorner().x())
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				if (rect.maxXMinYCorner().y() <= previousRect.maxXMinYCorner().y() && rect.maxXMaxYCorner().y() >= previousRect.maxXMaxYCorner().y())
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
WebCore::IntRect InjectedBundleHitTestResult::imageRect() const
{
    WebCore::IntRect imageRect = m_hitTestResult.imageRect();
    if (imageRect.isEmpty())
        return imageRect;
        
    // The image rect in WebCore::HitTestResult is in frame coordinates, but we need it in WKView
    // coordinates since WebKit2 clients don't have enough context to do the conversion themselves.
    WebFrame* webFrame = frame();
    if (!webFrame)
        return imageRect;
    
    WebCore::Frame* coreFrame = webFrame->coreFrame();
    if (!coreFrame)
        return imageRect;
    
    WebCore::FrameView* view = coreFrame->view();
    if (!view)
        return imageRect;
    
    return view->contentsToRootView(imageRect);
}
		bool DocumentNavigator::doAxisCheck(WebCore::IntRect rect)
		{
			
			int left = rect.x();
			int right = rect.x() + rect.width();
			int top = rect.y();
			int bottom = rect.y() + rect.height();

			//abaldeva: Feel like only one check is enough?
			//Fixes the navigation to the yahoo.com sports section link
			switch (mDirection)
			{
			case EA::WebKit::JumpRight:
				
				if(mStrictAxesCheck)
					return left >= mStartingPosition.x();
				else
					return !(left<mStartingPosition.x() && right<mStartingPosition.x());

				break;

			case EA::WebKit::JumpDown:
				if(mStrictAxesCheck)
					return top >= mStartingPosition.y();
				else
					return !(top<mStartingPosition.y() && bottom<mStartingPosition.y());
				
				break;

			case EA::WebKit::JumpLeft:
				if(mStrictAxesCheck)
					return right <= mStartingPosition.x();
				else
					return !(left>mStartingPosition.x() && right>mStartingPosition.x());
				
				break;

			case EA::WebKit::JumpUp:
				if(mStrictAxesCheck)
					return bottom <= mStartingPosition.y();
				else
					return !(top>mStartingPosition.y() && bottom>mStartingPosition.y());
				
				break;

			default:
				EAW_FAIL_MSG("Should not have got here\n");
			}

			return false;
		}
Example #19
0
void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
{
    gtk_widget_queue_draw_area(m_viewWidget, rect.x(), rect.y(), rect.width(), rect.height());
}
Example #20
0
void WebViewPrivate::scrollBackingStore(WebCore::FrameView* view, int dx, int dy, const WebCore::IntRect& scrollViewRect, const WebCore::IntRect& clipRect)
{
    IntRect updateRect = clipRect;
    updateRect.intersect(scrollViewRect);
    
#if 0
    dy = -dy;
    dx = -dx;
    
    int svWidth = scrollViewRect.width();
    int svHeight = scrollViewRect.height();
    int dirtyX = 0, dirtyY = 0, dirtyW = 0, dirtyH = 0;

    if (dy == 0 && dx < 0 && -dx < svWidth) {
        dirtyW = -dx;
        dirtyH = svHeight;
    }
    else if (dy == 0 && dx > 0 && dx < svWidth) {
        dirtyX = svWidth - dx;
        dirtyW = dx;
        dirtyH = svHeight;
    }
    else if (dx == 0 && dy < 0 && -dy < svHeight) {
        dirtyW = svWidth;
        dirtyH = -dy;
    }
    else if (dx == 0 && dy > 0 && dy < svHeight) {
        dirtyY = svHeight - dy;
        dirtyW = svWidth;
        dirtyH = dy;
    }

    if (m_webView->viewWindow() && dirtyW) {
        m_srcRect.x = dx > 0 ? dx + scrollViewRect.x() : scrollViewRect.x();
        m_srcRect.y = dy > 0 ? dy + scrollViewRect.y() : scrollViewRect.y();
        m_srcRect.w = dx > 0 ? scrollViewRect.width() - dx : scrollViewRect.width() + dx;
        m_srcRect.h = dy > 0 ? scrollViewRect.height() - dy : scrollViewRect.height() + dy;

        m_dstRect.x = dx > 0 ? scrollViewRect.x() : -dx + scrollViewRect.x();
        m_dstRect.y = dy > 0 ? scrollViewRect.y() : -dy + scrollViewRect.y();
        m_dstRect.w = dx > 0 ? scrollViewRect.width() - dx : scrollViewRect.width() + dx;
        m_dstRect.h = dy > 0 ? scrollViewRect.height() -dy : scrollViewRect.height() + dy;

        int x, y, w, h = 0;
        if (dx > 0) {
            m_srcRect.x += m_scrollUpdateRect.width();
            m_srcRect.w -= m_scrollUpdateRect.width();
            x = scrollViewRect.x() + dirtyX - m_scrollUpdateRect.width();
            w = dirtyW + m_scrollUpdateRect.width();
        } else if (dx < 0) {
            m_dstRect.x += m_scrollUpdateRect.width();
            m_srcRect.w -= m_scrollUpdateRect.width();
            x = scrollViewRect.x() + dirtyX + m_scrollUpdateRect.width();
            w = dirtyW + m_scrollUpdateRect.width();
        } else {
            x = scrollViewRect.x() + dirtyX;
            w = dirtyW;
        }

        if (dy > 0) {
            m_srcRect.y += m_scrollUpdateRect.height();
            m_srcRect.h -= m_scrollUpdateRect.height();
            y = scrollViewRect.y() + dirtyY - m_scrollUpdateRect.height();
            h = dirtyH + m_scrollUpdateRect.height();
        } else if (dy < 0) {
            m_dstRect.y += m_scrollUpdateRect.height();
            m_srcRect.h -= m_scrollUpdateRect.height();
            y = scrollViewRect.y() + dirtyY + m_scrollUpdateRect.height();
            h = dirtyH + m_scrollUpdateRect.height();
        } else {
            y = scrollViewRect.y() + dirtyY;
            h = dirtyH;
        }

        Uint32 rmask, gmask, bmask, amask;
#if !PLATFORM(AMIGAOS4) && SDL_BYTEORDER == SDL_BIG_ENDIAN
        rmask = 0xff000000;
        gmask = 0x00ff0000;
        bmask = 0x0000ff00;
        amask = 0x000000ff;
#else
        rmask = 0x00ff0000;
        gmask = 0x0000ff00;
        bmask = 0x000000ff;
        amask = 0xff000000;
#endif

        if (m_scrollSurface)
            SDL_FreeSurface(m_scrollSurface);
        m_scrollSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, m_dstRect.w, m_dstRect.h , 32, rmask, gmask, bmask, amask);

        SDL_Rect dRect = {0, 0, m_dstRect.w, m_dstRect.h};
        SDL_BlitSurface(m_webView->viewWindow(), &m_srcRect, m_scrollSurface, &dRect);

        m_scrollUpdateRect = IntRect(x, y, w, h);
        m_scrollUpdateRect.intersect(scrollViewRect);

        Scrollbar* hBar = view->horizontalScrollbar();
        Scrollbar* vBar = view->verticalScrollbar();
        if (dx && hBar)
            m_hUpdateRect = IntRect(scrollViewRect.x() + hBar->x(), scrollViewRect.y() + hBar->y(), hBar->width(), hBar->height());
        if (dy && vBar)
            m_vUpdateRect = IntRect(scrollViewRect.x() + vBar->x(), scrollViewRect.y() + vBar->y(), vBar->width(), vBar->height());

        m_webView->addToDirtyRegion(m_scrollUpdateRect);
        sendExposeEvent(m_scrollUpdateRect);
    }
#else
    m_webView->addToDirtyRegion(updateRect);
    sendExposeEvent(updateRect);
#endif
}
Example #21
0
void CachedNode::fixUpFocusRects()
{
    if (mFixedUpFocusRects)
        return;
    mFixedUpFocusRects = true;
    if (mNavableRects <= 1)
        return;
#if DEBUG_NAV_UI
    {
        WebCore::IntRect* boundsPtr = mFocusRing.begin() - 1;
        const WebCore::IntRect* const boundsEnd = mFocusRing.begin() + mFocusRing.size();
        while (++boundsPtr < boundsEnd)
            LOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, boundsPtr - mFocusRing.begin(),
                boundsPtr->x(), boundsPtr->y(), boundsPtr->width(), boundsPtr->height());
    }
#endif
    // q: need to know when rects are for drawing and hit-testing, but not mouse down calcs?
    bool again;
    do {
        again = false;
        size_t size = mFocusRing.size();
        WebCore::IntRect* unitBoundsPtr = mFocusRing.begin() - 1;
        const WebCore::IntRect* const unitBoundsEnd = mFocusRing.begin() + size;
        while (++unitBoundsPtr < unitBoundsEnd) {
            // any other unitBounds to the left or right of this one?
            int unitTop = unitBoundsPtr->y();
            int unitBottom = unitBoundsPtr->bottom();
            int unitLeft = unitBoundsPtr->x();
            int unitRight = unitBoundsPtr->right();
            WebCore::IntRect* testBoundsPtr = mFocusRing.begin() - 1;
            while (++testBoundsPtr < unitBoundsEnd) {
                if (unitBoundsPtr == testBoundsPtr)
                    continue;
                int testTop = testBoundsPtr->y();
                int testBottom = testBoundsPtr->bottom();
                int testLeft = testBoundsPtr->x();
                int testRight = testBoundsPtr->right();
                int candidateTop = unitTop > testTop ? unitTop : testTop;
                int candidateBottom = unitBottom < testBottom ? unitBottom : testBottom;
                int candidateLeft = unitRight < testLeft ? unitRight : testRight;
                int candidateRight = unitRight > testLeft ? unitLeft : testLeft;
                bool leftRight = true;
                if (candidateTop + OVERLAP >= candidateBottom ||
                        candidateLeft + OVERLAP >= candidateRight) {
                    candidateTop = unitBottom < testTop ? unitBottom : testBottom;
                    candidateBottom = unitBottom > testTop ? unitTop : testTop;
                    candidateLeft = unitLeft > testLeft ? unitLeft : testLeft;
                    candidateRight = unitRight < testRight ? unitRight : testRight;
                    if (candidateTop + OVERLAP >= candidateBottom ||
                            candidateLeft + OVERLAP >= candidateRight)
                        continue;
                    leftRight = false;
                }
                // construct candidate to add
                WebCore::IntRect candidate = WebCore::IntRect(candidateLeft, candidateTop, 
                    candidateRight - candidateLeft, candidateBottom - candidateTop);
                // does a different unit bounds intersect the candidate? if so, don't add
                WebCore::IntRect* checkBoundsPtr = mFocusRing.begin() - 1;
                while (++checkBoundsPtr < unitBoundsEnd) {
                    if (checkBoundsPtr->intersects(candidate) == false)
                        continue;
                    if (leftRight) {
                        if (candidateTop >= checkBoundsPtr->y() &&
                                candidateBottom > checkBoundsPtr->bottom())
                            candidateTop = checkBoundsPtr->bottom(); 
                        else if (candidateTop < checkBoundsPtr->y() &&
                                candidateBottom <= checkBoundsPtr->bottom())
                            candidateBottom = checkBoundsPtr->y();
                        else
                            goto nextCheck;
                    } else {
                        if (candidateLeft >= checkBoundsPtr->x() &&
                                candidateRight > checkBoundsPtr->right())
                            candidateLeft = checkBoundsPtr->right(); 
                        else if (candidateLeft < checkBoundsPtr->x() &&
                                candidateRight <= checkBoundsPtr->right())
                            candidateRight = checkBoundsPtr->x();
                        else
                            goto nextCheck;
                    }
                 } 
                 candidate = WebCore::IntRect(candidateLeft, candidateTop, 
                    candidateRight - candidateLeft, candidateBottom - candidateTop);
                 ASSERT(candidate.isEmpty() == false);
#if DEBUG_NAV_UI
                LOGD("%s %d:(%d, %d, %d, %d)\n", __FUNCTION__, mFocusRing.size(),
                    candidate.x(), candidate.y(), candidate.width(), candidate.height());
#endif
                mFocusRing.append(candidate);
                again = true;
                goto tryAgain;
        nextCheck:
                continue;
            }
        }
tryAgain:
        ;
    } while (again);
}
Example #22
0
void ChromeClient::invalidateWindow(const WebCore::IntRect& rect, bool immediate)
{
    m_webView->addDirtyArea(rect.x(), rect.y(), rect.width(), rect.height());
    //dbgMsg(L"invalidateWindow\n");
}
Example #23
0
void BackingStoreScrollbar::repaint(const WebCore::IntRect& hotRect, bool vertical)
{
    SurfaceOpenVG* surface = SurfacePool::globalSurfacePool()->tileRenderingSurface();
    const IntSize surfaceSize(surface->width(), surface->height());
    PainterOpenVG painter(surface);

    // If the rendering surface is smaller than the scrollbar
    // (e.g. when the screen is rotated), paint it multiple times.
    int lastXTile = (m_size.width() - 1) / surfaceSize.width();
    int lastYTile = (m_size.height() - 1) / surfaceSize.height();

    FloatRect innerRect = hotRect;
    innerRect.move(0.5, 0.5); // draw it pixel-perfect with a 1.0 wide stroke
    int radius = vertical ? hotRect.width() / 2 : hotRect.height() / 2;
    if (vertical)
        innerRect.inflateY(-radius);
    else
        innerRect.inflateX(-radius);

    Path path;

    if (vertical) {
        path.moveTo(FloatPoint(innerRect.x(), innerRect.y()));
        path.addArc(FloatPoint(innerRect.x() + radius, innerRect.y()), radius, piFloat, 0, false);
        path.addLineTo(FloatPoint(innerRect.right(), innerRect.bottom()));
        path.addArc(FloatPoint(innerRect.x() + radius, innerRect.bottom()), radius, 0, piFloat, false);
        path.closeSubpath();
    } else {
        path.moveTo(FloatPoint(innerRect.right(), innerRect.y()));
        path.addArc(FloatPoint(innerRect.right(), innerRect.y() + radius), radius, piFloat + piFloat / 2, piFloat / 2, false);
        path.addLineTo(FloatPoint(innerRect.x(), innerRect.bottom()));
        path.addArc(FloatPoint(innerRect.x(), innerRect.y() + radius), radius, piFloat / 2, piFloat + piFloat / 2, false);
        path.closeSubpath();
    }

    for (int i = 0; i <= lastXTile; ++i) {
        for (int j = 0; j <= lastYTile; ++j) {
            const int dstX = i * surfaceSize.width();
            const int dstY = j * surfaceSize.height();
            const int dstRight = (i == lastXTile) ? m_size.width() : (i + 1) * surfaceSize.width();
            const int dstBottom = (j == lastYTile) ? m_size.height() : (j + 1) * surfaceSize.height();

            painter.translate(rect().x(), rect().y());

            if (dstX || dstY)
                painter.translate(-dstX, -dstY);

            // Paint the actual scrollbar.
            painter.setFillColor(Color(255, 255, 255));
            painter.drawRect(IntRect(IntPoint(0, 0), rect().size()), VG_FILL_PATH);
            painter.setFillColor(Color(173, 176, 178));
            painter.drawPath(path, VG_FILL_PATH, WebCore::RULE_NONZERO);

            surface->makeCurrent();
            unsigned char* dstBufferStart = m_image + (dstY * imageStride()) + (dstX * imageBytesPerPixel());
            vgReadPixels(dstBufferStart, imageStride(), VG_sRGB_565,
                0, 0, dstRight - dstX, dstBottom - dstY);
            ASSERT_VG_NO_ERROR();

            // Paint the alpha channel for the actual scrollbar.
            painter.setCompositeOperation(CompositeClear);
            painter.setFillColor(Color(0, 0, 0));
            painter.drawRect(IntRect(IntPoint(0, 0), rect().size()), VG_FILL_PATH);
            painter.setCompositeOperation(CompositeSourceOver);
            painter.setFillColor(Color(255, 255, 255));
            painter.drawPath(path, VG_FILL_PATH, WebCore::RULE_NONZERO);

            surface->makeCurrent();
            // FIXME: We need VG_A_4 until proper alpha blending is available.
            //   When we get 8-bit formats, make sure to adapt both the format
            //   and remove the division by two when determining the dstAlphaBufferStart.
            unsigned char* dstAlphaBufferStart = m_alphaImage + (dstY * alphaImageStride()) + dstX / 2;
            vgReadPixels(dstAlphaBufferStart, alphaImageStride(), VG_A_4,
                0, 0, dstRight - dstX, dstBottom - dstY);
            ASSERT_VG_NO_ERROR();

            if (dstX || dstY)
                painter.translate(dstX, dstY);
        }
    }
}
Example #24
0
void NonCompositedContentHost::invalidateRect(const WebCore::IntRect& rect)
{
    WebCore::IntRect layerRect = rect;
    layerRect.move(-m_layerAdjust);
    m_graphicsLayer->setNeedsDisplayInRect(WebCore::FloatRect(layerRect));
}
Example #25
0
void ChromeClient::invalidateContentsForSlowScroll(const WebCore::IntRect& rect, bool immediate)
{
    m_webView->addDirtyArea(rect.x(), rect.y(), rect.width(), rect.height());
    //dbgMsg(L"invalidateContentsForSlowScroll\n");
}
void ViewNavigationDelegate::MoveMouseCursorToNode(WebCore::Node* node, bool scrollIfNecessary)
{
	if (node)
	{
		WebCore::HTMLElement* element = (WebCore::HTMLElement*)node;

		WebCore::IntRect rect = element->getRect();
		WebCore::IntPoint frameOffset;
		WebCore::IntPoint scrollOffset;

		WebCore::FrameView* pFrameView = element->document()->view(); //Can be NULL
		if(pFrameView)
		{
			//Use move here instead of setX/setY as it results in 1 call instead of two and takes advantage that ctor sets x,y to 0.
			frameOffset.move(pFrameView->x(), pFrameView->y());
			scrollOffset.move(pFrameView->scrollOffset().width(), pFrameView->scrollOffset().height());
		}

		int width = mView->GetSize().mWidth;
		int height = mView->GetSize().mHeight;

		// This will be true if this function is called from anywhere except JumpToNearestElement(). This enables us to not lose the cursor during
		// arbitrary jumping of elements from either code or webpage using the Navigation APIs.
		if(scrollIfNecessary)
		{
			int cursorX, cursorY;
			mView->GetCursorPosition(cursorX, cursorY);

			WebCore::IntPoint targetCursorLocation(frameOffset.x()+rect.x()+rect.width()/2  - scrollOffset.x(), frameOffset.y()+rect.y()+rect.height()/2  - scrollOffset.y());
			// Added 1 in all the line delta below resulting in a better visual behavior when the element happens to be at the edge.
			if(targetCursorLocation.y() > height)
			{
                float numLinesDelta = (((targetCursorLocation.y() - cursorY)/WebCore::Scrollbar::pixelsPerLineStep())+1);
				ScrollOnJump(true, -120, numLinesDelta);
			}
			if(targetCursorLocation.y()< 0.0f)
			{
				float numLinesDelta = (((cursorY - targetCursorLocation.y())/WebCore::Scrollbar::pixelsPerLineStep())+1);
				ScrollOnJump(true, 120, numLinesDelta);
			}
			if(targetCursorLocation.x() > width)
			{
				float numLinesDelta = (((targetCursorLocation.x() - cursorX)/WebCore::Scrollbar::pixelsPerLineStep())+1);
				ScrollOnJump(false, -120, numLinesDelta);
			}
			if(targetCursorLocation.x()< 0.0f)
			{
				float numLinesDelta = (((cursorX - targetCursorLocation.x())/WebCore::Scrollbar::pixelsPerLineStep())+1);
				ScrollOnJump(false, 120, numLinesDelta);
			}

			// Read the scroll offset again as it may have changed.
			if(pFrameView) 
			{
				scrollOffset.setX(pFrameView->scrollOffset().width());
				scrollOffset.setY(pFrameView->scrollOffset().height());
			}
		}

		mBestNodeFrame	= element->document()->frame(); //Can be NULL
		mBestNodeX		= frameOffset.x()  + rect.x();
		mBestNodeY		= frameOffset.y()  + rect.y();
		mBestNodeWidth	= rect.width();
		mBestNodeHeight = rect.height();

		int lastX, lastY;
		mView->GetCursorPosition(lastX, lastY);
		int newX		= mBestNodeX + rect.width()/2  - scrollOffset.x();
		int newY		= mBestNodeY + rect.height()/2 - scrollOffset.y();

		EA::WebKit::MouseMoveEvent moveEvent;
		memset( &moveEvent, 0, sizeof(moveEvent) );
		const int cursorInset = 5;// Make cursor stay inside 5 pixels from boundaries. No known issues but added this as a safety measure so that we do not lose cursor ever.
		moveEvent.mX	= Clamp( cursorInset, newX, width - cursorInset );
		moveEvent.mY	= Clamp( cursorInset, newY, height - cursorInset );

		mView->OnMouseMoveEvent( moveEvent );

		if(EAWebKitClient* const pClient = GetEAWebKitClient())
		{
			CursorMovedInfo cmInfo(mView, mView->GetUserData(), moveEvent.mX, moveEvent.mY);
			pClient->CursorMoved(cmInfo);
		}

		UpdateCachedHints(node);

	}
}
void ThreadedCoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect& rect)
{
    m_compositor->scrollTo(rect.location());
    scheduleLayerFlush();
}
		void DocumentNavigator::FindBestNode(WebCore::Node* rootNode)
		{
			// Note by Arpit Baldeva - Changed the recursive algorithm to an iterative algorithm. This results in 25% to 40% increase in efficiency.
			
			while (rootNode) 
			{
				IsNodeNavigableDelegate nodeNavigableDelegate(mView);
				// As it turns out, getRect on HTMLElement is pretty expensive. So we don't do it inside the delegate as we require getRect here too. We do that check here.
				// It is at least ~15% more efficient and can be up to ~25% more efficient (depends on the page layout and current node you are at).
				nodeNavigableDelegate(rootNode,false);

				if (nodeNavigableDelegate.FoundNode())
				{
					WebCore::HTMLElement* htmlElement = (WebCore::HTMLElement*) rootNode;
					WebCore::IntRect rectAbsolute = htmlElement->getRect();		
					// Adjust the rectangle position based on the frame offset so that we have absolute geometrical position.
					WebCore::FrameView* pFrameView = htmlElement->document()->view(); //Can be NULL
					if(pFrameView)
					{
						rectAbsolute.setX(rectAbsolute.x() + pFrameView->x());
						rectAbsolute.setY(rectAbsolute.y() + pFrameView->y());
					}

					 /* printf("Looking at ELEMENT_NODE : nodeName=%S (%d,%d)->(%d,%d) ThetaRange(%f,%f)\n\n%S\n-----------------------------------\n", 
											htmlElement->tagName().charactersWithNullTermination(),
											rect.topLeft().x(),rect.topLeft().y(),
											rect.bottomRight().x(), rect.bottomRight().y(),
											mMinThetaRange,mMaxThetaRange,
											htmlElement->innerHTML().charactersWithNullTermination()
											);
										*/

					if (!WouldBeTrappedInElement(rectAbsolute,mStartingPosition,mDirection))
					{
						if (!TryingToDoPerpendicularJump(rectAbsolute,mPreviousNodeRect,mDirection))
						{
							if(rectAbsolute.width()>=1 && rectAbsolute.height() >= 1) //Avoid 0 size elements
							{
								if (doAxisCheck(rectAbsolute))
								{
									PolarRegion pr(rectAbsolute, mStartingPosition);

									if (pr.minR < mMinR )
									{
										if (areAnglesInRange(pr.minTheta,pr.maxTheta))
										{
											mMinR = pr.minR;

											EAW_ASSERT( *(uint32_t*)rootNode > 10000000u );

											//mBestNode = rootNode; //We don't assign it here since we do the Z-layer testing later on.
											FoundNodeInfo foundNodeInfo = {rootNode, mMinR};
											mNodeListContainer->mFoundNodes.push_back(foundNodeInfo);
											/*printf("Found ELEMENT_NODE : nodeName=%s (%d,%d)->(%d,%d) polar: R(%f,%f) Theta(%f,%f) ThetaRange(%f,%f)  \n", 
											(char*)htmlElement->nodeName().characters(),
											rect.topLeft().x(),rect.topLeft().y(),
											rect.bottomRight().x(), rect.bottomRight().y(),
											pr.minR,pr.maxR,pr.minTheta,pr.maxTheta,
											mMinThetaRange,mMaxThetaRange
											);*/
											
										} 
										else
										{
											
#if EAWEBKIT_ENABLE_JUMP_NAVIGATION_DEBUGGING
											mNodeListContainer->mRejectedByAngleNodes.push_back(rootNode);
#endif
											/*printf("RejectedA ELEMENT_NODE : nodeName=%s (%d,%d)->(%d,%d) polar: R(%f,%f) Theta(%f,%f) ThetaRange(%f,%f)  \n", 
											(char*)htmlElement->nodeName().characters(),
											rect.topLeft().x(),rect.topLeft().y(),
											rect.bottomRight().x(), rect.bottomRight().y(),
											pr.minR,pr.maxR,pr.minTheta,pr.maxTheta,
											mMinThetaRange,mMaxThetaRange
											);*/
										}
									} 
									else
									{
#if EAWEBKIT_ENABLE_JUMP_NAVIGATION_DEBUGGING
										mNodeListContainer->mRejectedByRadiusNodes.push_back(rootNode);
#endif
										/*printf("RejectedR ELEMENT_NODE : nodeName=%s (%d,%d)->(%d,%d) polar: R(%f,%f) Theta(%f,%f) ThetaRange(%f,%f)  \n", 
										(char*)htmlElement->nodeName().characters(),
										rect.topLeft().x(),rect.topLeft().y(),
										rect.bottomRight().x(), rect.bottomRight().y(),
										pr.minR,pr.maxR,pr.minTheta,pr.maxTheta,
										mMinThetaRange,mMaxThetaRange
										);*/
									}
								}
								else
								{
									//printf(" - failed axis check\n");
								}
							}
							else
							{
								//printf(" - too small\n");
							}
						}
						else 
						{
							//printf(" - perpendicular\n");
						}							
					}
					else
					{
#if EAWEBKIT_ENABLE_JUMP_NAVIGATION_DEBUGGING
						mNodeListContainer->mRejectedWouldBeTrappedNodes.push_back(rootNode);
#endif
					}
				}
				
				rootNode = rootNode->traverseNextNode();
			}

			// Make sure that this element can be jumped to by passing z-check. This makes sure that we jump only on the element
			// at the top most layer (For example, a CSS+JavaScript pop up).
			// We don't try and check against Z-layer in the loop above as it has significant performance penalty. On an average, it causes traversal to be 50% slower. So what we do 
			// instead is to collect all the nodes and at the end, traverse this list from the end to begining. It is important to traverse from end as that is where the most suited element is 
			// based on the position.

			WebCore::Node* bestNode = NULL;
			float radialDistance = FLT_MAX; // A high value so that the max distance between any two elements in the surface is under it.
			bool matched = false;
			for (WebCoreFoundNodeInfoListReverseIterator rIt = mNodeListContainer->mFoundNodes.rbegin(); rIt != mNodeListContainer->mFoundNodes.rend(); ++rIt)
			{
				bestNode = (*rIt).mFoundNode;
				radialDistance = (*rIt).mRadialDistance;
				WebCore::HTMLElement* element = (WebCore::HTMLElement*)bestNode;

				WebCore::Frame*		frame = element->document()->frame();
				WebCore::FrameView* pFrameView = element->document()->view(); 

				WebCore::IntRect rect = element->getRect(); //This list is decently small so we don't worry about caching the rect size.
				// ElementFromPoint expects the point in its own coordinate system so we don't need to adjust the rectangle to its absolute position
				// on screen
				// elementFromPoint API changed compared to 1.x. The simplest thing to do at the moment is to adjust our input.
				int inputX = (rect.x()+rect.width()/2 - pFrameView->scrollX())/frame->pageZoomFactor();
				int inputY = (rect.y()+rect.height()/2 - pFrameView->scrollY())/frame->pageZoomFactor();
				
				WebCore::Node* hitElement = mDocument->elementFromPoint(inputX,inputY);
				while (hitElement)
				{
					if(bestNode == hitElement)
					{
						matched = true;
						break;
					}
					hitElement = hitElement->parentNode();//We need to find the element that responds to the events as that is what we jump to. For example, we don't jump to a "span".
				};

				if(matched)
					break;
			}

			if(matched)
			{
				mBestNode = bestNode;
				mMinR = radialDistance;
			}
			else
			{
				mBestNode = 0; //We didn't match anything based on the Z-layer testing.
				mMinR = FLT_MAX;
			}


			// A way to do Post Order traversal.
			//while (WebCore::Node* firstChild = rootNode->firstChild())
			//	rootNode = firstChild;
			//while(rootNode)
			//{
			//	rootNode = rootNode->traverseNextNodePostOrder();
			//}


/*
			//////////////////////////////////////////////////////////////////////////
			// THEN, FIND THE CHILDREN
			if (rootNode && rootNode->childNodeCount() > 0)
			{
				PassRefPtr<WebCore::NodeList> children = rootNode->childNodes();

				const uint32_t length = children->length();

				for (uint32_t i=0; i < length; ++i)
				{
					WebCore::Node* child = children->item(i);
					if (child)
					{
						FindBestNode(child);
					}
				}
			}
*/		
		}
void CachedHistory::pinMaxMin(const WebCore::IntRect& viewBounds)
{
    if (mMinWorkingHorizontal < viewBounds.y() || 
            mMinWorkingHorizontal >= viewBounds.bottom())
        mMinWorkingHorizontal = viewBounds.y();
    if (mMaxWorkingHorizontal > viewBounds.bottom() || 
            mMaxWorkingHorizontal <= viewBounds.y())
        mMaxWorkingHorizontal = viewBounds.bottom();
    if (mMinWorkingVertical < viewBounds.x() || 
            mMinWorkingVertical >= viewBounds.right())
        mMinWorkingVertical = viewBounds.x();
    if (mMaxWorkingVertical > viewBounds.right() || 
            mMaxWorkingVertical <= viewBounds.x())
        mMaxWorkingVertical = viewBounds.right();
}
Example #30
0
// Returns two point ranges (<left, width> pairs) at row 'canvasY', that belong to 'src' but not 'dst'.
// A point range is empty if the corresponding width is 0.
inline void findBlendRangeAtRow(const WebCore::IntRect& src, const WebCore::IntRect& dst, int canvasY, int& left1, int& width1, int& left2, int& width2)
{
    ASSERT_WITH_SECURITY_IMPLICATION(canvasY >= src.y() && canvasY < src.maxY());
    left1 = -1;
    width1 = 0;
    left2 = -1;
    width2 = 0;

    if (canvasY < dst.y() || canvasY >= dst.maxY() || src.x() >= dst.maxX() || src.maxX() <= dst.x()) {
        left1 = src.x();
        width1 = src.width();
        return;
    }

    if (src.x() < dst.x()) {
        left1 = src.x();
        width1 = dst.x() - src.x();
    }

    if (src.maxX() > dst.maxX()) {
        left2 = dst.maxX();
        width2 = src.maxX() - dst.maxX();
    }
}