| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/html/HTMLMetaElement.h" | 24 #include "core/html/HTMLMetaElement.h" |
| 25 | 25 |
| 26 #include "HTMLNames.h" | 26 #include "HTMLNames.h" |
| 27 #include "core/dom/Document.h" | 27 #include "core/dom/Document.h" |
| 28 #include "core/page/Page.h" | |
| 29 #include "core/page/Settings.h" | 28 #include "core/page/Settings.h" |
| 30 | 29 |
| 31 namespace WebCore { | 30 namespace WebCore { |
| 32 | 31 |
| 33 #define DEFINE_ARRAY_FOR_MATCHING(name, source, maxMatchLength) \ | 32 #define DEFINE_ARRAY_FOR_MATCHING(name, source, maxMatchLength) \ |
| 34 const UChar* name; \ | 33 const UChar* name; \ |
| 35 const unsigned uMaxMatchLength = maxMatchLength; \ | 34 const unsigned uMaxMatchLength = maxMatchLength; \ |
| 36 UChar characterBuffer[uMaxMatchLength]; \ | 35 UChar characterBuffer[uMaxMatchLength]; \ |
| 37 if (!source.is8Bit()) { \ | 36 if (!source.is8Bit()) { \ |
| 38 name = source.characters16(); \ | 37 name = source.characters16(); \ |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 CASE("device-height") { | 188 CASE("device-height") { |
| 190 return Length(100, ViewportPercentageHeight); | 189 return Length(100, ViewportPercentageHeight); |
| 191 } | 190 } |
| 192 } | 191 } |
| 193 | 192 |
| 194 float value = parsePositiveNumber(keyString, valueString); | 193 float value = parsePositiveNumber(keyString, valueString); |
| 195 | 194 |
| 196 if (value < 0) | 195 if (value < 0) |
| 197 return Length(); // auto | 196 return Length(); // auto |
| 198 | 197 |
| 199 if (!value && document().page() && document().page()->settings().viewportMet
aZeroValuesQuirk()) { | 198 if (!value && document().settings() && document().settings()->viewportMetaZe
roValuesQuirk()) { |
| 200 if (keyString == "width") | 199 if (keyString == "width") |
| 201 return Length(100, ViewportPercentageWidth); | 200 return Length(100, ViewportPercentageWidth); |
| 202 if (keyString == "height") | 201 if (keyString == "height") |
| 203 return Length(100, ViewportPercentageHeight); | 202 return Length(100, ViewportPercentageHeight); |
| 204 } | 203 } |
| 205 | 204 |
| 206 return Length(clampLengthValue(value), Fixed); | 205 return Length(clampLengthValue(value), Fixed); |
| 207 } | 206 } |
| 208 | 207 |
| 209 float HTMLMetaElement::parseViewportValueAsZoom(const String& keyString, const S
tring& valueString) | 208 float HTMLMetaElement::parseViewportValueAsZoom(const String& keyString, const S
tring& valueString) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 232 } | 231 } |
| 233 | 232 |
| 234 float value = parsePositiveNumber(keyString, valueString); | 233 float value = parsePositiveNumber(keyString, valueString); |
| 235 | 234 |
| 236 if (value < 0) | 235 if (value < 0) |
| 237 return ViewportDescription::ValueAuto; | 236 return ViewportDescription::ValueAuto; |
| 238 | 237 |
| 239 if (value > 10.0) | 238 if (value > 10.0) |
| 240 reportViewportWarning(MaximumScaleTooLargeError, String(), String()); | 239 reportViewportWarning(MaximumScaleTooLargeError, String(), String()); |
| 241 | 240 |
| 242 if (!value && document().page() && document().page()->settings().viewportMet
aZeroValuesQuirk()) | 241 if (!value && document().settings() && document().settings()->viewportMetaZe
roValuesQuirk()) |
| 243 return ViewportDescription::ValueAuto; | 242 return ViewportDescription::ValueAuto; |
| 244 | 243 |
| 245 return clampScaleValue(value); | 244 return clampScaleValue(value); |
| 246 } | 245 } |
| 247 | 246 |
| 248 float HTMLMetaElement::parseViewportValueAsUserZoom(const String& keyString, con
st String& valueString) | 247 float HTMLMetaElement::parseViewportValueAsUserZoom(const String& keyString, con
st String& valueString) |
| 249 { | 248 { |
| 250 // yes and no are used as keywords. | 249 // yes and no are used as keywords. |
| 251 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to
yes. | 250 // Numbers >= 1, numbers <= -1, device-width and device-height are mapped to
yes. |
| 252 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. | 251 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 message.replace("%replacement2", replacement2); | 391 message.replace("%replacement2", replacement2); |
| 393 | 392 |
| 394 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 393 // FIXME: This message should be moved off the console once a solution to ht
tps://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 395 document().addConsoleMessage(RenderingMessageSource, viewportErrorMessageLev
el(errorCode), message); | 394 document().addConsoleMessage(RenderingMessageSource, viewportErrorMessageLev
el(errorCode), message); |
| 396 } | 395 } |
| 397 | 396 |
| 398 void HTMLMetaElement::processViewportContentAttribute(const String& content, Vie
wportDescription::Type origin) | 397 void HTMLMetaElement::processViewportContentAttribute(const String& content, Vie
wportDescription::Type origin) |
| 399 { | 398 { |
| 400 ASSERT(!content.isNull()); | 399 ASSERT(!content.isNull()); |
| 401 | 400 |
| 402 if (!document().page() || !document().shouldOverrideLegacyViewport(origin)) | 401 if (!document().settings() || !document().shouldOverrideLegacyViewport(origi
n)) |
| 403 return; | 402 return; |
| 404 | 403 |
| 405 ViewportDescription newDescriptionFromLegacyTag(origin); | 404 ViewportDescription newDescriptionFromLegacyTag(origin); |
| 406 parseContentAttribute(content, &HTMLMetaElement::processViewportKeyValuePair
, (void*)&newDescriptionFromLegacyTag); | 405 parseContentAttribute(content, &HTMLMetaElement::processViewportKeyValuePair
, (void*)&newDescriptionFromLegacyTag); |
| 407 | 406 |
| 408 if (newDescriptionFromLegacyTag.minZoom == ViewportDescription::ValueAuto) | 407 if (newDescriptionFromLegacyTag.minZoom == ViewportDescription::ValueAuto) |
| 409 newDescriptionFromLegacyTag.minZoom = 0.25; | 408 newDescriptionFromLegacyTag.minZoom = 0.25; |
| 410 | 409 |
| 411 if (newDescriptionFromLegacyTag.maxZoom == ViewportDescription::ValueAuto) { | 410 if (newDescriptionFromLegacyTag.maxZoom == ViewportDescription::ValueAuto) { |
| 412 newDescriptionFromLegacyTag.maxZoom = 5; | 411 newDescriptionFromLegacyTag.maxZoom = 5; |
| 413 newDescriptionFromLegacyTag.minZoom = std::min(newDescriptionFromLegacyT
ag.minZoom, float(5)); | 412 newDescriptionFromLegacyTag.minZoom = std::min(newDescriptionFromLegacyT
ag.minZoom, float(5)); |
| 414 } | 413 } |
| 415 | 414 |
| 416 const Settings& settings = document().page()->settings(); | 415 const Settings* settings = document().settings(); |
| 417 | 416 |
| 418 if (newDescriptionFromLegacyTag.maxWidth.isAuto()) { | 417 if (newDescriptionFromLegacyTag.maxWidth.isAuto()) { |
| 419 if (newDescriptionFromLegacyTag.zoom == ViewportDescription::ValueAuto)
{ | 418 if (newDescriptionFromLegacyTag.zoom == ViewportDescription::ValueAuto)
{ |
| 420 newDescriptionFromLegacyTag.minWidth = Length(ExtendToZoom); | 419 newDescriptionFromLegacyTag.minWidth = Length(ExtendToZoom); |
| 421 newDescriptionFromLegacyTag.maxWidth = Length(settings.layoutFallbac
kWidth(), Fixed); | 420 newDescriptionFromLegacyTag.maxWidth = Length(settings->layoutFallba
ckWidth(), Fixed); |
| 422 } else if (newDescriptionFromLegacyTag.maxHeight.isAuto()) { | 421 } else if (newDescriptionFromLegacyTag.maxHeight.isAuto()) { |
| 423 newDescriptionFromLegacyTag.minWidth = Length(ExtendToZoom); | 422 newDescriptionFromLegacyTag.minWidth = Length(ExtendToZoom); |
| 424 newDescriptionFromLegacyTag.maxWidth = Length(ExtendToZoom); | 423 newDescriptionFromLegacyTag.maxWidth = Length(ExtendToZoom); |
| 425 } | 424 } |
| 426 } | 425 } |
| 427 | 426 |
| 428 document().setViewportDescription(newDescriptionFromLegacyTag); | 427 document().setViewportDescription(newDescriptionFromLegacyTag); |
| 429 } | 428 } |
| 430 | 429 |
| 431 | 430 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 { | 487 { |
| 489 return getAttribute(http_equivAttr); | 488 return getAttribute(http_equivAttr); |
| 490 } | 489 } |
| 491 | 490 |
| 492 String HTMLMetaElement::name() const | 491 String HTMLMetaElement::name() const |
| 493 { | 492 { |
| 494 return getNameAttribute(); | 493 return getNameAttribute(); |
| 495 } | 494 } |
| 496 | 495 |
| 497 } | 496 } |
| OLD | NEW |