summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-04 16:38:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-04 16:38:40 +0000
commitdc566b0a76f9d2ad112c8cc35fa6dc8eaf942316 (patch)
tree60e72e3b14db2f3cb26fbd595ea84fed58bd9548
parent1a2e4945f16f5dff4aba518a36edf938c9234ac3 (diff)
downloadpdfium-dc566b0a76f9d2ad112c8cc35fa6dc8eaf942316.tar.xz
Fix XFA caret blinking only while mouse moves.chromium/3389
Currently rect invalidations in XFA are only sent to the embedder only when RunInvalidate() is executed. For things which redraw on a timer, such as the caret, there was no user event to call RunInvalidate() so the page would not redraw. This CL changes the XFA code to send the invalidations to the embedder immediately and expects the embedder to combine the invalidations to limit overdraw. Bug: chromium:828561 Change-Id: I298052fd7d0c373b029eec191cc6c74c63978348 Reviewed-on: https://pdfium-review.googlesource.com/29670 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp20
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h6
-rw-r--r--xfa/fxfa/cxfa_fffield.cpp4
-rw-r--r--xfa/fxfa/cxfa_fflistbox.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp8
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h2
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp9
-rw-r--r--xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp2
12 files changed, 26 insertions, 51 deletions
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index f3d4d22f50..268d1da2b4 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -266,14 +266,14 @@ FormFieldType CXFA_FFComboBox::GetFormFieldType() {
void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) {
ToComboBox(m_pNormalWidget.get())->SetCurSel(bSelected ? nIndex : -1);
m_pNormalWidget->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFComboBox::InsertItem(const WideStringView& wsLabel,
int32_t nIndex) {
ToComboBox(m_pNormalWidget.get())->AddString(wsLabel);
m_pNormalWidget->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFComboBox::DeleteItem(int32_t nIndex) {
@@ -283,7 +283,7 @@ void CXFA_FFComboBox::DeleteItem(int32_t nIndex) {
ToComboBox(m_pNormalWidget.get())->RemoveAt(nIndex);
m_pNormalWidget->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFComboBox::OnTextChanged(CFWL_Widget* pWidget,
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 43879af2dc..86a2a9fee9 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -185,7 +185,6 @@ void CXFA_FFDocView::UpdateDocView() {
m_bLayoutEvent = false;
m_CalculateNodes.clear();
- RunInvalidate();
UnlockUpdate();
}
@@ -442,22 +441,9 @@ void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent);
}
-
-void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView,
- const CFX_RectF& rtInvalidate) {
- if (m_mapPageInvalidate[pPageView]) {
- m_mapPageInvalidate[pPageView]->Union(rtInvalidate);
- return;
- }
-
- m_mapPageInvalidate[pPageView] = pdfium::MakeUnique<CFX_RectF>(rtInvalidate);
-}
-
-void CXFA_FFDocView::RunInvalidate() {
- for (const auto& pair : m_mapPageInvalidate)
- m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second);
-
- m_mapPageInvalidate.clear();
+void CXFA_FFDocView::InvalidateRect(CXFA_FFPageView* pPageView,
+ const CFX_RectF& rtInvalidate) {
+ m_pDoc->GetDocEnvironment()->InvalidateRect(pPageView, rtInvalidate);
}
bool CXFA_FFDocView::RunLayout() {
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index bccbe33cb9..dbc7672caa 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -68,9 +68,8 @@ class CXFA_FFDocView {
void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
void LockUpdate() { m_iLock++; }
void UnlockUpdate() { m_iLock--; }
- void AddInvalidateRect(CXFA_FFPageView* pPageView,
- const CFX_RectF& rtInvalidate);
- void RunInvalidate();
+ void InvalidateRect(CXFA_FFPageView* pPageView,
+ const CFX_RectF& rtInvalidate);
void RunDocClose();
void ProcessValueChanged(CXFA_Node* node);
@@ -120,7 +119,6 @@ class CXFA_FFDocView {
UnownedPtr<CXFA_Node> m_pFocusNode;
UnownedPtr<CXFA_FFWidget> m_pFocusWidget;
UnownedPtr<CXFA_FFWidget> m_pOldFocusWidget;
- std::map<CXFA_FFPageView*, std::unique_ptr<CFX_RectF>> m_mapPageInvalidate;
std::vector<CXFA_Node*> m_ValidateNodes;
std::vector<CXFA_Node*> m_CalculateNodes;
std::vector<CXFA_BindItems*> m_BindItems;
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index 39c117b352..552a4e3f4b 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -505,7 +505,7 @@ bool CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) {
CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get());
TranslateFWLMessage(&ms);
m_dwStatus |= XFA_WidgetStatus_Focused;
- AddInvalidateRect();
+ InvalidateRect();
return true;
}
@@ -516,7 +516,7 @@ bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) {
CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget.get());
TranslateFWLMessage(&ms);
m_dwStatus &= ~XFA_WidgetStatus_Focused;
- AddInvalidateRect();
+ InvalidateRect();
CXFA_FFWidget::OnKillFocus(pNewWidget);
return true;
}
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp
index 92543e3e6b..50f9d4a772 100644
--- a/xfa/fxfa/cxfa_fflistbox.cpp
+++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -167,14 +167,14 @@ void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) {
auto* pListBox = ToListBox(m_pNormalWidget.get());
pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected);
m_pNormalWidget->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFListBox::InsertItem(const WideStringView& wsLabel, int32_t nIndex) {
WideString wsTemp(wsLabel);
ToListBox(m_pNormalWidget.get())->AddString(wsTemp.AsStringView());
m_pNormalWidget->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFListBox::DeleteItem(int32_t nIndex) {
@@ -185,7 +185,7 @@ void CXFA_FFListBox::DeleteItem(int32_t nIndex) {
pListBox->DeleteString(pListBox->GetItem(nullptr, nIndex));
pListBox->Update();
- AddInvalidateRect();
+ InvalidateRect();
}
void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) {
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 5ba699b168..5aca631914 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -333,7 +333,7 @@ void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_Attribute eAttr) {
CXFA_FFWidget* pWidget = m_pDoc->GetDocView()->GetWidgetForNode(pSender);
for (; pWidget; pWidget = pSender->GetNextWidget(pWidget)) {
if (pWidget->IsLoaded())
- pWidget->AddInvalidateRect();
+ pWidget->InvalidateRect();
}
}
@@ -397,7 +397,7 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
if (bUpdateProperty)
pWidget->UpdateWidgetProperty();
pWidget->PerformLayout();
- pWidget->AddInvalidateRect();
+ pWidget->InvalidateRect();
}
}
@@ -461,7 +461,7 @@ void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
} else {
pWidget->LoadWidget();
}
- pWidget->AddInvalidateRect();
+ pWidget->InvalidateRect();
}
void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
@@ -476,5 +476,5 @@ void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
pDocView->DeleteLayoutItem(pWidget);
m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget);
- pWidget->AddInvalidateRect();
+ pWidget->InvalidateRect();
}
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index d91e7f7086..51ee1478e1 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -114,7 +114,7 @@ bool CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) {
if (!IsFocused()) {
m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
- AddInvalidateRect();
+ InvalidateRect();
}
SetButtonDown(true);
@@ -134,7 +134,7 @@ bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) {
if (!IsFocused()) {
m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
- AddInvalidateRect();
+ InvalidateRect();
}
SetButtonDown(true);
@@ -159,7 +159,7 @@ bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) {
if (!IsFocused()) {
m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
- AddInvalidateRect();
+ InvalidateRect();
}
CXFA_FFWidget::OnSetFocus(pOldWidget);
CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget.get());
@@ -175,7 +175,7 @@ bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) {
SetEditScrollOffset();
ProcessCommittedData();
UpdateFWLData();
- AddInvalidateRect();
+ InvalidateRect();
CXFA_FFWidget::OnKillFocus(pNewWidget);
m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index c3e0d4de4d..f16e1ea573 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -346,10 +346,10 @@ void CXFA_FFWidget::DrawBorderWithFlag(CXFA_Graphics* pGS,
box->Draw(pGS, rtBorder, matrix, forceRound);
}
-void CXFA_FFWidget::AddInvalidateRect() {
+void CXFA_FFWidget::InvalidateRect() {
CFX_RectF rtWidget = GetBBox(XFA_WidgetStatus_Focused);
rtWidget.Inflate(2, 2);
- m_pDocView->AddInvalidateRect(m_pPageView, rtWidget);
+ m_pDocView->InvalidateRect(m_pPageView, rtWidget);
}
bool CXFA_FFWidget::OnMouseEnter() {
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 24f236e79b..2b72aa54a1 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -157,7 +157,7 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
CXFA_FFDoc* GetDoc();
CXFA_FFApp* GetApp();
IXFA_AppProvider* GetAppProvider();
- void AddInvalidateRect();
+ void InvalidateRect();
bool IsFocused() const { return !!(m_dwStatus & XFA_WidgetStatus_Focused); }
CFX_PointF Rotate2Normal(const CFX_PointF& point);
CFX_Matrix GetRotateMatrix();
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 87d7a14a3e..566923e590 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -72,7 +72,6 @@ bool CXFA_FFWidgetHandler::OnLButtonDblClk(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
const CFX_PointF& point) {
bool bRet = hWidget->OnLButtonDblClk(dwFlags, hWidget->Rotate2Normal(point));
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -80,7 +79,6 @@ bool CXFA_FFWidgetHandler::OnMouseMove(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
const CFX_PointF& point) {
bool bRet = hWidget->OnMouseMove(dwFlags, hWidget->Rotate2Normal(point));
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -90,7 +88,6 @@ bool CXFA_FFWidgetHandler::OnMouseWheel(CXFA_FFWidget* hWidget,
const CFX_PointF& point) {
bool bRet =
hWidget->OnMouseWheel(dwFlags, zDelta, hWidget->Rotate2Normal(point));
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -102,7 +99,6 @@ bool CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget,
m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget(
m_pDocView->GetDoc(), hWidget);
}
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -110,7 +106,6 @@ bool CXFA_FFWidgetHandler::OnRButtonUp(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
const CFX_PointF& point) {
bool bRet = hWidget->OnRButtonUp(dwFlags, hWidget->Rotate2Normal(point));
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -118,7 +113,6 @@ bool CXFA_FFWidgetHandler::OnRButtonDblClk(CXFA_FFWidget* hWidget,
uint32_t dwFlags,
const CFX_PointF& point) {
bool bRet = hWidget->OnRButtonDblClk(dwFlags, hWidget->Rotate2Normal(point));
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -126,7 +120,6 @@ bool CXFA_FFWidgetHandler::OnKeyDown(CXFA_FFWidget* hWidget,
uint32_t dwKeyCode,
uint32_t dwFlags) {
bool bRet = hWidget->OnKeyDown(dwKeyCode, dwFlags);
- m_pDocView->RunInvalidate();
m_pDocView->UpdateDocView();
return bRet;
}
@@ -135,7 +128,6 @@ bool CXFA_FFWidgetHandler::OnKeyUp(CXFA_FFWidget* hWidget,
uint32_t dwKeyCode,
uint32_t dwFlags) {
bool bRet = hWidget->OnKeyUp(dwKeyCode, dwFlags);
- m_pDocView->RunInvalidate();
return bRet;
}
@@ -143,7 +135,6 @@ bool CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget,
uint32_t dwChar,
uint32_t dwFlags) {
bool bRet = hWidget->OnChar(dwChar, dwFlags);
- m_pDocView->RunInvalidate();
return bRet;
}
diff --git a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
index 6fdd553712..befa8303a1 100644
--- a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
+++ b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
@@ -21,7 +21,7 @@ void CXFA_FWLAdapterWidgetMgr::RepaintWidget(CFWL_Widget* pWidget) {
if (!pFFWidget)
return;
- pFFWidget->AddInvalidateRect();
+ pFFWidget->InvalidateRect();
}
bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(CFWL_Widget* pWidget,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 505de1c849..b2535aee8c 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2680,7 +2680,7 @@ void CXFA_Node::UpdateUIDisplay(CXFA_FFDocView* docView,
continue;
}
pWidget->UpdateFWLData();
- pWidget->AddInvalidateRect();
+ pWidget->InvalidateRect();
}
}