Bug 875305 - Replace slow webvtt caption selectors with classes. r=bz, a=akeybl
authorRalph Giles <giles@mozilla.com>
Tue, 28 May 2013 13:55:00 -0700
changeset 142782 ddc11868e236c8b09fd132b47a0b962d0a7cd3f5
parent 142781 50125a7e87f7c6bb8fc62bcfe8be10aca3df638a
child 142783 6a355013cc59becb5c4a7a85615fc38b9e8d6030
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, akeybl
bugs875305, 833382
milestone23.0a2
Bug 875305 - Replace slow webvtt caption selectors with classes. r=bz, a=akeybl We set the class caption-box class on the anonymous div which acts as the parent container for the captions overlayed on the video frame. caption-text isn't currently used, but will be applied to child elements by when bug 833382 lands.
layout/generic/nsVideoFrame.cpp
layout/style/html.css
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -12,16 +12,17 @@
 #include "nsGkAtoms.h"
 
 #include "nsVideoFrame.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "nsIDOMHTMLVideoElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsDisplayList.h"
+#include "nsGenericHTMLElement.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "nsPresContext.h"
 #include "nsTransform2D.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsBoxLayoutState.h"
 #include "nsBoxFrame.h"
 #include "nsImageFrame.h"
@@ -105,16 +106,18 @@ nsVideoFrame::CreateAnonymousContent(nsT
     // Set up the caption overlay div for showing any TextTrack data
     nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::div,
                                             nullptr,
                                             kNameSpaceID_XHTML,
                                             nsIDOMNode::ELEMENT_NODE);
     NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
     mCaptionDiv = NS_NewHTMLDivElement(nodeInfo.forget());
     NS_ENSURE_TRUE(mCaptionDiv, NS_ERROR_OUT_OF_MEMORY);
+    nsGenericHTMLElement* div = static_cast<nsGenericHTMLElement*>(mCaptionDiv.get());
+    div->SetClassName(NS_LITERAL_STRING("caption-box"));
 
     if (!aElements.AppendElement(mCaptionDiv))
       return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // Set up "videocontrols" XUL element which will be XBL-bound to the
   // actual controls.
   nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::videocontrols,
--- a/layout/style/html.css
+++ b/layout/style/html.css
@@ -717,24 +717,24 @@ audio:not([controls]) {
 }
 
 *|*::-moz-html-canvas-content {
   display: block !important;
   /* we want to be an absolute and fixed container */
   -moz-transform: translate(0) !important;
 }
 
-video > div {
+video > .caption-box {
   text-align: center;
   font-weight: bold;
   font-size: 24px;
   pointer-events: none;
 }
 
-video > div p {
+video > div .caption-text {
   color: gold;
   background-color: rgba(105,105,105,0.4);
   pointer-events: auto;
 }
 
 /* emulation of non-standard HTML <marquee> tag */
 marquee {
   width: -moz-available;