OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 13 matching lines...) Expand all Loading... | |
24 */ | 24 */ |
25 | 25 |
26 #include "core/html/MediaDocument.h" | 26 #include "core/html/MediaDocument.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
30 #include "core/dom/ElementTraversal.h" | 30 #include "core/dom/ElementTraversal.h" |
31 #include "core/dom/RawDataDocumentParser.h" | 31 #include "core/dom/RawDataDocumentParser.h" |
32 #include "core/events/KeyboardEvent.h" | 32 #include "core/events/KeyboardEvent.h" |
33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
34 #include "core/html/HTMLAnchorElement.h" | |
34 #include "core/html/HTMLBodyElement.h" | 35 #include "core/html/HTMLBodyElement.h" |
36 #include "core/html/HTMLDivElement.h" | |
35 #include "core/html/HTMLHeadElement.h" | 37 #include "core/html/HTMLHeadElement.h" |
36 #include "core/html/HTMLHtmlElement.h" | 38 #include "core/html/HTMLHtmlElement.h" |
37 #include "core/html/HTMLMetaElement.h" | 39 #include "core/html/HTMLMetaElement.h" |
38 #include "core/html/HTMLSourceElement.h" | 40 #include "core/html/HTMLSourceElement.h" |
39 #include "core/html/HTMLVideoElement.h" | 41 #include "core/html/HTMLVideoElement.h" |
40 #include "core/loader/DocumentLoader.h" | 42 #include "core/loader/DocumentLoader.h" |
41 #include "core/loader/FrameLoader.h" | 43 #include "core/loader/FrameLoader.h" |
42 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
43 #include "platform/KeyboardCodes.h" | 45 #include "platform/KeyboardCodes.h" |
46 #include "platform/text/PlatformLocale.h" | |
44 | 47 |
45 namespace blink { | 48 namespace blink { |
46 | 49 |
47 using namespace HTMLNames; | 50 using namespace HTMLNames; |
48 | 51 |
49 // FIXME: Share more code with PluginDocumentParser. | 52 // FIXME: Share more code with PluginDocumentParser. |
50 class MediaDocumentParser : public RawDataDocumentParser { | 53 class MediaDocumentParser : public RawDataDocumentParser { |
51 public: | 54 public: |
52 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc ument) | 55 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc ument) |
53 { | 56 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 94 |
92 RefPtrWillBeRawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*do cument()); | 95 RefPtrWillBeRawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*do cument()); |
93 source->setSrc(document()->url()); | 96 source->setSrc(document()->url()); |
94 | 97 |
95 if (DocumentLoader* loader = document()->loader()) | 98 if (DocumentLoader* loader = document()->loader()) |
96 source->setType(loader->responseMIMEType()); | 99 source->setType(loader->responseMIMEType()); |
97 | 100 |
98 media->appendChild(source.release()); | 101 media->appendChild(source.release()); |
99 | 102 |
100 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document ()); | 103 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document ()); |
101 body->appendChild(media.release()); | |
102 | 104 |
105 RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*document()) ; | |
106 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.
| |
107 styleAttr, | |
108 "max-height: 100%;" | |
109 "max-width: 100%;" | |
110 "position: absolute;" | |
111 "top: 50%;" | |
112 "left: 50%;" | |
113 "margin-right: -50%;" | |
114 "transform: translate(-50%, -50%);"); | |
115 | |
116 if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { | |
117 // Padding is used to compensate for the height of the download button s o that the media element can still be centered. | |
118 RefPtrWillBeRawPtr<HTMLDivElement> padding = HTMLDivElement::create(*doc ument()); | |
119 padding->setAttribute(heightAttr, "68px;"); | |
120 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
| |
121 } | |
122 | |
123 div->appendChild(media.release()); | |
124 | |
125 if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) { | |
126 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create (*document()); | |
127 anchor->setAttribute(downloadAttr, ""); | |
128 anchor->setURL(document()->url()); | |
129 anchor->setTextContent(document()->getCachedLocale(document()->contentLa nguage()).queryString(WebLocalizedString::DownloadButtonLabel)); | |
130 // 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.
| |
131 anchor->setAttribute( | |
132 styleAttr, | |
133 "display: block;" | |
134 "width: 120px;" | |
135 "height: 36px;" | |
136 "background: #4285F4;" | |
137 "font-family: Roboto;" | |
138 "font-size: 14px;" | |
139 "border-radius: 5px;" | |
140 "color: white;" | |
141 "font-weight: bold;" | |
142 "text-decoration: none;" | |
143 "text-transform: uppercase;" | |
144 "text-align: center;" | |
145 "line-height: 36px;" | |
146 "margin: 32px auto 0 auto;"); | |
147 div->appendChild(anchor.release()); | |
148 } | |
149 | |
150 body->appendChild(div.release()); | |
103 rootElement->appendChild(head.release()); | 151 rootElement->appendChild(head.release()); |
104 rootElement->appendChild(body.release()); | 152 rootElement->appendChild(body.release()); |
105 | 153 |
106 m_didBuildDocumentStructure = true; | 154 m_didBuildDocumentStructure = true; |
107 } | 155 } |
108 | 156 |
109 void MediaDocumentParser::appendBytes(const char*, size_t) | 157 void MediaDocumentParser::appendBytes(const char*, size_t) |
110 { | 158 { |
111 if (m_didBuildDocumentStructure) | 159 if (m_didBuildDocumentStructure) |
112 return; | 160 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); | 193 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); |
146 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) { | 194 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) { |
147 // space or media key (play/pause) | 195 // space or media key (play/pause) |
148 video->togglePlayState(); | 196 video->togglePlayState(); |
149 event->setDefaultHandled(); | 197 event->setDefaultHandled(); |
150 } | 198 } |
151 } | 199 } |
152 } | 200 } |
153 | 201 |
154 } // namespace blink | 202 } // namespace blink |
OLD | NEW |