Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTableColElement.cpp

Issue 2518163002: [css-tables] Fix divide-by-zero resulting from 32-bit overflow (Closed)
Patch Set: update wpt -expected.txt and span-attribute.html but not -expected.txt Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public License 19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to 20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA. 22 * Boston, MA 02110-1301, USA.
23 */ 23 */
24 24
25 #include "core/html/HTMLTableColElement.h" 25 #include "core/html/HTMLTableColElement.h"
26 26
27 #include "core/CSSPropertyNames.h" 27 #include "core/CSSPropertyNames.h"
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/html/HTMLTableCellElement.h"
29 #include "core/html/HTMLTableElement.h" 30 #include "core/html/HTMLTableElement.h"
30 #include "core/html/parser/HTMLParserIdioms.h" 31 #include "core/html/parser/HTMLParserIdioms.h"
31 #include "core/layout/LayoutTableCol.h" 32 #include "core/layout/LayoutTableCol.h"
33 #include <algorithm>
32 34
33 namespace blink { 35 namespace blink {
34 36
35 using namespace HTMLNames; 37 using namespace HTMLNames;
36 38
37 inline HTMLTableColElement::HTMLTableColElement(const QualifiedName& tagName, 39 inline HTMLTableColElement::HTMLTableColElement(const QualifiedName& tagName,
38 Document& document) 40 Document& document)
39 : HTMLTablePartElement(tagName, document), m_span(1) {} 41 : HTMLTablePartElement(tagName, document), m_span(1) {}
40 42
41 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableColElement) 43 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableColElement)
(...skipping 20 matching lines...) Expand all
62 const AtomicString& oldValue, 64 const AtomicString& oldValue,
63 const AtomicString& value) { 65 const AtomicString& value) {
64 if (name == spanAttr) { 66 if (name == spanAttr) {
65 unsigned newSpan = 0; 67 unsigned newSpan = 0;
66 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, newSpan) || 68 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, newSpan) ||
67 newSpan < 1) { 69 newSpan < 1) {
68 // If the value of span is not a valid non-negative integer greater than 70 // If the value of span is not a valid non-negative integer greater than
69 // zero, set it to 1. 71 // zero, set it to 1.
70 newSpan = 1; 72 newSpan = 1;
71 } 73 }
74 newSpan = std::min(newSpan, HTMLTableCellElement::maxColSpan());
72 m_span = newSpan; 75 m_span = newSpan;
73 if (layoutObject() && layoutObject()->isLayoutTableCol()) 76 if (layoutObject() && layoutObject()->isLayoutTableCol())
74 layoutObject()->updateFromElement(); 77 layoutObject()->updateFromElement();
75 } else if (name == widthAttr) { 78 } else if (name == widthAttr) {
76 if (!value.isEmpty()) { 79 if (!value.isEmpty()) {
77 if (layoutObject() && layoutObject()->isLayoutTableCol()) { 80 if (layoutObject() && layoutObject()->isLayoutTableCol()) {
78 LayoutTableCol* col = toLayoutTableCol(layoutObject()); 81 LayoutTableCol* col = toLayoutTableCol(layoutObject());
79 int newWidth = width().toInt(); 82 int newWidth = width().toInt();
80 if (newWidth != col->size().width()) 83 if (newWidth != col->size().width())
81 col->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( 84 col->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
(...skipping 16 matching lines...) Expand all
98 101
99 void HTMLTableColElement::setSpan(unsigned n) { 102 void HTMLTableColElement::setSpan(unsigned n) {
100 setUnsignedIntegralAttribute(spanAttr, n ? n : 1); 103 setUnsignedIntegralAttribute(spanAttr, n ? n : 1);
101 } 104 }
102 105
103 const AtomicString& HTMLTableColElement::width() const { 106 const AtomicString& HTMLTableColElement::width() const {
104 return getAttribute(widthAttr); 107 return getAttribute(widthAttr);
105 } 108 }
106 109
107 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698