2015-05-03 22:32:37 +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: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2008-02-21 23:39:20 +03:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
#include "HTMLFrameSetElement.h"
|
2012-12-21 18:07:28 +04:00
|
|
|
#include "mozilla/dom/HTMLFrameSetElementBinding.h"
|
2012-11-26 18:19:02 +04:00
|
|
|
#include "mozilla/dom/EventHandlerBinding.h"
|
2012-12-21 18:07:28 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
2015-11-03 21:29:19 +03:00
|
|
|
#include "mozilla/UniquePtrExtensions.h"
|
2008-02-21 23:39:20 +03:00
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(FrameSet)
|
1999-10-07 04:35:04 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::~HTMLFrameSetElement()
|
1998-09-03 05:03:33 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
HTMLFrameSetElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-21 18:07:28 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return HTMLFrameSetElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLFrameSetElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLFrameSetElement)
|
2008-02-21 23:39:20 +03:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLFrameSetElement)
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLFrameSetElement::SetCols(const nsAString& aCols)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetCols(aCols, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLFrameSetElement::GetCols(nsAString& aCols)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString cols;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetCols(cols);
|
2015-02-13 04:27:39 +03:00
|
|
|
cols.ToString(aCols);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLFrameSetElement::SetRows(const nsAString& aRows)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetRows(aRows, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLFrameSetElement::GetRows(nsAString& aRows)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString rows;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetRows(rows);
|
2015-02-13 04:27:39 +03:00
|
|
|
rows.ToString(aRows);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
nsresult
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::SetAttr(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
nsIAtom* aPrefix,
|
|
|
|
const nsAString& aValue,
|
|
|
|
bool aNotify)
|
2002-08-06 05:06:50 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
/* The main goal here is to see whether the _number_ of rows or
|
|
|
|
* columns has changed. If it has, we need to reframe; otherwise
|
|
|
|
* we want to reflow. So we set mCurrentRowColHint here, then call
|
2004-02-10 22:36:43 +03:00
|
|
|
* nsGenericHTMLElement::SetAttr, which will end up calling
|
|
|
|
* GetAttributeChangeHint and notifying layout with that hint.
|
|
|
|
* Once nsGenericHTMLElement::SetAttr returns, we want to go back to our
|
|
|
|
* normal hint, which is NS_STYLE_HINT_REFLOW.
|
2002-08-06 05:06:50 +04:00
|
|
|
*/
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::rows && aNameSpaceID == kNameSpaceID_None) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t oldRows = mNumRows;
|
2015-11-03 21:29:19 +03:00
|
|
|
ParseRowCol(aValue, mNumRows, &mRowSpecs);
|
2016-07-06 08:06:14 +03:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (mNumRows != oldRows) {
|
2016-07-06 08:06:14 +03:00
|
|
|
mCurrentRowColHint = nsChangeHint_ReconstructFrame;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::cols &&
|
2002-08-06 05:06:50 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t oldCols = mNumCols;
|
2015-11-03 21:29:19 +03:00
|
|
|
ParseRowCol(aValue, mNumCols, &mColSpecs);
|
2002-08-06 05:06:50 +04:00
|
|
|
|
|
|
|
if (mNumCols != oldCols) {
|
2016-07-06 08:06:14 +03:00
|
|
|
mCurrentRowColHint = nsChangeHint_ReconstructFrame;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
}
|
2016-07-06 08:06:14 +03:00
|
|
|
|
2004-02-10 22:36:43 +03:00
|
|
|
rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute, aPrefix,
|
|
|
|
aValue, aNotify);
|
2002-08-06 05:06:50 +04:00
|
|
|
mCurrentRowColHint = NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:14 +03:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-08 23:04:10 +04:00
|
|
|
nsresult
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::GetRowSpec(int32_t *aNumValues,
|
|
|
|
const nsFramesetSpec** aSpecs)
|
2002-08-06 05:06:50 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!");
|
|
|
|
NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
|
|
|
|
*aNumValues = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSpecs = nullptr;
|
2002-08-06 05:06:50 +04:00
|
|
|
|
|
|
|
if (!mRowSpecs) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (value && value->Type() == nsAttrValue::eString) {
|
2005-03-09 19:47:30 +03:00
|
|
|
nsresult rv = ParseRowCol(value->GetStringValue(), mNumRows,
|
2015-11-03 21:29:19 +03:00
|
|
|
&mRowSpecs);
|
2002-08-06 05:06:50 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mRowSpecs) { // we may not have had an attr or had an empty attr
|
2015-11-03 21:29:19 +03:00
|
|
|
mRowSpecs = MakeUnique<nsFramesetSpec[]>(1);
|
2002-08-06 05:06:50 +04:00
|
|
|
mNumRows = 1;
|
|
|
|
mRowSpecs[0].mUnit = eFramesetUnit_Relative;
|
|
|
|
mRowSpecs[0].mValue = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:29:19 +03:00
|
|
|
*aSpecs = mRowSpecs.get();
|
2002-08-06 05:06:50 +04:00
|
|
|
*aNumValues = mNumRows;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-08 23:04:10 +04:00
|
|
|
nsresult
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::GetColSpec(int32_t *aNumValues,
|
|
|
|
const nsFramesetSpec** aSpecs)
|
2002-08-06 05:06:50 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNumValues, "Must have a pointer to an integer here!");
|
|
|
|
NS_PRECONDITION(aSpecs, "Must have a pointer to an array of nsFramesetSpecs");
|
|
|
|
*aNumValues = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSpecs = nullptr;
|
2002-08-06 05:06:50 +04:00
|
|
|
|
|
|
|
if (!mColSpecs) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (value && value->Type() == nsAttrValue::eString) {
|
2005-03-09 19:47:30 +03:00
|
|
|
nsresult rv = ParseRowCol(value->GetStringValue(), mNumCols,
|
2015-11-03 21:29:19 +03:00
|
|
|
&mColSpecs);
|
2002-08-06 05:06:50 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mColSpecs) { // we may not have had an attr or had an empty attr
|
2015-11-03 21:29:19 +03:00
|
|
|
mColSpecs = MakeUnique<nsFramesetSpec[]>(1);
|
2002-08-06 05:06:50 +04:00
|
|
|
mNumCols = 1;
|
|
|
|
mColSpecs[0].mUnit = eFramesetUnit_Relative;
|
|
|
|
mColSpecs[0].mValue = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:29:19 +03:00
|
|
|
*aSpecs = mColSpecs.get();
|
2002-08-06 05:06:50 +04:00
|
|
|
*aNumValues = mNumCols;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-03 05:03:33 +04:00
|
|
|
{
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::bordercolor) {
|
2010-07-17 12:09:14 +04:00
|
|
|
return aResult.ParseColor(aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::frameborder) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseFrameborderValue(aValue, aResult);
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::border) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return aResult.ParseIntWithBounds(aValue, 0, 100);
|
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
2005-11-29 19:37:15 +03:00
|
|
|
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2004-10-24 21:10:32 +04:00
|
|
|
nsChangeHint
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) const
|
1999-07-07 05:24:40 +04:00
|
|
|
{
|
2004-10-24 21:10:32 +04:00
|
|
|
nsChangeHint retval =
|
|
|
|
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::rows ||
|
|
|
|
aAttribute == nsGkAtoms::cols) {
|
2016-05-23 06:26:03 +03:00
|
|
|
retval |= mCurrentRowColHint;
|
2003-07-12 01:16:12 +04:00
|
|
|
}
|
2004-10-24 21:10:32 +04:00
|
|
|
return retval;
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
2005-03-09 19:47:30 +03:00
|
|
|
/**
|
|
|
|
* Translate a "rows" or "cols" spec into an array of nsFramesetSpecs
|
|
|
|
*/
|
2002-08-06 05:06:50 +04:00
|
|
|
nsresult
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
|
|
|
|
int32_t& aNumSpecs,
|
2015-11-03 21:29:19 +03:00
|
|
|
UniquePtr<nsFramesetSpec[]>* aSpecs)
|
2002-08-06 05:06:50 +04:00
|
|
|
{
|
2005-03-09 19:47:30 +03:00
|
|
|
if (aValue.IsEmpty()) {
|
|
|
|
aNumSpecs = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSpecs = nullptr;
|
2005-03-09 19:47:30 +03:00
|
|
|
return NS_OK;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t sAster('*');
|
|
|
|
static const char16_t sPercent('%');
|
|
|
|
static const char16_t sComma(',');
|
2002-08-06 05:06:50 +04:00
|
|
|
|
2005-03-09 19:47:30 +03:00
|
|
|
nsAutoString spec(aValue);
|
2003-11-07 07:26:30 +03:00
|
|
|
// remove whitespace (Bug 33699) and quotation marks (bug 224598)
|
2002-08-06 05:06:50 +04:00
|
|
|
// also remove leading/trailing commas (bug 31482)
|
2005-03-09 19:47:30 +03:00
|
|
|
spec.StripChars(" \n\r\t\"\'");
|
|
|
|
spec.Trim(",");
|
2002-08-06 05:06:50 +04:00
|
|
|
|
2010-07-21 04:37:08 +04:00
|
|
|
// Count the commas. Don't count more than X commas (bug 576447).
|
2013-11-11 12:03:59 +04:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT * sizeof(nsFramesetSpec) < (1 << 30),
|
|
|
|
"Too many frameset specs allowed to allocate");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t commaX = spec.FindChar(sComma);
|
|
|
|
int32_t count = 1;
|
2011-01-25 04:38:07 +03:00
|
|
|
while (commaX != kNotFound && count < NS_MAX_FRAMESET_SPEC_COUNT) {
|
2002-08-06 05:06:50 +04:00
|
|
|
count++;
|
2005-03-09 19:47:30 +03:00
|
|
|
commaX = spec.FindChar(sComma, commaX + 1);
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
|
2015-11-03 21:29:19 +03:00
|
|
|
auto specs = MakeUniqueFallible<nsFramesetSpec[]>(count);
|
2005-03-09 19:47:30 +03:00
|
|
|
if (!specs) {
|
2012-07-30 18:20:58 +04:00
|
|
|
*aSpecs = nullptr;
|
2005-03-09 19:47:30 +03:00
|
|
|
aNumSpecs = 0;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
|
2005-03-09 19:47:30 +03:00
|
|
|
// Pre-grab the compat mode; we may need it later in the loop.
|
2011-10-18 14:53:36 +04:00
|
|
|
bool isInQuirks = InNavQuirksMode(OwnerDoc());
|
2005-03-09 19:47:30 +03:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
// Parse each comma separated token
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t start = 0;
|
|
|
|
int32_t specLen = spec.Length();
|
2002-08-06 05:06:50 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < count; i++) {
|
2002-08-06 05:06:50 +04:00
|
|
|
// Find our comma
|
2005-03-09 19:47:30 +03:00
|
|
|
commaX = spec.FindChar(sComma, start);
|
|
|
|
NS_ASSERTION(i == count - 1 || commaX != kNotFound,
|
|
|
|
"Failed to find comma, somehow");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t end = (commaX == kNotFound) ? specLen : commaX;
|
2002-08-06 05:06:50 +04:00
|
|
|
|
|
|
|
// Note: If end == start then it means that the token has no
|
2005-03-09 19:47:30 +03:00
|
|
|
// data in it other than a terminating comma (or the end of the spec).
|
|
|
|
// So default to a fixed width of 0.
|
|
|
|
specs[i].mUnit = eFramesetUnit_Fixed;
|
|
|
|
specs[i].mValue = 0;
|
2002-08-06 05:06:50 +04:00
|
|
|
if (end > start) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numberEnd = end;
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t ch = spec.CharAt(numberEnd - 1);
|
2002-08-06 05:06:50 +04:00
|
|
|
if (sAster == ch) {
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mUnit = eFramesetUnit_Relative;
|
2002-08-06 05:06:50 +04:00
|
|
|
numberEnd--;
|
|
|
|
} else if (sPercent == ch) {
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mUnit = eFramesetUnit_Percent;
|
2002-08-06 05:06:50 +04:00
|
|
|
numberEnd--;
|
|
|
|
// check for "*%"
|
|
|
|
if (numberEnd > start) {
|
2005-03-09 19:47:30 +03:00
|
|
|
ch = spec.CharAt(numberEnd - 1);
|
2002-08-06 05:06:50 +04:00
|
|
|
if (sAster == ch) {
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mUnit = eFramesetUnit_Relative;
|
2002-08-06 05:06:50 +04:00
|
|
|
numberEnd--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Translate value to an integer
|
2005-03-09 19:47:30 +03:00
|
|
|
nsAutoString token;
|
|
|
|
spec.Mid(token, start, numberEnd - start);
|
2002-08-06 05:06:50 +04:00
|
|
|
|
|
|
|
// Treat * as 1*
|
2005-03-09 19:47:30 +03:00
|
|
|
if ((eFramesetUnit_Relative == specs[i].mUnit) &&
|
2002-08-06 05:06:50 +04:00
|
|
|
(0 == token.Length())) {
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mValue = 1;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Otherwise just convert to integer.
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult err;
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mValue = token.ToInteger(&err);
|
2012-08-07 18:58:47 +04:00
|
|
|
if (NS_FAILED(err)) {
|
2005-03-09 19:47:30 +03:00
|
|
|
specs[i].mValue = 0;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Treat 0* as 1* in quirks mode (bug 40383)
|
2006-12-05 18:46:18 +03:00
|
|
|
if (isInQuirks) {
|
2005-03-09 19:47:30 +03:00
|
|
|
if ((eFramesetUnit_Relative == specs[i].mUnit) &&
|
|
|
|
(0 == specs[i].mValue)) {
|
|
|
|
specs[i].mValue = 1;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-07 04:20:35 +04:00
|
|
|
// Catch zero and negative frame sizes for Nav compatibility
|
2002-08-06 05:06:50 +04:00
|
|
|
// Nav resized absolute and relative frames to "1" and
|
|
|
|
// percent frames to an even percentage of the width
|
|
|
|
//
|
2006-12-05 18:46:18 +03:00
|
|
|
//if (isInQuirks && (specs[i].mValue <= 0)) {
|
2005-03-09 19:47:30 +03:00
|
|
|
// if (eFramesetUnit_Percent == specs[i].mUnit) {
|
|
|
|
// specs[i].mValue = 100 / count;
|
2002-08-06 05:06:50 +04:00
|
|
|
// } else {
|
2005-03-09 19:47:30 +03:00
|
|
|
// specs[i].mValue = 1;
|
2002-08-06 05:06:50 +04:00
|
|
|
// }
|
|
|
|
//} else {
|
|
|
|
|
|
|
|
// In standards mode, just set negative sizes to zero
|
2005-03-09 19:47:30 +03:00
|
|
|
if (specs[i].mValue < 0) {
|
|
|
|
specs[i].mValue = 0;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
|
|
|
start = end + 1;
|
|
|
|
}
|
|
|
|
}
|
2005-03-09 19:47:30 +03:00
|
|
|
|
|
|
|
aNumSpecs = count;
|
|
|
|
// Transfer ownership to caller here
|
2015-11-03 21:29:19 +03:00
|
|
|
*aSpecs = Move(specs);
|
|
|
|
|
2005-03-09 19:47:30 +03:00
|
|
|
return NS_OK;
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
2011-08-24 23:49:25 +04:00
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
bool
|
|
|
|
HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
|
|
|
|
{
|
|
|
|
return nsContentUtils::IsEventAttributeName(aName,
|
|
|
|
EventNameType_HTML |
|
|
|
|
EventNameType_HTMLBodyOrFramesetOnly);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-24 23:49:25 +04:00
|
|
|
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
|
2012-11-26 18:19:02 +04:00
|
|
|
// nsGenericHTMLElement::GetOnError returns
|
|
|
|
// already_AddRefed<EventHandlerNonNull> while other getters return
|
|
|
|
// EventHandlerNonNull*, so allow passing in the type to use here.
|
2012-12-21 18:07:28 +04:00
|
|
|
#define WINDOW_EVENT_HELPER(name_, type_) \
|
|
|
|
type_* \
|
|
|
|
HTMLFrameSetElement::GetOn##name_() \
|
2012-12-21 18:06:50 +04:00
|
|
|
{ \
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) { \
|
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win); \
|
2012-12-21 18:07:28 +04:00
|
|
|
return globalWin->GetOn##name_(); \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
return nullptr; \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
void \
|
2013-09-17 15:01:28 +04:00
|
|
|
HTMLFrameSetElement::SetOn##name_(type_* handler) \
|
2012-12-21 18:06:50 +04:00
|
|
|
{ \
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow(); \
|
2013-04-29 19:34:16 +04:00
|
|
|
if (!win) { \
|
2012-12-21 18:07:28 +04:00
|
|
|
return; \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
\
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win); \
|
2013-09-17 15:01:28 +04:00
|
|
|
return globalWin->SetOn##name_(handler); \
|
2013-11-16 16:31:37 +04:00
|
|
|
}
|
2012-12-21 18:07:28 +04:00
|
|
|
#define WINDOW_EVENT(name_, id_, type_, struct_) \
|
|
|
|
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
|
|
|
|
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
|
2013-10-08 19:51:15 +04:00
|
|
|
WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
|
2014-04-01 15:42:12 +04:00
|
|
|
#include "mozilla/EventNameList.h" // IWYU pragma: keep
|
2012-12-21 18:07:28 +04:00
|
|
|
#undef BEFOREUNLOAD_EVENT
|
2011-08-24 23:49:25 +04:00
|
|
|
#undef WINDOW_EVENT
|
2012-12-21 18:07:28 +04:00
|
|
|
#undef WINDOW_EVENT_HELPER
|
2011-08-24 23:49:25 +04:00
|
|
|
#undef EVENT
|
2012-12-21 18:06:50 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|