Index: third_party/WebKit/Source/core/html/MediaDocument.cpp |
diff --git a/third_party/WebKit/Source/core/html/MediaDocument.cpp b/third_party/WebKit/Source/core/html/MediaDocument.cpp |
index 525d869dbb2ff380d5110f98d9e9b3d3e17ac593..f02ff63f568ce03ecebe419c50e1c4b805a8e903 100644 |
--- a/third_party/WebKit/Source/core/html/MediaDocument.cpp |
+++ b/third_party/WebKit/Source/core/html/MediaDocument.cpp |
@@ -31,7 +31,9 @@ |
#include "core/dom/RawDataDocumentParser.h" |
#include "core/events/KeyboardEvent.h" |
#include "core/frame/LocalFrame.h" |
+#include "core/html/HTMLAnchorElement.h" |
#include "core/html/HTMLBodyElement.h" |
+#include "core/html/HTMLDivElement.h" |
#include "core/html/HTMLHeadElement.h" |
#include "core/html/HTMLHtmlElement.h" |
#include "core/html/HTMLMetaElement.h" |
@@ -41,6 +43,7 @@ |
#include "core/loader/FrameLoader.h" |
#include "core/loader/FrameLoaderClient.h" |
#include "platform/KeyboardCodes.h" |
+#include "platform/text/PlatformLocale.h" |
namespace blink { |
@@ -98,8 +101,53 @@ void MediaDocumentParser::createDocumentStructure() |
media->appendChild(source.release()); |
RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document()); |
- body->appendChild(media.release()); |
+ RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*document()); |
+ div->setAttribute( |
Xianzhu
2016/03/17 21:49:21
Add a comment about why you inline these styles he
qinmin
2016/03/17 22:07:59
Done.
|
+ styleAttr, |
+ "max-height: 100%;" |
+ "max-width: 100%;" |
+ "position: absolute;" |
+ "top: 50%;" |
+ "left: 50%;" |
+ "margin-right: -50%;" |
+ "transform: translate(-50%, -50%);"); |
+ |
+ if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { |
+ // Padding is used to compensate for the height of the download button so that the media element can still be centered. |
+ RefPtrWillBeRawPtr<HTMLDivElement> padding = HTMLDivElement::create(*document()); |
+ padding->setAttribute(heightAttr, "68px;"); |
+ div->appendChild(padding.release()); |
Xianzhu
2016/03/17 21:49:21
Can you just use padding-top on the first div?
qinmin
2016/03/17 22:07:59
the first div is also used in MediaDocuent without
|
+ } |
+ |
+ div->appendChild(media.release()); |
+ |
+ if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { |
+ RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*document()); |
+ anchor->setAttribute(downloadAttr, ""); |
+ anchor->setURL(document()->url()); |
+ anchor->setTextContent(document()->getCachedLocale(document()->contentLanguage()).queryString(WebLocalizedString::DownloadButtonLabel)); |
+ // Using css style according to android material design. |
Xianzhu
2016/03/17 21:49:21
Nit: s/css/CSS/, s/android/Android/.
qinmin
2016/03/17 22:07:59
Done.
|
+ anchor->setAttribute( |
+ styleAttr, |
+ "display: block;" |
+ "width: 120px;" |
+ "height: 36px;" |
+ "background: #4285F4;" |
+ "font-family: Roboto;" |
+ "font-size: 14px;" |
+ "border-radius: 5px;" |
+ "color: white;" |
+ "font-weight: bold;" |
+ "text-decoration: none;" |
+ "text-transform: uppercase;" |
+ "text-align: center;" |
+ "line-height: 36px;" |
+ "margin: 32px auto 0 auto;"); |
+ div->appendChild(anchor.release()); |
+ } |
+ |
+ body->appendChild(div.release()); |
rootElement->appendChild(head.release()); |
rootElement->appendChild(body.release()); |