void  RenderMathMLSubSup::stretchToHeight(int height)
{
    RenderObject* base = firstChild();
    if (!base)
        return;
    
    if (base->isRenderMathMLBlock()) {
        RenderMathMLBlock* block = toRenderMathMLBlock(base);
        block->stretchToHeight(static_cast<int>(gSubSupStretch * height));
    }
    if (height > 0 && m_kind == SubSup && m_scripts) {
        RenderObject* script = m_scripts->firstChild();
        if (script) {
            // Calculate the script height without the container margins.
            RenderObject* top = script;
            int topHeight = getBoxModelObjectHeight(top->firstChild());
            int topAdjust = topHeight / gTopAdjustDivisor;
            top->style()->setMarginTop(Length(-topAdjust, Fixed));
            top->style()->setMarginBottom(Length(height - topHeight + topAdjust, Fixed));
            if (top->isBoxModelObject()) {
                RenderBoxModelObject* topBox = toRenderBoxModelObject(top);
                topBox->updateBoxModelInfoFromStyle();
            }
            m_scripts->setNeedsLayoutAndPrefWidthsRecalc();
            m_scripts->markContainingBlocksForLayout();
        }
    }
    updateBoxModelInfoFromStyle();
    setNeedsLayoutAndPrefWidthsRecalc();
    markContainingBlocksForLayout();
}
int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels)
{
    // Make sure the element is not freed during the layout.
    RefPtrWillBeRawPtr<Element> protect(element);
    element->document().updateLayout();

    RenderBoxModelObject* box = enclosingBoxModelObject(element->renderer());
    if (!box)
        return -1;

    LocalFrame* frame = element->document().frame();
    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
    PrintContext printContext(frame);
    printContext.begin(pageRect.width(), pageRect.height());
    FloatSize scaledPageSize = pageSizeInPixels;
    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
    printContext.computePageRectsWithPageSize(scaledPageSize, false);

    int top = box->pixelSnappedOffsetTop();
    int left = box->pixelSnappedOffsetLeft();
    size_t pageNumber = 0;
    for (; pageNumber < printContext.pageCount(); pageNumber++) {
        const IntRect& page = printContext.pageRect(pageNumber);
        if (page.x() <= left && left < page.maxX() && page.y() <= top && top < page.maxY())
            return pageNumber;
    }
    return -1;
}
bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
{
    if (!isLink())
        return HTMLElement::isKeyboardFocusable(event);

    if (!isFocusable())
        return false;
    
    if (!document()->frame())
        return false;

    if (!document()->frame()->eventHandler()->tabsToLinks(event))
        return false;

    if (!renderer() || !renderer()->isBoxModelObject())
        return false;
    
    // Before calling absoluteRects, check for the common case where the renderer
    // is non-empty, since this is a faster check and almost always returns true.
    RenderBoxModelObject* box = toRenderBoxModelObject(renderer());
    if (!box->borderBoundingBox().isEmpty())
        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;
}
Example #4
0
int InlineBox::logicalHeight() const
{
//SISO_HTMLComposer Start
    int result = 0;
    int lineHeightAdjust = root()->isLineHeightAdjust()? root()->lineHeightAdjustValue() : 0;
//SISO_HTMLComposer End
#if ENABLE(SVG)
    if (hasVirtualLogicalHeight())
        return virtualLogicalHeight();
#endif
//SISO_HTMLComposer Start
    
    if (renderer()->isText()) {
        result = m_isText ? renderer()->style(m_firstLine)->fontMetrics().height() : 0;
        result += lineHeightAdjust;
        return result;
    }
    if (renderer()->isBox() && parent()) { 
        result = isHorizontal() ? toRenderBox(m_renderer)->height() : toRenderBox(m_renderer)->width();
        result += lineHeightAdjust;
        return result;
    }
//SISO_HTMLComposer End

    ASSERT(isInlineFlowBox());
    RenderBoxModelObject* flowObject = boxModelObject();
    const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics();
    result = fontMetrics.height();
    if (parent())
        result += flowObject->borderAndPaddingLogicalHeight();
//SISO_HTMLComposer Start
    result += lineHeightAdjust;
//SISO_HTMLComposer End
    return result;
}
Example #5
0
void RenderMathMLSquareRoot::layout()
{
    int maxHeight = 0;
    
    RenderObject* current = firstChild();
    while (current) {
        if (current->isBoxModelObject()) {
            RenderBoxModelObject* box = toRenderBoxModelObject(current);
            
            if (box->pixelSnappedOffsetHeight() > maxHeight)
                maxHeight = box->pixelSnappedOffsetHeight();
            
            box->style()->setVerticalAlign(BASELINE);
        }
        current = current->nextSibling();
    }
    
    if (!maxHeight)
        maxHeight = style()->fontSize();

    
    if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
        style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));

    
    RenderBlock::layout();
}
RenderMathMLOperator* RenderMathMLSubSup::unembellishedOperator()
{
    RenderBoxModelObject* base = this->base();
    if (!base || !base->isRenderMathMLBlock())
        return 0;
    return toRenderMathMLBlock(base)->unembellishedOperator();
}
Example #7
0
WebRenderLayer::WebRenderLayer(RenderLayer* layer)
{
    RenderBoxModelObject* renderer = layer->renderer();

    m_renderObjectName = renderer->renderName();

    if (Node* node = renderer->node()) {
        if (node->isElementNode()) {
            Element* element = toElement(node);
            m_elementTagName = element->tagName();
            m_elementID = element->getIdAttribute();
            if (element->isStyledElement() && element->hasClass()) {
                StyledElement* styledElement = static_cast<StyledElement*>(element);
                if (size_t classNameCount = styledElement->classNames().size()) {
                    m_elementClassNames = MutableArray::create();
                    for (size_t i = 0; i < classNameCount; ++i)
                        m_elementClassNames->append(WebString::create(styledElement->classNames()[i]).get());
                }
            }

        }
    }

    m_isReflection = layer->isReflection();

#if USE(ACCELERATED_COMPOSITING)
    if (layer->isComposited()) {
        RenderLayerBacking* backing = layer->backing();
        m_isClipping = backing->hasClippingLayer();
        m_isClipped = backing->hasAncestorClippingLayer();
        switch (backing->compositingLayerType()) {
        case NormalCompositingLayer:
            m_compositingLayerType = Normal;
            break;
        case TiledCompositingLayer:
            m_compositingLayerType = Tiled;
            break;
        case MediaCompositingLayer:
            m_compositingLayerType = Media;
            break;
        case ContainerCompositingLayer:
            m_compositingLayerType = Container;
            break;
        }
    } else {
#endif
        m_isClipping = false;
        m_isClipped = false;
        m_compositingLayerType = None;
#if USE(ACCELERATED_COMPOSITING)
    }
#endif

    m_absoluteBoundingBox = layer->absoluteBoundingBox();

    m_negativeZOrderList = createArrayFromLayerList(layer->negZOrderList());
    m_normalFlowList = createArrayFromLayerList(layer->normalFlowList());
    m_positiveZOrderList = createArrayFromLayerList(layer->posZOrderList());
}
Example #8
0
inline int getOffsetHeight(RenderObject* obj) 
{
    if (obj->isBoxModelObject()) {
        RenderBoxModelObject* box = toRenderBoxModelObject(obj);
        return box->offsetHeight();
    }
   
    return 0;
}
void RenderMathMLUnderOver::stretchToHeight(int height)
{
    RenderBoxModelObject* base = this->base();
    if (base && base->isRenderMathMLBlock()) {
        RenderMathMLBlock* block = toRenderMathMLBlock(base);
        block->stretchToHeight(height);
        setNeedsLayout(true);
    }
}
// Finds a RenderListItem parent give a node.
static RenderListItem* renderListItemContainerForNode(Node* node)
{
    for (; node; node = node->parentNode()) {
        RenderBoxModelObject* renderer = node->renderBoxModelObject();
        if (renderer && renderer->isListItem())
            return toRenderListItem(renderer);
    }
    return 0;
}
Example #11
0
void RenderMathMLSubSup::layout()
{
    RenderBlock::layout();
    
    if (m_kind != SubSup || !m_scripts)
        return;
    RenderBoxModelObject* base = this->base();
    RenderObject* superscriptWrapper = m_scripts->firstChild();
    RenderObject* subscriptWrapper = m_scripts->lastChild();
    if (!base || !superscriptWrapper || !subscriptWrapper || superscriptWrapper == subscriptWrapper)
        return;
    ASSERT(superscriptWrapper->isRenderMathMLBlock());
    ASSERT(subscriptWrapper->isRenderMathMLBlock());
    RenderObject* superscript = superscriptWrapper->firstChild();
    RenderObject* subscript = subscriptWrapper->firstChild();
    if (!superscript || !subscript)
        return;
    
    LineDirectionMode lineDirection = style()->isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
    LayoutUnit baseBaseline = base->baselinePosition(AlphabeticBaseline, true, lineDirection);
    LayoutUnit baseExtendUnderBaseline = getBoxModelObjectHeight(base) - baseBaseline;
    LayoutUnit axis = style()->fontMetrics().xHeight() / 2;
    LayoutUnit superscriptHeight = getBoxModelObjectHeight(superscript);
    LayoutUnit subscriptHeight = getBoxModelObjectHeight(subscript);
    
    // Our layout rules are: Don't let the superscript go below the "axis" (half x-height above the
    // baseline), or the subscript above the axis. Also, don't let the superscript's top edge be
    // below the base's top edge, or the subscript's bottom edge above the base's bottom edge.
    //
    // FIXME: Check any subscriptshift or superscriptshift attributes, and maybe use more sophisticated
    // heuristics from TeX or elsewhere. See https://bugs.webkit.org/show_bug.cgi?id=79274#c5.
    
    // Above we did scriptsStyle->setVerticalAlign(TOP) for mscripts' style, so the superscript's
    // top edge will equal the top edge of the base's padding.
    LayoutUnit basePaddingTop = superscriptHeight + axis - baseBaseline;
    // If basePaddingTop is positive, it's indeed the base's padding-top that we need. If it's negative,
    // then we should instead use its absolute value to pad the bottom of the superscript, to get the
    // superscript's bottom edge down to the axis. First we compute how much more we need to shift the
    // subscript down, once its top edge is at the axis.
    LayoutUnit superPaddingBottom = max<LayoutUnit>(baseExtendUnderBaseline + axis - subscriptHeight, 0);
    if (basePaddingTop < 0) {
        superPaddingBottom += -basePaddingTop;
        basePaddingTop = 0;
    }
    
    setChildNeedsLayout(true, false);
    
    RenderObject* baseWrapper = firstChild();
    baseWrapper->style()->setPaddingTop(Length(basePaddingTop, Fixed));
    baseWrapper->setNeedsLayout(true, false);
    
    superscriptWrapper->style()->setPaddingBottom(Length(superPaddingBottom, Fixed));
    superscriptWrapper->setNeedsLayout(true, false);
    m_scripts->setNeedsLayout(true, false);
    
    RenderBlock::layout();
}
Example #12
0
void RenderMathMLRow::layout() 
{
    RenderBlock::layout();
    
    LayoutUnit maxHeight = 0;
    int childCount = 0;
    int operatorCount = 0;

    // Calculate the non-operator max height of the row.
    LayoutUnit operatorHeight = 0;
    for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
        childCount++;
        if (current->isRenderMathMLBlock()) {
            RenderMathMLBlock* block = toRenderMathMLBlock(current);
            // Check to see if the non-operator block has a greater height.
            if (!block->hasBase() && !block->isRenderMathMLOperator() && block->offsetHeight() > maxHeight)
                maxHeight = block->offsetHeight();
            if (block->hasBase() && block->nonOperatorHeight() > maxHeight) 
                maxHeight = block->nonOperatorHeight();
            // If the block is an operator, capture the maximum height and increment the count.
            if (block->isRenderMathMLOperator()) {
                if (block->offsetHeight() > operatorHeight)
                    operatorHeight = block->offsetHeight();
                operatorCount++;
            }
        } else if (current->isBoxModelObject()) {
            RenderBoxModelObject* box = toRenderBoxModelObject(current);
            // Check to see if this box has a larger height.
            if (box->offsetHeight() > maxHeight)
                maxHeight = box->offsetHeight();
        }
    }
    
    if (childCount > 0 && childCount == operatorCount) {
        // We have only operators and so set the max height to the operator height.
        maxHeight = operatorHeight;
    }
    
    // Stretch everything to the same height (blocks can ignore the request).
    if (maxHeight > 0) {
        bool didStretch = false;
        for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
            if (current->isRenderMathMLBlock()) {
                RenderMathMLBlock* block = toRenderMathMLBlock(current);
                block->stretchToHeight(maxHeight);
                didStretch = true;
            }
        }
        if (didStretch) {
            setNeedsLayout(true);
            setPreferredLogicalWidthsDirty(true, false);
            RenderBlock::layout();
        }
    }
    
}    
void RenderMathMLRoot::layout()
{
    // Our computePreferredLogicalWidths() may change our logical width and then layout our children, which
    // RenderBlock::layout()'s relayoutChildren logic isn't expecting.
    if (preferredLogicalWidthsDirty())
        computePreferredLogicalWidths();
    
    RenderMathMLBlock::layout();
    
    RenderBoxModelObject* index = this->index();
    // If |index|, it should be a RenderBlock here, unless the user has overriden its { position: absolute }.
    if (index && index->isBox())
        toRenderBox(index)->setLogicalTop(m_indexTop);
}
Example #14
0
PassRefPtr<ClientRectList> Element::getClientRects()
{
    document().updateLayout();

    RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject();
    if (!renderBoxModelObject)
        return ClientRectList::create();

    // FIXME: Handle SVG elements.
    // FIXME: Handle table/inline-table with a caption.

    Vector<FloatQuad> quads;
    renderBoxModelObject->absoluteQuads(quads);
    return ClientRectList::create(quads);
}
Example #15
0
static PassRefPtr<AccessibilityObject> createFromRenderer(RenderObject* renderer)
{
    // FIXME: How could renderer->node() ever not be an Element?
    Node* node = renderer->node();

    // If the node is aria role="list" or the aria role is empty and its a
    // ul/ol/dl type (it shouldn't be a list if aria says otherwise).
    if (node && ((nodeHasRole(node, "list") || nodeHasRole(node, "directory"))
                      || (nodeHasRole(node, nullAtom) && (node->hasTagName(ulTag) || node->hasTagName(olTag) || node->hasTagName(dlTag)))))
        return AccessibilityList::create(renderer);

    // aria tables
    if (nodeHasRole(node, "grid") || nodeHasRole(node, "treegrid"))
        return AccessibilityARIAGrid::create(renderer);
    if (nodeHasRole(node, "row"))
        return AccessibilityARIAGridRow::create(renderer);
    if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "columnheader") || nodeHasRole(node, "rowheader"))
        return AccessibilityARIAGridCell::create(renderer);

#if ENABLE(VIDEO)
    // media controls
    if (node && node->isMediaControlElement())
        return AccessibilityMediaControl::create(renderer);
#endif

#if ENABLE(SVG)
    if (renderer->isSVGRoot())
        return AccessibilitySVGRoot::create(renderer);
#endif
    
    if (renderer->isBoxModelObject()) {
        RenderBoxModelObject* cssBox = toRenderBoxModelObject(renderer);
        if (cssBox->isListBox())
            return AccessibilityListBox::create(toRenderListBox(cssBox));
        if (cssBox->isMenuList())
            return AccessibilityMenuList::create(toRenderMenuList(cssBox));

        // standard tables
        if (cssBox->isTable())
            return AccessibilityTable::create(toRenderTable(cssBox));
        if (cssBox->isTableRow())
            return AccessibilityTableRow::create(toRenderTableRow(cssBox));
        if (cssBox->isTableCell())
            return AccessibilityTableCell::create(toRenderTableCell(cssBox));

#if ENABLE(PROGRESS_ELEMENT)
        // progress bar
        if (cssBox->isProgress())
            return AccessibilityProgressIndicator::create(toRenderProgress(cssBox));
#endif

        // input type=range
        if (cssBox->isSlider())
            return AccessibilitySlider::create(toRenderSlider(cssBox));
    }

    return AccessibilityRenderObject::create(renderer);
}
Example #16
0
static inline RenderBoxModelObject& findRendererDefininingTextDecoration(InlineFlowBox* parentBox)
{
    // Lookup first render object in parent hierarchy which has text-decoration set.
    RenderBoxModelObject* renderer = nullptr;
    while (parentBox) {
        renderer = &parentBox->renderer();

        if (renderer->style()->textDecoration() != TextDecorationNone)
            break;

        parentBox = parentBox->parent();
    }

    ASSERT(renderer);
    return *renderer;
}
void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject& start, bool& lastCharacterWasSpace)
{
    ASSERT(!is<RenderSVGText>(start) || m_textPositions.isEmpty());

    for (RenderObject* child = start.firstChild(); child; child = child->nextSibling()) {
        if (is<RenderSVGInlineText>(*child)) {
            processRenderSVGInlineText(downcast<RenderSVGInlineText>(*child), m_textLength, lastCharacterWasSpace);
            continue;
        }

        if (!is<RenderSVGInline>(*child))
            continue;

        RenderSVGInline& inlineChild = downcast<RenderSVGInline>(*child);
        SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);

        unsigned atPosition = m_textPositions.size();
        if (element)
            m_textPositions.append(TextPosition(element, m_textLength));

        collectTextPositioningElements(inlineChild, lastCharacterWasSpace);

        if (!element)
            continue;

        // Update text position, after we're back from recursion.
        TextPosition& position = m_textPositions[atPosition];
        ASSERT(!position.length);
        position.length = m_textLength - position.start;
    }
}
int RenderMathMLSubSup::baselinePosition(bool firstLine, bool isRootLineBox) const
{
    RenderObject* base = firstChild();
    if (!base) 
        return offsetHeight();
    base = base->firstChild();
    if (!base) 
        return offsetHeight();
    
    int baseline = offsetHeight();
    
    switch (m_kind) {
    case SubSup:
        if (m_scripts) {
            int topAdjust = 0;
            if (base->isBoxModelObject()) {
                RenderBoxModelObject* box = toRenderBoxModelObject(base);
                topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2;
            }
            return topAdjust + (base ? base->baselinePosition(firstLine, isRootLineBox) : 0) + 4;
        }
        break;
    case Sup:
        if (base) {
            baseline = base->baselinePosition(firstLine, isRootLineBox) + 4;
            // FIXME: The extra amount of the superscript ascending above the base's box
            // isn't taken into account.  This should be calculated in a more reliable
            // way.
            RenderObject* sup = base->nextSibling();
            if (sup && sup->isBoxModelObject()) {
                RenderBoxModelObject* box = toRenderBoxModelObject(sup);
                // we'll take half of the sup's box height into account in the baseline
                baseline += static_cast<int>(box->offsetHeight() * 0.5);
            }
            baseline++;
        }
        break;
    case Sub:
        if (base) 
            baseline = base->baselinePosition(true) + 4;
    }
    
    return baseline;
    
}
Example #19
0
static PassRefPtr<AXObject> createFromRenderer(RenderObject* renderer)
{
    // FIXME: How could renderer->node() ever not be an Element?
    Node* node = renderer->node();

    // If the node is aria role="list" or the aria role is empty and its a
    // ul/ol/dl type (it shouldn't be a list if aria says otherwise).
    if (node && ((nodeHasRole(node, "list") || nodeHasRole(node, "directory"))
        || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(*node) || isHTMLOListElement(*node) || isHTMLDListElement(*node)))))
        return AXList::create(renderer);

    // aria tables
    if (nodeHasRole(node, "grid") || nodeHasRole(node, "treegrid"))
        return AXARIAGrid::create(renderer);
    if (nodeHasRole(node, "row"))
        return AXARIAGridRow::create(renderer);
    if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "columnheader") || nodeHasRole(node, "rowheader"))
        return AXARIAGridCell::create(renderer);

    // media controls
    if (node && node->isMediaControlElement())
        return AccessibilityMediaControl::create(renderer);

    if (isHTMLOptionElement(node))
        return AXListBoxOption::create(renderer);

    if (renderer->isSVGRoot())
        return AXSVGRoot::create(renderer);

    if (renderer->isBoxModelObject()) {
        RenderBoxModelObject* cssBox = toRenderBoxModelObject(renderer);
        if (cssBox->isListBox())
            return AXListBox::create(toRenderListBox(cssBox));
        if (cssBox->isMenuList())
            return AXMenuList::create(toRenderMenuList(cssBox));

        // standard tables
        if (cssBox->isTable())
            return AXTable::create(toRenderTable(cssBox));
        if (cssBox->isTableRow())
            return AXTableRow::create(toRenderTableRow(cssBox));
        if (cssBox->isTableCell())
            return AXTableCell::create(toRenderTableCell(cssBox));

        // progress bar
        if (cssBox->isProgress())
            return AXProgressIndicator::create(toRenderProgress(cssBox));

        // input type=range
        if (cssBox->isSlider())
            return AXSlider::create(toRenderSlider(cssBox));
    }

    return AXRenderObject::create(renderer);
}
Example #20
0
void PluginView::invalidateRect(const IntRect& dirtyRect)
{
    if (!parent() || !m_plugin || !m_isInitialized)
        return;

#if PLATFORM(MAC)
    if (m_plugin->pluginLayer())
        return;
#endif

    RenderBoxModelObject* renderer = toRenderBoxModelObject(m_pluginElement->renderer());
    if (!renderer)
        return;
    
    IntRect contentRect(dirtyRect);
    contentRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop());
    renderer->repaintRectangle(contentRect);
}
Example #21
0
float InlineBox::logicalHeight() const
{
    if (hasVirtualLogicalHeight())
        return virtualLogicalHeight();
    
    if (renderer()->isText())
        return m_bitfields.isText() ? renderer()->style(isFirstLineStyle())->fontMetrics().height() : 0;
    if (renderer()->isBox() && parent())
        return isHorizontal() ? toRenderBox(m_renderer)->height() : toRenderBox(m_renderer)->width();

    ASSERT(isInlineFlowBox());
    RenderBoxModelObject* flowObject = boxModelObject();
    const FontMetrics& fontMetrics = renderer()->style(isFirstLineStyle())->fontMetrics();
    float result = fontMetrics.height();
    if (parent())
        result += flowObject->borderAndPaddingLogicalHeight();
    return result;
}
Example #22
0
void RenderMathMLFenced::layout() 
{
    RenderMathMLRow::layout();
    
    int width = 0;
    for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
        if (current->isBoxModelObject()) {
            RenderBoxModelObject* box = toRenderBoxModelObject(current);
            width += box->offsetWidth();
        }
    }
    width++;
    style()->setWidth(Length(width, Fixed));

    setNeedsLayoutAndPrefWidthsRecalc();
    markContainingBlocksForLayout();
    RenderBlock::layout();
}
Example #23
0
float InlineBox::logicalHeight() const
{
    if (hasVirtualLogicalHeight())
        return virtualLogicalHeight();

    const RenderStyle& lineStyle = this->lineStyle();
    if (renderer().isTextOrLineBreak())
        return behavesLikeText() ? lineStyle.fontMetrics().height() : 0;
    if (renderer().isBox() && parent())
        return isHorizontal() ? toRenderBox(renderer()).height() : toRenderBox(renderer()).width();

    ASSERT(isInlineFlowBox());
    RenderBoxModelObject* flowObject = boxModelObject();
    const FontMetrics& fontMetrics = lineStyle.fontMetrics();
    float result = fontMetrics.height();
    if (parent())
        result += flowObject->borderAndPaddingLogicalHeight();
    return result;
}
Example #24
0
bool ScrollingCoordinator::hasNonLayerFixedObjects(FrameView* frameView) const
{
    const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
    if (!viewportConstrainedObjects)
        return false;

#if USE(ACCELERATED_COMPOSITING)
    for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
        RenderObject* viewportConstrainedObject = *it;
        if (!viewportConstrainedObject->isBoxModelObject() || !viewportConstrainedObject->hasLayer())
            return true;
        RenderBoxModelObject* viewportConstrainedBoxModelObject = toRenderBoxModelObject(viewportConstrainedObject);
        if (!viewportConstrainedBoxModelObject->layer()->backing())
            return true;
    }
    return false;
#else
    return viewportConstrainedObjects->size();
#endif
}
Example #25
0
int RenderMathMLRow::nonOperatorHeight() const
{
    int maxHeight = 0;
    for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
        if (current->isRenderMathMLBlock()) {
            RenderMathMLBlock* block = toRenderMathMLBlock(current);
            int blockHeight = block->nonOperatorHeight();
            // Check to see if this box has a larger height
            if (blockHeight > maxHeight)
                maxHeight = blockHeight;
        } else if (current->isBoxModelObject()) {
            RenderBoxModelObject* box = toRenderBoxModelObject(current);
            // Check to see if this box has a larger height
            if (box->offsetHeight() > maxHeight)
                maxHeight = box->offsetHeight();
        }
        
    }
    return maxHeight;
}
Example #26
0
int InlineBox::logicalHeight() const
{
#if ENABLE(SVG)
    if (hasVirtualLogicalHeight())
        return virtualLogicalHeight();
#endif
    
    if (renderer()->isText())
        return m_isText ? renderer()->style(m_firstLine)->fontMetrics().height() : 0;
    if (renderer()->isBox() && parent())
        return isHorizontal() ? toRenderBox(m_renderer)->height() : toRenderBox(m_renderer)->width();

    ASSERT(isInlineFlowBox());
    RenderBoxModelObject* flowObject = boxModelObject();
    const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics();
    int result = fontMetrics.height();
    if (parent())
        result += flowObject->borderAndPaddingLogicalHeight();
    return result;
}
Example #27
0
int InlineBox::height() const
{
#if ENABLE(SVG)
    if (hasVirtualHeight())
        return virtualHeight();
#endif
    
    if (renderer()->isText())
        return m_isText ? renderer()->style(m_firstLine)->font().height() : 0;
    if (renderer()->isBox() && parent())
        return toRenderBox(m_renderer)->height();

    ASSERT(isInlineFlowBox());
    RenderBoxModelObject* flowObject = boxModelObject();
    const Font& font = renderer()->style(m_firstLine)->font();
    int result = font.height();
    if (parent())
        result += flowObject->borderAndPaddingHeight();
    return result;
}
Example #28
0
void RenderMathMLRow::layout() 
{
    RenderBlock::layout();
    
    int maxHeight = 0;

    // Calculate the non-operator max height of the row.
    for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
        if (current->isRenderMathMLBlock()) {
            RenderMathMLBlock* block = toRenderMathMLBlock(current);
            if (!block->unembellishedOperator() && block->offsetHeight() > maxHeight)
                maxHeight = block->offsetHeight();
        } else if (current->isBoxModelObject()) {
            RenderBoxModelObject* box = toRenderBoxModelObject(current);
            // Check to see if this box has a larger height.
            if (box->pixelSnappedOffsetHeight() > maxHeight)
                maxHeight = box->pixelSnappedOffsetHeight();
        }
    }
    
    if (!maxHeight)
        maxHeight = style()->fontSize();
    
    // Stretch everything to the same height (blocks can ignore the request).
    if (maxHeight > 0) {
        bool didStretch = false;
        for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
            if (current->isRenderMathMLBlock()) {
                RenderMathMLBlock* block = toRenderMathMLBlock(current);
                block->stretchToHeight(maxHeight);
                didStretch = true;
            }
        }
        if (didStretch) {
            setNeedsLayout(true);
            setPreferredLogicalWidthsDirty(true, false);
            RenderBlock::layout();
        }
    }
    
}    
Example #29
0
void RenderMathMLRoot::layout()
{
    RenderBlock::layout();

    if (!firstChild() || !lastChild())
        return;

    int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
    if (!baseHeight)
        baseHeight = style()->fontSize();
    
    RenderObject* base = lastChild()->firstChild();
    if (base)
        base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
    
    // Base height above which the shape of the root changes
    int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
    int overbarLeftPointShift = 0;
    
    // FIXME: Can style() and indexBox->style() be modified (4 times below)?
    if (baseHeight > thresholdHeight && thresholdHeight) {
        float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
        if (shift > 1.)
            shift = 1.0f;
        int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
        overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
        
        style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
    }
    
    // Positioning of the index
    RenderObject* possibleIndex = firstChild()->firstChild();
    while (possibleIndex && !possibleIndex->isBoxModelObject())
        possibleIndex = possibleIndex->nextSibling();
    RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
    if (!indexBox)
        return;
    
    int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
    int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
    int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
        - (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
    
    style()->setPaddingLeft(Length(shiftForIndex, Fixed));
    if (rootExtraTop > 0)
        style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
    
    setNeedsLayout(true);
    setPreferredLogicalWidthsDirty(true, MarkOnlyThis); // FIXME: Can this really be right?
    RenderBlock::layout();

    indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));

    // Now that we've potentially changed its position, we need layout the index again.
    indexBox->setNeedsLayout(true);
    indexBox->layout();
}
void RenderMathMLRoot::layout()
{
    RenderBlock::layout();

    if (!firstChild() || !lastChild())
        return;

    int maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();
    
    RenderObject* current = lastChild()->firstChild();
    if (current)
        current->style()->setVerticalAlign(BASELINE);
    
    if (!maxHeight)
        maxHeight = style()->fontSize();
    
    // Base height above which the shape of the root changes
    int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
    int topStartShift = 0;
    
    if (maxHeight > thresholdHeight && thresholdHeight) {
        float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
        if (shift > 1.)
            shift = 1.0f;
        int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
        topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
        
        style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
    }
    
    // Positioning of the index
    RenderObject* possibleIndex = firstChild()->firstChild();
    while (possibleIndex && !possibleIndex->isBoxModelObject())
        possibleIndex = possibleIndex->nextSibling();
    RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
    if (!indexBox)
        return;
    
    int indexShift = indexBox->offsetWidth() + topStartShift;
    int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
    int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight() - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
    
    style()->setPaddingLeft(Length(indexShift, Fixed));
    if (rootMarginTop > 0)
        style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
    
    setNeedsLayout(true);
    setPreferredLogicalWidthsDirty(true, false);
    RenderBlock::layout();

    indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed));

    // Now that we've potentially changed its position, we need layout the index again.
    indexBox->setNeedsLayout(true);
    indexBox->layout();
}