bool WMLAElement::isKeyboardFocusable(KeyboardEvent* event) const { if (!isFocusable()) return false; if (!document()->frame()) return false; if (!document()->frame()->eventHandler()->tabsToLinks(event)) return false; // Before calling absoluteRects, check for the common case where the renderer // or one of the continuations is non-empty, since this is a faster check and // almost always returns true. for (RenderObject* r = renderer(); r; r = r->continuation()) if (r->width() > 0 && r->height() > 0) return true; Vector<IntRect> rects; FloatPoint absPos = renderer()->localToAbsolute(); renderer()->absoluteRects(rects, absPos.x(), absPos.y()); size_t n = rects.size(); for (size_t i = 0; i < n; ++i) if (!rects[i].isEmpty()) return true; return false; }
bool HTMLAnchorElement::isFocusable() const { if (isContentEditable()) return HTMLElement::isFocusable(); // FIXME: Even if we are not visible, we might have a child that is visible. // Dave wants to fix that some day with a "has visible content" flag or the like. if (!(m_isLink && renderer() && renderer()->style()->visibility() == VISIBLE)) return false; // Before calling absoluteRects, check for the common case where the renderer // or one of the continuations is non-empty, since this is a faster check and // almost always returns true. for (RenderObject* r = renderer(); r; r = r->continuation()) if (r->width() > 0 && r->height() > 0) return true; Vector<IntRect> rects; int x, y; renderer()->absolutePosition(x, y); renderer()->absoluteRects(rects, x, y); size_t n = rects.size(); for (size_t i = 0; i < n; ++i) if (!rects[i].isEmpty()) return true; return false; }
Position RenderInline::positionForCoordinates(int x, int y) { for (RenderObject *c = continuation(); c; c = c->continuation()) { if (c->isInline() || c->firstChild()) return c->positionForCoordinates(x, y); } return RenderFlow::positionForCoordinates(x, y); }
void RenderContainer::removeLeftoverAnonymousBoxes() { // we have to go over all child nodes and remove anonymous boxes, that do _not_ // have inline children to keep the tree flat RenderObject *child = firstChild(); while( child ) { RenderObject *next = child->nextSibling(); if ( child->isRenderBlock() && child->isAnonymousBlock() && !child->continuation() && !child->childrenInline() && !child->isTableCell() ) { RenderObject *firstAnChild = child->firstChild(); RenderObject *lastAnChild = child->lastChild(); if ( firstAnChild ) { RenderObject *o = firstAnChild; while( o ) { o->setParent( this ); o = o->nextSibling(); } firstAnChild->setPreviousSibling( child->previousSibling() ); lastAnChild->setNextSibling( child->nextSibling() ); if ( child->previousSibling() ) child->previousSibling()->setNextSibling( firstAnChild ); if ( child->nextSibling() ) child->nextSibling()->setPreviousSibling( lastAnChild ); } else { if ( child->previousSibling() ) child->previousSibling()->setNextSibling( child->nextSibling() ); if ( child->nextSibling() ) child->nextSibling()->setPreviousSibling( child->previousSibling() ); } if ( child == firstChild() ) m_first = firstAnChild; if ( child == lastChild() ) m_last = lastAnChild; child->setParent( 0 ); child->setPreviousSibling( 0 ); child->setNextSibling( 0 ); if ( !child->isText() ) { RenderContainer *c = static_cast<RenderContainer *>(child); c->m_first = 0; c->m_next = 0; } child->detach(); } child = next; } if ( parent() ) parent()->removeLeftoverAnonymousBoxes(); }
VisiblePosition RenderInline::positionForCoordinates(int x, int y) { // Translate the coords from the pre-anonymous block to the post-anonymous block. RenderBlock* cb = containingBlock(); int parentBlockX = cb->xPos() + x; int parentBlockY = cb->yPos() + y; for (RenderObject* c = continuation(); c; c = c->continuation()) { RenderObject* contBlock = c; if (c->isInline()) contBlock = c->containingBlock(); if (c->isInline() || c->firstChild()) return c->positionForCoordinates(parentBlockX - contBlock->xPos(), parentBlockY - contBlock->yPos()); } return RenderFlow::positionForCoordinates(x, y); }