| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2010, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2010, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 else | 165 else |
| 166 first = false; | 166 first = false; |
| 167 text.append(m_queries[i]->cssText()); | 167 text.append(m_queries[i]->cssText()); |
| 168 } | 168 } |
| 169 return text.toString(); | 169 return text.toString(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 MediaList::MediaList(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet) | 172 MediaList::MediaList(MediaQuerySet* mediaQueries, CSSStyleSheet* parentSheet) |
| 173 : m_mediaQueries(mediaQueries) | 173 : m_mediaQueries(mediaQueries) |
| 174 , m_parentStyleSheet(parentSheet) | 174 , m_parentStyleSheet(parentSheet) |
| 175 , m_parentRule(nullptr) | |
| 176 { | 175 { |
| 177 } | 176 } |
| 178 | 177 |
| 179 MediaList::MediaList(MediaQuerySet* mediaQueries, CSSRule* parentRule) | |
| 180 : m_mediaQueries(mediaQueries) | |
| 181 , m_parentStyleSheet(nullptr) | |
| 182 , m_parentRule(parentRule) | |
| 183 { | |
| 184 } | |
| 185 | |
| 186 MediaList::~MediaList() | 178 MediaList::~MediaList() |
| 187 { | 179 { |
| 188 } | 180 } |
| 189 | 181 |
| 190 void MediaList::setMediaText(const String& value) | |
| 191 { | |
| 192 CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule); | |
| 193 | |
| 194 m_mediaQueries->set(value); | |
| 195 | |
| 196 if (m_parentStyleSheet) | |
| 197 m_parentStyleSheet->didMutate(); | |
| 198 } | |
| 199 | |
| 200 String MediaList::item(unsigned index) const | |
| 201 { | |
| 202 const Vector<OwnPtr<MediaQuery> >& queries = m_mediaQueries->queryVector(); | |
| 203 if (index < queries.size()) | |
| 204 return queries[index]->cssText(); | |
| 205 return String(); | |
| 206 } | |
| 207 | |
| 208 void MediaList::deleteMedium(const String& medium, ExceptionState& exceptionStat
e) | |
| 209 { | |
| 210 CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule); | |
| 211 | |
| 212 bool success = m_mediaQueries->remove(medium); | |
| 213 if (!success) { | |
| 214 exceptionState.throwDOMException(NotFoundError, "Failed to delete '" + m
edium + "'."); | |
| 215 return; | |
| 216 } | |
| 217 if (m_parentStyleSheet) | |
| 218 m_parentStyleSheet->didMutate(); | |
| 219 } | |
| 220 | |
| 221 void MediaList::appendMedium(const String& medium, ExceptionState& exceptionStat
e) | |
| 222 { | |
| 223 CSSStyleSheet::RuleMutationScope mutationScope(m_parentRule); | |
| 224 | |
| 225 bool success = m_mediaQueries->add(medium); | |
| 226 if (!success) { | |
| 227 exceptionState.throwDOMException(InvalidCharacterError, "The value provi
ded ('" + medium + "') is not a valid medium."); | |
| 228 return; | |
| 229 } | |
| 230 | |
| 231 if (m_parentStyleSheet) | |
| 232 m_parentStyleSheet->didMutate(); | |
| 233 } | |
| 234 | |
| 235 void MediaList::reattach(MediaQuerySet* mediaQueries) | |
| 236 { | |
| 237 ASSERT(mediaQueries); | |
| 238 m_mediaQueries = mediaQueries; | |
| 239 } | |
| 240 | |
| 241 static void addResolutionWarningMessageToConsole(Document* document, const Strin
g& serializedExpression, CSSPrimitiveValue::UnitType type) | 182 static void addResolutionWarningMessageToConsole(Document* document, const Strin
g& serializedExpression, CSSPrimitiveValue::UnitType type) |
| 242 { | 183 { |
| 243 ASSERT(document); | 184 ASSERT(document); |
| 244 | 185 |
| 245 DEFINE_STATIC_LOCAL(String, mediaQueryMessage, ("Consider using 'dppx' units
, as in CSS '%replacementUnits%' means dots-per-CSS-%lengthUnit%, not dots-per-p
hysical-%lengthUnit%, so does not correspond to the actual '%replacementUnits%'
of a screen. In media query expression: ")); | 186 DEFINE_STATIC_LOCAL(String, mediaQueryMessage, ("Consider using 'dppx' units
, as in CSS '%replacementUnits%' means dots-per-CSS-%lengthUnit%, not dots-per-p
hysical-%lengthUnit%, so does not correspond to the actual '%replacementUnits%'
of a screen. In media query expression: ")); |
| 246 DEFINE_STATIC_LOCAL(String, mediaValueDPI, ("dpi")); | 187 DEFINE_STATIC_LOCAL(String, mediaValueDPI, ("dpi")); |
| 247 DEFINE_STATIC_LOCAL(String, mediaValueDPCM, ("dpcm")); | 188 DEFINE_STATIC_LOCAL(String, mediaValueDPCM, ("dpcm")); |
| 248 DEFINE_STATIC_LOCAL(String, lengthUnitInch, ("inch")); | 189 DEFINE_STATIC_LOCAL(String, lengthUnitInch, ("inch")); |
| 249 DEFINE_STATIC_LOCAL(String, lengthUnitCentimeter, ("centimeter")); | 190 DEFINE_STATIC_LOCAL(String, lengthUnitCentimeter, ("centimeter")); |
| 250 | 191 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 240 } |
| 300 } | 241 } |
| 301 } | 242 } |
| 302 } | 243 } |
| 303 | 244 |
| 304 if (suspiciousType && !dotsPerPixelUsed) | 245 if (suspiciousType && !dotsPerPixelUsed) |
| 305 addResolutionWarningMessageToConsole(document, mediaQuerySet->mediaText(
), suspiciousType); | 246 addResolutionWarningMessageToConsole(document, mediaQuerySet->mediaText(
), suspiciousType); |
| 306 } | 247 } |
| 307 | 248 |
| 308 } | 249 } |
| OLD | NEW |