void LayoutVTTCue::layout() { LayoutBlockFlow::layout(); // If WebVTT Regions are used, the regular WebVTT layout algorithm is no // longer necessary, since cues having the region parameter set do not have // any positioning parameters. Also, in this case, the regions themselves // have positioning information. if (!m_cue->regionId().isEmpty()) return; ASSERT(firstChild()); LayoutState state(*this, locationOffset()); // Determine the area covered by the media controls, if any. If the controls // are present, they are the next sibling of the text track container, which // is our parent. (LayoutMedia ensures that the media controls are laid out // before text tracks, so that the layout is up-to-date here.) ASSERT(parent()->node()->isTextTrackContainer()); IntRect controlsRect; if (LayoutObject* parentSibling = parent()->nextSibling()) { // Only a part of the media controls is used for overlap avoidance. MediaControls* controls = toMediaControls(parentSibling->node()); if (LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLayout()) controlsRect = controlsLayout->absoluteBoundingBoxRect(); } // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. if (m_cue->snapToLines()) { SnapToLinesLayouter(*this, controlsRect, m_cue->calculateComputedLinePosition()).layout(); adjustForTopAndBottomMarginBorderAndPadding(); } else { repositionCueSnapToLinesNotSet(); } }
IntRect LayoutVTTCue::computeControlsRect() const { // Determine the area covered by the media controls, if any. If the controls // are present, they are the next sibling of the text track container, which // is our parent. (LayoutMedia ensures that the media controls are laid out // before text tracks, so that the layout is up to date here.) DCHECK(parent()->node()->isTextTrackContainer()); LayoutObject* controlsContainer = parent()->nextSibling(); if (!controlsContainer) return IntRect(); // Only a part of the media controls is used for overlap avoidance. MediaControls* controls = toMediaControls(controlsContainer->node()); LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLayout(); // The (second part of the) following is mostly defensive - in general // there should be a LayoutBox representing the part of the controls that // are relevant for overlap avoidance. (The controls pseudo elements are // generally reachable from outside the shadow tree though, hence the // "mostly".) if (!controlsLayout || !controlsLayout->isBox()) return IntRect(); // Assume that the controls container are positioned in the same relative // position as the text track container. (LayoutMedia::layout ensures this.) return contentBoxRelativeToAncestor(toLayoutBox(*controlsLayout), toLayoutBox(*controlsContainer)); }
MediaControls* MediaControls::create(HTMLMediaElement& mediaElement) { MediaControls* controls = new MediaControls(mediaElement); controls->setShadowPseudoId(AtomicString("-webkit-media-controls")); controls->initializeControls(); return controls; }
void MediaPlayerPrivateEA::paint(GraphicsContext* context, const IntRect& r) { if (!context) return; // Can get a NULL platform context so need to verify. Seems that UpdateControlTints does what is called a "fake" paint // with a null platform context just to get an invalidate. PlatformContextCairo* pPlatformContext = context->platformContext(); if (!pPlatformContext) return; cairo_t* cr = context->platformContext()->cr(); if (!cr) return; MediaUpdateInfo& info = GetMediaUpdateInfo(); const FrameView* pFV = mpWebCorePlayer->frameView(); if (!pFV) return; // Convert and store movie rect to device coords using the graphic context. double x = (double) r.x(); double y = (double) r.y(); double w = (double) r.width(); double h = (double) r.height(); cairo_user_to_device (cr, &x, &y); cairo_user_to_device_distance(cr, &w, &h); const IntRect rect((int) x, (int) y, (int) w, (int) h); // The intersection of frameView contents and the movie is used as clip rect for we just want to know what part of the movie is visible. IntRect clip = pFV->windowClipRect(true); clip.intersect(rect); // Find controls intersection HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient()); if(element && element->controls()) { MediaControls* pControls = element->mediaControls(); bool hideControls = pControls->shouldHideControls(); if (!hideControls) { const int kControlHeight = 16; // EAWebKitTODO: Consider finding a way to extract this info directly from the controls or pass as a theme param. IntRect boundingRect = pControls->getRect(); x = (double) boundingRect.x(); y = (double) boundingRect.y(); w = (double) boundingRect.width(); h = (double) (boundingRect.height() - kControlHeight); cairo_user_to_device (cr, &x, &y); cairo_user_to_device_distance(cr, &w, &h); const IntRect ctrlRect((int) x, (int) y, (int) w, (int) h); clip.intersect(ctrlRect); } } if ((rect != mMovieRect) || (clip != mWindowRect)) { mMovieRect = rect; // Store copy locally to detect changes. mWindowRect = clip; info.mMovieRect = rect; info.mWindowRect = clip; ClientUpdate(MediaUpdateInfo::kWindowSize); } ClientUpdate(MediaUpdateInfo::kPaint); if (info.mReturnData) { // Draw surface to view #ifndef NDEBUG static bool sAssertChecked = false; if(!sAssertChecked) { EAW_ASSERT(!info.mReturnData); sAssertChecked = true; } #endif context->save(); RefPtr<cairo_surface_t> cairoSurface = adoptRef(cairo_image_surface_create_for_data((unsigned char*) info.mReturnData, CAIRO_FORMAT_ARGB32, w, h, w * sizeof(uint32_t))); EAW_ASSERT(cairo_surface_status(cairoSurface.get()) == CAIRO_STATUS_SUCCESS); cairo_set_source_surface(cr, cairoSurface.get(), rect.x(), rect.y()); cairo_paint(cr); context->restore(); } else { // Draw a default black background. context->save(); context->setStrokeStyle(NoStroke); context->setFillColor(Color::black, ColorSpaceDeviceRGB); context->drawRect(r); context->restore(); } }
MediaControlInputElement::MediaControlInputElement( MediaControls& mediaControls, MediaControlElementType displayType) : HTMLInputElement(mediaControls.document(), false), MediaControlElement(mediaControls, displayType, this) {}
MediaControlDivElement::MediaControlDivElement( MediaControls& mediaControls, MediaControlElementType displayType) : HTMLDivElement(mediaControls.document()), MediaControlElement(mediaControls, displayType, this) {}