Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: Source/core/layout/LayoutTextTrackContainer.cpp

Issue 994063003: Move TextTrackContainer::updateSizes to the layout-side (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/LayoutTextTrackContainer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutTextTrackContainer.cpp
diff --git a/Source/core/layout/LayoutTextTrackContainer.cpp b/Source/core/layout/LayoutTextTrackContainer.cpp
index 2ca076ae06a162802f44514dd7bea813c0f72239..eb3dc1d28566749abf540f0ae454badbb6ab0388 100644
--- a/Source/core/layout/LayoutTextTrackContainer.cpp
+++ b/Source/core/layout/LayoutTextTrackContainer.cpp
@@ -29,13 +29,13 @@
#include "core/layout/LayoutTextTrackContainer.h"
#include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h"
-#include "core/html/HTMLMediaElement.h"
-#include "core/html/track/TextTrackContainer.h"
+#include "core/layout/LayoutVideo.h"
namespace blink {
LayoutTextTrackContainer::LayoutTextTrackContainer(Element* element)
: LayoutBlockFlow(element)
+ , m_fontSize(0)
{
}
@@ -47,11 +47,32 @@ void LayoutTextTrackContainer::layout()
DeprecatedScheduleStyleRecalcDuringLayout marker(node()->document().lifecycle());
- TextTrackContainer* textTrackContainer = toTextTrackContainer(node());
- ASSERT(textTrackContainer);
// Overlay enclosure -> Media controls -> Media element
LayoutObject* mediaElementLayoutObject = parent()->parent()->parent();
- textTrackContainer->updateSizes(mediaElementLayoutObject);
+ if (!mediaElementLayoutObject || !mediaElementLayoutObject->isVideo())
+ return;
+ if (updateSizes(toLayoutVideo(*mediaElementLayoutObject)))
+ toElement(node())->setInlineStyleProperty(CSSPropertyFontSize, m_fontSize, CSSPrimitiveValue::CSS_PX);
+}
+
+bool LayoutTextTrackContainer::updateSizes(const LayoutVideo& videoLayoutObject)
+{
+ // FIXME: The video size is used to calculate the font size (a workaround
+ // for lack of per-spec vh/vw support) but the whole media element is used
+ // for cue rendering. This is inconsistent. See also the somewhat related
+ // spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28105
+ IntSize videoSize = videoLayoutObject.videoBox().size();
+ if (m_videoSize == videoSize)
+ return false;
+ m_videoSize = videoSize;
+
+ float smallestDimension = std::min(m_videoSize.height(), m_videoSize.width());
+
+ float fontSize = smallestDimension * 0.05f;
+ if (m_fontSize == fontSize)
+ return false;
+ m_fontSize = fontSize;
+ return true;
}
} // namespace blink
« no previous file with comments | « Source/core/layout/LayoutTextTrackContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698