Esempio n. 1
0
html::HTMLElement HTMLTableRowElementImp::insertCell(int index)
{
    if (index < -1)
        return nullptr;   // TODO: throw an IndexSizeError exception
    int count = 0;
    for (Element child = getFirstElementChild(); child; child = child.getNextElementSibling()) {
        if (auto cell = std::dynamic_pointer_cast<HTMLTableCellElementImp>(child.self())) {
            if (count == index) {
                html::HTMLTableDataCellElement td = std::make_shared<HTMLTableDataCellElementImp>(getOwnerDocumentImp().get());
                if (td)
                    insertBefore(td, cell);
                return td;
            }
            ++count;
        }
    }
    if (count < index)
        return nullptr;   // TODO: throw an IndexSizeError exception
    html::HTMLTableDataCellElement td = std::make_shared<HTMLTableDataCellElementImp>(getOwnerDocumentImp().get());
    if (td)
        appendChild(td);
    return td;
}
Esempio n. 2
0
void HTMLOptionElement::setText(const String &text, ExceptionCode& ec)
{
    RefPtr<Node> protectFromMutationEvents(this);

    // Changing the text causes a recalc of a select's items, which will reset the selected
    // index to the first item if the select is single selection with a menu list. We attempt to
    // preserve the selected item.
    RefPtr<HTMLSelectElement> select = ownerSelectElement();
    bool selectIsMenuList = select && select->usesMenuList();
    int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1;

    // Handle the common special case where there's exactly 1 child node, and it's a text node.
    Node* child = firstChild();
    if (child && child->isTextNode() && !child->nextSibling())
        static_cast<Text *>(child)->setData(text, ec);
    else {
        removeChildren();
        appendChild(Text::create(document(), text), ec);
    }
    
    if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex)
        select->setSelectedIndex(oldSelectedIndex);
}
void
ColladaNode::handleInstanceLight(domInstance_light *instLight)
{
    ColladaInstanceLightRefPtr colInstLight =
        getUserDataAs<ColladaInstanceLight>(instLight);

    if(colInstLight == NULL)
    {
        colInstLight = dynamic_pointer_cast<ColladaInstanceLight>(
            ColladaElementFactory::the()->create(instLight, getGlobal()));

        colInstLight->read();
    }

    //Append the lights beacon node
    GroupUnrecPtr lightBeacon = Group::create();
    NodeRecPtr lightBeaconN = Node::create();
    lightBeaconN->setCore(lightBeacon);
    /*std::string BeaconNodeName(instLight->getName());
    BeaconNodeName += "_beacon";
    setName(lightBeaconN, BeaconNodeName);*/

    //TODO: set beacon name
    appendChild(lightBeaconN);
    
    //push the Light onto the root
    LightUnrecPtr light = colInstLight->process(this);
    light->setBeacon(lightBeaconN);

    NodeRecPtr lightN = Node::create();
    lightN->setCore(light);
    //setName(lightN,instLight->getName());
    //TODO: set light noame

    _visualScene->pushNodeToRoot(lightN);

}
void
ColladaNode::handleNode(domNode *node)
{
    ColladaNodeRefPtr colNode = getUserDataAs<ColladaNode>(node);

    if(colNode == NULL)
    {
        colNode = dynamic_pointer_cast<ColladaNode>(
            ColladaElementFactory::the()->create(node, getGlobal()));

        colNode->setVisualScene(_visualScene);
        colNode->read();
    }

    Node *childN = colNode->getTopNode();

    if(childN->getParent() != NULL)
    {
        SWARNING << "ColladaNode::handleNode: Node already has a parent."
                 << std::endl;
    }

    appendChild(childN);
}
Esempio n. 5
0
// addChild helper, faster than insertChild
void SpriteBatchNode::appendChild(Sprite* sprite)
{
    _reorderChildDirty=true;
    sprite->setBatchNode(this);
    sprite->setDirty(true);

    if(_textureAtlas->getTotalQuads() == _textureAtlas->getCapacity()) {
        increaseAtlasCapacity();
    }

    _descendants.push_back(sprite);
    int index = static_cast<int>(_descendants.size()-1);

    sprite->setAtlasIndex(index);

    V3F_C4B_T2F_Quad quad = sprite->getQuad();
    _textureAtlas->insertQuad(&quad, index);

    // add children recursively
    auto& children = sprite->getChildren();
    for(const auto &child: children) {
        appendChild(static_cast<Sprite*>(child));
    }
}
QList<Variable*> Locals::updateLocals(QStringList locals)
{
    QSet<QString> existing, current;
    for (int i = 0; i < childItems.size(); i++)
    {
        Q_ASSERT(dynamic_cast<KDevelop::Variable*>(child(i)));
        Variable* var= static_cast<KDevelop::Variable*>(child(i));
        existing << var->expression();
    }

    foreach (const QString& var, locals) {
        current << var;
        // If we currently don't display this local var, add it.
        if( !existing.contains( var ) ) {
            // FIXME: passing variableCollection this way is awkward.
            // In future, variableCollection probably should get a
            // method to create variable.
            Variable* v = 
                currentSession()->variableController()->createVariable(
                    ICore::self()->debugController()->variableCollection(),
                    this, var );
            appendChild( v, false );
        }
    }
void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target)
{
    if (target.isNull())
        return;

    // copy content
    d->symbolLocations = target->d->symbolLocations;
    d->icon = target->d->icon;
    d->symbolInformations.clear();

    // reserve memory
//    int amount = qMin(100 , target->d_ptr->symbolInformations.count() * 2);
//    d_ptr->symbolInformations.reserve(amount);

    // every child
    CitSymbolInformations cur = target->d->symbolInformations.constBegin();
    CitSymbolInformations end = target->d->symbolInformations.constEnd();

    for (; cur != end; ++cur) {
        ParserTreeItem::Ptr item(new ParserTreeItem());
        item->copyTree(cur.value());
        appendChild(item, cur.key());
    }
}
Esempio n. 8
0
File: View.cpp Progetto: laoo/LSC
client::HTMLElement * View::createMesureCell( int rowNr )
{
  auto ch = "input"_c;
  ch->setAttribute( "type", "checkbox" );

  auto in = "input"_c;
  in->setAttribute( "type", "number" );
  in->setAttribute( "value", mModel.getStringMeasure( rowNr ) );
  addEventListener( in, "change", [&]( client::Element * e )
  {
    double value = static_cast<client::HTMLInputElement*>( e )->get_valueAsNumber();
    mModel.setStringMeasure( rowNr, value );
    reset();
  } );


  //in->setAttribute( "disabled", "disabled" );

  auto div = "div"_c;
  div->appendChild( ch );
  div->appendChild( in );

  return div;
}
Esempio n. 9
0
RegisterItem::RegisterItem(const Register &reg) :
    m_reg(reg), m_format(HexadecimalFormat), m_changed(true)
{
    if (m_reg.kind == UnknownRegister)
        m_reg.guessMissingData();

    if (m_reg.kind == IntegerRegister || m_reg.kind == VectorRegister) {
        if (m_reg.size <= 8) {
            appendChild(new RegisterSubItem(IntegerRegister, m_reg.size, 1, SignedDecimalFormat));
            appendChild(new RegisterSubItem(IntegerRegister, m_reg.size, 1, DecimalFormat));
        }
        for (int s = m_reg.size / 2; s; s = s / 2) {
            appendChild(new RegisterSubItem(IntegerRegister, s, m_reg.size / s, HexadecimalFormat));
            appendChild(new RegisterSubItem(IntegerRegister, s, m_reg.size / s, SignedDecimalFormat));
            appendChild(new RegisterSubItem(IntegerRegister, s, m_reg.size / s, DecimalFormat));
            if (s == 1)
                appendChild(new RegisterSubItem(IntegerRegister, s, m_reg.size / s, CharacterFormat));
        }
    }
    if (m_reg.kind == IntegerRegister || m_reg.kind == VectorRegister) {
        for (int s = m_reg.size; s >= 4; s = s / 2)
            appendChild(new RegisterSubItem(FloatRegister, s, m_reg.size / s, DecimalFormat));
    }
}
Esempio n. 10
0
void XMLWriter::Layer(QDomElement& scene,int num){
    auto list = mpMng->mList[num]->LayerList();
    for(int i=0; i<list.count(); i++){
        QString tag;
        if(!list[i]->IsObject()){
            tag = "Layer";
        }else{
            tag = "ObjectLayer";
        }
        auto layer = doc.createElement(tag+QString::number(i+1));
        layer.setAttribute("id",list[i]->ID());
        scene.appendChild(layer);
        //name
        auto name = doc.createElement("Name");
        layer.appendChild(name);
        auto nameText = doc.createTextNode(list[i]->Name());
        name.appendChild(nameText);
        //speed
        auto speed = doc.createElement("Speed");
        layer.appendChild(speed);
        auto speedText = doc.createTextNode(QString::number(list[i]->Speed()));
        speed.appendChild(speedText);
        //zOrder
        auto zOrder = doc.createElement("ZOrder");
        layer.appendChild(zOrder);
        auto zOrderText = doc.createTextNode(QString::number(i));
        zOrder.appendChild(zOrderText);
        //size
        int width = list[i]->Size().width();
        int height = list[i]->Size().height();
        createSizeElement(layer,width,height);
        //pos
        createPosElement(layer,0,0);
        //item
        Item(layer,list[i]);
    }
}
void vogleditor_stateTreeProgramItem::add_diffable_child(vogleditor_stateTreeProgramDiffableItem* pItem)
{
    m_diffableItems.push_back(pItem);
    appendChild(pItem);
}
Esempio n. 12
0
// The media controls DOM structure looks like:
//
// MediaControls                                       (-webkit-media-controls)
// +-MediaControlOverlayEnclosureElement               (-webkit-media-controls-overlay-enclosure)
// | +-MediaControlOverlayPlayButtonElement            (-webkit-media-controls-overlay-play-button)
// | | {if mediaControlsOverlayPlayButtonEnabled}
// | \-MediaControlCastButtonElement                   (-internal-media-controls-overlay-cast-button)
// \-MediaControlPanelEnclosureElement                 (-webkit-media-controls-enclosure)
//   \-MediaControlPanelElement                        (-webkit-media-controls-panel)
//     +-MediaControlPlayButtonElement                 (-webkit-media-controls-play-button)
//     | {if !RTE::newMediaPlaybackUi()}
//     +-MediaControlTimelineElement                   (-webkit-media-controls-timeline)
//     +-MediaControlCurrentTimeDisplayElement         (-webkit-media-controls-current-time-display)
//     +-MediaControlTimeRemainingDisplayElement       (-webkit-media-controls-time-remaining-display)
//     | {if RTE::newMediaPlaybackUi()}
//     +-MediaControlTimelineElement                   (-webkit-media-controls-timeline)
//     +-MediaControlMuteButtonElement                 (-webkit-media-controls-mute-button)
//     +-MediaControlVolumeSliderElement               (-webkit-media-controls-volume-slider)
//     +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-toggle-closed-captions-button)
//     +-MediaControlCastButtonElement                 (-internal-media-controls-cast-button)
//     \-MediaControlFullscreenButtonElement           (-webkit-media-controls-fullscreen-button)
void MediaControls::initializeControls()
{
    const bool useNewUi = RuntimeEnabledFeatures::newMediaPlaybackUiEnabled();
    RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = MediaControlOverlayEnclosureElement::create(*this);

    if (document().settings() && document().settings()->mediaControlsOverlayPlayButtonEnabled()) {
        RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButton = MediaControlOverlayPlayButtonElement::create(*this);
        m_overlayPlayButton = overlayPlayButton.get();
        overlayEnclosure->appendChild(overlayPlayButton.release());
    }

    RefPtrWillBeRawPtr<MediaControlCastButtonElement> overlayCastButton = MediaControlCastButtonElement::create(*this, true);
    m_overlayCastButton = overlayCastButton.get();
    overlayEnclosure->appendChild(overlayCastButton.release());

    m_overlayEnclosure = overlayEnclosure.get();
    appendChild(overlayEnclosure.release());

    // Create an enclosing element for the panel so we can visually offset the controls correctly.
    RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaControlPanelEnclosureElement::create(*this);

    RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElement::create(*this);

    RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlPlayButtonElement::create(*this);
    m_playButton = playButton.get();
    panel->appendChild(playButton.release());

    RefPtrWillBeRawPtr<MediaControlTimelineElement> timeline = MediaControlTimelineElement::create(*this);
    m_timeline = timeline.get();
    // In old UX, timeline is before the time / duration text.
    if (!useNewUi)
        panel->appendChild(timeline.release());
    // else we will attach it later.

    RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(*this);
    m_currentTimeDisplay = currentTimeDisplay.get();
    m_currentTimeDisplay->setIsWanted(useNewUi);
    panel->appendChild(currentTimeDisplay.release());

    RefPtrWillBeRawPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaControlTimeRemainingDisplayElement::create(*this);
    m_durationDisplay = durationDisplay.get();
    panel->appendChild(durationDisplay.release());

    // Timeline is after the time / duration text if newMediaPlaybackUiEnabled.
    if (useNewUi)
        panel->appendChild(timeline.release());

    RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlMuteButtonElement::create(*this);
    m_muteButton = muteButton.get();
    panel->appendChild(muteButton.release());
    if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document()))
        m_muteButton->setIsWanted(false);

    RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVolumeSliderElement::create(*this);
    m_volumeSlider = slider.get();
    panel->appendChild(slider.release());
    if (m_allowHiddenVolumeControls && preferHiddenVolumeControls(document()))
        m_volumeSlider->setIsWanted(false);

    RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this);
    m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get();
    panel->appendChild(toggleClosedCaptionsButton.release());

    RefPtrWillBeRawPtr<MediaControlCastButtonElement> castButton = MediaControlCastButtonElement::create(*this, false);
    m_castButton = castButton.get();
    panel->appendChild(castButton.release());

    RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = MediaControlFullscreenButtonElement::create(*this);
    m_fullScreenButton = fullscreenButton.get();
    panel->appendChild(fullscreenButton.release());

    m_panel = panel.get();
    enclosure->appendChild(panel.release());

    m_enclosure = enclosure.get();
    appendChild(enclosure.release());
}
Esempio n. 13
0
AndNode::AndNode(Node* child1, Node* child2): Node("and",  2){
    appendChild(child1);
    appendChild(child2);
}
Esempio n. 14
0
// The media controls DOM structure looks like:
//
// MediaControls                                       (-webkit-media-controls)
// +-MediaControlOverlayEnclosureElement               (-webkit-media-controls-overlay-enclosure)
// | +-MediaControlOverlayPlayButtonElement            (-webkit-media-controls-overlay-play-button)
// | | {if mediaControlsOverlayPlayButtonEnabled}
// | \-MediaControlCastButtonElement                   (-internal-media-controls-overlay-cast-button)
// \-MediaControlPanelEnclosureElement                 (-webkit-media-controls-enclosure)
//   \-MediaControlPanelElement                        (-webkit-media-controls-panel)
//     +-MediaControlPlayButtonElement                 (-webkit-media-controls-play-button)
//     +-MediaControlTimelineElement                   (-webkit-media-controls-timeline)
//     +-MediaControlCurrentTimeDisplayElement         (-webkit-media-controls-current-time-display)
//     +-MediaControlTimeRemainingDisplayElement       (-webkit-media-controls-time-remaining-display)
//     +-MediaControlMuteButtonElement                 (-webkit-media-controls-mute-button)
//     +-MediaControlVolumeSliderElement               (-webkit-media-controls-volume-slider)
//     +-MediaControlToggleClosedCaptionsButtonElement (-webkit-media-controls-toggle-closed-captions-button)
//     +-MediaControlCastButtonElement                 (-internal-media-controls-cast-button)
//     \-MediaControlFullscreenButtonElement           (-webkit-media-controls-fullscreen-button)
void MediaControls::initializeControls()
{
    RefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> overlayEnclosure = MediaControlOverlayEnclosureElement::create(*this);

    if (document().settings() && document().settings()->mediaControlsOverlayPlayButtonEnabled()) {
        RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> overlayPlayButton = MediaControlOverlayPlayButtonElement::create(*this);
        m_overlayPlayButton = overlayPlayButton.get();
        overlayEnclosure->appendChild(overlayPlayButton.release());
    }

    RefPtrWillBeRawPtr<MediaControlCastButtonElement> overlayCastButton = MediaControlCastButtonElement::create(*this, true);
    m_overlayCastButton = overlayCastButton.get();
    overlayEnclosure->appendChild(overlayCastButton.release());

    m_overlayEnclosure = overlayEnclosure.get();
    appendChild(overlayEnclosure.release());

    // Create an enclosing element for the panel so we can visually offset the controls correctly.
    RefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> enclosure = MediaControlPanelEnclosureElement::create(*this);

    RefPtrWillBeRawPtr<MediaControlPanelElement> panel = MediaControlPanelElement::create(*this);

    RefPtrWillBeRawPtr<MediaControlPlayButtonElement> playButton = MediaControlPlayButtonElement::create(*this);
    m_playButton = playButton.get();
    panel->appendChild(playButton.release());

    RefPtrWillBeRawPtr<MediaControlTimelineElement> timeline = MediaControlTimelineElement::create(*this);
    m_timeline = timeline.get();
    panel->appendChild(timeline.release());

    RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(*this);
    m_currentTimeDisplay = currentTimeDisplay.get();
    m_currentTimeDisplay->hide();
    panel->appendChild(currentTimeDisplay.release());

    RefPtrWillBeRawPtr<MediaControlTimeRemainingDisplayElement> durationDisplay = MediaControlTimeRemainingDisplayElement::create(*this);
    m_durationDisplay = durationDisplay.get();
    panel->appendChild(durationDisplay.release());

    RefPtrWillBeRawPtr<MediaControlMuteButtonElement> muteButton = MediaControlMuteButtonElement::create(*this);
    m_muteButton = muteButton.get();
    panel->appendChild(muteButton.release());

    RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = MediaControlVolumeSliderElement::create(*this);
    m_volumeSlider = slider.get();
    panel->appendChild(slider.release());

    RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(*this);
    m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get();
    panel->appendChild(toggleClosedCaptionsButton.release());

    RefPtrWillBeRawPtr<MediaControlCastButtonElement> castButton = MediaControlCastButtonElement::create(*this, false);
    m_castButton = castButton.get();
    panel->appendChild(castButton.release());

    RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> fullscreenButton = MediaControlFullscreenButtonElement::create(*this);
    m_fullScreenButton = fullscreenButton.get();
    panel->appendChild(fullscreenButton.release());

    m_panel = panel.get();
    enclosure->appendChild(panel.release());

    m_enclosure = enclosure.get();
    appendChild(enclosure.release());
}
Esempio n. 15
0
OrNode::OrNode(Node* child1, Node* child2): Node("or",  2){
	appendChild(child1);
	appendChild(child2);
}
Esempio n. 16
0
// The media controls DOM structure looks like:
//
// MediaControls
//     (-webkit-media-controls)
// +-MediaControlOverlayEnclosureElement
// |    (-webkit-media-controls-overlay-enclosure)
// | +-MediaControlOverlayPlayButtonElement
// | |    (-webkit-media-controls-overlay-play-button)
// | | {if mediaControlsOverlayPlayButtonEnabled}
// | \-MediaControlCastButtonElement
// |     (-internal-media-controls-overlay-cast-button)
// \-MediaControlPanelEnclosureElement
//   |    (-webkit-media-controls-enclosure)
//   \-MediaControlPanelElement
//     |    (-webkit-media-controls-panel)
//     +-MediaControlPlayButtonElement
//     |    (-webkit-media-controls-play-button)
//     +-MediaControlCurrentTimeDisplayElement
//     |    (-webkit-media-controls-current-time-display)
//     +-MediaControlTimeRemainingDisplayElement
//     |    (-webkit-media-controls-time-remaining-display)
//     +-MediaControlTimelineElement
//     |    (-webkit-media-controls-timeline)
//     +-MediaControlMuteButtonElement
//     |    (-webkit-media-controls-mute-button)
//     +-MediaControlVolumeSliderElement
//     |    (-webkit-media-controls-volume-slider)
//     +-MediaControlFullscreenButtonElement
//     |    (-webkit-media-controls-fullscreen-button)
//     +-MediaControlDownloadButtonElement
//     |    (-internal-media-controls-download-button)
//     +-MediaControlToggleClosedCaptionsButtonElement
//     |    (-webkit-media-controls-toggle-closed-captions-button)
//     \-MediaControlCastButtonElement
//         (-internal-media-controls-cast-button)
// +-MediaControlTextTrackListElement
// |    (-internal-media-controls-text-track-list)
// | {for each renderable text track}
//  \-MediaControlTextTrackListItem
//  |   (-internal-media-controls-text-track-list-item)
//  +-MediaControlTextTrackListItemInput
//  |    (-internal-media-controls-text-track-list-item-input)
//  +-MediaControlTextTrackListItemCaptions
//  |    (-internal-media-controls-text-track-list-kind-captions)
//  +-MediaControlTextTrackListItemSubtitles
//       (-internal-media-controls-text-track-list-kind-subtitles)
void MediaControls::initializeControls() {
  MediaControlOverlayEnclosureElement* overlayEnclosure =
      MediaControlOverlayEnclosureElement::create(*this);

  if (document().settings() &&
      document().settings()->mediaControlsOverlayPlayButtonEnabled()) {
    MediaControlOverlayPlayButtonElement* overlayPlayButton =
        MediaControlOverlayPlayButtonElement::create(*this);
    m_overlayPlayButton = overlayPlayButton;
    overlayEnclosure->appendChild(overlayPlayButton);
  }

  MediaControlCastButtonElement* overlayCastButton =
      MediaControlCastButtonElement::create(*this, true);
  m_overlayCastButton = overlayCastButton;
  overlayEnclosure->appendChild(overlayCastButton);

  m_overlayEnclosure = overlayEnclosure;
  appendChild(overlayEnclosure);

  // Create an enclosing element for the panel so we can visually offset the
  // controls correctly.
  MediaControlPanelEnclosureElement* enclosure =
      MediaControlPanelEnclosureElement::create(*this);

  MediaControlPanelElement* panel = MediaControlPanelElement::create(*this);

  MediaControlPlayButtonElement* playButton =
      MediaControlPlayButtonElement::create(*this);
  m_playButton = playButton;
  panel->appendChild(playButton);

  MediaControlCurrentTimeDisplayElement* currentTimeDisplay =
      MediaControlCurrentTimeDisplayElement::create(*this);
  m_currentTimeDisplay = currentTimeDisplay;
  m_currentTimeDisplay->setIsWanted(true);
  panel->appendChild(currentTimeDisplay);

  MediaControlTimeRemainingDisplayElement* durationDisplay =
      MediaControlTimeRemainingDisplayElement::create(*this);
  m_durationDisplay = durationDisplay;
  panel->appendChild(durationDisplay);

  MediaControlTimelineElement* timeline =
      MediaControlTimelineElement::create(*this);
  m_timeline = timeline;
  panel->appendChild(timeline);

  MediaControlMuteButtonElement* muteButton =
      MediaControlMuteButtonElement::create(*this);
  m_muteButton = muteButton;
  panel->appendChild(muteButton);

  MediaControlVolumeSliderElement* slider =
      MediaControlVolumeSliderElement::create(*this);
  m_volumeSlider = slider;
  panel->appendChild(slider);
  if (preferHiddenVolumeControls(document()))
    m_volumeSlider->setIsWanted(false);

  MediaControlFullscreenButtonElement* fullscreenButton =
      MediaControlFullscreenButtonElement::create(*this);
  m_fullscreenButton = fullscreenButton;
  panel->appendChild(fullscreenButton);

  MediaControlDownloadButtonElement* downloadButton =
      MediaControlDownloadButtonElement::create(*this);
  m_downloadButton = downloadButton;
  panel->appendChild(downloadButton);

  MediaControlCastButtonElement* castButton =
      MediaControlCastButtonElement::create(*this, false);
  m_castButton = castButton;
  panel->appendChild(castButton);

  MediaControlToggleClosedCaptionsButtonElement* toggleClosedCaptionsButton =
      MediaControlToggleClosedCaptionsButtonElement::create(*this);
  m_toggleClosedCaptionsButton = toggleClosedCaptionsButton;
  panel->appendChild(toggleClosedCaptionsButton);

  m_panel = panel;
  enclosure->appendChild(panel);

  m_enclosure = enclosure;
  appendChild(enclosure);

  MediaControlTextTrackListElement* textTrackList =
      MediaControlTextTrackListElement::create(*this);
  m_textTrackList = textTrackList;
  appendChild(textTrackList);

  MediaControlOverflowMenuButtonElement* overflowMenu =
      MediaControlOverflowMenuButtonElement::create(*this);
  m_overflowMenu = overflowMenu;
  panel->appendChild(overflowMenu);

  MediaControlOverflowMenuListElement* overflowList =
      MediaControlOverflowMenuListElement::create(*this);
  m_overflowList = overflowList;
  appendChild(overflowList);

  // The order in which we append elements to the overflow list is significant
  // because it determines how the elements show up in the overflow menu
  // relative to each other.  The first item appended appears at the top of the
  // overflow menu.
  m_overflowList->appendChild(m_playButton->createOverflowElement(
      *this, MediaControlPlayButtonElement::create(*this)));
  m_overflowList->appendChild(m_fullscreenButton->createOverflowElement(
      *this, MediaControlFullscreenButtonElement::create(*this)));
  m_overflowList->appendChild(m_downloadButton->createOverflowElement(
      *this, MediaControlDownloadButtonElement::create(*this)));
  m_overflowList->appendChild(m_muteButton->createOverflowElement(
      *this, MediaControlMuteButtonElement::create(*this)));
  m_overflowList->appendChild(m_castButton->createOverflowElement(
      *this, MediaControlCastButtonElement::create(*this, false)));
  m_overflowList->appendChild(
      m_toggleClosedCaptionsButton->createOverflowElement(
          *this, MediaControlToggleClosedCaptionsButtonElement::create(*this)));
}
Esempio n. 17
0
WhileNode::WhileNode(Node* child1, Node* child2): Node("while",  2){
	appendChild(child1);
	appendChild(child2);
}
Esempio n. 18
0
HeadersNode::HeadersNode(Node* child1, Node* child2): Node("headers",  2){
    appendChild(child1);
    appendChild(child2);
}
Esempio n. 19
0
IfElseNode::IfElseNode(Node* child1, Node* child2, Node* child3): Node("ifelse",  3){
	appendChild(child1);
	appendChild(child2);
	appendChild(child3);
}
RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& document)
{
    if (!document.page())
        return nullptr;

    auto controls = adoptRef(*new MediaControlsApple(document));

    auto panel = MediaControlPanelElement::create(document);

    ExceptionCode ec;

    auto rewindButton = MediaControlRewindButtonElement::create(document);
    controls->m_rewindButton = rewindButton.ptr();
    panel->appendChild(WTFMove(rewindButton), ec);
    if (ec)
        return nullptr;

    auto playButton = MediaControlPlayButtonElement::create(document);
    controls->m_playButton = playButton.ptr();
    panel->appendChild(WTFMove(playButton), ec);
    if (ec)
        return nullptr;

    auto returnToRealtimeButton = MediaControlReturnToRealtimeButtonElement::create(document);
    controls->m_returnToRealTimeButton = returnToRealtimeButton.ptr();
    panel->appendChild(WTFMove(returnToRealtimeButton), ec);
    if (ec)
        return nullptr;

    if (document.page()->theme().usesMediaControlStatusDisplay()) {
        auto statusDisplay = MediaControlStatusDisplayElement::create(document);
        controls->m_statusDisplay = statusDisplay.ptr();
        panel->appendChild(WTFMove(statusDisplay), ec);
        if (ec)
            return nullptr;
    }

    auto timelineContainer = MediaControlTimelineContainerElement::create(document);

    auto currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
    controls->m_currentTimeDisplay = currentTimeDisplay.ptr();
    timelineContainer->appendChild(WTFMove(currentTimeDisplay), ec);
    if (ec)
        return nullptr;

    auto timeline = MediaControlTimelineElement::create(document, controls.ptr());
    controls->m_timeline = timeline.ptr();
    timelineContainer->appendChild(WTFMove(timeline), ec);
    if (ec)
        return nullptr;

    auto timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(document);
    controls->m_timeRemainingDisplay = timeRemainingDisplay.ptr();
    timelineContainer->appendChild(WTFMove(timeRemainingDisplay), ec);
    if (ec)
        return nullptr;

    controls->m_timelineContainer = timelineContainer.ptr();
    panel->appendChild(WTFMove(timelineContainer), ec);
    if (ec)
        return nullptr;

    // FIXME: Only create when needed <http://webkit.org/b/57163>
    auto seekBackButton = MediaControlSeekBackButtonElement::create(document);
    controls->m_seekBackButton = seekBackButton.ptr();
    panel->appendChild(WTFMove(seekBackButton), ec);
    if (ec)
        return nullptr;

    // FIXME: Only create when needed <http://webkit.org/b/57163>
    auto seekForwardButton = MediaControlSeekForwardButtonElement::create(document);
    controls->m_seekForwardButton = seekForwardButton.ptr();
    panel->appendChild(WTFMove(seekForwardButton), ec);
    if (ec)
        return nullptr;

    if (document.page()->theme().supportsClosedCaptioning()) {
        auto closedCaptionsContainer = MediaControlClosedCaptionsContainerElement::create(document);

        auto closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.ptr());
        controls->m_closedCaptionsTrackList = closedCaptionsTrackList.ptr();
        closedCaptionsContainer->appendChild(WTFMove(closedCaptionsTrackList), ec);
        if (ec)
            return nullptr;

        auto toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(document, controls.ptr());
        controls->m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.ptr();
        panel->appendChild(WTFMove(toggleClosedCaptionsButton), ec);
        if (ec)
            return nullptr;

        controls->m_closedCaptionsContainer = closedCaptionsContainer.ptr();
        controls->appendChild(WTFMove(closedCaptionsContainer), ec);
        if (ec)
            return nullptr;
    }

    // FIXME: Only create when needed <http://webkit.org/b/57163>
    auto fullScreenButton = MediaControlFullscreenButtonElement::create(document);
    controls->m_fullScreenButton = fullScreenButton.ptr();
    panel->appendChild(WTFMove(fullScreenButton), ec);

    // The mute button and the slider element should be in the same div.
    auto panelVolumeControlContainer = HTMLDivElement::create(document);

    if (document.page()->theme().usesMediaControlVolumeSlider()) {
        auto volumeSliderContainer = MediaControlVolumeSliderContainerElement::create(document);

        auto slider = MediaControlPanelVolumeSliderElement::create(document);
        controls->m_volumeSlider = slider.ptr();
        volumeSliderContainer->appendChild(WTFMove(slider), ec);
        if (ec)
            return nullptr;

        // This is a duplicate mute button, which is visible in some ports at the bottom of the volume bar.
        // It's important only when the volume bar is displayed below the controls.
        auto volumeSliderMuteButton = MediaControlVolumeSliderMuteButtonElement::create(document);
        controls->m_volumeSliderMuteButton = volumeSliderMuteButton.ptr();
        volumeSliderContainer->appendChild(WTFMove(volumeSliderMuteButton), ec);

        if (ec)
            return nullptr;

        controls->m_volumeSliderContainer = volumeSliderContainer.ptr();
        panelVolumeControlContainer->appendChild(WTFMove(volumeSliderContainer), ec);
        if (ec)
            return nullptr;
    }

    auto panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.ptr());
    controls->m_panelMuteButton = panelMuteButton.ptr();
    panelVolumeControlContainer->appendChild(WTFMove(panelMuteButton), ec);
    if (ec)
        return nullptr;

    panel->appendChild(WTFMove(panelVolumeControlContainer), ec);
    if (ec)
        return nullptr;

    // FIXME: Only create when needed <http://webkit.org/b/57163>
    auto fullScreenMinVolumeButton = MediaControlFullscreenVolumeMinButtonElement::create(document);
    controls->m_fullScreenMinVolumeButton = fullScreenMinVolumeButton.ptr();
    panel->appendChild(WTFMove(fullScreenMinVolumeButton), ec);
    if (ec)
        return nullptr;

    auto fullScreenVolumeSlider = MediaControlFullscreenVolumeSliderElement::create(document);
    controls->m_fullScreenVolumeSlider = fullScreenVolumeSlider.ptr();
    panel->appendChild(WTFMove(fullScreenVolumeSlider), ec);
    if (ec)
        return nullptr;

    auto fullScreenMaxVolumeButton = MediaControlFullscreenVolumeMaxButtonElement::create(document);
    controls->m_fullScreenMaxVolumeButton = fullScreenMaxVolumeButton.ptr();
    panel->appendChild(WTFMove(fullScreenMaxVolumeButton), ec);
    if (ec)
        return nullptr;

    controls->m_panel = panel.ptr();
    controls->appendChild(WTFMove(panel), ec);
    if (ec)
        return nullptr;

    return WTFMove(controls);
}
Esempio n. 21
0
    Q_FOREACH(const Attribute& attribute, m_attributes){

      std::string value;
      std::string dataType;
      switch (attribute.valueType().value()){
        case AttributeValueType::Boolean :
          if (attribute.valueAsBoolean()){
            value = "true";
          }else{
            value = "false";
          }
          dataType = "boolean";
          break;
        case AttributeValueType::Double :
          value = attribute.toString();
          dataType = "float";
          break;
        case AttributeValueType::Quantity :
          value = toString(attribute.valueAsQuantity().value());
          dataType = "float";
          break;
        case AttributeValueType::Unit :
          value = attribute.valueAsUnit().standardString();
          dataType = "string";
          break;
        case AttributeValueType::Integer :
          value = attribute.toString();
          dataType = "integer";
          break;
        case AttributeValueType::Unsigned :
          value = attribute.toString();
          dataType = "unsigned";
          break;
        case AttributeValueType::String :
          value = attribute.toString();
          dataType = "string";
          break;
        case AttributeValueType::AttributeVector :
          // can't handle this yet
          continue;
          break;
        default:
          // can't handle this yet
          continue;
      }

      QDomElement attributeElement = doc.createElement("attribute");
      element.appendChild(attributeElement);

      QDomElement nameElement = doc.createElement("name");
      attributeElement.appendChild(nameElement);
      nameElement.appendChild(doc.createTextNode(toQString(attribute.name())));

      QDomElement valueElement = doc.createElement("value");
      attributeElement.appendChild(valueElement);
      valueElement.appendChild(doc.createTextNode(toQString(value)));

      QDomElement dataTypeElement = doc.createElement("datatype");
      attributeElement.appendChild(dataTypeElement);
      dataTypeElement.appendChild(doc.createTextNode(toQString(dataType)));

      boost::optional<std::string> units = attribute.units();
      if (units){
        QDomElement unitsElement = doc.createElement("units");
        attributeElement.appendChild(unitsElement);
        unitsElement.appendChild(doc.createTextNode(toQString(*units)));
      }
    }
Esempio n. 22
0
XmlDomElement* XmlDomElement::appendChild(const QString& name) noexcept
{
    XmlDomElement* child = new XmlDomElement(name);
    appendChild(child);
    return child;
}
Esempio n. 23
0
bool UDXFile::exportRecords(const QString &url, ContactList &list)
{
    QDomDocument::clear();
    QDomElement root = createElement("DataExchangeInfo");
    appendChild(root);
    // Original format also was UDX?
    bool wasUDX = false;
    if (!list.isEmpty())
        if (list[0].originalFormat=="UDX")
            wasUDX = true;
    // XML header
    QDomNode node = createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
    insertBefore(node, firstChild());
    // UDX header
    QDomElement recInfo = addElement(root, "RecordInfo");
    addElement(recInfo, "VendorInfo", "VendorUDX");
    addElement(recInfo, "DeviceInfo", "DeviceUDX");
    if (wasUDX)
        addElement(recInfo, "UdxVersion", list[0].version);
    else
        addElement(recInfo, "UdxVersion", "1.0");
    addElement(recInfo, "UserAgent", "AgentUDX");
    addElement(recInfo, "UserInfo", "UserUDX");
    addElement(recInfo, "Encoding", "UTF-8");
    addElement(recInfo, "FileSize", "          "); // strongly 10 spaces! (~~)
    addElement(recInfo, "Date", QDate::currentDate().toString("dd.MM.yyyy"));
    addElement(recInfo, "Language","CHS"); // wtf, but this code was in real russian-language udx
    QDomElement vcfInfo = addElement(recInfo, "RecordOfvCard");
    if (wasUDX)
        addElement(vcfInfo, "vCardVersion", list[0].subVersion);
    else
        addElement(vcfInfo, "vCardVersion", "2.1");
    addElement(vcfInfo, "vCardRecord", QString::number(list.count()));
    addElement(vcfInfo, "vCardLength", "          "); // strongly 10 spaces! (~~)
    addElement(recInfo, "RecordOfvCalendar");
    addElement(recInfo, "RecordOfSMS");
    addElement(recInfo, "RecordOfMMS");
    addElement(recInfo, "RecordOfEmail");
    // Parent tag for all records
    QDomElement vCard = addElement(root, "vCard");
    // Add missing sequences to records
    int maxSeq = 0;
    if (wasUDX) { // wasUDX - simply add missing
        foreach (const ContactItem& item, list)
            if (item.id.toInt()>maxSeq)
                    maxSeq = item.id.toInt();
        QSet<int> seqs;
        for (int i=0; i<list.count(); i++) {
            ContactItem& item = list[i];
            int currentID = item.id.toInt();
            if (currentID<1) // simply missing
                item.id = QString::number(++maxSeq);
            if (seqs.contains(currentID)) { // duplicate?
                _errors << QObject::tr("Warning: contact %1, duplicate id %2 changed to %3")
                     .arg(item.visibleName).arg(currentID).arg(++maxSeq);
                item.id = QString::number(maxSeq);
            }
            seqs.insert(item.id.toInt());
        }
    }
    else { // if original wasn't UDX, completely renumerate all
        for (int i=0; i<list.count(); i++)
Esempio n. 24
0
EnlightedNode::EnlightedNode() {
  m_geometryNode.setMaterial(&m_material);
  appendChild(&m_geometryNode);
}
Esempio n. 25
0
void CNesicideProject::initializeProject()
{
   QString cc65home = qgetenv("CC65_HOME");
   QDir dir = m_projectOutputBasePath;
   
   // Initialize this node's attributes
   m_projectPaletteEntries.clear();
   m_sourceSearchPaths.clear();

   // Palette is target-dependent!
   if ( !m_projectTarget.compare("nes",Qt::CaseInsensitive) )
   {
      for (int col=0; col < nesGetNumColors(); col++)
      {
         m_projectPaletteEntries.append(QColor(nesGetPaletteRedComponent(col),
                                               nesGetPaletteGreenComponent(col),
                                               nesGetPaletteBlueComponent(col)));
      }
      
      // Add default expected source search paths that are target-dependent.
      // Doing it here to prevent users with pre-existing projects from having
      // to add the paths manually.
      addSourceSearchPath(QDir::fromNativeSeparators(cc65home+"/libsrc/nes"));
   }
   else if ( !m_projectTarget.compare("c64",Qt::CaseInsensitive) )
   {
      for (int col=0; col < c64GetNumColors(); col++)
      {
         m_projectPaletteEntries.append(QColor(c64GetPaletteRedComponent(col),
                                               c64GetPaletteGreenComponent(col),
                                               c64GetPaletteBlueComponent(col)));
      }
      
      // Add default expected source search paths that are target-dependent.
      // Doing it here to prevent users with pre-existing projects from having
      // to add the paths manually.
      addSourceSearchPath(QDir::fromNativeSeparators(cc65home+"/libsrc/c64"));
   }
   
   // Add default expected source search paths that are target-independent.
   // Doing it here to prevent users with pre-existing projects from having
   // to add the paths manually.
   addSourceSearchPath(QDir::fromNativeSeparators(cc65home+"/libsrc"));

   // Notify the fact that the project data has been initialized properly
   m_projectFileName = "(unset)";
   m_projectTitle = "(No project loaded)";
   setProjectOutputBasePath(".");
   setProjectOutputName("");
   m_projectHeaderFileName = PROJECT_HEADER_FILE;
   m_projectSourceFileName = PROJECT_SOURCE_FILE;
   m_compilerDefinedSymbols = "";
   m_compilerIncludePaths = "";
   m_compilerAdditionalOptions = "";
   m_assemblerDefinedSymbols = "";
   m_assemblerIncludePaths = "";
   m_assemblerAdditionalOptions = "";
   m_linkerConfigFile = "";
   m_makefileCustomRulesFile = "";
   m_linkerAdditionalOptions = "";
   m_linkerAdditionalDependencies = "";

   m_saveStateDoc.clear();

   m_tileProperties.clear();

   m_isInitialized = true;
   m_isDirty = false;

   // Initialize child nodes
   m_pProject->initializeProject();
   m_pCartridge->initializeProject();

   // Add child nodes to tree
   appendChild(m_pProject);
   appendChild(m_pCartridge);
}
Esempio n. 26
0
TernaryArrayNode::TernaryArrayNode(Node* child1, Node* child2, Node* child3): Node("ternaryarray",  3){
    appendChild(child1);
    appendChild(child2);
    appendChild(child3);
}
Esempio n. 27
0
BrowseFeature::BrowseFeature(QObject* parent,
                             UserSettingsPointer pConfig,
                             TrackCollection* pTrackCollection,
                             RecordingManager* pRecordingManager)
        : LibraryFeature(parent),
          m_pConfig(pConfig),
          m_browseModel(this, pTrackCollection, pRecordingManager),
          m_proxyModel(&m_browseModel),
          m_pTrackCollection(pTrackCollection),
          m_pLastRightClickedItem(NULL) {
    connect(this, SIGNAL(requestAddDir(QString)),
            parent, SLOT(slotRequestAddDir(QString)));

    m_pAddQuickLinkAction = new QAction(tr("Add to Quick Links"),this);
    connect(m_pAddQuickLinkAction, SIGNAL(triggered()), this, SLOT(slotAddQuickLink()));

    m_pRemoveQuickLinkAction = new QAction(tr("Remove from Quick Links"),this);
    connect(m_pRemoveQuickLinkAction, SIGNAL(triggered()), this, SLOT(slotRemoveQuickLink()));

    m_pAddtoLibraryAction = new QAction(tr("Add to Library"),this);
    connect(m_pAddtoLibraryAction, SIGNAL(triggered()),
            this, SLOT(slotAddToLibrary()));

    m_proxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_proxyModel.setSortCaseSensitivity(Qt::CaseInsensitive);
    // BrowseThread sets the Qt::UserRole of every QStandardItem to the sort key
    // of the item.
    m_proxyModel.setSortRole(Qt::UserRole);
    // Dynamically re-sort contents as we add items to the source model.
    m_proxyModel.setDynamicSortFilter(true);

    // The invisible root item of the child model
    auto pRootItem = std::make_unique<TreeItem>(this);

    m_pQuickLinkItem = pRootItem->appendChild(tr("Quick Links"), QUICK_LINK_NODE);

    // Create the 'devices' shortcut
#if defined(__WINDOWS__)
    TreeItem* devices_link = pRootItem->appendChild(tr("Devices"), DEVICE_NODE);
    // show drive letters
    QFileInfoList drives = QDir::drives();
    // show drive letters
    foreach (QFileInfo drive, drives) {
        // Using drive.filePath() to get path to display instead of drive.canonicalPath()
        // as it delay the startup too much if there is a network share mounted
        // (drive letter assigned) but unavailable
        // We avoid using canonicalPath() here because it makes an
        // unneeded system call to the underlying filesystem which
        // can be very long if the said filesystem is an unavailable
        // network share. drive.filePath() doesn't make any filesystem call
        // in this case because drive is an absolute path as it is taken from
        // QDir::drives(). See Qt's QDir code, especially qdir.cpp
        QString display_path = drive.filePath();
        if (display_path.endsWith("/")) {
            display_path.chop(1);
        }
        TreeItem* driveLetter =
        devices_link->appendChild(
                display_path, // Displays C:
                drive.filePath()); // Displays C:/
    }
Esempio n. 28
0
/* parent node is "current" node in block.c */
int
note_parse_tlit(struct node *parent, int current_level, unsigned char **lines)
{
  int nlines;
  struct node *n;
  char tagbuf[8], *m = tagbuf;
  unsigned char *notelabel = NULL, *notetext = NULL;
  const unsigned char *tag = NULL, *mark = NULL;

  *tagbuf = '\0';
  lines[0] += 6;
  while (isspace(lines[0][0]))
    ++lines[0];
  
  if ('^' == lines[0][0])
    {
      struct note *np;
      /* the note should already be registered at the tag-point in the line */
      ++lines[0];
      while (lines[0][0] && '^' != lines[0][0])
	{
	  *m++ = lines[0][0];
	  ++lines[0];
	}
      *m = '\0';
      ++lines[0];
      tag = (const unsigned char *)tagbuf;
      np = note_find_in_line(tag);
      if (np)
	{
	  mark = np->mark;
	}
      else
	{
	  warning("tag in note does not have corresponding tag in preceding line");
	  return 1;
	}
    }
  else
    {
      if (list_len(notes_in_line))
	{
	  warning("tagged notes cannot be mixed with untagged ones");
	  return 1;
	}
      else
	{
	  struct node *lastC = note_attach_point(parent);
	  
	  /* If there is no note tag we have to do two things: fix the attach point and set the tag to "1" */
	  if (lastC)
	    {
	      struct node *xmark = NULL;
	      enum e_type e;
	      enum block_levels l;
	      switch (lastC->etype)
		{
		case e_l:
		  {
		    struct node *lastCchild = lastChild(lastC);
		    if (lastCchild && lastCchild->etype == e_c)
		      {
			/* the attach point is either the cell or its
			   chield field if there is one */
			struct node *cField = lastChild(lastCchild);
			if (cField->etype == e_f)
			  lastC = cField;
			else
			  lastC = lastCchild;
			l = WORD;
		      }
		    else if (lastCchild && lastCchild->etype == e_f)
		      {
			/* the attach point is the field */
			lastC = lastCchild;
			l = WORD;
		      }
		    else
		      l = LINE;
		    e = e_g_nonw;
		  }
		  break;
		case e_composite:
		case e_score:
		case e_transliteration:
		  l = TEXT;
		  e = e_note_link;
		  break;
		case e_object:
		  l = OBJECT;
		  e = e_note_link;
		  break;
		case e_surface:
		  l = SURFACE;
		  e = e_note_link;
		  break;
		case e_column:
		  l = COLUMN;
		  e = e_note_link;
		  break;
		  /* FIXME: THIS CAN'T BE RIGHT */
		case e_variant:
		  l = LINE;
		  e = e_note_link;
		  break;
		default:
		  vwarning("unhandled note parent %s", lastC->names[0].pname);
		  break;
		}
	      xmark = elem(e,NULL,lnum,l);
	      if (e == e_g_nonw)
		appendAttr(xmark, attr(a_type, (unsigned char *)"notelink"));
	      appendChild(lastC, xmark);
	      tag = "1";
	      mark = note_register_tag(tag, xmark);
	    }
	  else
	    {
	      warning("nowhere to attach note mark to; please provide context and mark");
	      tag = NULL;
	    }
	}
    }

  if (tag)
    {
      while (isspace(lines[0][0]))
	++lines[0];
      if (!strncmp((char*)lines[0],"@notelabel{", 11))
	{
	  lines[0] += 11;
	  notelabel = lines[0];
	  while (lines[0][0] != '}')
	    ++lines[0];
	  lines[0][0] = '\0';
	  ++lines[0];
	  while (isspace(lines[0][0]))
	    ++lines[0];
	}

      n = elem(e_note_text,NULL,lnum,current_level);
      appendAttr(n, attr(a_note_mark, mark));
      note_register_note(tag, n);

      if (notelabel)
	set_or_append_attr(n,a_note_label,"notelabel",notelabel);

      /* This is a bit weird, but the last character before the content is
	 either a space after #note:, or a space or the closer character
	 after a note mark or label, so we are safe to play this trick
	 with the scan_comment routine */
      --lines[0];
      lines[0][0] = '#';
      notetext = npool_copy(scan_comment_sub(lines,&nlines,0), note_pool);
      (void)trans_inline(n,notetext,NULL,0);
      appendChild(parent,n);
    }

  return nlines;
}
Esempio n. 29
0
bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec, AttachBehavior attachBehavior)
{
    // Check that this node is not "floating".
    // If it is, it can be deleted as a side effect of sending mutation events.
    ASSERT(refCount() || parentOrShadowHostNode());

    RefPtr<Node> protect(this);

    ec = 0;

    // insertBefore(node, 0) is equivalent to appendChild(node)
    if (!refChild)
        return appendChild(newChild, ec, attachBehavior);

    // Make sure adding the new child is OK.
    if (!checkAddChild(this, newChild.get(), ec))
        return false;

    // NOT_FOUND_ERR: Raised if refChild is not a child of this node
    if (refChild->parentNode() != this) {
        ec = NOT_FOUND_ERR;
        return false;
    }

    if (refChild->previousSibling() == newChild || refChild == newChild) // nothing to do
        return true;

    RefPtr<Node> next = refChild;

    NodeVector targets;
    collectChildrenAndRemoveFromOldParent(newChild.get(), targets, ec);
    if (ec)
        return false;
    if (targets.isEmpty())
        return true;

    // We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
    if (!checkAcceptChildGuaranteedNodeTypes(this, newChild.get(), ec))
        return false;

    InspectorInstrumentation::willInsertDOMNode(document(), this);

    ChildListMutationScope mutation(this);
    for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) {
        Node* child = it->get();

        // Due to arbitrary code running in response to a DOM mutation event it's
        // possible that "next" is no longer a child of "this".
        // It's also possible that "child" has been inserted elsewhere.
        // In either of those cases, we'll just stop.
        if (next->parentNode() != this)
            break;
        if (child->parentNode())
            break;

        treeScope()->adoptIfNeeded(child);

        insertBeforeCommon(next.get(), child);

        updateTreeAfterInsertion(this, child, attachBehavior);
    }

    dispatchSubtreeModifiedEvent();
    return true;
}
Esempio n. 30
0
const unsigned char *
note_register_tag(const unsigned char *tag, struct node *parent)
{
  if (!tag)
    {
      if (notes_in_line)
	{
	  struct note *last_np = list_last(notes_in_line);
	  if (last_np)
	    {
	      int m = atoi((char*)last_np->tag);
	      if (m > 0)
		{
		  static char buf[10];
		  sprintf(buf, "%d", m+1);
		  return note_register_tag((const unsigned char *)buf, parent);
		}
	      else
		/* this is a stop-gap; it means that alpha notes can be done
		   explicitly, but they'll get mixed with numeric marks if
		   no mark is used in a #note: */
		return note_register_tag((const unsigned char *)"1", parent);
	    }
	  else
	    return note_register_tag((const unsigned char *)"1", parent);
	}
      else
	{
	  return note_register_tag((const unsigned char *)"1", parent);
	}
    }

  if (note_find_in_line(tag))
    {
      vwarning("note tag %s is used more than once in this line", tag);
      return NULL;
    }
  else
    {
      struct note *np = mb_new(mb);
      unsigned char *note_mark_text = NULL;
      struct node *note_mark_node = parent;
      if (note_index < 1000000)
	{
	  unsigned char markbuf[8];
	  sprintf((char*)markbuf,"%d",note_index++);
	  note_mark_text = npool_copy(markbuf, note_pool);
	}
      /* If there was a ^1^ tag in the line we need to replace the text
	 content of the parent element here; otherwise, we have a fresh
	 parent element and just need to append the text node */
      if (note_mark_node->children.lastused)
	((struct node*)(note_mark_node->children.nodes[0]))->data = note_mark_text;
      else
	appendChild(note_mark_node, textNode(note_mark_text));
      np->tag = tag;
      np->mark = note_mark_text;
      np->node = note_mark_node;
      np->status = NOTE_REGISTERED;
      if (notes_in_line)
	list_add(notes_in_line, np);
      /* list_add(notes_in_text, np); */
      return tag;
    }
}