static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3"); static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2"); static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1"); static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0"); static Image* soundDisabled = platformResource("mediaplayerSoundDisabled"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled); if (mediaElement->muted() || mediaElement->volume() <= 0) return paintMediaButton(paintInfo.context, rect, soundLevel0); if (mediaElement->volume() <= 0.33) return paintMediaButton(paintInfo.context, rect, soundLevel1); if (mediaElement->volume() <= 0.66) return paintMediaButton(paintInfo.context, rect, soundLevel2); return paintMediaButton(paintInfo.context, rect, soundLevel3); }
bool MediaControlsPainter::paintMediaMuteButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; // The new UI uses "muted" and "not muted" only. static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3", "mediaplayerSoundLevel3New"); static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2", "mediaplayerSoundLevel3New"); static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1", "mediaplayerSoundLevel3New"); static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0", "mediaplayerSoundLevel0New"); static Image* soundDisabled = platformResource("mediaplayerSoundDisabled", "mediaplayerSoundLevel0New"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled, false); if (mediaElement->muted() || mediaElement->volume() <= 0) return paintMediaButton(paintInfo.context, rect, soundLevel0); if (mediaElement->volume() <= 0.33) return paintMediaButton(paintInfo.context, rect, soundLevel1); if (mediaElement->volume() <= 0.66) return paintMediaButton(paintInfo.context, rect, soundLevel2); return paintMediaButton(paintInfo.context, rect, soundLevel3); }
VFSSource* DirectoryProvider::getSource(const std::string& path) const { VFSSource* source = NULL; if (hasSource(path)) { source = m_sources.find(path)->second; } return source; }
QVariantMap ExtSysMonAggregator::initialData(const QString source) const { qCDebug(LOG_ESM) << "Source" << source; return hasSource(source) ? m_map[source]->initialData(source) : QVariantMap(); }
bool MediaControlsPainter::paintMediaOverlayPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->paused()) return false; static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay", "mediaplayerOverlayPlayNew"); IntRect buttonRect(rect); if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { // Overlay play button covers the entire player, so center and draw a // smaller button. Center in the entire element. const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); if (!box) return false; int mediaHeight = box->pixelSnappedHeight(); buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidthNew / 2); buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeightNew / 2 + (mediaHeight - rect.height()) / 2); buttonRect.setWidth(mediaOverlayPlayButtonWidthNew); buttonRect.setHeight(mediaOverlayPlayButtonHeightNew); } return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); }
VFSSource* VFS::createSource(const std::string& path) { if (hasSource(path)) { FL_WARN(_log, LMsg(path) << " is already used as VFS source"); return 0; } type_providers::const_iterator end = m_providers.end(); for (type_providers::const_iterator i = m_providers.begin(); i != end; ++i) { VFSSourceProvider* provider = *i; if (!provider->isReadable(path)) continue; try { VFSSource* source = provider->createSource(path); return source; } catch (const Exception& ex) { FL_WARN(_log, LMsg(provider->getName()) << " thought it could load " << path << " but didn't succeed (" << ex.what() << ")"); continue; } catch (...) { FL_WARN(_log, LMsg(provider->getName()) << " thought it could load " << path << " but didn't succeed (unknown exception)"); continue; } } FL_WARN(_log, LMsg("no provider for ") << path << " found"); return 0; }
std::shared_ptr<base::ISource> BlockFS::createSource(const std::string &name, const std::string &type) { if (name.empty()) { throw EmptyString("name"); } if (hasSource(name)) { throw DuplicateName("createSource"); } std::string id = util::createId(); return std::make_shared<SourceFS>(file(), block(), source_dir.location(), id, type, name); }
static bool paintMediaOverlayPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->canPlay()) return false; static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay); }
static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { ASSERT(object->node()); HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); }
static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { ASSERT(object->node()); HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return true; static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); }
void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source) { DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources))); DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video.Autoplay.Muted", static_cast<int>(AutoplaySource::NumberOfSources))); DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources))); DEFINE_STATIC_LOCAL( EnumerationHistogram, blockedMutedVideoHistogram, ("Media.Video.Autoplay.Muted.Blocked", AutoplayBlockedReasonMax)); // Autoplay already initiated // TODO(zqzhang): how about having autoplay attribute and calling `play()` in // the script? if (hasSource()) return; m_source = source; // Record the source. if (m_element->isHTMLVideoElement()) { videoHistogram.count(static_cast<int>(m_source)); if (m_element->muted()) mutedVideoHistogram.count(static_cast<int>(m_source)); } else { audioHistogram.count(static_cast<int>(m_source)); } // Record if it will be blocked by Data Saver or Autoplay setting. if (m_element->isHTMLVideoElement() && m_element->muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { bool dataSaverEnabled = m_element->document().settings() && m_element->document().settings()->dataSaverEnabled(); bool blockedBySetting = !m_element->isAutoplayAllowedPerSettings(); if (dataSaverEnabled && blockedBySetting) { blockedMutedVideoHistogram.count( AutoplayBlockedReasonDataSaverAndSetting); } else if (dataSaverEnabled) { blockedMutedVideoHistogram.count(AutoplayBlockedReasonDataSaver); } else if (blockedBySetting) { blockedMutedVideoHistogram.count(AutoplayBlockedReasonSetting); } } m_element->addEventListener(EventTypeNames::playing, this, false); }
FIFE::VFSSource* DirectoryProvider::createSource(const std::string& path) { if (isReadable(path)) { VFSSource* source = NULL; if ( hasSource(path)) { source = m_sources[path]; } else { source = new VFSDirectory(getVFS(), path); m_sources[path] = source; } return source; } else throw Exception("Path " + path + " is not readable."); }
static bool paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaPlay = platformResource("mediaPlay"); static Image* mediaPause = platformResource("mediaPause"); static Image* mediaPlayDisabled = platformResource("mediaPlayDisabled"); if (!hasSource(mediaElement)) return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); return paintMediaButton(paintInfo.context, rect, mediaElement->canPlay() ? mediaPlay : mediaPause); }
static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* soundFull = platformResource("mediaSoundFull"); static Image* soundNone = platformResource("mediaSoundNone"); static Image* soundDisabled = platformResource("mediaSoundDisabled"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled); return paintMediaButton(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); }
static bool paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { if (!object->parent()->isSlider()) return false; HTMLMediaElement* mediaElement = toParentMediaElement(object->parent()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; static Image* mediaSliderThumb = platformResource("mediaSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); }
bool MediaControlsPainter::paintMediaVolumeSlider(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; GraphicsContext* context = paintInfo.context; const ComputedStyle& style = object.styleRef(); // Paint the slider bar. Color sliderBackgroundColor; if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) sliderBackgroundColor = Color(11, 11, 11); else sliderBackgroundColor = Color(0x9f, 0x9f, 0x9f); paintRoundedSliderBackground(rect, style, context, sliderBackgroundColor); // Calculate volume position for white background rectangle. float volume = mediaElement->volume(); if (std::isnan(volume) || volume < 0) return true; if (volume > 1) volume = 1; if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->muted()) volume = 0; // Calculate the position relative to the center of the thumb. float fillWidth = 0; if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { if (volume > 0) { float thumbCenter = mediaVolumeSliderThumbWidth / 2; float zoomLevel = style.effectiveZoom(); float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter)); fillWidth = positionWidth + (zoomLevel * thumbCenter / 2); } } else { fillWidth = volume * rect.width(); } Color startColor = Color(195, 195, 195); Color endColor = Color(217, 217, 217); if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) startColor = endColor = Color(0x42, 0x85, 0xf4); // blue. paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, endColor); return true; }
bool MediaControlsPainter::paintMediaPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaPlay = platformResource("mediaplayerPlay", "mediaplayerPlayNew"); static Image* mediaPause = platformResource("mediaplayerPause", "mediaplayerPauseNew"); // For this case, the new UI draws the normal icon, but the entire panel // grays out. static Image* mediaPlayDisabled = platformResource("mediaplayerPlayDisabled", "mediaplayerPlayNew"); if (!hasSource(mediaElement)) return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, false); Image * image = !object.node()->isMediaControlElement() || mediaControlElementType(object.node()) == MediaPlayButton ? mediaPlay : mediaPause; return paintMediaButton(paintInfo.context, rect, image); }
bool MediaControlsPainter::paintMediaSliderThumb(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object.node()) return false; const HTMLMediaElement* mediaElement = toParentMediaElement(object.node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); IntRect paintRect; const ComputedStyle& style = object.styleRef(); adjustMediaSliderThumbPaintSize(rect, style, paintRect); return paintMediaButton(paintInfo.context, paintRect, mediaSliderThumb); }
bool MediaControlsPainter::paintMediaSlider(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; GraphicsContext* context = paintInfo.context; // Should we paint the slider partially transparent? bool drawUiGrayed = !hasSource(mediaElement) && RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); if (drawUiGrayed) context->beginLayer(kDisabledAlpha); paintMediaSliderInternal(object, paintInfo, rect); if (drawUiGrayed) context->endLayer(); return true; }
bool SourceHDF5::deleteSource(const string &name_or_id) { boost::optional<H5Group> g = source_group(); bool deleted = false; if(g) { // call deleteSource on sources to trigger recursive call to all sub-sources if (hasSource(name_or_id)) { // get instance of source about to get deleted Source source = getSource(name_or_id); // loop through all child sources and call deleteSource on them for(auto &child : source.sources()) { source.deleteSource(child.id()); } // if hasSource is true then source_group always exists deleted = g->removeAllLinks(source.name()); } } return deleted; }
bool MediaControlsPainter::paintMediaVolumeSliderThumb(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object.node()) return false; const HTMLMediaElement* mediaElement = toParentMediaElement(object.node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return true; static Image* mediaVolumeSliderThumb = platformResource( "mediaplayerVolumeSliderThumb", "mediaplayerVolumeSliderThumbNew"); IntRect paintRect; const ComputedStyle& style = object.styleRef(); adjustMediaSliderThumbPaintSize(rect, style, paintRect); return paintMediaButton(paintInfo.context, paintRect, mediaVolumeSliderThumb); }
bool MediaControlsPainter::paintMediaFullscreenButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; // With the new player UI, we have separate assets for enter / exit // fullscreen mode. static Image* mediaEnterFullscreenButton = platformResource( "mediaplayerFullscreen", "mediaplayerEnterFullscreen"); static Image* mediaExitFullscreenButton = platformResource( "mediaplayerFullscreen", "mediaplayerExitFullscreen"); bool isEnabled = hasSource(mediaElement); if (mediaControlElementType(object.node()) == MediaExitFullscreenButton) return paintMediaButton(paintInfo.context, rect, mediaExitFullscreenButton, isEnabled); return paintMediaButton(paintInfo.context, rect, mediaEnterFullscreenButton, isEnabled); }
static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; GraphicsContext* context = paintInfo.context; RenderStyle* style = object->style(); paintRoundedSliderBackground(rect, style, context); // Calculate volume position for white background rectangle. float volume = mediaElement->volume(); if (std::isnan(volume) || volume < 0) return true; if (volume > 1) volume = 1; if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->muted()) volume = 0; // Calculate the position relative to the center of the thumb. float fillWidth = 0; if (volume > 0) { float thumbCenter = mediaVolumeSliderThumbWidth / 2; float zoomLevel = style->effectiveZoom(); float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter)); fillWidth = positionWidth + (zoomLevel * thumbCenter / 2); } Color startColor = Color(195, 195, 195); Color endColor = Color(217, 217, 217); paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, endColor); return true; }
QVariant ExtSysMonAggregator::data(const QString source) const { qCDebug(LOG_ESM) << "Source" << source; return hasSource(source) ? m_map[source]->data(source) : QVariant(); }
bool GraphNodeLink::isConnected() { return (hasSource() && hasTarget()); }