提交 f9e0a463 编写于 作者: O Ojan Vafai

Remove meta viewport and @viewport CSS rules.

We won't need configurations like this since we don't have things
like page zoom and a default width.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/654693004
上级 ac7ea65e
......@@ -38,7 +38,6 @@
#include "bindings/core/v8/V8CSSMediaRule.h"
#include "bindings/core/v8/V8CSSStyleRule.h"
#include "bindings/core/v8/V8CSSSupportsRule.h"
#include "bindings/core/v8/V8CSSViewportRule.h"
namespace blink {
......@@ -63,8 +62,6 @@ v8::Handle<v8::Object> wrap(CSSRule* impl, v8::Handle<v8::Object> creationContex
return wrap(toCSSKeyframesRule(impl), creationContext, isolate);
case CSSRule::SUPPORTS_RULE:
return wrap(toCSSSupportsRule(impl), creationContext, isolate);
case CSSRule::VIEWPORT_RULE:
return wrap(toCSSViewportRule(impl), creationContext, isolate);
case CSSRule::WEBKIT_FILTER_RULE:
return wrap(toCSSFilterRule(impl), creationContext, isolate);
}
......
......@@ -215,8 +215,6 @@ sky_core_files = [
"css/CSSValueList.cpp",
"css/CSSValuePool.cpp",
"css/CSSValuePool.h",
"css/CSSViewportRule.cpp",
"css/CSSViewportRule.h",
"css/DOMWindowCSS.cpp",
"css/DOMWindowCSS.h",
"css/DocumentFontFaceSet.cpp",
......@@ -346,8 +344,6 @@ sky_core_files = [
"css/resolver/StyleResourceLoader.h",
"css/resolver/TransformBuilder.cpp",
"css/resolver/TransformBuilder.h",
"css/resolver/ViewportStyleResolver.cpp",
"css/resolver/ViewportStyleResolver.h",
"dom/ActiveDOMObject.cpp",
"dom/Attr.cpp",
"dom/AttributeCollection.h",
......@@ -476,8 +472,6 @@ sky_core_files = [
"dom/TreeShared.h",
"dom/UserActionElementSet.cpp",
"dom/UserActionElementSet.h",
"dom/ViewportDescription.cpp",
"dom/ViewportDescription.h",
"dom/WeakNodeMap.cpp",
"dom/WeakNodeMap.h",
"dom/custom/CustomElement.cpp",
......@@ -1222,7 +1216,6 @@ core_idl_files = get_path_info([
"css/CSSUnknownRule.idl",
"css/CSSValue.idl",
"css/CSSValueList.idl",
"css/CSSViewportRule.idl",
"css/FontFace.idl",
"css/FontFaceSet.idl",
"css/FontFaceSetForEachCallback.idl",
......
......@@ -96,7 +96,6 @@ struct CSSRuleSourceData : public RefCountedWillBeGarbageCollected<CSSRuleSource
MEDIA_RULE = 3,
FONT_FACE_RULE = 4,
KEYFRAMES_RULE = 6,
VIEWPORT_RULE = 7,
SUPPORTS_RULE = 8,
FILTER_RULE = 9
};
......
......@@ -49,8 +49,6 @@ struct SameSizeAsCSSRule : public RefCountedWillBeGarbageCollectedFinalized<Same
COMPILE_ASSERT(sizeof(CSSRule) == sizeof(SameSizeAsCSSRule), CSSRule_should_stay_small);
COMPILE_ASSERT(StyleRuleBase::Viewport == static_cast<StyleRuleBase::Type>(CSSRule::VIEWPORT_RULE), enums_should_match);
void CSSRule::setCSSText(const String&)
{
notImplemented();
......
......@@ -46,7 +46,6 @@ public:
KEYFRAMES_RULE = 7,
KEYFRAME_RULE,
SUPPORTS_RULE = 12,
VIEWPORT_RULE = 15,
WEBKIT_FILTER_RULE = 17
};
......
......@@ -34,7 +34,6 @@
const unsigned short KEYFRAMES_RULE = 7;
const unsigned short KEYFRAME_RULE = 8;
const unsigned short SUPPORTS_RULE = 12;
[RuntimeEnabled=CSSViewport] const unsigned short VIEWPORT_RULE = 15;
const unsigned short WEBKIT_FILTER_RULE = 17;
readonly attribute unsigned short type;
......
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "core/css/CSSViewportRule.h"
#include "core/css/PropertySetCSSStyleDeclaration.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "wtf/text/StringBuilder.h"
namespace blink {
CSSViewportRule::CSSViewportRule(StyleRuleViewport* viewportRule, CSSStyleSheet* sheet)
: CSSRule(sheet)
, m_viewportRule(viewportRule)
{
}
CSSViewportRule::~CSSViewportRule()
{
#if !ENABLE(OILPAN)
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->clearParentRule();
#endif
}
CSSStyleDeclaration* CSSViewportRule::style() const
{
if (!m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_viewportRule->mutableProperties(), const_cast<CSSViewportRule*>(this));
return m_propertiesCSSOMWrapper.get();
}
String CSSViewportRule::cssText() const
{
StringBuilder result;
result.appendLiteral("@viewport { ");
String decls = m_viewportRule->properties().asText();
result.append(decls);
if (!decls.isEmpty())
result.append(' ');
result.append('}');
return result.toString();
}
void CSSViewportRule::reattach(StyleRuleBase* rule)
{
ASSERT(rule);
m_viewportRule = toStyleRuleViewport(rule);
if (m_propertiesCSSOMWrapper)
m_propertiesCSSOMWrapper->reattach(m_viewportRule->mutableProperties());
}
void CSSViewportRule::trace(Visitor* visitor)
{
visitor->trace(m_viewportRule);
visitor->trace(m_propertiesCSSOMWrapper);
CSSRule::trace(visitor);
}
} // namespace blink
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef CSSViewportRule_h
#define CSSViewportRule_h
#include "core/css/CSSRule.h"
#include "platform/heap/Handle.h"
namespace blink {
class CSSStyleDeclaration;
class StyleRuleViewport;
class StyleRuleCSSStyleDeclaration;
class CSSViewportRule final: public CSSRule {
public:
static PassRefPtrWillBeRawPtr<CSSViewportRule> create(StyleRuleViewport* viewportRule, CSSStyleSheet* sheet)
{
return adoptRefWillBeNoop(new CSSViewportRule(viewportRule, sheet));
}
virtual ~CSSViewportRule();
virtual CSSRule::Type type() const override { return VIEWPORT_RULE; }
virtual String cssText() const override;
virtual void reattach(StyleRuleBase*) override;
CSSStyleDeclaration* style() const;
virtual void trace(Visitor*) override;
private:
CSSViewportRule(StyleRuleViewport*, CSSStyleSheet*);
RefPtrWillBeMember<StyleRuleViewport> m_viewportRule;
mutable RefPtrWillBeMember<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
};
DEFINE_CSS_RULE_TYPE_CASTS(CSSViewportRule, VIEWPORT_RULE);
} // namespace blink
#endif // CSSViewportRule_h
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
interface CSSViewportRule : CSSRule {
readonly attribute CSSStyleDeclaration style;
};
......@@ -165,12 +165,6 @@ void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR
}
}
void RuleSet::addViewportRule(StyleRuleViewport* rule)
{
ensurePendingRules(); // So that m_viewportRules.shrinkToFit() gets called.
m_viewportRules.append(rule);
}
void RuleSet::addFontFaceRule(StyleRuleFontFace* rule)
{
ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called.
......@@ -202,8 +196,6 @@ void RuleSet::addChildRules(const WillBeHeapVector<RefPtrWillBeMember<StyleRuleB
addFontFaceRule(toStyleRuleFontFace(rule));
} else if (rule->isKeyframesRule()) {
addKeyframesRule(toStyleRuleKeyframes(rule));
} else if (rule->isViewportRule()) {
addViewportRule(toStyleRuleViewport(rule));
} else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) {
addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags);
}
......@@ -251,7 +243,6 @@ void RuleSet::compactRules()
compactPendingRules(pendingRules->tagRules, m_tagRules);
compactPendingRules(pendingRules->shadowPseudoElementRules, m_shadowPseudoElementRules);
m_universalRules.shrinkToFit();
m_viewportRules.shrinkToFit();
m_fontFaceRules.shrinkToFit();
m_keyframesRules.shrinkToFit();
}
......@@ -280,7 +271,6 @@ void RuleSet::trace(Visitor* visitor)
visitor->trace(m_shadowPseudoElementRules);
visitor->trace(m_universalRules);
visitor->trace(m_features);
visitor->trace(m_viewportRules);
visitor->trace(m_fontFaceRules);
visitor->trace(m_keyframesRules);
visitor->trace(m_viewportDependentMediaQueryResults);
......
......@@ -96,7 +96,6 @@ public:
const WillBeHeapTerminatedArray<RuleData>* tagRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_tagRules.get(key); }
const WillBeHeapTerminatedArray<RuleData>* shadowPseudoElementRules(const AtomicString& key) const { ASSERT(!m_pendingRules); return m_shadowPseudoElementRules.get(key); }
const WillBeHeapVector<RuleData>* universalRules() const { ASSERT(!m_pendingRules); return &m_universalRules; }
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport> >& viewportRules() const { ASSERT(!m_pendingRules); return m_viewportRules; }
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> >& fontFaceRules() const { return m_fontFaceRules; }
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> >& keyframesRules() const { return m_keyframesRules; }
const MediaQueryResultList& viewportDependentMediaQueryResults() const { return m_viewportDependentMediaQueryResults; }
......@@ -126,7 +125,6 @@ private:
}
void addToRuleSet(const AtomicString& key, PendingRuleMap&, const RuleData&);
void addViewportRule(StyleRuleViewport*);
void addFontFaceRule(StyleRuleFontFace*);
void addKeyframesRule(StyleRuleKeyframes*);
......@@ -164,7 +162,6 @@ private:
CompactRuleMap m_shadowPseudoElementRules;
WillBeHeapVector<RuleData> m_universalRules;
RuleFeatureSet m_features;
WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport> > m_viewportRules;
WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> > m_fontFaceRules;
WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > m_keyframesRules;
......
......@@ -28,7 +28,6 @@
#include "core/css/CSSMediaRule.h"
#include "core/css/CSSStyleRule.h"
#include "core/css/CSSSupportsRule.h"
#include "core/css/CSSViewportRule.h"
#include "core/css/StylePropertySet.h"
namespace blink {
......@@ -67,9 +66,6 @@ void StyleRuleBase::trace(Visitor* visitor)
case Keyframes:
toStyleRuleKeyframes(this)->traceAfterDispatch(visitor);
return;
case Viewport:
toStyleRuleViewport(this)->traceAfterDispatch(visitor);
return;
case Filter:
toStyleRuleFilter(this)->traceAfterDispatch(visitor);
return;
......@@ -99,9 +95,6 @@ void StyleRuleBase::finalizeGarbageCollectedObject()
case Keyframes:
toStyleRuleKeyframes(this)->~StyleRuleKeyframes();
return;
case Viewport:
toStyleRuleViewport(this)->~StyleRuleViewport();
return;
case Filter:
toStyleRuleFilter(this)->~StyleRuleFilter();
return;
......@@ -131,9 +124,6 @@ void StyleRuleBase::destroy()
case Keyframes:
delete toStyleRuleKeyframes(this);
return;
case Viewport:
delete toStyleRuleViewport(this);
return;
case Filter:
delete toStyleRuleFilter(this);
return;
......@@ -158,8 +148,6 @@ PassRefPtrWillBeRawPtr<StyleRuleBase> StyleRuleBase::copy() const
return toStyleRuleSupports(this)->copy();
case Keyframes:
return toStyleRuleKeyframes(this)->copy();
case Viewport:
return toStyleRuleViewport(this)->copy();
case Filter:
return toStyleRuleFilter(this)->copy();
case Unknown:
......@@ -191,9 +179,6 @@ PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet*
case Keyframes:
rule = CSSKeyframesRule::create(toStyleRuleKeyframes(self), parentSheet);
break;
case Viewport:
rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet);
break;
case Filter:
rule = CSSFilterRule::create(toStyleRuleFilter(self), parentSheet);
break;
......@@ -342,39 +327,6 @@ StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o)
{
}
StyleRuleViewport::StyleRuleViewport()
: StyleRuleBase(Viewport)
{
}
StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o)
: StyleRuleBase(o)
, m_properties(o.m_properties->mutableCopy())
{
}
StyleRuleViewport::~StyleRuleViewport()
{
}
MutableStylePropertySet& StyleRuleViewport::mutableProperties()
{
if (!m_properties->isMutable())
m_properties = m_properties->mutableCopy();
return *toMutableStylePropertySet(m_properties);
}
void StyleRuleViewport::setProperties(PassRefPtrWillBeRawPtr<StylePropertySet> properties)
{
m_properties = properties;
}
void StyleRuleViewport::traceAfterDispatch(Visitor* visitor)
{
visitor->trace(m_properties);
StyleRuleBase::traceAfterDispatch(visitor);
}
StyleRuleFilter::StyleRuleFilter(const String& filterName)
: StyleRuleBase(Filter)
, m_filterName(filterName)
......
......@@ -46,7 +46,6 @@ public:
Keyframes = 5,
Keyframe, // Not used. These are internally non-rule StyleKeyframe objects.
Supports = 12,
Viewport = 15,
Filter = 17
};
......@@ -57,7 +56,6 @@ public:
bool isMediaRule() const { return type() == Media; }
bool isStyleRule() const { return type() == Style; }
bool isSupportsRule() const { return type() == Supports; }
bool isViewportRule() const { return type() == Viewport; }
bool isFilterRule() const { return type() == Filter; }
PassRefPtrWillBeRawPtr<StyleRuleBase> copy() const;
......@@ -201,28 +199,6 @@ private:
bool m_conditionIsSupported;
};
class StyleRuleViewport : public StyleRuleBase {
public:
static PassRefPtrWillBeRawPtr<StyleRuleViewport> create() { return adoptRefWillBeNoop(new StyleRuleViewport); }
~StyleRuleViewport();
const StylePropertySet& properties() const { return *m_properties; }
MutableStylePropertySet& mutableProperties();
void setProperties(PassRefPtrWillBeRawPtr<StylePropertySet>);
PassRefPtrWillBeRawPtr<StyleRuleViewport> copy() const { return adoptRefWillBeNoop(new StyleRuleViewport(*this)); }
void traceAfterDispatch(Visitor*);
private:
StyleRuleViewport();
StyleRuleViewport(const StyleRuleViewport&);
RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null
};
class StyleRuleFilter : public StyleRuleBase {
public:
static PassRefPtrWillBeRawPtr<StyleRuleFilter> create(const String& filterName) { return adoptRefWillBeNoop(new StyleRuleFilter(filterName)); }
......@@ -255,7 +231,6 @@ DEFINE_TYPE_CASTS(StyleRule, StyleRuleBase, rule, rule->isStyleRule(), rule.isSt
DEFINE_STYLE_RULE_TYPE_CASTS(FontFace);
DEFINE_STYLE_RULE_TYPE_CASTS(Media);
DEFINE_STYLE_RULE_TYPE_CASTS(Supports);
DEFINE_STYLE_RULE_TYPE_CASTS(Viewport);
DEFINE_STYLE_RULE_TYPE_CASTS(Filter);
} // namespace blink
......
......@@ -235,7 +235,6 @@ static bool childRulesHaveFailedOrCanceledSubresources(const WillBeHeapVector<Re
case StyleRuleBase::Unknown:
case StyleRuleBase::Keyframe:
case StyleRuleBase::Supports:
case StyleRuleBase::Viewport:
case StyleRuleBase::Filter:
break;
}
......
......@@ -83,7 +83,6 @@ static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule)
case StyleRule::Media: // If the media rule doesn't apply, we could avoid recalc.
case StyleRule::FontFace: // If the fonts aren't in use, we could avoid recalc.
case StyleRule::Supports: // If we evaluated the supports-clause we could avoid recalc.
case StyleRule::Viewport: // If the viewport doesn't match, we could avoid recalcing.
// FIXME: Unclear if any of the rest need to cause style recalc:
case StyleRule::Filter:
return true;
......
......@@ -899,10 +899,7 @@ bool BisonCSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropert
m_id = propertyID;
m_important = important;
{
StyleDeclarationScope scope(this, declaration);
cssyyparse(this);
}
cssyyparse(this);
m_rule = nullptr;
m_id = CSSPropertyInvalid;
......@@ -1020,10 +1017,7 @@ bool BisonCSSParser::parseDeclaration(MutableStylePropertySet* declaration, cons
m_observer->startRuleBody(0);
}
{
StyleDeclarationScope scope(this, declaration);
cssyyparse(this);
}
cssyyparse(this);
m_rule = nullptr;
......@@ -1881,23 +1875,4 @@ void BisonCSSParser::startEndUnknownRule()
m_observer->startEndUnknownRule();
}
StyleRuleBase* BisonCSSParser::createViewportRule()
{
// Allow @viewport rules from UA stylesheets even if the feature is disabled.
if (!RuntimeEnabledFeatures::cssViewportEnabled() && !isUASheetBehavior(m_context.mode()))
return 0;
m_allowImportRules = m_allowNamespaceDeclarations = false;
RefPtrWillBeRawPtr<StyleRuleViewport> rule = StyleRuleViewport::create();
rule->setProperties(createStylePropertySet());
clearProperties();
StyleRuleViewport* result = rule.get();
m_parsedRules.append(rule.release());
return result;
}
}
......@@ -213,38 +213,9 @@ public:
void tokenToLowerCase(CSSParserString& token);
void markViewportRuleBodyStart() { m_inViewport = true; }
void markViewportRuleBodyEnd() { m_inViewport = false; }
StyleRuleBase* createViewportRule();
CSSParserLocation currentLocation() { return m_tokenizer.currentLocation(); }
private:
class StyleDeclarationScope {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(StyleDeclarationScope);
public:
StyleDeclarationScope(BisonCSSParser* parser, const StylePropertySet* declaration)
: m_parser(parser)
, m_mode(declaration->cssParserMode())
{
if (isCSSViewportParsingEnabledForMode(m_mode)) {
ASSERT(!m_parser->inViewport());
m_parser->markViewportRuleBodyStart();
}
}
~StyleDeclarationScope()
{
if (isCSSViewportParsingEnabledForMode(m_mode))
m_parser->markViewportRuleBodyEnd();
}
private:
BisonCSSParser* m_parser;
CSSParserMode m_mode;
};
inline void ensureLineEndings();
void setStyleSheet(StyleSheetContents* styleSheet) { m_styleSheet = styleSheet; }
......
......@@ -177,7 +177,6 @@ inline static CSSParserValue makeIdentValue(CSSParserString string)
%token SUPPORTS_SYM
%token FONT_FACE_SYM
%token CHARSET_SYM
%token VIEWPORT_RULE_SYM
%token INTERNAL_DECLS_SYM
%token INTERNAL_MEDIALIST_SYM
%token INTERNAL_RULE_SYM
......@@ -252,7 +251,6 @@ inline static CSSParserValue makeIdentValue(CSSParserString string)
%type <rule> block_rule
%type <rule> block_valid_rule
%type <rule> supports
%type <rule> viewport
%type <boolean> keyframes_rule_start
%type <string> ident_or_string
......@@ -453,7 +451,6 @@ valid_rule:
| font_face
| keyframes
| supports
| viewport
;
before_rule:
......@@ -498,7 +495,6 @@ block_valid_rule:
| media
| keyframes
| supports
| viewport
;
block_rule:
......@@ -832,21 +828,6 @@ font_face:
}
;
before_viewport_rule:
/* empty */ {
parser->markViewportRuleBodyStart();
parser->startRuleHeader(CSSRuleSourceData::VIEWPORT_RULE);
}
;
viewport:
before_viewport_rule VIEWPORT_RULE_SYM at_rule_header_end_maybe_space
'{' at_rule_body_start maybe_space_before_declaration declaration_list closing_brace {
$$ = parser->createViewportRule();
parser->markViewportRuleBodyEnd();
}
;
maybe_unary_operator:
unary_operator
| /* empty */ { $$ = 1; }
......@@ -1444,9 +1425,6 @@ regular_invalid_at_rule_header:
parser->reportError($4, InvalidSupportsConditionCSSError);
parser->popSupportsRuleData();
}
| before_viewport_rule VIEWPORT_RULE_SYM at_rule_header_recovery {
parser->markViewportRuleBodyEnd();
}
| error_location invalid_at at_rule_header_recovery {
parser->resumeErrorLogging();
parser->reportError($1, InvalidRuleCSSError);
......
......@@ -916,9 +916,6 @@ inline void CSSTokenizer::detectAtToken(int length, bool hasEscape)
m_parsingMode = SupportsMode;
m_token = SUPPORTS_SYM;
}
CASE("viewport") {
m_token = VIEWPORT_RULE_SYM;
}
CASE("-internal-rule") {
if (LIKELY(!hasEscape && m_internal))
m_token = INTERNAL_RULE_SYM;
......
......@@ -32,7 +32,6 @@
#include "core/css/StyleRule.h"
#include "core/css/StyleSheetContents.h"
#include "core/css/resolver/StyleResolver.h" // For MatchRequest.
#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/ShadowRoot.h"
......@@ -133,14 +132,6 @@ void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle
}
}
void ScopedStyleResolver::collectViewportRulesTo(StyleResolver* resolver) const
{
if (!m_scope->rootNode().isDocumentNode())
return;
for (size_t i = 0; i < m_authorStyleSheets.size(); ++i)
resolver->viewportStyleResolver()->collectViewportRules(&m_authorStyleSheets[i]->contents()->ruleSet(), ViewportStyleResolver::AuthorOrigin);
}
void ScopedStyleResolver::trace(Visitor* visitor)
{
#if ENABLE(OILPAN)
......
......@@ -64,7 +64,6 @@ public:
void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, StyleResolver*);
void collectFeaturesTo(RuleFeatureSet&, HashSet<const StyleSheetContents*>& visitedSharedStyleSheetContents) const;
void resetAuthorStyle();
void collectViewportRulesTo(StyleResolver*) const;
void trace(Visitor*);
......
......@@ -62,7 +62,6 @@
#include "core/css/resolver/StyleAdjuster.h"
#include "core/css/resolver/StyleResolverState.h"
#include "core/css/resolver/StyleResolverStats.h"
#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/StyleEngine.h"
#include "core/dom/Text.h"
......@@ -102,7 +101,6 @@ static void addFontFaceRule(Document* document, CSSFontSelector* cssFontSelector
StyleResolver::StyleResolver(Document& document)
: m_document(document)
, m_viewportStyleResolver(ViewportStyleResolver::create(&document))
, m_needCollectFeatures(false)
, m_printMediaType(false)
, m_styleResourceLoader(document.fetcher())
......@@ -171,8 +169,6 @@ void StyleResolver::finishAppendAuthorStyleSheets()
if (document().renderView() && document().renderView()->style())
document().renderView()->style()->font().update(document().styleEngine()->fontSelector());
collectViewportRules();
}
void StyleResolver::resetRuleFeatures()
......@@ -572,18 +568,6 @@ PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
return CSSAnimatableValueFactory::create(property, *state.style());
}
void StyleResolver::collectViewportRules()
{
CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance();
viewportStyleResolver()->collectViewportRules(defaultStyleSheets.defaultStyle(), ViewportStyleResolver::UserAgentOrigin);
viewportStyleResolver()->collectViewportRules(defaultStyleSheets.defaultViewportStyle(), ViewportStyleResolver::UserAgentOrigin);
if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
scopedResolver->collectViewportRulesTo(this);
viewportStyleResolver()->resolve();
}
PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
{
StyleResolverState state(document(), 0);
......@@ -872,7 +856,6 @@ void StyleResolver::invalidateMatchedPropertiesCache()
void StyleResolver::notifyResizeForViewportUnits()
{
collectViewportRules();
m_matchedPropertiesCache.clearViewportDependent();
}
......@@ -1028,7 +1011,6 @@ void StyleResolver::trace(Visitor* visitor)
visitor->trace(m_keyframesRuleMap);
visitor->trace(m_matchedPropertiesCache);
visitor->trace(m_viewportDependentMediaQueryResults);
visitor->trace(m_viewportStyleResolver);
visitor->trace(m_features);
visitor->trace(m_attributeRuleSet);
visitor->trace(m_styleSharingLists);
......
......@@ -63,7 +63,6 @@ class StylePropertySet;
class StyleResolverStats;
class StyleRule;
class StyleRuleKeyframes;
class ViewportStyleResolver;
class MatchResult;
......@@ -146,8 +145,6 @@ public:
// |properties| is an array with |count| elements.
void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, RenderStyle*);
ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResolver.get(); }
void addMediaQueryResults(const MediaQueryResultList&);
MediaQueryResultList* viewportDependentMediaQueryResults() { return &m_viewportDependentMediaQueryResults; }
bool hasViewportDependentMediaQueries() const { return !m_viewportDependentMediaQueryResults.isEmpty(); }
......@@ -236,8 +233,6 @@ private:
template <StyleResolver::StyleApplicationPass pass>
void applyAllProperty(StyleResolverState&, CSSValue*);
void collectViewportRules();
// FIXME: This likely belongs on RuleSet.
typedef WillBeHeapHashMap<StringImpl*, RefPtrWillBeMember<StyleRuleKeyframes> > KeyframesRuleMap;
KeyframesRuleMap m_keyframesRuleMap;
......@@ -251,8 +246,6 @@ private:
RawPtrWillBeMember<Document> m_document;
OwnPtrWillBeMember<ViewportStyleResolver> m_viewportStyleResolver;
WillBeHeapListHashSet<RawPtrWillBeMember<CSSStyleSheet>, 16> m_pendingStyleSheets;
// FIXME: The entire logic of collecting features on StyleResolver, as well as transferring them
......
/*
* Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/CSSValueKeywords.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/CSSToLengthConversionData.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
#include "core/dom/Document.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/ViewportDescription.h"
#include "core/frame/FrameView.h"
namespace blink {
DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver);
ViewportStyleResolver::ViewportStyleResolver(Document* document)
: m_document(document)
, m_hasAuthorStyle(false)
{
ASSERT(m_document);
}
void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin)
{
rules->compactRulesIfNeeded();
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport> >& viewportRules = rules->viewportRules();
for (size_t i = 0; i < viewportRules.size(); ++i)
addViewportRule(viewportRules[i], origin);
}
void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Origin origin)
{
StylePropertySet& propertySet = viewportRule->mutableProperties();
unsigned propertyCount = propertySet.propertyCount();
if (!propertyCount)
return;
if (origin == AuthorOrigin)
m_hasAuthorStyle = true;
if (!m_propertySet) {
m_propertySet = propertySet.mutableCopy();
return;
}
// We cannot use mergeAndOverrideOnConflict() here because it doesn't
// respect the !important declaration (but addParsedProperty() does).
for (unsigned i = 0; i < propertyCount; ++i)
m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty());
}
void ViewportStyleResolver::resolve()
{
if (!m_document)
return;
if (!m_propertySet) {
m_document->setViewportDescription(ViewportDescription(ViewportDescription::UserAgentStyleSheet));
return;
}
ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::AuthorStyleSheet : ViewportDescription::UserAgentStyleSheet);
description.userZoom = viewportArgumentValue(CSSPropertyUserZoom);
description.zoom = viewportArgumentValue(CSSPropertyZoom);
description.minZoom = viewportArgumentValue(CSSPropertyMinZoom);
description.maxZoom = viewportArgumentValue(CSSPropertyMaxZoom);
description.minWidth = viewportLengthValue(CSSPropertyMinWidth);
description.maxWidth = viewportLengthValue(CSSPropertyMaxWidth);
description.minHeight = viewportLengthValue(CSSPropertyMinHeight);
description.maxHeight = viewportLengthValue(CSSPropertyMaxHeight);
description.orientation = viewportArgumentValue(CSSPropertyOrientation);
m_document->setViewportDescription(description);
m_propertySet = nullptr;
m_hasAuthorStyle = false;
}
float ViewportStyleResolver::viewportArgumentValue(CSSPropertyID id) const
{
float defaultValue = ViewportDescription::ValueAuto;
// UserZoom default value is CSSValueZoom, which maps to true, meaning that
// yes, it is user scalable. When the value is set to CSSValueFixed, we
// return false.
if (id == CSSPropertyUserZoom)
defaultValue = 1;
RefPtrWillBeRawPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id);
if (!value || !value->isPrimitiveValue())
return defaultValue;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
if (primitiveValue->isNumber() || primitiveValue->isPx())
return primitiveValue->getFloatValue();
if (primitiveValue->isFontRelativeLength())
return primitiveValue->getFloatValue() * m_document->renderStyle()->fontDescription().computedSize();
if (primitiveValue->isPercentage()) {
float percentValue = primitiveValue->getFloatValue() / 100.0f;
switch (id) {
case CSSPropertyMaxZoom:
case CSSPropertyMinZoom:
case CSSPropertyZoom:
return percentValue;
default:
ASSERT_NOT_REACHED();
break;
}
}
switch (primitiveValue->getValueID()) {
case CSSValueAuto:
return defaultValue;
case CSSValueLandscape:
return ViewportDescription::ValueLandscape;
case CSSValuePortrait:
return ViewportDescription::ValuePortrait;
case CSSValueZoom:
return defaultValue;
case CSSValueInternalExtendToZoom:
return ViewportDescription::ValueExtendToZoom;
case CSSValueFixed:
return 0;
default:
return defaultValue;
}
}
Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const
{
ASSERT(id == CSSPropertyMaxHeight
|| id == CSSPropertyMinHeight
|| id == CSSPropertyMaxWidth
|| id == CSSPropertyMinWidth);
RefPtrWillBeRawPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id);
if (!value || !value->isPrimitiveValue())
return Length(); // auto
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
if (primitiveValue->getValueID() == CSSValueInternalExtendToZoom)
return Length(ExtendToZoom);
RenderStyle* documentStyle = m_document->renderStyle();
// If we have viewport units the conversion will mark the document style as having viewport units.
bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits();
documentStyle->setHasViewportUnits(false);
FrameView* view = m_document->view();
float width = view ? view->width() : 0;
float height = view ? view->height() : 0;
Length result = primitiveValue->convertToLength<AnyConversion>(CSSToLengthConversionData(documentStyle, documentStyle, width, height, 1.0f));
if (documentStyle->hasViewportUnits())
m_document->setHasViewportUnits();
documentStyle->setHasViewportUnits(documentStyleHasViewportUnits);
return result;
}
void ViewportStyleResolver::trace(Visitor* visitor)
{
visitor->trace(m_propertySet);
visitor->trace(m_document);
}
} // namespace blink
/*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef ViewportStyleResolver_h
#define ViewportStyleResolver_h
#include "core/CSSPropertyNames.h"
#include "core/css/RuleSet.h"
#include "platform/Length.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
namespace blink {
class Document;
class MutableStylePropertySet;
class StyleRuleViewport;
class ViewportStyleResolver : public NoBaseWillBeGarbageCollected<ViewportStyleResolver> {
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver);
public:
static PassOwnPtrWillBeRawPtr<ViewportStyleResolver> create(Document* document)
{
return adoptPtrWillBeNoop(new ViewportStyleResolver(document));
}
enum Origin { UserAgentOrigin, AuthorOrigin };
void collectViewportRules(RuleSet*, Origin);
void resolve();
void trace(Visitor*);
private:
explicit ViewportStyleResolver(Document*);
void addViewportRule(StyleRuleViewport*, Origin);
float viewportArgumentValue(CSSPropertyID) const;
Length viewportLengthValue(CSSPropertyID) const;
RawPtrWillBeMember<Document> m_document;
RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
bool m_hasAuthorStyle;
};
} // namespace blink
#endif // ViewportStyleResolver_h
......@@ -1774,42 +1774,6 @@ void Document::maybeHandleHttpRefresh(const String& content, HttpRefreshType htt
// FIXME(sky): remove
}
void Document::setViewportDescription(const ViewportDescription& viewportDescription)
{
// The UA-defined min-width is used by the processing of legacy meta tags.
if (!viewportDescription.isSpecifiedByAuthor())
m_viewportDefaultMinWidth = viewportDescription.minWidth;
if (viewportDescription.isLegacyViewportType()) {
if (settings() && !settings()->viewportMetaEnabled())
return;
m_legacyViewportDescription = viewportDescription;
// When no author style for @viewport is present, and a meta tag for defining
// the viewport is, apply the meta tag viewport instead of the UA styles.
if (m_viewportDescription.type == ViewportDescription::AuthorStyleSheet)
return;
m_viewportDescription = viewportDescription;
} else {
// If the legacy viewport tag has higher priority than the cascaded @viewport
// descriptors, use the values from the legacy tag.
if (!shouldOverrideLegacyDescription(viewportDescription.type))
m_viewportDescription = m_legacyViewportDescription;
else
m_viewportDescription = viewportDescription;
}
updateViewportDescription();
}
void Document::updateViewportDescription()
{
if (frame()) {
frameHost()->chrome().dispatchViewportPropertiesDidChange(m_viewportDescription);
}
}
void Document::processReferrerPolicy(const String& policy)
{
ASSERT(!policy.isNull());
......
......@@ -41,7 +41,6 @@
#include "core/dom/TextLinkColors.h"
#include "core/dom/TreeScope.h"
#include "core/dom/UserActionElementSet.h"
#include "core/dom/ViewportDescription.h"
#include "core/dom/custom/CustomElement.h"
#include "core/fetch/ResourceClient.h"
#include "core/loader/DocumentLoadTiming.h"
......@@ -203,9 +202,6 @@ public:
// DOM methods & attributes for Document
bool shouldOverrideLegacyDescription(ViewportDescription::Type);
void setViewportDescription(const ViewportDescription&);
const ViewportDescription& viewportDescription() const { return m_viewportDescription; }
Length viewportDefaultMinWidth() const { return m_viewportDefaultMinWidth; }
void setReferrerPolicy(ReferrerPolicy);
......@@ -467,7 +463,6 @@ public:
* @param inDocumentHeadElement Is the element in the document's <head> element?
*/
void processHttpEquiv(const AtomicString& equiv, const AtomicString& content, bool inDocumentHeadElement);
void updateViewportDescription();
void processReferrerPolicy(const String& policy);
String title() const { return m_title; }
......@@ -848,8 +843,6 @@ private:
int m_loadEventDelayCount;
Timer<Document> m_loadEventDelayTimer;
ViewportDescription m_viewportDescription;
ViewportDescription m_legacyViewportDescription;
Length m_viewportDefaultMinWidth;
bool m_didSetReferrerPolicy;
......@@ -892,14 +885,6 @@ private:
mutable DocumentLoadTiming m_documentLoadTiming;
};
inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin)
{
// The different (legacy) meta tags have different priorities based on the type
// regardless of which order they appear in the DOM. The priority is given by the
// ViewportDescription::Type enum.
return origin >= m_legacyViewportDescription.type;
}
inline void Document::scheduleRenderTreeUpdateIfNeeded()
{
// Inline early out to avoid the function calls below.
......
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include "core/dom/ViewportDescription.h"
#include "core/dom/Document.h"
#include "core/frame/FrameHost.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/Platform.h"
namespace blink {
float ViewportDescription::resolveViewportLength(const Length& length, const FloatSize& initialViewportSize, Direction direction)
{
if (length.isAuto())
return ViewportDescription::ValueAuto;
if (length.isFixed())
return length.getFloatValue();
if (length.type() == ExtendToZoom)
return ViewportDescription::ValueExtendToZoom;
if (length.type() == Percent && direction == Horizontal)
return initialViewportSize.width() * length.getFloatValue() / 100.0f;
if (length.type() == Percent && direction == Vertical)
return initialViewportSize.height() * length.getFloatValue() / 100.0f;
if (length.type() == DeviceWidth)
return initialViewportSize.width();
if (length.type() == DeviceHeight)
return initialViewportSize.height();
ASSERT_NOT_REACHED();
return ViewportDescription::ValueAuto;
}
void ViewportDescription::reportMobilePageStats(const LocalFrame* mainFrame) const
{
#if OS(ANDROID)
enum ViewportUMAType {
NoViewportTag,
DeviceWidth,
ConstantWidth,
MetaWidthOther,
MetaHandheldFriendly,
MetaMobileOptimized,
XhtmlMobileProfile,
TypeCount
};
if (!mainFrame || !mainFrame->host() || !mainFrame->view() || !mainFrame->document())
return;
// Avoid chrome:// pages like the new-tab page (on Android new tab is non-http).
if (!mainFrame->document()->url().protocolIsInHTTPFamily())
return;
if (!isSpecifiedByAuthor()) {
Platform::current()->histogramEnumeration("Viewport.MetaTagType", NoViewportTag, TypeCount);
return;
}
if (isMetaViewportType()) {
if (maxWidth.type() == blink::Fixed) {
Platform::current()->histogramEnumeration("Viewport.MetaTagType", ConstantWidth, TypeCount);
if (mainFrame->view()) {
// To get an idea of how "far" the viewport is from the device's ideal width, we
// report the zoom level that we'd need to be at for the entire page to be visible.
int viewportWidth = maxWidth.intValue();
int windowWidth = mainFrame->view()->frameRect().width();
int overviewZoomPercent = 100 * windowWidth / static_cast<float>(viewportWidth);
Platform::current()->histogramSparse("Viewport.OverviewZoom", overviewZoomPercent);
}
} else if (maxWidth.type() == blink::DeviceWidth || maxWidth.type() == blink::ExtendToZoom) {
Platform::current()->histogramEnumeration("Viewport.MetaTagType", DeviceWidth, TypeCount);
} else {
// Overflow bucket for cases we may be unaware of.
Platform::current()->histogramEnumeration("Viewport.MetaTagType", MetaWidthOther, TypeCount);
}
} else if (type == ViewportDescription::HandheldFriendlyMeta) {
Platform::current()->histogramEnumeration("Viewport.MetaTagType", MetaHandheldFriendly, TypeCount);
} else if (type == ViewportDescription::MobileOptimizedMeta) {
Platform::current()->histogramEnumeration("Viewport.MetaTagType", MobileOptimizedMeta, TypeCount);
}
#endif
}
} // namespace blink
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef ViewportDescription_h
#define ViewportDescription_h
#include "platform/Length.h"
#include "platform/geometry/FloatSize.h"
namespace blink {
class LocalFrame;
struct ViewportDescription {
enum Type {
// These are ordered in increasing importance.
UserAgentStyleSheet,
HandheldFriendlyMeta,
MobileOptimizedMeta,
ViewportMeta,
AuthorStyleSheet
} type;
enum {
ValueAuto = -1,
ValueDeviceWidth = -2,
ValueDeviceHeight = -3,
ValuePortrait = -4,
ValueLandscape = -5,
ValueDeviceDPI = -6,
ValueLowDPI = -7,
ValueMediumDPI = -8,
ValueHighDPI = -9,
ValueExtendToZoom = -10
};
ViewportDescription(Type type = UserAgentStyleSheet)
: type(type)
, zoom(ValueAuto)
, minZoom(ValueAuto)
, maxZoom(ValueAuto)
, userZoom(true)
, orientation(ValueAuto)
, deprecatedTargetDensityDPI(ValueAuto)
, zoomIsExplicit(false)
, minZoomIsExplicit(false)
, maxZoomIsExplicit(false)
, userZoomIsExplicit(false)
{
}
Length minWidth;
Length maxWidth;
Length minHeight;
Length maxHeight;
float zoom;
float minZoom;
float maxZoom;
bool userZoom;
float orientation;
float deprecatedTargetDensityDPI; // Only used for Android WebView
// Whether the computed value was explicitly specified rather than being
// inferred.
bool zoomIsExplicit;
bool minZoomIsExplicit;
bool maxZoomIsExplicit;
bool userZoomIsExplicit;
bool operator==(const ViewportDescription& other) const
{
// Used for figuring out whether to reset the viewport or not,
// thus we are not taking type into account.
return minWidth == other.minWidth
&& maxWidth == other.maxWidth
&& minHeight == other.minHeight
&& maxHeight == other.maxHeight
&& zoom == other.zoom
&& minZoom == other.minZoom
&& maxZoom == other.maxZoom
&& userZoom == other.userZoom
&& orientation == other.orientation
&& deprecatedTargetDensityDPI == other.deprecatedTargetDensityDPI
&& zoomIsExplicit == other.zoomIsExplicit
&& minZoomIsExplicit == other.minZoomIsExplicit
&& maxZoomIsExplicit == other.maxZoomIsExplicit
&& userZoomIsExplicit == other.userZoomIsExplicit;
}
bool operator!=(const ViewportDescription& other) const
{
return !(*this == other);
}
bool isLegacyViewportType() const { return type >= HandheldFriendlyMeta && type <= ViewportMeta; }
bool isMetaViewportType() const { return type == ViewportMeta; }
bool isSpecifiedByAuthor() const { return type != UserAgentStyleSheet; }
// Reports UMA stat on whether the page is considered mobile or desktop and what kind of
// mobile it is. Applies only to Android, must only be called once per page load.
void reportMobilePageStats(const LocalFrame*) const;
private:
enum Direction { Horizontal, Vertical };
static float resolveViewportLength(const Length&, const FloatSize& initialViewportSize, Direction);
};
} // namespace blink
#endif // ViewportDescription_h
......@@ -240,7 +240,6 @@ PassRefPtrWillBeRawPtr<Document> LocalDOMWindow::installNewDocument(const Docume
m_document->attach();
m_frame->script().updateDocument();
m_document->updateViewportDescription();
return m_document;
}
......
......@@ -109,7 +109,7 @@ selectionIncludesAltImageText initial=false
# Used by the android_webview to support a horizontal height auto-sizing
# mode.
forceZeroLayoutHeight initial=false, invalidate=ViewportDescription
forceZeroLayoutHeight initial=false
# Touch based text selection and editing on desktop.
# crbug.com/304873 tracks removal once it's been enabled on all platforms.
......@@ -120,8 +120,8 @@ useSolidColorScrollbars initial=true
mainFrameClipsContent initial=true
# Presumably used by tests? Unclear.
useWideViewport initial=true, invalidate=ViewportDescription
loadWithOverviewMode initial=true, invalidate=ViewportDescription
useWideViewport initial=true
loadWithOverviewMode initial=true
# Only set by Layout Tests.
mediaTypeOverride type=String, initial="screen", invalidate=MediaType
......@@ -131,9 +131,6 @@ mediaTypeOverride type=String, initial="screen", invalidate=MediaType
loadsImagesAutomatically initial=false, invalidate=ImageLoading
imagesEnabled initial=true, invalidate=ImageLoading
viewportEnabled initial=false, invalidate=ViewportDescription
viewportMetaEnabled initial=false
# V8 supports different types of caching. Used by V8 bindings.
v8CacheOptions type=V8CacheOptions, initial=V8CacheOptionsOff
......
......@@ -50,7 +50,6 @@ public:
// functions to make generating Settings.in slightly easier.
enum ChangeType {
StyleChange,
ViewportDescriptionChange,
MediaTypeChange,
MultisamplingChange,
ImageLoadingChange,
......
......@@ -34,20 +34,6 @@
namespace blink {
#define DEFINE_ARRAY_FOR_MATCHING(name, source, maxMatchLength) \
const UChar* name; \
const unsigned uMaxMatchLength = maxMatchLength; \
UChar characterBuffer[uMaxMatchLength]; \
if (!source.is8Bit()) { \
name = source.characters16(); \
} else { \
unsigned bufferLength = std::min(uMaxMatchLength, source.length()); \
const LChar* characters8 = source.characters8(); \
for (unsigned i = 0; i < bufferLength; ++i) \
characterBuffer[i] = characters8[i]; \
name = characterBuffer; \
}
inline HTMLMetaElement::HTMLMetaElement(Document& document)
: HTMLElement(HTMLNames::metaTag, document)
{
......@@ -56,365 +42,6 @@ inline HTMLMetaElement::HTMLMetaElement(Document& document)
DEFINE_NODE_FACTORY(HTMLMetaElement)
static bool isInvalidSeparator(UChar c)
{
return c == ';';
}
// Though isspace() considers \t and \v to be whitespace, Win IE doesn't.
static bool isSeparator(UChar c)
{
return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
}
void HTMLMetaElement::parseContentAttribute(const String& content, KeyValuePairCallback callback, void* data)
{
bool error = false;
// Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
unsigned keyBegin, keyEnd;
unsigned valueBegin, valueEnd;
String buffer = content.lower();
unsigned length = buffer.length();
for (unsigned i = 0; i < length; /* no increment here */) {
// skip to first non-separator, but don't skip past the end of the string
while (isSeparator(buffer[i])) {
if (i >= length)
break;
i++;
}
keyBegin = i;
// skip to first separator
while (!isSeparator(buffer[i])) {
error |= isInvalidSeparator(buffer[i]);
if (i >= length)
break;
i++;
}
keyEnd = i;
// skip to first '=', but don't skip past a ',' or the end of the string
while (buffer[i] != '=') {
error |= isInvalidSeparator(buffer[i]);
if (buffer[i] == ',' || i >= length)
break;
i++;
}
// skip to first non-separator, but don't skip past a ',' or the end of the string
while (isSeparator(buffer[i])) {
if (buffer[i] == ',' || i >= length)
break;
i++;
}
valueBegin = i;
// skip to first separator
while (!isSeparator(buffer[i])) {
error |= isInvalidSeparator(buffer[i]);
if (i >= length)
break;
i++;
}
valueEnd = i;
ASSERT_WITH_SECURITY_IMPLICATION(i <= length);
String keyString = buffer.substring(keyBegin, keyEnd - keyBegin);
String valueString = buffer.substring(valueBegin, valueEnd - valueBegin);
(this->*callback)(keyString, valueString, data);
}
if (error) {
String message = "Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead.";
document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, WarningMessageLevel, message));
}
}
static inline float clampLengthValue(float value)
{
// Limits as defined in the css-device-adapt spec.
if (value != ViewportDescription::ValueAuto)
return std::min(float(10000), std::max(value, float(1)));
return value;
}
static inline float clampScaleValue(float value)
{
// Limits as defined in the css-device-adapt spec.
if (value != ViewportDescription::ValueAuto)
return std::min(float(10), std::max(value, float(0.1)));
return value;
}
float HTMLMetaElement::parsePositiveNumber(const String& keyString, const String& valueString, bool* ok)
{
size_t parsedLength;
float value;
if (valueString.is8Bit())
value = charactersToFloat(valueString.characters8(), valueString.length(), parsedLength);
else
value = charactersToFloat(valueString.characters16(), valueString.length(), parsedLength);
if (!parsedLength) {
reportViewportWarning(UnrecognizedViewportArgumentValueError, valueString, keyString);
if (ok)
*ok = false;
return 0;
}
if (parsedLength < valueString.length())
reportViewportWarning(TruncatedViewportArgumentValueError, valueString, keyString);
if (ok)
*ok = true;
return value;
}
Length HTMLMetaElement::parseViewportValueAsLength(const String& keyString, const String& valueString)
{
// 1) Non-negative number values are translated to px lengths.
// 2) Negative number values are translated to auto.
// 3) device-width and device-height are used as keywords.
// 4) Other keywords and unknown values translate to 0.0.
unsigned length = valueString.length();
DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13);
SWITCH(characters, length) {
CASE("device-width") {
return Length(DeviceWidth);
}
CASE("device-height") {
return Length(DeviceHeight);
}
}
float value = parsePositiveNumber(keyString, valueString);
if (value < 0)
return Length(); // auto
return Length(clampLengthValue(value), Fixed);
}
float HTMLMetaElement::parseViewportValueAsZoom(const String& keyString, const String& valueString, bool& computedValueMatchesParsedValue)
{
// 1) Non-negative number values are translated to <number> values.
// 2) Negative number values are translated to auto.
// 3) yes is translated to 1.0.
// 4) device-width and device-height are translated to 10.0.
// 5) no and unknown values are translated to 0.0
computedValueMatchesParsedValue = false;
unsigned length = valueString.length();
DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13);
SWITCH(characters, length) {
CASE("yes") {
return 1;
}
CASE("no") {
return 0;
}
CASE("device-width") {
return 10;
}
CASE("device-height") {
return 10;
}
}
float value = parsePositiveNumber(keyString, valueString);
if (value < 0)
return ViewportDescription::ValueAuto;
if (value > 10.0)
reportViewportWarning(MaximumScaleTooLargeError, String(), String());
float clampedValue = clampScaleValue(value);
if (clampedValue == value)
computedValueMatchesParsedValue = true;
return clampedValue;
}
bool HTMLMetaElement::parseViewportValueAsUserZoom(const String& keyString, const String& valueString, bool& computedValueMatchesParsedValue)
{
// yes and no are used as keywords.
// Numbers >= 1, numbers <= -1, device-width and device-height are mapped to yes.
// Numbers in the range <-1, 1>, and unknown values, are mapped to no.
computedValueMatchesParsedValue = false;
unsigned length = valueString.length();
DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 13);
SWITCH(characters, length) {
CASE("yes") {
computedValueMatchesParsedValue = true;
return true;
}
CASE("no") {
computedValueMatchesParsedValue = true;
return false;
}
CASE("device-width") {
return true;
}
CASE("device-height") {
return true;
}
}
float value = parsePositiveNumber(keyString, valueString);
if (fabs(value) < 1)
return false;
return true;
}
float HTMLMetaElement::parseViewportValueAsDPI(const String& keyString, const String& valueString)
{
unsigned length = valueString.length();
DEFINE_ARRAY_FOR_MATCHING(characters, valueString, 10);
SWITCH(characters, length) {
CASE("device-dpi") {
return ViewportDescription::ValueDeviceDPI;
}
CASE("low-dpi") {
return ViewportDescription::ValueLowDPI;
}
CASE("medium-dpi") {
return ViewportDescription::ValueMediumDPI;
}
CASE("high-dpi") {
return ViewportDescription::ValueHighDPI;
}
}
bool ok;
float value = parsePositiveNumber(keyString, valueString, &ok);
if (!ok || value < 70 || value > 400)
return ViewportDescription::ValueAuto;
return value;
}
void HTMLMetaElement::processViewportKeyValuePair(const String& keyString, const String& valueString, void* data)
{
ViewportDescription* description = static_cast<ViewportDescription*>(data);
unsigned length = keyString.length();
DEFINE_ARRAY_FOR_MATCHING(characters, keyString, 17);
SWITCH(characters, length) {
CASE("width") {
const Length& width = parseViewportValueAsLength(keyString, valueString);
if (width.isAuto())
return;
description->minWidth = Length(ExtendToZoom);
description->maxWidth = width;
return;
}
CASE("height") {
const Length& height = parseViewportValueAsLength(keyString, valueString);
if (height.isAuto())
return;
description->minHeight = Length(ExtendToZoom);
description->maxHeight = height;
return;
}
CASE("initial-scale") {
description->zoom = parseViewportValueAsZoom(keyString, valueString, description->zoomIsExplicit);
return;
}
CASE("minimum-scale") {
description->minZoom = parseViewportValueAsZoom(keyString, valueString, description->minZoomIsExplicit);
return;
}
CASE("maximum-scale") {
description->maxZoom = parseViewportValueAsZoom(keyString, valueString, description->maxZoomIsExplicit);
return;
}
CASE("user-scalable") {
description->userZoom = parseViewportValueAsUserZoom(keyString, valueString, description->userZoomIsExplicit);
return;
}
CASE("target-densitydpi") {
description->deprecatedTargetDensityDPI = parseViewportValueAsDPI(keyString, valueString);
reportViewportWarning(TargetDensityDpiUnsupported, String(), String());
return;
}
CASE("minimal-ui") {
// Ignore vendor-specific argument.
return;
}
}
reportViewportWarning(UnrecognizedViewportArgumentKeyError, keyString, String());
}
static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
{
static const char* const errors[] = {
"The key \"%replacement1\" is not recognized and ignored.",
"The value \"%replacement1\" for key \"%replacement2\" is invalid, and has been ignored.",
"The value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.",
"The value for key \"maximum-scale\" is out of bounds and the value has been clamped.",
"The key \"target-densitydpi\" is not supported.",
};
return errors[errorCode];
}
static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode)
{
switch (errorCode) {
case TruncatedViewportArgumentValueError:
case TargetDensityDpiUnsupported:
case UnrecognizedViewportArgumentKeyError:
case UnrecognizedViewportArgumentValueError:
case MaximumScaleTooLargeError:
return WarningMessageLevel;
}
ASSERT_NOT_REACHED();
return ErrorMessageLevel;
}
void HTMLMetaElement::reportViewportWarning(ViewportErrorCode errorCode, const String& replacement1, const String& replacement2)
{
if (!document().frame())
return;
String message = viewportErrorMessageTemplate(errorCode);
if (!replacement1.isNull())
message.replace("%replacement1", replacement1);
if (!replacement2.isNull())
message.replace("%replacement2", replacement2);
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, viewportErrorMessageLevel(errorCode), message));
}
void HTMLMetaElement::processViewportContentAttribute(const String& content, ViewportDescription::Type origin)
{
ASSERT(!content.isNull());
if (!document().shouldOverrideLegacyDescription(origin))
return;
ViewportDescription descriptionFromLegacyTag(origin);
parseContentAttribute(content, &HTMLMetaElement::processViewportKeyValuePair, (void*)&descriptionFromLegacyTag);
if (descriptionFromLegacyTag.minZoom == ViewportDescription::ValueAuto)
descriptionFromLegacyTag.minZoom = 0.25;
if (descriptionFromLegacyTag.maxZoom == ViewportDescription::ValueAuto) {
descriptionFromLegacyTag.maxZoom = 5;
descriptionFromLegacyTag.minZoom = std::min(descriptionFromLegacyTag.minZoom, float(5));
}
document().setViewportDescription(descriptionFromLegacyTag);
}
void HTMLMetaElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == HTMLNames::http_equivAttr || name == HTMLNames::contentAttr) {
......@@ -448,16 +75,8 @@ void HTMLMetaElement::process()
return;
const AtomicString& nameValue = getAttribute(HTMLNames::nameAttr);
if (!nameValue.isEmpty()) {
if (equalIgnoringCase(nameValue, "viewport"))
processViewportContentAttribute(contentValue, ViewportDescription::ViewportMeta);
else if (equalIgnoringCase(nameValue, "referrer"))
document().processReferrerPolicy(contentValue);
else if (equalIgnoringCase(nameValue, "handheldfriendly") && equalIgnoringCase(contentValue, "true"))
processViewportContentAttribute("width=device-width", ViewportDescription::HandheldFriendlyMeta);
else if (equalIgnoringCase(nameValue, "mobileoptimized"))
processViewportContentAttribute("width=device-width, initial-scale=1", ViewportDescription::MobileOptimizedMeta);
}
if (!nameValue.isEmpty() && equalIgnoringCase(nameValue, "referrer"))
document().processReferrerPolicy(contentValue);
// Get the document to process the tag, but only if we're actually part of DOM
// tree (changing a meta tag while it's not in the tree shouldn't have any effect
......
......@@ -23,19 +23,10 @@
#ifndef HTMLMetaElement_h
#define HTMLMetaElement_h
#include "core/dom/ViewportDescription.h"
#include "core/html/HTMLElement.h"
namespace blink {
enum ViewportErrorCode {
UnrecognizedViewportArgumentKeyError,
UnrecognizedViewportArgumentValueError,
TruncatedViewportArgumentValueError,
MaximumScaleTooLargeError,
TargetDensityDpiUnsupported
};
class HTMLMetaElement final : public HTMLElement {
DEFINE_WRAPPERTYPEINFO();
public:
......@@ -48,25 +39,11 @@ public:
private:
explicit HTMLMetaElement(Document&);
typedef void (HTMLMetaElement::*KeyValuePairCallback)(const String& key, const String& value, void* data);
void processViewportKeyValuePair(const String& key, const String& value, void* data);
void parseContentAttribute(const String& content, KeyValuePairCallback, void* data);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
virtual void didNotifySubtreeInsertionsToDocument() override;
float parsePositiveNumber(const String& key, const String& value, bool* ok = 0);
Length parseViewportValueAsLength(const String& key, const String& value);
float parseViewportValueAsZoom(const String& key, const String& value, bool& computedValueMatchesParsedValue);
bool parseViewportValueAsUserZoom(const String& key, const String& value, bool& computedValueMatchesParsedValue);
float parseViewportValueAsDPI(const String& key, const String& value);
void reportViewportWarning(ViewportErrorCode, const String& replacement1, const String& replacement2);
void process();
void processViewportContentAttribute(const String& content, ViewportDescription::Type origin);
};
} // namespace blink
......
......@@ -40,7 +40,6 @@
#include "bindings/core/v8/SerializedScriptValue.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/dom/ViewportDescription.h"
#include "core/editing/Editor.h"
#include "core/editing/UndoStack.h"
#include "core/events/PageTransitionEvent.h"
......
......@@ -129,11 +129,6 @@ void Chrome::setToolTip(const HitTestResult& result)
m_client->setToolTip(toolTip, toolTipDirection);
}
void Chrome::dispatchViewportPropertiesDidChange(const ViewportDescription& description) const
{
m_client->dispatchViewportPropertiesDidChange(description);
}
void Chrome::setCursor(const Cursor& cursor)
{
m_client->setCursor(cursor);
......
......@@ -43,7 +43,6 @@ class Node;
class Page;
struct DateTimeChooserParameters;
struct ViewportDescription;
class Chrome final : public HostWindow {
public:
......@@ -81,8 +80,6 @@ public:
void setToolTip(const HitTestResult&);
void dispatchViewportPropertiesDidChange(const ViewportDescription&) const;
void willBeDestroyed();
private:
......
......@@ -56,7 +56,6 @@ class Widget;
struct DateTimeChooserParameters;
struct GraphicsDeviceAdapter;
struct ViewportDescription;
class ChromeClient {
public:
......@@ -94,8 +93,6 @@ public:
virtual void scheduleAnimation() = 0;
// End methods used by HostWindow.
virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const { }
virtual void layoutUpdated(LocalFrame*) const { }
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
......
......@@ -134,11 +134,6 @@ void Page::makeOrdinary()
ordinaryPages().add(this);
}
ViewportDescription Page::viewportDescription() const
{
return mainFrame() && mainFrame()->document() ? mainFrame()->document()->viewportDescription() : ViewportDescription();
}
ScrollingCoordinator* Page::scrollingCoordinator()
{
if (!m_scrollingCoordinator)
......@@ -300,10 +295,6 @@ void Page::settingsChanged(SettingsDelegate::ChangeType changeType)
case SettingsDelegate::StyleChange:
setNeedsRecalcStyleInAllFrames();
break;
case SettingsDelegate::ViewportDescriptionChange:
if (mainFrame() && mainFrame()->document())
mainFrame()->document()->updateViewportDescription();
break;
case SettingsDelegate::MediaTypeChange:
if (mainFrame()) {
mainFrame()->view()->setMediaType(AtomicString(settings().mediaTypeOverride()));
......
......@@ -21,7 +21,6 @@
#ifndef Page_h
#define Page_h
#include "core/dom/ViewportDescription.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/SettingsDelegate.h"
#include "core/frame/UseCounter.h"
......@@ -100,8 +99,6 @@ public:
void setNeedsRecalcStyleInAllFrames();
void updateAcceleratedCompositingSettings();
ViewportDescription viewportDescription() const;
EditorClient& editorClient() const { return *m_editorClient; }
SpellCheckerClient& spellCheckerClient() const { return *m_spellCheckerClient; }
UndoStack& undoStack() const { return *m_undoStack; }
......
......@@ -82,7 +82,6 @@ public:
virtual int availableHoverTypes() const = 0;
virtual HoverType primaryHoverType() const = 0;
virtual bool shrinksViewportContentToFit() const = 0;
virtual bool viewportEnabled() const = 0;
virtual void setAccelerated2dCanvasEnabled(bool) = 0;
virtual void setAccelerated2dCanvasMSAASampleCount(int) = 0;
virtual void setPreferCompositingToLCDTextEnabled(bool) = 0;
......@@ -149,8 +148,6 @@ public:
virtual void setUseSolidColorScrollbars(bool) = 0;
virtual void setUseWideViewport(bool) = 0;
virtual void setV8CacheOptions(V8CacheOptions) = 0;
virtual void setViewportEnabled(bool) = 0;
virtual void setViewportMetaEnabled(bool) = 0;
virtual void setWebGLErrorsToConsoleEnabled(bool) = 0;
protected:
......
......@@ -327,11 +327,6 @@ void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir)
m_webView->client()->setToolTipText(tooltipText, toWebTextDirection(dir));
}
void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescription& description) const
{
m_webView->updatePageDefinedViewportConstraints(description);
}
void ChromeClientImpl::setCursor(const Cursor& cursor)
{
setCursor(WebCursorInfo(cursor));
......
......@@ -85,7 +85,6 @@ public:
virtual void mouseDidMoveOverElement(
const HitTestResult&, unsigned modifierFlags) override;
virtual void setToolTip(const WTF::String& tooltipText, TextDirection) override;
virtual void dispatchViewportPropertiesDidChange(const ViewportDescription&) const override;
virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) override;
virtual void setCursor(const Cursor&) override;
virtual void needTouchEvents(bool needTouchEvents) override;
......
......@@ -355,11 +355,6 @@ WebSettings::HoverType WebSettingsImpl::primaryHoverType() const
return static_cast<HoverType>(m_settings->primaryHoverType());
}
bool WebSettingsImpl::viewportEnabled() const
{
return m_settings->viewportEnabled();
}
bool WebSettingsImpl::mockGestureTapHighlightsEnabled() const
{
return m_settings->mockGestureTapHighlightsEnabled();
......@@ -389,16 +384,6 @@ void WebSettingsImpl::setMediaPlaybackRequiresUserGesture(bool required)
m_settings->setMediaPlaybackRequiresUserGesture(required);
}
void WebSettingsImpl::setViewportEnabled(bool enabled)
{
m_settings->setViewportEnabled(enabled);
}
void WebSettingsImpl::setViewportMetaEnabled(bool enabled)
{
m_settings->setViewportMetaEnabled(enabled);
}
void WebSettingsImpl::setSelectionIncludesAltImageText(bool enabled)
{
m_settings->setSelectionIncludesAltImageText(enabled);
......
......@@ -48,7 +48,6 @@ public:
virtual PointerType primaryPointerType() const override;
virtual int availableHoverTypes() const override;
virtual HoverType primaryHoverType() const override;
virtual bool viewportEnabled() const override;
virtual void setAccelerated2dCanvasEnabled(bool) override;
virtual void setAccelerated2dCanvasMSAASampleCount(int) override;
virtual void setPreferCompositingToLCDTextEnabled(bool) override;
......@@ -112,8 +111,6 @@ public:
virtual void setUseSolidColorScrollbars(bool) override;
virtual void setUseWideViewport(bool) override;
virtual void setV8CacheOptions(V8CacheOptions) override;
virtual void setViewportEnabled(bool) override;
virtual void setViewportMetaEnabled(bool) override;
virtual void setWebGLErrorsToConsoleEnabled(bool) override;
bool showFPSCounter() const { return m_showFPSCounter; }
......
......@@ -938,7 +938,6 @@ WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() const
void WebViewImpl::performResize()
{
updatePageDefinedViewportConstraints(localFrameRootTemporary()->frame()->document()->viewportDescription());
updateMainFrameLayoutSize();
// If the virtual viewport pinch mode is enabled, the main frame will be resized
......@@ -1818,26 +1817,6 @@ void WebViewImpl::setDeviceScaleFactor(float scaleFactor)
updateLayerTreeDeviceScaleFactor();
}
void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription& description)
{
if (!settings()->viewportEnabled() || !page() || (!m_size.width && !m_size.height))
return;
Document* document = page()->mainFrame()->document();
m_matchesHeuristicsForGpuRasterization = description.maxWidth == Length(DeviceWidth)
&& description.minZoom == 1.0
&& description.minZoomIsExplicit;
if (m_layerTreeView)
m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuristicsForGpuRasterization);
Length defaultMinWidth = document->viewportDefaultMinWidth();
if (defaultMinWidth.isAuto())
defaultMinWidth = Length(ExtendToZoom);
updateMainFrameLayoutSize();
}
void WebViewImpl::updateMainFrameLayoutSize()
{
if (m_fixedLayoutSizeLock || !mainFrameImpl())
......
......@@ -264,7 +264,6 @@ public:
void didRemoveAllPendingStylesheet(WebLocalFrameImpl*);
void updateMainFrameLayoutSize();
void updatePageDefinedViewportConstraints(const ViewportDescription&);
// Returns the input event we're currently processing. This is used in some
// cases where the WebCore DOM event doesn't have the information we need.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册