summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-08-18 11:33:53 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-08-18 11:33:53 -0700
commit218fd5c9321bfa0033ab86955fe22858fcc262fb (patch)
tree86fc17da71dc697ea1f015f3e0f47fb8c92c01b4 /WebKit/android
parent1272b79ac7617044b2bb907d03d71a4689269523 (diff)
parent1b7c6c8d699a6520472f566710662983ed0ac650 (diff)
downloadexternal_webkit-218fd5c9321bfa0033ab86955fe22858fcc262fb.zip
external_webkit-218fd5c9321bfa0033ab86955fe22858fcc262fb.tar.gz
external_webkit-218fd5c9321bfa0033ab86955fe22858fcc262fb.tar.bz2
Merge "Add CSS cursor ring definitions"
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp58
-rw-r--r--WebKit/android/nav/CachedColor.cpp58
-rw-r--r--WebKit/android/nav/CachedColor.h87
-rw-r--r--WebKit/android/nav/CachedFrame.cpp6
-rw-r--r--WebKit/android/nav/CachedFrame.h6
-rw-r--r--WebKit/android/nav/CachedNode.cpp1
-rw-r--r--WebKit/android/nav/CachedNode.h3
7 files changed, 219 insertions, 0 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index c05395c..3453d20 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -929,6 +929,35 @@ static void AddLayer(CachedFrame* frame, size_t index, const IntPoint& location,
}
#endif
+static int FindColorIndex(WTF::Vector<CachedColor>& colorTracker,
+ const CachedColor& cachedColor)
+{
+ CachedColor* work = colorTracker.begin() - 1;
+ CachedColor* end = colorTracker.end();
+ while (++work < end) {
+ if (*work == cachedColor)
+ return work - colorTracker.begin();
+ }
+ int result = colorTracker.size();
+ colorTracker.grow(result + 1);
+ CachedColor& newColor = colorTracker.last();
+ newColor = cachedColor;
+ return result;
+}
+
+static void InitColor(CachedColor* color)
+{
+ color->setFillColor(RenderStyle::initialRingFillColor());
+ color->setInnerWidth(RenderStyle::initialRingInnerWidth());
+ color->setOuterWidth(RenderStyle::initialRingOuterWidth());
+ color->setOutset(RenderStyle::initialRingOutset());
+ color->setPressedInnerColor(RenderStyle::initialRingPressedInnerColor());
+ color->setPressedOuterColor(RenderStyle::initialRingPressedOuterColor());
+ color->setRadius(RenderStyle::initialRingRadius());
+ color->setSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor());
+ color->setSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor());
+}
+
// when new focus is found, push it's parent on a stack
// as long as more focii are found with the same (grand) parent, note it
// (which only requires retrieving the last parent on the stack)
@@ -956,6 +985,8 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
bzero(clipTracker.data(), sizeof(ClipColumnTracker));
WTF::Vector<TabIndexTracker> tabIndexTracker(1); // sentinel
bzero(tabIndexTracker.data(), sizeof(TabIndexTracker));
+ WTF::Vector<CachedColor> colorTracker(1);
+ InitColor(colorTracker.data());
#if DUMP_NAV_CACHE
char* frameNamePtr = cachedFrame->mDebug.mFrameName;
Builder(frame)->mDebug.frameName(frameNamePtr, frameNamePtr +
@@ -971,9 +1002,12 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
#if DUMP_NAV_CACHE
cachedParentNode.mDebug.mNodeIndex = nodeIndex;
#endif
+ cachedFrame->add(colorTracker[0]);
cachedFrame->add(cachedParentNode);
Node* node = parent;
int cacheIndex = 1;
+ int colorIndex = 0; // assume no special css ring colors
+ const void* lastStyleDataPtr = 0;
int textInputIndex = 0;
Node* focused = doc->focusedNode();
if (focused)
@@ -1108,6 +1142,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
TextDirection direction = LTR;
String exported;
CachedNodeType type = NORMAL_CACHEDNODETYPE;
+ CachedColor cachedColor;
CachedInput cachedInput;
IntRect bounds;
IntRect absBounds;
@@ -1303,6 +1338,28 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
globalOffsetX, globalOffsetY, &cachedNode.mCursorRing) == false)
continue;
keepTextNode:
+ if (nodeRenderer) { // area tags' node->renderer() == 0
+ RenderStyle* style = nodeRenderer->style();
+ const void* styleDataPtr = style->ringData();
+ // to save time, see if we're pointing to the same style data as before
+ if (lastStyleDataPtr != styleDataPtr) {
+ lastStyleDataPtr = styleDataPtr;
+ cachedColor.setFillColor(style->ringFillColor());
+ cachedColor.setInnerWidth(style->ringInnerWidth());
+ cachedColor.setOuterWidth(style->ringOuterWidth());
+ cachedColor.setOutset(style->ringOutset());
+ cachedColor.setPressedInnerColor(style->ringPressedInnerColor());
+ cachedColor.setPressedOuterColor(style->ringPressedOuterColor());
+ cachedColor.setRadius(style->ringRadius());
+ cachedColor.setSelectedInnerColor(style->ringSelectedInnerColor());
+ cachedColor.setSelectedOuterColor(style->ringSelectedOuterColor());
+ int oldSize = colorTracker.size();
+ colorIndex = FindColorIndex(colorTracker, cachedColor);
+ if (colorIndex == oldSize)
+ cachedFrame->add(cachedColor);
+ }
+ } else
+ colorIndex = 0;
IntRect clip = hasClip ? bounds : absBounds;
size_t clipIndex = clipTracker.size();
if (clipTracker.last().mNode == node)
@@ -1347,6 +1404,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
}
#endif
cachedNode.setNavableRects();
+ cachedNode.setColorIndex(colorIndex);
cachedNode.setExport(exported);
cachedNode.setHasCursorRing(hasCursorRing);
cachedNode.setHasMouseOver(hasMouseOver);
diff --git a/WebKit/android/nav/CachedColor.cpp b/WebKit/android/nav/CachedColor.cpp
new file mode 100644
index 0000000..c610022
--- /dev/null
+++ b/WebKit/android/nav/CachedColor.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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 HOLDERS ``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 OWNER OR
+ * CONTRIBUTORS 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 "CachedPrefix.h"
+#include "CachedColor.h"
+
+namespace android {
+
+#if DUMP_NAV_CACHE
+
+#define DEBUG_PRINT_COLOR(field) \
+ DUMP_NAV_LOGD("// SkColor " #field "=0x%08x;\n", b->field)
+
+CachedColor* CachedColor::Debug::base() const {
+ CachedColor* nav = (CachedColor*) ((char*) this - OFFSETOF(CachedColor, mDebug));
+ return nav;
+}
+
+void CachedColor::Debug::print() const
+{
+ CachedColor* b = base();
+ DEBUG_PRINT_COLOR(mFillColor);
+ DUMP_NAV_LOGD("// int mInnerWidth=%d;\n", b->mInnerWidth);
+ DUMP_NAV_LOGD("// int mOuterWidth=%d;\n", b->mOuterWidth);
+ DUMP_NAV_LOGD("// int mOutset=%d;\n", b->mOutset);
+ DEBUG_PRINT_COLOR(mPressedInnerColor);
+ DEBUG_PRINT_COLOR(mPressedOuterColor);
+ DUMP_NAV_LOGD("// int mRadius=%d;\n", b->mRadius);
+ DEBUG_PRINT_COLOR(mSelectedInnerColor);
+ DEBUG_PRINT_COLOR(mSelectedOuterColor);
+}
+
+#endif
+
+}
+
diff --git a/WebKit/android/nav/CachedColor.h b/WebKit/android/nav/CachedColor.h
new file mode 100644
index 0000000..4b39810
--- /dev/null
+++ b/WebKit/android/nav/CachedColor.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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 HOLDERS ``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 OWNER OR
+ * CONTRIBUTORS 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 CachedColor_H
+#define CachedColor_H
+
+#include "CachedDebug.h"
+#include "Color.h"
+#include "Length.h"
+#include "SkColor.h"
+
+using namespace WebCore;
+
+namespace android {
+
+class CachedColor {
+public:
+ CachedColor() {
+ // Initiaized to 0 in its array, so nothing to do in the
+ // constructor
+ }
+ bool operator==(const CachedColor& o) const {
+ return memcmp(&o, this, sizeof(this)) == 0; }
+ SkColor fillColor() const { return mFillColor; }
+ void init();
+ int innerWidth() const { return mInnerWidth; }
+ int outerWidth() const { return mOuterWidth; }
+ int outset() const { return mOutset; }
+ SkColor pressedInnerColor() const { return mPressedInnerColor; }
+ SkColor pressedOuterColor() const { return mPressedOuterColor; }
+ int radius() const { return mRadius; }
+ SkColor selectedInnerColor() const { return mSelectedInnerColor; }
+ SkColor selectedOuterColor() const { return mSelectedOuterColor; }
+ void setFillColor(const Color& c) { mFillColor = c.rgb(); }
+ void setInnerWidth(Length l) { mInnerWidth = l.value(); }
+ void setOuterWidth(Length l) { mOuterWidth = l.value(); }
+ void setOutset(Length l) { mOutset = l.value(); }
+ void setPressedInnerColor(const Color& c) { mPressedInnerColor = c.rgb(); }
+ void setPressedOuterColor(const Color& c) { mPressedOuterColor = c.rgb(); }
+ void setRadius(Length l) { mRadius = l.value(); }
+ void setSelectedInnerColor(const Color& c) { mSelectedInnerColor = c.rgb(); }
+ void setSelectedOuterColor(const Color& c) { mSelectedOuterColor = c.rgb(); }
+private:
+ SkColor mFillColor;
+ int mInnerWidth;
+ int mOuterWidth;
+ int mOutset;
+ SkColor mPressedInnerColor;
+ SkColor mPressedOuterColor;
+ int mRadius;
+ SkColor mSelectedInnerColor;
+ SkColor mSelectedOuterColor;
+#if DUMP_NAV_CACHE
+public:
+ class Debug {
+public:
+ CachedColor* base() const;
+ void print() const;
+ } mDebug;
+#endif
+};
+
+}
+
+#endif
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index 3bf16fc..4219d66 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -1423,6 +1423,12 @@ void CachedFrame::Debug::print() const
}
DUMP_NAV_LOGD("// }; // end of layers\n");
#endif // USE(ACCELERATED_COMPOSITING)
+ DUMP_NAV_LOGD("// CachedColor mCachedColors={ // count=%d\n", b->mCachedColors.size());
+ for (CachedColor* color = b->mCachedColors.begin();
+ color != b->mCachedColors.end(); color++) {
+ color->mDebug.print();
+ }
+ DUMP_NAV_LOGD("// }; // end of colors\n");
DUMP_NAV_LOGD("// CachedFrame mCachedFrames={ // count=%d\n", b->mCachedFrames.size());
for (CachedFrame* child = b->mCachedFrames.begin();
child != b->mCachedFrames.end(); child++)
diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h
index caba482..590c75d 100644
--- a/WebKit/android/nav/CachedFrame.h
+++ b/WebKit/android/nav/CachedFrame.h
@@ -26,6 +26,7 @@
#ifndef CachedFrame_H
#define CachedFrame_H
+#include "CachedColor.h"
#include "CachedInput.h"
#include "CachedLayer.h"
#include "CachedNode.h"
@@ -70,6 +71,7 @@ public:
CURSOR_SET = 0
};
CachedFrame() {}
+ void add(CachedColor& color) { mCachedColors.append(color); }
void add(CachedInput& input) { mCachedTextInputs.append(input); }
#if USE(ACCELERATED_COMPOSITING)
void add(CachedLayer& layer) { mCachedLayers.append(layer); }
@@ -86,6 +88,9 @@ public:
bool checkVisited(const CachedNode* , CachedFrame::Direction ) const;
size_t childCount() { return mCachedFrames.size(); }
void clearCursor();
+ const CachedColor& color(const CachedNode* node) const {
+ return mCachedColors[node->colorIndex()];
+ }
const CachedNode* currentCursor() const { return currentCursor(NULL); }
const CachedNode* currentCursor(const CachedFrame** ) const;
const CachedNode* currentFocus() const { return currentFocus(NULL); }
@@ -226,6 +231,7 @@ private: // since computing these is complicated, protect them so that the
WebCore::IntRect mContents;
WebCore::IntRect mLocalViewBounds;
WebCore::IntRect mViewBounds;
+ WTF::Vector<CachedColor> mCachedColors;
WTF::Vector<CachedNode> mCachedNodes;
WTF::Vector<CachedFrame> mCachedFrames;
WTF::Vector<CachedInput> mCachedTextInputs;
diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp
index dda9385..47711fd 100644
--- a/WebKit/android/nav/CachedNode.cpp
+++ b/WebKit/android/nav/CachedNode.cpp
@@ -404,6 +404,7 @@ void CachedNode::Debug::print() const
DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects);
DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex);
DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex);
+ DUMP_NAV_LOGD("// int mColorIndex=%d;\n", b->mColorIndex);
DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition));
DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType));
DEBUG_PRINT_BOOL(mClippedOut);
diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h
index 2ade73b..0014e07 100644
--- a/WebKit/android/nav/CachedNode.h
+++ b/WebKit/android/nav/CachedNode.h
@@ -95,6 +95,7 @@ public:
WTF::Vector<WebCore::IntRect>* rings);
bool clip(const WebCore::IntRect& );
bool clippedOut() { return mClippedOut; }
+ int colorIndex() const { return mColorIndex; }
WebCore::IntRect cursorRingBounds(const CachedFrame* ) const;
void cursorRings(const CachedFrame* , WTF::Vector<WebCore::IntRect>* ) const;
bool disabled() const { return mDisabled; }
@@ -147,6 +148,7 @@ public:
WebCore::IntRect ring(const CachedFrame* , size_t part) const;
void setBounds(const WebCore::IntRect& bounds) { mBounds = bounds; }
void setClippedOut(bool clipped) { mClippedOut = clipped; }
+ void setColorIndex(int index) { mColorIndex = index; }
void setCondition(Condition condition) const { mCondition = condition; }
void setDataIndex(int index) { mDataIndex = index; }
void setDisabled(bool disabled) { mDisabled = disabled; }
@@ -190,6 +192,7 @@ private:
int mNavableRects; // FIXME: could be bitfield once I limit max number of rects
int mParentIndex;
int mTabIndex;
+ int mColorIndex; // index to ring color and other stylable properties
mutable Condition mCondition : 5; // why the node was not chosen on the first pass
CachedNodeType mType : 4;
bool mClippedOut : 1;