예제 #1
0
void SVGFEImageElement::notifyFinished(CachedResource*)
{
    if (!inDocument())
        return;

    Element* parent = parentElement();
    ASSERT(parent);

    if (!parent->hasTagName(SVGNames::filterTag))
        return;

    RenderElement* parentRenderer = parent->renderer();
    if (!parentRenderer)
        return;

    RenderSVGResource::markForLayoutAndParentResourceInvalidation(*parentRenderer);
}
예제 #2
0
QLineF TableRowElement::cursorLine ( int position ) const
{
    TableElement* parentTable = static_cast<TableElement*>( parentElement() );
    QPointF top=absoluteBoundingRect().topLeft();
    qreal hOffset = 0;
    if( childElements().isEmpty() ) {
        // center cursor in elements that have no children
        top += QPointF( width()/2, 0 );
    } else { 
        for (int i=0; i<position; ++i) {
            hOffset+=parentTable->columnWidth(i);
        }
        top += QPointF( hOffset, 0.0 );
	}
    QPointF bottom = top + QPointF( 0.0, height() );
    return QLineF(top, bottom);
}
예제 #3
0
bool SVGForeignObjectElement::rendererIsNeeded(const RenderStyle& style)
{
    // Suppress foreignObject renderers in SVG hidden containers.
    // (https://bugs.webkit.org/show_bug.cgi?id=87297)
    // Note that we currently do not support foreignObject instantiation via <use>, hence it is safe
    // to use parentElement() here. If that changes, this method should be updated to use
    // parentOrShadowHostElement() instead.
    Element* ancestor = parentElement();
    while (ancestor && ancestor->isSVGElement()) {
        if (ancestor->renderer() && ancestor->renderer()->isSVGHiddenContainer())
            return false;

        ancestor = ancestor->parentElement();
    }

    return SVGGraphicsElement::rendererIsNeeded(style);
}
예제 #4
0
nsresult
nsHTMLSelectOptionAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
{
  NS_ENSURE_ARG_POINTER(aAttributes);
  if (!mDOMNode) {
    return NS_ERROR_FAILURE;  // Accessible shut down
  }

  nsresult rv = nsHyperTextAccessibleWrap::GetAttributesInternal(aAttributes);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMNode> parentNode;
  mDOMNode->GetParentNode(getter_AddRefs(parentNode));
  nsCOMPtr<nsIDOMElement> parentElement(do_QueryInterface(parentNode));
  NS_ENSURE_TRUE(parentElement, NS_ERROR_FAILURE);
  nsAutoString parentTagName;
  parentNode->GetLocalName(parentTagName);

  PRInt32 level = parentTagName.LowerCaseEqualsLiteral("optgroup") ? 2 : 1;
  if (level == 1 && nsAccUtils::Role(this) != nsIAccessibleRole::ROLE_HEADING) {
    level = 0; // In a single level list, the level is irrelevant
  }

  nsAutoString tagName;
  mDOMNode->GetLocalName(tagName);  // Will be looking for similar DOM siblings
  nsCOMPtr<nsIDOMNodeList> siblings;
  parentElement->GetElementsByTagName(tagName, getter_AddRefs(siblings));
  PRInt32 posInSet = 0;
  PRUint32 setSize = 0;
  if (siblings) {
    siblings->GetLength(&setSize);
    nsCOMPtr<nsIDOMNode> itemNode;
    while (NS_SUCCEEDED(siblings->Item(posInSet ++, getter_AddRefs(itemNode))) &&
           itemNode != mDOMNode) {
      // Keep looping, to increment posInSet
    }
  }

  nsAccUtils::SetAccGroupAttrs(aAttributes, level, posInSet,
                               static_cast<PRInt32>(setSize));
  return  NS_OK;
}
예제 #5
0
void SVGFEImageElement::imageChanged(CachedImage* cachedImage, const IntRect*)
{
    if (!cachedImage || !cachedImage->isLoaded())
        return;

    if (!inDocument())
        return;

    Element* parent = parentElement();
    ASSERT(parent);

    if (!parent->hasTagName(SVGNames::filterTag))
        return;

    RenderElement* parentRenderer = parent->renderer();
    if (!parentRenderer)
        return;

    RenderSVGResource::markForLayoutAndParentResourceInvalidation(*parentRenderer);
}
예제 #6
0
void TableRowElement::layout( const AttributeManager* am )
{
    Q_UNUSED( am )
    // Get the parent table to query width/ height values
    TableElement* parentTable = static_cast<TableElement*>( parentElement() );
    setHeight( parentTable->rowHeight( this ) );

    // Get alignment for every table data
    QList<Align> verticalAlign = alignments( Qt::Vertical );
    QList<Align> horizontalAlign = alignments( Qt::Horizontal );

    // align the row's entries
    QPointF origin;
    qreal hOffset = 0.0;
    for ( int i = 0; i < m_data.count(); i++ ) {
//         origin = QPointF();
        hOffset = 0.0;
        if( verticalAlign[ i ] == Bottom )
            origin.setY( height() - m_data[ i ]->height() );
        else if( verticalAlign[ i ] == Center || verticalAlign[ i ] == BaseLine )
            origin.setY( ( height() - m_data[ i ]->height() ) / 2 );
            // Baseline is treated like Center for the moment until someone also refines
            // TableElement::determineDimensions so that it pays attention to baseline.
            // Axis as alignment option is ignored as it is tought to be an option for
            // the table itsself.
//         kDebug() << horizontalAlign[ i ]<<","<<Axis;
        if( horizontalAlign[ i ] == Center ) {
            hOffset = ( parentTable->columnWidth( i ) - m_data[ i ]->width() ) / 2;
        }
        else if( horizontalAlign[ i ] == Right ) {
            hOffset = parentTable->columnWidth( i ) - m_data[ i ]->width();
        }

        m_data[ i ]->setOrigin( origin + QPointF( hOffset, 0.0 ) );
        origin += QPointF( parentTable->columnWidth( i ), 0.0 );
    }

    setWidth( origin.x() );
    // setting of the baseline should not be needed as the table row will only occur
    // inside a table where it does not matter if a table row has a baseline or not
}
예제 #7
0
QList<Align> TableRowElement::alignments( Qt::Orientation orientation )
{
    // choose name of the attribute to query
    QString align = ( orientation == Qt::Horizontal ) ? "columnalign" : "rowalign";

    // get the alignment values of the parental TableElement
    AttributeManager am;
    QList<Align> parentAlignList = am.alignListOf( align, parentElement() );
    // iterate over all entries and look on per data specification of alignment
    QList<Align> alignList;
    for( int i = 0; i < m_data.count(); i++ ) {
        // element got own value for align
        if( !m_data[ i ]->attribute( align ).isEmpty() )
            alignList << am.alignOf( align, m_data[ i ] );
        else if( i < parentAlignList.count() )
            alignList << parentAlignList[ i ];
        else
            alignList << parentAlignList.last();
    }
    return alignList;
}
예제 #8
0
bool TableRowElement::setCursorTo(FormulaCursor& cursor, QPointF point)
{
    if (cursor.isSelecting()) {
        if (m_data.isEmpty() || point.x()<0.0) {
            cursor.setCurrentElement(this);
            cursor.setPosition(0);
            return true;
        }
        //check if the point is behind all child elements
        if (point.x() >= width()) {
            cursor.setCurrentElement(this);
            cursor.setPosition(endPosition());
            return true;
        }
    }
    int i=0;
    qreal x=0.0;
    TableElement* parentTable = static_cast<TableElement*>( parentElement() );
    for (; i<m_data.count()-1; ++i) {
        //Find the child element the point is in
        x+=parentTable->columnWidth( i );
        if (x>=point.x()) {
            break;
        }
    }
    if (cursor.isSelecting()) {
        //we don't need to change current element because we are already in this element
        if (cursor.mark()<=i) {
            cursor.setPosition(i+1);
        }
        else {
            cursor.setPosition(i);
        }
        return true;
        } else {
        point-=m_data[i]->origin();
        return m_data[i]->setCursorTo(cursor,point);
    }
}
예제 #9
0
DISABLE_CFI_PERF
void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(
    CSSPropertyID unresolvedProperty,
    const String& customPropertyName,
    const String& value,
    bool important,
    ExceptionState&) {
  StyleAttributeMutationScope mutationScope(this);
  willMutate();

  bool didChange = false;
  if (unresolvedProperty == CSSPropertyVariable) {
    bool isAnimationTainted = isKeyframeStyle();
    didChange =
        propertySet()
            .setProperty(AtomicString(customPropertyName), value, important,
                         contextStyleSheet(), isAnimationTainted)
            .didChange;
  } else {
    didChange = propertySet()
                    .setProperty(unresolvedProperty, value, important,
                                 contextStyleSheet())
                    .didChange;
  }

  didMutate(didChange ? PropertyChanged : NoChanges);

  if (!didChange)
    return;

  Element* parent = parentElement();
  if (parent)
    parent->document().styleEngine().attributeChangedForElement(
        HTMLNames::styleAttr, *parent);
  mutationScope.enqueueMutationRecord();
}
예제 #10
0
static bool findPlaceForCounter(RenderObject* counterOwner, const AtomicString& identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& previousSibling)
{
    // We cannot stop searching for counters with the same identifier before we also
    // check this renderer, because it may affect the positioning in the tree of our counter.
    RenderObject* searchEndRenderer = previousSiblingOrParent(counterOwner);
    // We check renderers in preOrder from the renderer that our counter is attached to
    // towards the begining of the document for counters with the same identifier as the one
    // we are trying to find a place for. This is the next renderer to be checked.
    RenderObject* currentRenderer = previousInPreOrder(counterOwner);
    previousSibling = 0;
    RefPtr<CounterNode> previousSiblingProtector = 0;

    while (currentRenderer) {
        CounterNode* currentCounter = makeCounterNode(currentRenderer, identifier, false);
        if (searchEndRenderer == currentRenderer) {
            // We may be at the end of our search.
            if (currentCounter) {
                // We have a suitable counter on the EndSearchRenderer.
                if (previousSiblingProtector) { // But we already found another counter that we come after.
                    if (currentCounter->actsAsReset()) {
                        // We found a reset counter that is on a renderer that is a sibling of ours or a parent.
                        if (isReset && areRenderersElementsSiblings(currentRenderer, counterOwner)) {
                            // We are also a reset counter and the previous reset was on a sibling renderer
                            // hence we are the next sibling of that counter if that reset is not a root or
                            // we are a root node if that reset is a root.
                            parent = currentCounter->parent();
                            previousSibling = parent ? currentCounter : 0;
                            return parent;
                        }
                        // We are not a reset node or the previous reset must be on an ancestor of our owner renderer
                        // hence we must be a child of that reset counter.
                        parent = currentCounter;
                        // In some cases renders can be reparented (ex. nodes inside a table but not in a column or row).
                        // In these cases the identified previousSibling will be invalid as its parent is different from
                        // our identified parent.
                        if (previousSiblingProtector->parent() != currentCounter)
                            previousSiblingProtector = 0;

                        previousSibling = previousSiblingProtector.get();
                        return true;
                    }
                    // CurrentCounter, the counter at the EndSearchRenderer, is not reset.
                    if (!isReset || !areRenderersElementsSiblings(currentRenderer, counterOwner)) {
                        // If the node we are placing is not reset or we have found a counter that is attached
                        // to an ancestor of the placed counter's owner renderer we know we are a sibling of that node.
                        if (currentCounter->parent() != previousSiblingProtector->parent())
                            return false;

                        parent = currentCounter->parent();
                        previousSibling = previousSiblingProtector.get();
                        return true;
                    }
                } else { 
                    // We are at the potential end of the search, but we had no previous sibling candidate
                    // In this case we follow pretty much the same logic as above but no ASSERTs about 
                    // previousSibling, and when we are a sibling of the end counter we must set previousSibling
                    // to currentCounter.
                    if (currentCounter->actsAsReset()) {
                        if (isReset && areRenderersElementsSiblings(currentRenderer, counterOwner)) {
                            parent = currentCounter->parent();
                            previousSibling = currentCounter;
                            return parent;
                        }
                        parent = currentCounter;
                        previousSibling = previousSiblingProtector.get();
                        return true;
                    }
                    if (!isReset || !areRenderersElementsSiblings(currentRenderer, counterOwner)) {
                        parent = currentCounter->parent();
                        previousSibling = currentCounter;
                        return true;
                    }
                    previousSiblingProtector = currentCounter;
                }
            }
            // We come here if the previous sibling or parent of our owner renderer had no
            // good counter, or we are a reset node and the counter on the previous sibling
            // of our owner renderer was not a reset counter.
            // Set a new goal for the end of the search.
            searchEndRenderer = previousSiblingOrParent(currentRenderer);
        } else {
            // We are searching descendants of a previous sibling of the renderer that the
            // counter being placed is attached to.
            if (currentCounter) {
                // We found a suitable counter.
                if (previousSiblingProtector) {
                    // Since we had a suitable previous counter before, we should only consider this one as our 
                    // previousSibling if it is a reset counter and hence the current previousSibling is its child.
                    if (currentCounter->actsAsReset()) {
                        previousSiblingProtector = currentCounter;
                        // We are no longer interested in previous siblings of the currentRenderer or their children
                        // as counters they may have attached cannot be the previous sibling of the counter we are placing.
                        currentRenderer = parentElement(currentRenderer)->renderer();
                        continue;
                    }
                } else
                    previousSiblingProtector = currentCounter;
                currentRenderer = previousSiblingOrParent(currentRenderer);
                continue;
            }
        }
        // This function is designed so that the same test is not done twice in an iteration, except for this one
        // which may be done twice in some cases. Rearranging the decision points though, to accommodate this 
        // performance improvement would create more code duplication than is worthwhile in my oppinion and may further
        // impede the readability of this already complex algorithm.
        if (previousSiblingProtector)
            currentRenderer = previousSiblingOrParent(currentRenderer);
        else
            currentRenderer = previousInPreOrder(currentRenderer);
    }
    return false;
}
예제 #11
0
static inline bool areRenderersElementsSiblings(RenderObject* first, RenderObject* second)
{
    return parentElement(first) == parentElement(second);
}
예제 #12
0
HTMLMediaElement* HTMLTrackElement::mediaElement() const {
  Element* parent = parentElement();
  if (isHTMLMediaElement(parent))
    return toHTMLMediaElement(parent);
  return nullptr;
}
예제 #13
0
static inline bool areLayoutObjectsElementsSiblings(LayoutObject& first, LayoutObject& second)
{
    return parentElement(first) == parentElement(second);
}
예제 #14
0
void HTMLSourceElement::notifyMediaQueryChanged()
{
    Element* parent = parentElement();
    if (isHTMLPictureElement(parent))
        toHTMLPictureElement(parent)->sourceOrMediaChanged();
}
예제 #15
0
void Bookmarks::parseFolderElement(const QDomElement &element,
                                   QTreeWidgetItem* parentItem, const QString &/*elementID*/)
{
    QDomElement parentElement(element);
    QString id = "";
    if (parentElement.tagName() == "folder") {
        //old files that their 'folder' tag don't use 'id' attribute
        // just contain 'folder' tag of type 'Verses'!
        id = parentElement.attribute("id", "Verses");
        parentElement.setAttribute("id", id);
    }

    QTreeWidgetItem* item = createItem(parentElement, parentItem, id);

    QString title;
    if (id == "Verses") {
        title = tr("Verses");
    }
    else {
        title = element.firstChildElement("title").text();
    }
    if (title.isEmpty()) {
        title = QObject::tr("Folder");
    }

    item->setIcon(0, m_folderIcon);
    item->setText(0, title);
    item->setToolTip(0, title);

    bool folded = (parentElement.attribute("folded") != "no");
    setItemExpanded(item, !folded);

    QDomElement child = parentElement.firstChildElement();
    while (!child.isNull()) {
        if (child.tagName() == "folder") {
//TODO: we can save labguage within a 'metadata' tag of this 'folder'
//          //update node title by new loaded translation
            QString id = child.attribute("id");
            QString title = child.firstChildElement("title").text();

            if (id.isEmpty()) {
                //old files that their 'folder' tags don't use 'id' attribute just contain 'folder' tags of type 'Verses'!
                id = "Verses";
                title = tr(title.toLocal8Bit().data());
                QDomElement oldTitleElement = child.firstChildElement("title");
                QDomElement newTitleElement = m_domDocument.createElement("title");
                QDomText newTitleText = m_domDocument.createTextNode(tr("Verses"));
                newTitleElement.appendChild(newTitleText);

                child.replaceChild(newTitleElement, oldTitleElement);
                child.setAttribute("id", "Verses");
            }
            parseFolderElement(child, item, id);
        }
        else if (child.tagName() == "bookmark") {
            QTreeWidgetItem* childItem = createItem(child, item);

            QString title = child.firstChildElement("title").text();
            if (title.isEmpty()) {
                title = QObject::tr("Folder");
            }

            QDomElement infoChild = child.firstChildElement("info");
            QDomElement metaData = infoChild.firstChildElement("metadata");
            while (!metaData.isNull()) {
                QString owner = metaData.attribute("owner");
                if (owner == "http://saaghar.pozh.org") {
                    break;
                }
                metaData = metaData.nextSiblingElement("metadata");
            }
            if (!metaData.isNull() && metaData.attribute("owner") == "http://saaghar.pozh.org") {
                childItem->setData(0, Qt::UserRole, metaData.text());
            }
            else {
                qDebug() << "This DOM-NODE SHOULD deleted--->" << title;
            }
            //href data URL data
            childItem->setData(1, Qt::UserRole, child.attribute("href", "http://saaghar.pozh.org"));
            childItem->setIcon(0, m_bookmarkIcon);
            childItem->setText(0, title);
            childItem->setToolTip(0, title);
            childItem->setText(1, child.firstChildElement("desc").text());
            childItem->setToolTip(1, child.firstChildElement("desc").text());
        }
        else if (child.tagName() == "separator") {
            QTreeWidgetItem* childItem = createItem(child, item);
            childItem->setFlags(item->flags() & ~(Qt::ItemIsSelectable | Qt::ItemIsEditable));
            childItem->setText(0, QString(30, 0xB7));
        }
        child = child.nextSiblingElement();
    }
}