// TextTrack parameter when passed in as a nullptr, creates the "Off" list item in the track list. Element* MediaControlTextTrackListElement::createTextTrackListItem(TextTrack* track) { int trackIndex = track ? track->trackIndex() : trackIndexOffValue; HTMLLabelElement* trackItem = HTMLLabelElement::create(document()); trackItem->setShadowPseudoId(AtomicString("-internal-media-controls-text-track-list-item")); HTMLInputElement* trackItemInput = HTMLInputElement::create(document(), nullptr, false); trackItemInput->setShadowPseudoId(AtomicString("-internal-media-controls-text-track-list-item-input")); trackItemInput->setType(InputTypeNames::checkbox); trackItemInput->setIntegralAttribute(trackIndexAttrName(), trackIndex); if (!mediaElement().textTracksVisible()) { if (!track) trackItemInput->setChecked(true); } else { // If there are multiple text tracks set to showing, they must all have // checkmarks displayed. if (track && track->mode() == TextTrack::showingKeyword()) trackItemInput->setChecked(true); } trackItem->appendChild(trackItemInput); String trackLabel = getTextTrackLabel(track); trackItem->appendChild(Text::create(document(), trackLabel)); // Add a track kind marker icon if there are multiple tracks with the same label or if the track has no label. if (track && (track->label().isEmpty() || hasDuplicateLabel(track))) { HTMLSpanElement* trackKindMarker = HTMLSpanElement::create(document()); if (track->kind() == track->captionsKeyword()) { trackKindMarker->setShadowPseudoId(AtomicString("-internal-media-controls-text-track-list-kind-captions")); } else { DCHECK_EQ(track->kind(), track->subtitlesKeyword()); trackKindMarker->setShadowPseudoId(AtomicString("-internal-media-controls-text-track-list-kind-subtitles")); } trackItem->appendChild(trackKindMarker); } return trackItem; }
HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeValue) { if (forAttributeValue.isEmpty()) return 0; if (!m_labelsByForAttribute) { // Populate the map on first access. m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(element)) { if (element->hasTagName(labelTag)) { HTMLLabelElement* label = static_cast<HTMLLabelElement*>(element); const AtomicString& forValue = label->fastGetAttribute(forAttr); if (!forValue.isEmpty()) addLabel(forValue, label); } } } return static_cast<HTMLLabelElement*>(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue.impl(), this)); }
HTMLElement* MediaControlInputElement::createOverflowElement( MediaControls& mediaControls, MediaControlInputElement* button) { if (!button) return nullptr; // We don't want the button visible within the overflow menu. button->setIsWanted(false); m_overflowMenuText = Text::create(mediaControls.document(), button->getOverflowMenuString()); HTMLLabelElement* element = HTMLLabelElement::create(mediaControls.document()); element->setShadowPseudoId( AtomicString("-internal-media-controls-overflow-menu-list-item")); // Appending a button to a label element ensures that clicks on the label // are passed down to the button, performing the action we'd expect. element->appendChild(button); element->appendChild(m_overflowMenuText); m_overflowMenuElement = element; return element; }
bool HTMLLabelElement::rendererIsFocusable() const { HTMLLabelElement* that = const_cast<HTMLLabelElement*>(this); return that->isContentEditable(); }
static v8::Handle<v8::Value> controlAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { HTMLLabelElement* imp = V8HTMLLabelElement::toNative(info.Holder()); return toV8Fast(imp->control(), info, imp); }
bool HTMLLabelElement::layoutObjectIsFocusable() const { HTMLLabelElement* that = const_cast<HTMLLabelElement*>(this); return that->isContentEditable(); }