| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 if (DocumentLoader* loader = document()->loader()) | 139 if (DocumentLoader* loader = document()->loader()) |
| 140 source->setType(loader->responseMIMEType()); | 140 source->setType(loader->responseMIMEType()); |
| 141 | 141 |
| 142 media->appendChild(source); | 142 media->appendChild(source); |
| 143 | 143 |
| 144 HTMLBodyElement* body = HTMLBodyElement::create(*document()); | 144 HTMLBodyElement* body = HTMLBodyElement::create(*document()); |
| 145 body->setAttribute(styleAttr, "margin: 0px;"); | 145 body->setAttribute(styleAttr, "margin: 0px;"); |
| 146 | 146 |
| 147 HTMLDivElement* div = HTMLDivElement::create(*document()); | 147 HTMLDivElement* div = HTMLDivElement::create(*document()); |
| 148 // Style sheets for media controls are lazily loaded until a media element is
encountered. | 148 // Style sheets for media controls are lazily loaded until a media element is |
| 149 // As a result, elements encountered before the media element will not get the
right | 149 // encountered. As a result, elements encountered before the media element |
| 150 // style at first if we put the styles in mediacontrols.css. To solve this iss
ue, set the | 150 // will not get the right style at first if we put the styles in |
| 151 // styles inline so that they will be applied when the page loads. | 151 // mediacontrols.css. To solve this issue, set the styles inline so that they |
| 152 // See w3c example on how to centering an element: https://www.w3.org/Style/Ex
amples/007/center.en.html | 152 // will be applied when the page loads. See w3c example on how to centering |
| 153 // an element: https://www.w3.org/Style/Examples/007/center.en.html |
| 153 div->setAttribute(styleAttr, | 154 div->setAttribute(styleAttr, |
| 154 "display: flex;" | 155 "display: flex;" |
| 155 "flex-direction: column;" | 156 "flex-direction: column;" |
| 156 "justify-content: center;" | 157 "justify-content: center;" |
| 157 "align-items: center;" | 158 "align-items: center;" |
| 158 "min-height: min-content;" | 159 "min-height: min-content;" |
| 159 "height: 100%;"); | 160 "height: 100%;"); |
| 160 HTMLContentElement* content = HTMLContentElement::create(*document()); | 161 HTMLContentElement* content = HTMLContentElement::create(*document()); |
| 161 div->appendChild(content); | 162 div->appendChild(content); |
| 162 | 163 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 190 HTMLDivElement* buttonContainer = HTMLDivElement::create(*document()); | 191 HTMLDivElement* buttonContainer = HTMLDivElement::create(*document()); |
| 191 buttonContainer->setAttribute(styleAttr, | 192 buttonContainer->setAttribute(styleAttr, |
| 192 "text-align: center;" | 193 "text-align: center;" |
| 193 "height: 0;" | 194 "height: 0;" |
| 194 "flex: none"); | 195 "flex: none"); |
| 195 buttonContainer->appendChild(anchor); | 196 buttonContainer->appendChild(anchor); |
| 196 div->appendChild(buttonContainer); | 197 div->appendChild(buttonContainer); |
| 197 recordDownloadMetric(MediaDocumentDownloadButtonShown); | 198 recordDownloadMetric(MediaDocumentDownloadButtonShown); |
| 198 } | 199 } |
| 199 | 200 |
| 200 // According to https://html.spec.whatwg.org/multipage/browsers.html#read-medi
a, | 201 // According to |
| 202 // https://html.spec.whatwg.org/multipage/browsers.html#read-media, |
| 201 // MediaDocument should have a single child which is the video element. Use | 203 // MediaDocument should have a single child which is the video element. Use |
| 202 // shadow root to hide all the elements we added here. | 204 // shadow root to hide all the elements we added here. |
| 203 ShadowRoot& shadowRoot = body->ensureUserAgentShadowRoot(); | 205 ShadowRoot& shadowRoot = body->ensureUserAgentShadowRoot(); |
| 204 shadowRoot.appendChild(div); | 206 shadowRoot.appendChild(div); |
| 205 body->appendChild(media); | 207 body->appendChild(media); |
| 206 rootElement->appendChild(head); | 208 rootElement->appendChild(head); |
| 207 rootElement->appendChild(body); | 209 rootElement->appendChild(body); |
| 208 | 210 |
| 209 m_didBuildDocumentStructure = true; | 211 m_didBuildDocumentStructure = true; |
| 210 } | 212 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if (keyboardEvent->key() == " " || | 251 if (keyboardEvent->key() == " " || |
| 250 keyboardEvent->keyCode() == VKEY_MEDIA_PLAY_PAUSE) { | 252 keyboardEvent->keyCode() == VKEY_MEDIA_PLAY_PAUSE) { |
| 251 // space or media key (play/pause) | 253 // space or media key (play/pause) |
| 252 video->togglePlayState(); | 254 video->togglePlayState(); |
| 253 event->setDefaultHandled(); | 255 event->setDefaultHandled(); |
| 254 } | 256 } |
| 255 } | 257 } |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace blink | 260 } // namespace blink |
| OLD | NEW |