2019-07-25 07:24:08 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef DOM_VIEWPORT_META_DATA_H_
|
|
|
|
#define DOM_VIEWPORT_META_DATA_H_
|
|
|
|
|
2020-04-29 12:02:05 +03:00
|
|
|
#include "nsString.h"
|
2019-07-25 07:24:08 +03:00
|
|
|
#include "nsAString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
struct ViewportMetaData {
|
Bug 1498729 - Store each viewport meta data by the viewport meta tag and use the last one. r=smaug,botond
This is what Chrome and Safari do.
See https://webcompat.com/issues/20701#issuecomment-436054739
So for exmaple, if there are two viewport meta tags like this;
<meta name="viewport" content="width=980">
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
We will use "initial-scale=1,maximum-scale=1". Before this change we used to
use merged "width=980,initial-scale=1,maximum-scale=1".
Another example is to replace the content of a single viewport meta tag like this;
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1">
what will happen when this tag is replaced by below;
<meta id="viewport" name="viewport" content="width=1080">
We will use the replacing one (i.e. "width=1080"), before this change, we used
to use merged "width=1080,initial-scale=1".
As of this commit, we don't properly remove corresponding viewport meta data
when a) viewport meta tag is detached from document and b) `name` attribute is
changed from 'viewport'. These cases will be handled in subsequent commits.
Note that we no longer store invididual viewport meta data in Document::mHeaderData
so that nsIDOMWindowUtils.getDocumentMetadata doesn't work any more for the
invididual viewport meta data, but there is no use cases for them other than
two test cases which are removed in this commit.
Differential Revision: https://phabricator.services.mozilla.com/D38922
--HG--
extra : moz-landing-system : lando
2019-07-25 23:51:23 +03:00
|
|
|
// https://drafts.csswg.org/css-device-adapt/#meta-properties
|
|
|
|
nsString mWidth;
|
|
|
|
nsString mHeight;
|
|
|
|
nsString mInitialScale;
|
|
|
|
nsString mMinimumScale;
|
|
|
|
nsString mMaximumScale;
|
|
|
|
nsString mUserScalable;
|
2020-01-20 11:40:05 +03:00
|
|
|
nsString mViewportFit;
|
Bug 1498729 - Store each viewport meta data by the viewport meta tag and use the last one. r=smaug,botond
This is what Chrome and Safari do.
See https://webcompat.com/issues/20701#issuecomment-436054739
So for exmaple, if there are two viewport meta tags like this;
<meta name="viewport" content="width=980">
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
We will use "initial-scale=1,maximum-scale=1". Before this change we used to
use merged "width=980,initial-scale=1,maximum-scale=1".
Another example is to replace the content of a single viewport meta tag like this;
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1">
what will happen when this tag is replaced by below;
<meta id="viewport" name="viewport" content="width=1080">
We will use the replacing one (i.e. "width=1080"), before this change, we used
to use merged "width=1080,initial-scale=1".
As of this commit, we don't properly remove corresponding viewport meta data
when a) viewport meta tag is detached from document and b) `name` attribute is
changed from 'viewport'. These cases will be handled in subsequent commits.
Note that we no longer store invididual viewport meta data in Document::mHeaderData
so that nsIDOMWindowUtils.getDocumentMetadata doesn't work any more for the
invididual viewport meta data, but there is no use cases for them other than
two test cases which are removed in this commit.
Differential Revision: https://phabricator.services.mozilla.com/D38922
--HG--
extra : moz-landing-system : lando
2019-07-25 23:51:23 +03:00
|
|
|
|
|
|
|
bool operator==(const ViewportMetaData& aOther) const {
|
|
|
|
return mWidth == aOther.mWidth && mHeight == aOther.mHeight &&
|
|
|
|
mInitialScale == aOther.mInitialScale &&
|
|
|
|
mMinimumScale == aOther.mMinimumScale &&
|
|
|
|
mMaximumScale == aOther.mMaximumScale &&
|
2020-01-20 11:40:05 +03:00
|
|
|
mUserScalable == aOther.mUserScalable &&
|
|
|
|
mViewportFit == aOther.mViewportFit;
|
Bug 1498729 - Store each viewport meta data by the viewport meta tag and use the last one. r=smaug,botond
This is what Chrome and Safari do.
See https://webcompat.com/issues/20701#issuecomment-436054739
So for exmaple, if there are two viewport meta tags like this;
<meta name="viewport" content="width=980">
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
We will use "initial-scale=1,maximum-scale=1". Before this change we used to
use merged "width=980,initial-scale=1,maximum-scale=1".
Another example is to replace the content of a single viewport meta tag like this;
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1">
what will happen when this tag is replaced by below;
<meta id="viewport" name="viewport" content="width=1080">
We will use the replacing one (i.e. "width=1080"), before this change, we used
to use merged "width=1080,initial-scale=1".
As of this commit, we don't properly remove corresponding viewport meta data
when a) viewport meta tag is detached from document and b) `name` attribute is
changed from 'viewport'. These cases will be handled in subsequent commits.
Note that we no longer store invididual viewport meta data in Document::mHeaderData
so that nsIDOMWindowUtils.getDocumentMetadata doesn't work any more for the
invididual viewport meta data, but there is no use cases for them other than
two test cases which are removed in this commit.
Differential Revision: https://phabricator.services.mozilla.com/D38922
--HG--
extra : moz-landing-system : lando
2019-07-25 23:51:23 +03:00
|
|
|
}
|
|
|
|
bool operator!=(const ViewportMetaData& aOther) const {
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewportMetaData() = default;
|
2019-07-25 07:24:08 +03:00
|
|
|
/* Process viewport META data. This gives us information for the scale
|
|
|
|
* and zoom of a page on mobile devices. We stick the information in
|
|
|
|
* the document header and use it later on after rendering.
|
|
|
|
*
|
|
|
|
* See Bug #436083
|
|
|
|
*/
|
Bug 1498729 - Store each viewport meta data by the viewport meta tag and use the last one. r=smaug,botond
This is what Chrome and Safari do.
See https://webcompat.com/issues/20701#issuecomment-436054739
So for exmaple, if there are two viewport meta tags like this;
<meta name="viewport" content="width=980">
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
We will use "initial-scale=1,maximum-scale=1". Before this change we used to
use merged "width=980,initial-scale=1,maximum-scale=1".
Another example is to replace the content of a single viewport meta tag like this;
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1">
what will happen when this tag is replaced by below;
<meta id="viewport" name="viewport" content="width=1080">
We will use the replacing one (i.e. "width=1080"), before this change, we used
to use merged "width=1080,initial-scale=1".
As of this commit, we don't properly remove corresponding viewport meta data
when a) viewport meta tag is detached from document and b) `name` attribute is
changed from 'viewport'. These cases will be handled in subsequent commits.
Note that we no longer store invididual viewport meta data in Document::mHeaderData
so that nsIDOMWindowUtils.getDocumentMetadata doesn't work any more for the
invididual viewport meta data, but there is no use cases for them other than
two test cases which are removed in this commit.
Differential Revision: https://phabricator.services.mozilla.com/D38922
--HG--
extra : moz-landing-system : lando
2019-07-25 23:51:23 +03:00
|
|
|
explicit ViewportMetaData(const nsAString& aViewportInfo);
|
2019-07-25 07:24:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // DOM_VIEWPORT_META_DATA_H_
|