Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, CableLabs Inc. All rights reserved. |
|
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
nit: This should use the Chromium header in the Bl
| |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * 3. Neither the name of Opera Software ASA nor the names of its | 12 * 3. Neither the name of Opera Software ASA nor the names of its |
| 13 * contributors may be used to endorse or promote products derived | 13 * contributors may be used to endorse or promote products derived |
| 14 * from this software without specific prior written permission. | 14 * from this software without specific prior written permission. |
| 15 * | 15 * |
| 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "CSSTestHelper.h" | 31 #include "core/html/track/DataCue.h" |
| 32 | |
| 33 #include "core/css/CSSRuleList.h" | |
| 34 #include "core/css/CSSStyleSheet.h" | |
| 35 #include "core/css/RuleSet.h" | |
| 36 #include "core/css/StyleSheetContents.h" | |
| 37 #include "core/dom/Document.h" | |
| 38 #include "wtf/text/WTFString.h" | |
| 39 | |
| 40 #include <gtest/gtest.h> | |
| 41 | 32 |
| 42 namespace WebCore { | 33 namespace WebCore { |
| 43 | 34 |
| 44 CSSTestHelper::~CSSTestHelper() | 35 DataCue::DataCue(ExecutionContext* context, double startTime, double endTime, Ar rayBuffer* data, ExceptionState& exceptionState) |
| 36 : TextTrackCue(startTime, endTime) | |
|
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
I'm surprised that there doesn't appear to be any
Brendan Long
2014/05/28 16:31:48
I don't see anything about that:
http://www.w3.or
philipj_slow
2014/06/02 07:50:52
Right, there is no such restriction. Negative time
| |
| 37 , m_executionContext(context) | |
|
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
DataCue should probably from ContextLifecycleObser
| |
| 38 { | |
| 39 ScriptWrappable::init(this); | |
| 40 setData(data, exceptionState); | |
| 41 } | |
| 42 | |
| 43 DataCue::~DataCue() | |
| 45 { | 44 { |
| 46 } | 45 } |
| 47 | 46 |
| 48 CSSTestHelper::CSSTestHelper() | 47 #ifndef NDEBUG |
| 48 String DataCue::toString() const | |
| 49 { | 49 { |
| 50 m_document = Document::create(); | 50 return String::format("%p id=%s interval=%f-->%f)", this, id().utf8().data() , startTime(), endTime()); |
| 51 TextPosition position; | 51 } |
| 52 m_styleSheet = CSSStyleSheet::createInline(m_document.get(), KURL(), positio n, "UTF-8"); | 52 #endif |
| 53 | |
| 54 PassRefPtr<ArrayBuffer> DataCue::data() const | |
| 55 { | |
| 56 ASSERT(m_data); | |
| 57 return ArrayBuffer::create(m_data.get()); | |
| 53 } | 58 } |
| 54 | 59 |
| 55 RuleSet& CSSTestHelper::ruleSet() | 60 void DataCue::setData(ArrayBuffer* data, ExceptionState& exceptionState) |
| 56 { | 61 { |
| 57 RuleSet& ruleSet = m_styleSheet->contents()->ensureRuleSet(MediaQueryEvaluat or(), RuleHasNoSpecialState); | 62 if (!data) |
| 58 ruleSet.compactRulesIfNeeded(); | 63 exceptionState.throwDOMException(InvalidNodeTypeError, "DataCue.data mus t be a non-null ArrayBuffer"); |
|
philipj_slow
2014/04/04 14:54:33
[StrictTypeChecking] in the IDL should take care o
Brendan Long
2014/04/04 15:07:22
I tried that and it still accepted null and string
fs
2014/04/04 17:10:35
Sounds like an issue with the bindings generator -
Brendan Long
2014/04/04 17:43:06
That looks like it would fix the null case. For st
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
Should this be exceptionState.throwTypeError() ins
| |
| 59 return ruleSet; | 64 else |
| 65 m_data = ArrayBuffer::create(data); | |
| 60 } | 66 } |
| 61 | 67 |
| 62 void CSSTestHelper::addCSSRules(const char* cssText) | 68 String DataCue::text(bool& isNull) const |
| 63 { | 69 { |
| 64 TextPosition position; | 70 isNull = true; |
| 65 unsigned sheetLength = m_styleSheet->length(); | 71 return String(); |
|
philipj_slow
2014/04/04 14:54:33
"The text attribute, on getting, must return UTF-1
Brendan Long
2014/04/04 15:07:22
My problem is, how do we identify the encoding? As
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
I agree with Philip here. It seems odd that we wou
Brendan Long
2014/05/28 16:31:48
There was some discussion about removing .text, bu
philipj_slow
2014/06/02 07:50:52
It's been removed now: https://github.com/w3c/html
| |
| 66 ASSERT_TRUE(m_styleSheet->contents()->parseStringAtPosition(cssText, positio n, true)); | 72 } |
| 67 ASSERT_TRUE(m_styleSheet->length() > sheetLength); | 73 |
| 74 ExecutionContext* DataCue::executionContext() const | |
| 75 { | |
| 76 return m_executionContext; | |
| 68 } | 77 } |
| 69 | 78 |
| 70 } // namespace WebCore | 79 } // namespace WebCore |
| OLD | NEW |